Ian Lance Taylor would like Cherry Mui to review this change.
cmd/cgo: read CGO_LDFLAGS environment variable
For #66456 we changed from the CGO_LDFLAGS environment variable to
the -ldflags option. This broke Bazel, which uses CGO_LDFLAGS.
So restore reading CGO_LDFLAGS for now.
For #66456
diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go
index 156038b..5699cc5 100644
--- a/src/cmd/cgo/main.go
+++ b/src/cmd/cgo/main.go
@@ -343,6 +343,21 @@
p.addToFlag("LDFLAGS", args)
}
+ // For backward compatibility for Bazel, record CGO_LDFLAGS
+ // from the environment for external linking.
+ // This should not happen with cmd/go, which removes CGO_LDFLAGS
+ // from the environment when invoking cgo.
+ // This can be removed when we no longer need to support
+ // older versions of Bazel. See issue #66456 and
+ // https://github.com/bazelbuild/rules_go/issues/3979.
+ if envFlags := os.Getenv("CGO_LDFLAGS"); envFlags != "" {
+ args, err := splitQuoted(envFlags)
+ if err != nil {
+ fatalf("bad CGO_LDFLAGS: %q (%s)", envFlags, err)
+ }
+ p.addToFlag("LDFLAGS", args)
+ }
+
// Need a unique prefix for the global C symbols that
// we use to coordinate between gcc and ourselves.
// We already put _cgo_ at the beginning, so the main
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Auto-Submit | +1 |
Code-Review | +1 |
Commit-Queue | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
cmd/cgo: read CGO_LDFLAGS environment variable
For #66456 we changed from the CGO_LDFLAGS environment variable to
the -ldflags option. This broke Bazel, which uses CGO_LDFLAGS.
So restore reading CGO_LDFLAGS for now.
For #66456
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |