}
pkgpath := pkgPath(a)
- gcargs := []string{"-p", pkgpath}
+ gcflags := []string{"-p", pkgpath}
if p.Module != nil {
v := p.Module.GoVersion
if v == "" {
v = "1.16"
}
if allowedVersion(v) {
- gcargs = append(gcargs, "-lang=go"+v)
+ gcflags = append(gcflags, "-lang=go"+v)
}
}
if p.Standard {
- gcargs = append(gcargs, "-std")
+ gcflags = append(gcflags, "-std")
}
_, compilingRuntime := runtimePackages[p.ImportPath]
compilingRuntime = compilingRuntime && p.Standard
// runtime compiles with a special gc flag to check for
// memory allocations that are invalid in the runtime package,
// and to implement some special compiler pragmas.
- gcargs = append(gcargs, "-+")
+ gcflags = append(gcflags, "-+")
}
// If we're giving the compiler the entire package (no C etc files), tell it that,
}
}
if extFiles == 0 {
- gcargs = append(gcargs, "-complete")
+ gcflags = append(gcflags, "-complete")
}
if cfg.BuildContext.InstallSuffix != "" {
- gcargs = append(gcargs, "-installsuffix", cfg.BuildContext.InstallSuffix)
+ gcflags = append(gcflags, "-installsuffix", cfg.BuildContext.InstallSuffix)
}
if a.buildID != "" {
- gcargs = append(gcargs, "-buildid", a.buildID)
+ gcflags = append(gcflags, "-buildid", a.buildID)
}
if p.Internal.OmitDebug || cfg.Goos == "plan9" || cfg.Goarch == "wasm" {
- gcargs = append(gcargs, "-dwarf=false")
+ gcflags = append(gcflags, "-dwarf=false")
}
if strings.HasPrefix(runtimeVersion, "go1") && !strings.Contains(os.Args[0], "go_bootstrap") {
- gcargs = append(gcargs, "-goversion", runtimeVersion)
+ gcflags = append(gcflags, "-goversion", runtimeVersion)
}
if symabis != "" {
- gcargs = append(gcargs, "-symabis", symabis)
+ gcflags = append(gcflags, "-symabis", symabis)
}
- gcflags := str.StringList(forcedGcflags, p.Internal.Gcflags)
+ gcflags = append(gcflags, str.StringList(forcedGcflags, p.Internal.Gcflags)...)
if compilingRuntime {
// Remove -N, if present.
// It is not possible to build the runtime with no optimizations,
}
}
- args := []interface{}{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", a.trimpath(), gcflags, gcargs}
+ args := []interface{}{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", a.trimpath(), gcflags}
if p.Internal.LocalPrefix != "" {
// Workaround #43883.
args = append(args, "-D", p.Internal.LocalPrefix)
# -gcflags=-e applies to named packages, not dependencies
go build -n -v -gcflags=-e z1 z2
-stderr 'compile.* -e.* -p z1'
-stderr 'compile.* -e.* -p z2'
+stderr 'compile.* -p z1.* -e'
+stderr 'compile.* -p z2.* -e'
stderr 'compile.* -p y'
-! stderr 'compile.* -e.* -p [^z]'
+! stderr 'compile.* -p [^z].* -e'
# -gcflags can specify package=flags, and can be repeated; last match wins
go build -n -v -gcflags=-e -gcflags=z1=-N z1 z2
-stderr 'compile.* -N.* -p z1'
-! stderr 'compile.* -e.* -p z1'
-! stderr 'compile.* -N.* -p z2'
-stderr 'compile.* -e.* -p z2'
+stderr 'compile.* -p z1.* -N'
+! stderr 'compile.* -p z1.* -e'
+! stderr 'compile.* -p z2.* -N'
+stderr 'compile.* -p z2.* -e'
stderr 'compile.* -p y'
-! stderr 'compile.* -e.* -p [^z]'
-! stderr 'compile.* -N.* -p [^z]'
+! stderr 'compile.* -p [^z].* -e'
+! stderr 'compile.* -p [^z].* -N'
# -gcflags can have arbitrary spaces around the flags
go build -n -v -gcflags=' z1 = -e ' z1
-stderr 'compile.* -e.* -p z1'
+stderr 'compile.* -p z1.* -e'
# -gcflags='all=-e' should apply to all packages, even with go test
go test -c -n -gcflags='all=-e' z1
-stderr 'compile.* -e.* -p z3 '
+stderr 'compile.* -p z3.* -e '
# this particular -gcflags argument made the compiler crash
! go build -gcflags=-d=ssa/ z1