[go] cmd/cgo: read CGO_LDFLAGS environment variable

0 views
Skip to first unread message

Ian Lance Taylor (Gerrit)

unread,
2:22 PM (7 hours ago) 2:22 PM
to Cherry Mui, goph...@pubsubhelper.golang.org, Ian Lance Taylor, golang-co...@googlegroups.com
Attention needed from Cherry Mui

Ian Lance Taylor has uploaded the change for review

Ian Lance Taylor would like Cherry Mui to review this change.

Commit message

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
Change-Id: Iebdd8bde1c7c18da09c6370e284c7ac7fa08fc54

Change diff

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

Change information

Files:
  • M src/cmd/cgo/main.go
Change size: S
Delta: 1 file changed, 15 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Iebdd8bde1c7c18da09c6370e284c7ac7fa08fc54
Gerrit-Change-Number: 596615
Gerrit-PatchSet: 1
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Cherry Mui (Gerrit)

unread,
2:43 PM (7 hours ago) 2:43 PM
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
Attention needed from Ian Lance Taylor

Cherry Mui voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Lance Taylor
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Iebdd8bde1c7c18da09c6370e284c7ac7fa08fc54
Gerrit-Change-Number: 596615
Gerrit-PatchSet: 1
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Comment-Date: Wed, 03 Jul 2024 18:43:39 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
3:01 PM (6 hours ago) 3:01 PM
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, Cherry Mui, Go LUCI, golang-co...@googlegroups.com
Attention needed from Ian Lance Taylor

Ian Lance Taylor voted

Auto-Submit+1
Code-Review+1
Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Lance Taylor
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Iebdd8bde1c7c18da09c6370e284c7ac7fa08fc54
    Gerrit-Change-Number: 596615
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
    Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Comment-Date: Wed, 03 Jul 2024 19:00:56 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    3:02 PM (6 hours ago) 3:02 PM
    to Ian Lance Taylor, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Cherry Mui, Go LUCI, golang-co...@googlegroups.com

    Gopher Robot submitted the change

    Change information

    Commit message:
    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
    Change-Id: Iebdd8bde1c7c18da09c6370e284c7ac7fa08fc54
    Reviewed-by: Ian Lance Taylor <ia...@google.com>
    Auto-Submit: Ian Lance Taylor <ia...@google.com>
    Commit-Queue: Ian Lance Taylor <ia...@google.com>
    Auto-Submit: Ian Lance Taylor <ia...@golang.org>
    Reviewed-by: Cherry Mui <cher...@google.com>
    Files:
    • M src/cmd/cgo/main.go
    Change size: S
    Delta: 1 file changed, 15 insertions(+), 0 deletions(-)
    Branch: refs/heads/master
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Ian Lance Taylor, +2 by Cherry Mui
    • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Iebdd8bde1c7c18da09c6370e284c7ac7fa08fc54
    Gerrit-Change-Number: 596615
    Gerrit-PatchSet: 2
    Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages