-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Make lto
and linker-plugin-lto
work the same for compiler_builtins
#142323
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
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in tests/ui/sanitizer cc @rcvalle Some changes occurred in compiler/rustc_codegen_ssa |
So it does seem to also work for fully linked programs with a custom-built std. The remaining thing to check is whether a side-injected implementation of methods in
(I had to slightly adjust the deps to deal with modern cargo, but it seems to work fine.) I have also tested this patch on the current Android platform build, which does a lot of different things with LTO being on and off. Is there anything else folks think we should test? cc @tgross35 in case he has ideas of ways this might break stuff. |
r? @dianqk |
When using (I might reply slowly recently.) |
tl;dr: From CFI's perspective, yes, In an ideal world, At a high level, enabling CFI or KCFI for a crate does two things:
KCFI transmits this information through the program text itself, CFI transmits it through a global data structure constructed through LTO. If we actually exclude Finally, suppressing CFI or KCFI in |
Thanks for your explanation, but your code doesn't get RUSTC_LOG=rustc_codegen_llvm::back::lto rustc +stage1 -Clto=fat main.rs IIUC, Clang has not applied CFI to compiler-rt. Getting X participated in LTO is very tricky, or at least no one has ever tried it before. @rustbot author |
Reminder, once the PR becomes ready for a review, use |
I will double check the logs with the right command, but for CFI (or my change) to work, you need a stdlib builtin that configuration, which isn't normally implied by just adding Probably the right command for a dummy cargo package looks like
I'll get back to you with a concrete dump of the change in compilation if you think this may not be working. Given that the error went away, the only potential failure mode I expect is that the CFI in compiler-builtins might be in a segregated alias-space from the rest of the binary. That would be good to know, because it would mean the issue isn't entirely fixed, but it would mean it would be harder to trigger, because the user code would need to use a compiler-builtins function as a pointer, or compiler-builtins would need to take a user function pointer (not currently present). |
Fixes: #142284
This still needs more testing to make sure it doesn't bring back #118609