package flags
import (
+ "cmd/internal/obj"
"cmd/internal/objabi"
"flag"
"fmt"
Linkshared = flag.Bool("linkshared", false, "generate code that will be linked against Go shared libraries")
AllErrors = flag.Bool("e", false, "no limit on number of errors reported")
SymABIs = flag.Bool("gensymabis", false, "write symbol ABI information to output file, don't assemble")
- Importpath = flag.String("p", "", "set expected package import to path")
+ Importpath = flag.String("p", obj.UnlinkablePkg, "set expected package import to path")
Spectre = flag.String("spectre", "", "enable spectre mitigations in `list` (all, ret)")
CompilingRuntime = flag.Bool("compiling-runtime", false, "source to be compiled is part of the Go runtime")
)
const SymABIstatic = ^uint16(0)
const (
- ObjFlagShared = 1 << iota // this object is built with -shared
- ObjFlagNeedNameExpansion // the linker needs to expand `"".` to package path in symbol names
- ObjFlagFromAssembly // object is from asm src, not go
- ObjFlagUnlinkable // unlinkable package (linker will emit an error)
+ ObjFlagShared = 1 << iota // this object is built with -shared
+ _ // was ObjFlagNeedNameExpansion
+ ObjFlagFromAssembly // object is from asm src, not go
+ ObjFlagUnlinkable // unlinkable package (linker will emit an error)
)
// Sym.Flag
}
func (r *Reader) Shared() bool { return r.Flags()&ObjFlagShared != 0 }
-func (r *Reader) NeedNameExpansion() bool { return r.Flags()&ObjFlagNeedNameExpansion != 0 }
+func (r *Reader) NeedNameExpansion() bool { return false } // TODO: delete
func (r *Reader) FromAssembly() bool { return r.Flags()&ObjFlagFromAssembly != 0 }
func (r *Reader) Unlinkable() bool { return r.Flags()&ObjFlagUnlinkable != 0 }
flags |= goobj.ObjFlagUnlinkable
}
if w.pkgpath == "" {
- flags |= goobj.ObjFlagNeedNameExpansion
+ log.Fatal("empty package path")
}
if ctxt.IsAsm {
flags |= goobj.ObjFlagFromAssembly
cflags := strings.Fields(runGo("env", "GOGCCFLAGS"))
// Compile, assemble and pack the Go and C code.
- runGo("tool", "asm", "-gensymabis", "-o", "symabis", "x.s")
+ runGo("tool", "asm", "-p=main", "-gensymabis", "-o", "symabis", "x.s")
runGo("tool", "compile", "-symabis", "symabis", "-p=main", "-o", "x1.o", "main.go")
- runGo("tool", "asm", "-o", "x2.o", "x.s")
+ runGo("tool", "asm", "-p=main", "-o", "x2.o", "x.s")
run(cc, append(cflags, "-c", "-o", "x3.o", "x.c")...)
runGo("tool", "pack", "c", "x.a", "x1.o", "x2.o", "x3.o")
t.err = fmt.Errorf("write empty go_asm.h: %s", err)
return
}
- cmd := []string{goTool(), "tool", "asm", "-gensymabis", "-o", "symabis"}
+ cmd := []string{goTool(), "tool", "asm", "-p=main", "-gensymabis", "-o", "symabis"}
cmd = append(cmd, asms...)
_, err = runcmd(cmd...)
if err != nil {
}
objs = append(objs, "go.o")
if len(asms) > 0 {
- cmd = []string{goTool(), "tool", "asm", "-e", "-I", ".", "-o", "asm.o"}
+ cmd = []string{goTool(), "tool", "asm", "-p=main", "-e", "-I", ".", "-o", "asm.o"}
cmd = append(cmd, asms...)
_, err = runcmd(cmd...)
if err != nil {