aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/work/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/go/internal/work/init.go')
-rw-r--r--src/cmd/go/internal/work/init.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go
index b0d6133768..d65c076c6a 100644
--- a/src/cmd/go/internal/work/init.go
+++ b/src/cmd/go/internal/work/init.go
@@ -9,6 +9,7 @@ package work
import (
"cmd/go/internal/base"
"cmd/go/internal/cfg"
+ "cmd/go/internal/fsys"
"cmd/go/internal/modload"
"cmd/internal/objabi"
"cmd/internal/sys"
@@ -24,6 +25,9 @@ func BuildInit() {
modload.Init()
instrumentInit()
buildModeInit()
+ if err := fsys.Init(base.Cwd); err != nil {
+ base.Fatalf("go: %v", err)
+ }
// Make sure -pkgdir is absolute, because we run commands
// in different directories.
@@ -37,6 +41,13 @@ func BuildInit() {
cfg.BuildPkgdir = p
}
+ // Make sure CC and CXX are absolute paths
+ for _, key := range []string{"CC", "CXX"} {
+ if path := cfg.Getenv(key); !filepath.IsAbs(path) && path != "" && path != filepath.Base(path) {
+ base.Fatalf("go %s: %s environment variable is relative; must be absolute path: %s\n", flag.Args()[0], key, path)
+ }
+ }
+
// For each experiment that has been enabled in the toolchain, define a
// build tag with the same name but prefixed by "goexperiment." which can be
// used for compiling alternative files for the experiment. This allows
@@ -157,7 +168,10 @@ func buildModeInit() {
ldBuildmode = "pie"
case "windows":
ldBuildmode = "pie"
- case "darwin", "ios":
+ case "ios":
+ codegenArg = "-shared"
+ ldBuildmode = "pie"
+ case "darwin":
switch cfg.Goarch {
case "arm64":
codegenArg = "-shared"