-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Implement -Zgcc-ld=lld
stabilization MCP
#96401
Conversation
16f42bb
to
56dee54
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Distro builds don't distribute it by default, and can't use `-Clink-self-contained=linker -Clinker-flavor=gcc:lld` to enable it.
only the stable values for `-Clinker-flavor` and `-Clink-self-contained` can be used on stable until we have more feedback on the interface
These values require using `-Z unstable options`
…` match currently only "lld" is usable in this context
ensures that the wrapped linker is indeed passed straight to cc
using the `-C linker-flavor=gcc:lld -C link-self-contained=linker` stable flags
I understand that the PR is intended to show the final state of the feature, but for actually landing this I'd strongly prefer to implement the orthogonal parts as separate PRs, the |
Thanks a bunch @petrochenkov, I will separate these in different PRs. |
I've extracted the |
I've now extracted the Would you prefer I add the change that make use of both flags to trigger using |
☔ The latest upstream changes (presumably #97239) made this pull request unmergeable. Please resolve the merge conflicts. |
@lqd @petrochenkov any updates on this? |
Closing this pr as inactive |
This PR is a draft implementation of MCP #510 to stabilize
-Zgcc-ld=lld
as-Clink-self-contained=linker -Clinker-flavor=gcc:lld
.The changes to the
-Clink-self-contained
and-Clinker-flavor
flags described below are tentative, currently protected by-Z unstable-options
to gather feedback on nightly, and subject to FCP (either in this PR or when they are truly stabilized when removing the-Z unstable-options
check).1.
-C link-self-contained
Today,
-C link-self-contained
is a tristate bool, whose default value is determined by the current target spec. Theon
andoff
values force the rust-provided CRT objects to be linked.The way to choose the target-defined behavior is to omit the flag, there is no value one can use.
Proposed behavior: to model using a rust-provided linker (like
rust-lld
), a new value-C link-self-contained=linker
is added. This flag becomes a bit more complex, controlling two facets: the CRT linking, and the use of arustup
linker.In order to not change stable behavior:
-C link-self-contained=y
still targets only the CRT linking (although it can be argued that this could opt in to both)-C link-self-contained=n
disables both-C link-self-contained=linker
turns on the linker facet, but keeps the default CRT facet-C link-self-contained=auto
. Iflinker
ever becomes a default, this would allow to turn off the linker facet while still keeping the target-defined CRT-linking behavior. Otherwise, the fact that this value is only available when the flag is absent will prevent picking it explicitly.-C link-self-contained=y
to mean a single or both facets, a value like-C link-self-contained=crt
would be useful iflinker
ever became the default: this would allow to turn off the linker facet while opting into the CRT-linking.-C link-self-contained=all
. We had discussed e.g.-C link-self-contained=crt,linker
, but without a way or need to turn off CRT-linking while enabling the linker (a use-case-C link-self-contained=linker
would serve most of the time, as the CRT-linking is only enabled in a very limited number or targets) it doesn't seem that useful to specify both ascrt,linker
. If we need a way to do so, then-C link-self-contained=crt,linker
and e.g.-C link-self-contained=no-crt,linker
could be used.2.
-C linker-flavor
Today,
-C linker-flavor
is a list of flavor mappings (LinkerFlavor
s) that target specs can use.Proposed behavior: these stable values are retained, but a new extensible one is added for the
gcc
flavor:gcc:*
. Thegcc:
prefix would allow to specify a linker forcc
to use, much like one would add a-fuse-ld
link-arg today:-C linker-flavor=gcc:lld
would be a thin wrapper over that, and pass-fuse-ld=lld
to thecc
process.3.
-C linker-flavor=gcc:lld -C link-self-contained=linker
This is the combination that allows using
rust-lld
, by providing either-fuse-ld
or-B
with the sysroot path containing thelld-wrapper
s that will launchrust-lld
.Opening as draft for discussion about:
-Clink-self-contained
described above: the individual and aggregate opt-ins and opt-outs, making sure that stable behavior is preserved, and that there are adequate options to keep the stable behavior iflinker
becomes a default one dayand because:
gcc
linker-flavor (andrust-lld
already with-C linker=rust-lld
). Maybe nothing in particular--help
text or wait for when we'll drop the-Z unstable-options
requirement ?run-make
tests, maybe some need to be more constrained (e.g. linux only), and would love feedback about themr? @ghost