-
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
Cannot opt out of LLVM MergeFunctions pass on stable #64310
Comments
Is it a mergefunc bug or a ThinLTO bug? Can it be triggered without ThinLTO? If not, I would rather not blindly disable it on macOS, at least not when ThinLTO isn't enabled.
|
It's not a bug in mergefunc. It might not even be a bug in ThinLTO. It's just that mergefunc is the only thing in |
Has the ld64 bug been reported somewhere? |
We could use |
@nox This is already supported via either |
@nikic Do you mean that the test case also fails with |
rust/src/librustc_codegen_llvm/llvm_util.rs Lines 65 to 74 in 185b9ac
Answering my own question, we already have a knob for that. |
Which was added because aliases already cause issues on other architectures. |
As @nikic and @nox point to there is the unstable |
Yes, I've been told that it has been reported to Apple. On nightly, one can already control the mergefunc pass. On stable, however, one is stuck with the default behavior. That's what this issue is mostly about. |
@michaelwoerister just want to double-check my understanding: I would have thought one could use the Am I incorrect about this? (If I am correct, I nonetheless will admit that this is an ugly (and very fragile) method to opt out of the MergeFunctions pass) |
@pnkfelix I think that is correct, yes. It would be rather hard, however, to re-create the set of passes meaningfully, I suspect. Even the compiler delegates this to methods within LLVM, iirc. |
I think using |
So did that help, @michaelwoerister? |
Unfortunately not. Specifying this gives me:
|
…, r=varkor Enable opting out of specific default LLVM arguments. `rustc` by default adds a few arguments to LLVM (like `-mergefunc-use-aliases` for example). With this PR `rustc` will only emit these arguments if the same argument has not already been specified by the user via `-Cllvm-args`. This enables opting out of these defaults. The PR also removes a PGO specific `-Z` flag the effect of which can also be easily achieved by `-Cllvm-args`. Fixes rust-lang#64310.
…, r=varkor Enable opting out of specific default LLVM arguments. `rustc` by default adds a few arguments to LLVM (like `-mergefunc-use-aliases` for example). With this PR `rustc` will only emit these arguments if the same argument has not already been specified by the user via `-Cllvm-args`. This enables opting out of these defaults. The PR also removes a PGO specific `-Z` flag the effect of which can also be easily achieved by `-Cllvm-args`. Fixes rust-lang#64310.
LLVM's MergeFunctions introduces aliases which can trigger a bug in macOS's
ld64
linker when compiling with ThinLTO: https://github.com/froydnj/ld64-aliases-bugFor this reason Firefox has to be built with a patched version of
ld64
when compiling with xLTO. Since the bug in question is pretty nasty (the above example shows a program just returning a different value with no indication that anything is wrong), we should probably try to not trigger it.Right now, however, it seems that one cannot even turn the MergeFunctions pass off in stable Rust. (I wonder if the pass should even be disabled by default on macOS?)
cc @rust-lang/compiler, @rust-lang/wg-codegen & @peterhj (this seems related to #57356)
The text was updated successfully, but these errors were encountered: