Skip to content

builder: Make paths absolute for stdliblist (#1357) #3748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go/tools/builders/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ You may need to use the flags --cpu=x64_windows --compiler=mingw-gcc.`)
os.Setenv("GO111MODULE", "off")

// Make sure we have an absolute path to the C compiler.
// TODO(#1357): also take absolute paths of includes and other paths in flags.
os.Setenv("CC", quotePathIfNeeded(abs(os.Getenv("CC"))))

// Ensure paths are absolute.
Expand Down Expand Up @@ -159,7 +158,7 @@ You may need to use the flags --cpu=x64_windows --compiler=mingw-gcc.`)
installArgs = append(installArgs, "-ldflags="+allSlug+strings.Join(ldflags, " "))
installArgs = append(installArgs, "-asmflags="+allSlug+strings.Join(asmflags, " "))

// Modifying CGO flags to use only absolute path
// Modify CGO flags to use only absolute path
// because go is having its own sandbox, all CGO flags must use absolute path
if err := absEnv(cgoEnvVars, cgoAbsEnvFlags); err != nil {
return fmt.Errorf("error modifying cgo environment to absolute path: %v", err)
Expand Down
7 changes: 6 additions & 1 deletion go/tools/builders/stdliblist.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,18 @@ func stdliblist(args []string) error {

cgoEnabled := os.Getenv("CGO_ENABLED") == "1"
// Make sure we have an absolute path to the C compiler.
// TODO(#1357): also take absolute paths of includes and other paths in flags.
ccEnv, ok := os.LookupEnv("CC")
if cgoEnabled && !ok {
return fmt.Errorf("CC must be set")
}
os.Setenv("CC", quotePathIfNeeded(abs(ccEnv)))

// Modify CGO flags to use only absolute path
// because go is having its own sandbox, all CGO flags must use absolute path
if err := absEnv(cgoEnvVars, cgoAbsEnvFlags); err != nil {
return fmt.Errorf("error modifying cgo environment to absolute path: %v", err)
}

// We want to keep the cache around so that the processed files can be used by other tools.
absCachePath := abs(*cachePath)
os.Setenv("GOCACHE", absCachePath)
Expand Down