File tree 1 file changed +15
-0
lines changed 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,21 @@ func main() {
343
343
p .addToFlag ("LDFLAGS" , args )
344
344
}
345
345
346
+ // For backward compatibility for Bazel, record CGO_LDFLAGS
347
+ // from the environment for external linking.
348
+ // This should not happen with cmd/go, which removes CGO_LDFLAGS
349
+ // from the environment when invoking cgo.
350
+ // This can be removed when we no longer need to support
351
+ // older versions of Bazel. See issue #66456 and
352
+ // https://github.com/bazelbuild/rules_go/issues/3979.
353
+ if envFlags := os .Getenv ("CGO_LDFLAGS" ); envFlags != "" {
354
+ args , err := splitQuoted (envFlags )
355
+ if err != nil {
356
+ fatalf ("bad CGO_LDFLAGS: %q (%s)" , envFlags , err )
357
+ }
358
+ p .addToFlag ("LDFLAGS" , args )
359
+ }
360
+
346
361
// Need a unique prefix for the global C symbols that
347
362
// we use to coordinate between gcc and ourselves.
348
363
// We already put _cgo_ at the beginning, so the main
You can’t perform that action at this time.
0 commit comments