-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Functions referenced by global_asm
merged into other functions by LLVM
#96797
Comments
global_asm
merged into other functions by LLVM
I think |
It could be argued that this is actually an LLVM bug since
|
I had to have 1af3e0a to prevent |
Anyway, the biggest issue is the |
This is fixed by #97900.
The proper behavior for LLVM is still unclear, but at least #97900 fixes the immediate issue since those symbols now have external linkage.
This is a separate issue, but I think the proper way to fix this is to ensure that the |
It's of a different cause, but will have the same effect. I prefer to have it tracked in the same issue (but different work items).
The problem is two fold. For the normal non-LTO linking, what you described is sufficient. The major issue is LTO. Because LTO works on IR but not binary, it doesn't know if a symbol is being used in |
Do you have an example demonstrating the LTO related issue? Optimizations during LTO cannot remove symbols from
|
That comment suggests that even with internal visibility, LLVM isn't supposed to delete a symbol that is used by |
Here's my attempt at a fix in LLVM, but I'm not too happy about the code. It could use some review by someone more familiar with LLVM. |
Rebase LLVM submodule This is a rebase of our LLVM fork onto LLVM 14.0.5, which is intended to be the last release of the 14.x series. Additionally: * I've dropped three patches that were needed to build on FreeBSD 11, which is no longer necessary after rust-lang#97944. * I've dropped some cherry-picks that were later reverted. * I've cherry-picked llvm/llvm-project@caa2a82 for rust-lang#96797 (fyi `@Amanieu)`
This was fixed in LLVM which was updated in rust-lang#98285. https://reviews.llvm.org/D127751 Fixes rust-lang#96797
Add test for rust-lang#96797 This was fixed in LLVM which was updated in rust-lang#98285. https://reviews.llvm.org/D127751 Fixes rust-lang#96797
Add test for rust-lang#96797 This was fixed in LLVM which was updated in rust-lang#98285. https://reviews.llvm.org/D127751 Fixes rust-lang#96797
This code will fail to link because
foobar
is merged intomy_func
.Since global asms in LLVM can't reference symbols natively, we currently will add the mangled name to the string and pass it to LLVM. To prevent the file being optimized away, we add it to
llvm.compiler.used
.A few issues exist:
rustc_monomorphize
does not handle these functions specially, and thereforefoobar
above is considered as internal function and haveinternal
attribute attached.llvm.compiler.used
. I think LLVM should be allowed to this because we emit the internal linkage, and from my understanding renaming a local symbol should probably be allowed. @tmiasko argues otherwise and says thatllvm.compiler.used
shouldn't touch the symbol.llvm.compiler.used
, but it wouldn't show up as used in the exported symbol list, so it can still be stripped while doing LTO.We should do the following:
exported_symbols/linked_symbols
and thus reach the linker/LTO.llvm.compiler.used
+internal
.cc @Amanieu @tmiasko
@rustbot label: +A-inline-assembly +F-asm
This will block #93333
The text was updated successfully, but these errors were encountered: