Skip to content
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

cmd/link: linker fails on linux/amd64 when gcc's lto options are used [1.20 backport] #59051

Closed
gopherbot opened this issue Mar 15, 2023 · 2 comments
Assignees
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge GoCommand cmd/go
Milestone

Comments

@gopherbot
Copy link

@thanm requested issue #58619 to be considered for backport to the next 1.20 minor release.

@gopherbot please open backport issues

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Mar 15, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 15, 2023
@gopherbot gopherbot added this to the Go1.20.3 milestone Mar 15, 2023
@thanm thanm self-assigned this Mar 15, 2023
@thanm thanm added the GoCommand cmd/go label Mar 15, 2023
@cherrymui cherrymui added the CherryPickApproved Used during the release process for point releases label Mar 15, 2023
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Mar 15, 2023
@gopherbot
Copy link
Author

Change https://go.dev/cl/476577 mentions this issue: [release-branch.go1.20] cmd/go,cmd/link: prefer external linking when strange cgo flags seen

gopherbot pushed a commit that referenced this issue Mar 17, 2023
… strange cgo flags seen

This patch changes the Go command to examine the set of compiler
flags feeding into the C compiler when packages that use cgo are built.
If any of a specific set of strange/dangerous flags are in use,
then the Go command generates a token file ("preferlinkext") and
embeds it into the compiled package's archive.

When the Go linker reads the archives of the packages feeding into the
link and detects a "preferlinkext" token, it will then use external
linking for the program by default (although this default can be
overridden with an explicit "-linkmode" flag).

The intent here is to avoid having to teach the Go linker's host object
reader to grok/understand the various odd symbols/sections/types that
can result from boutique flag use, but rather to just boot the objects
in question over to the C linker instead.

Fixes #59051.
Updates #58619.
Updates #58620.
Updates #58848.

Change-Id: I56382dd305de8dac3841a7a7e664277826061eaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/475375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 035db07)
Reviewed-on: https://go-review.googlesource.com/c/go/+/476577
@gopherbot
Copy link
Author

Closed by merging 3ff6dbd to release-branch.go1.20.

@golang golang locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge GoCommand cmd/go
Projects
None yet
Development

No branches or pull requests

3 participants