-
Notifications
You must be signed in to change notification settings - Fork 112
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
Re-enable lto support guarded behind feature flags #198
Conversation
- fat-lto for fat lto, will override thin-lto if specified - thin-lto for thin lto, will fallback to fat-lto is not supported Signed-off-by: Jiahao XU <[email protected]>
if cfg!(feature = "fat-lto") { | ||
config.flag_if_supported("-flto"); | ||
} else if cfg!(feature = "thin-lto") { | ||
flag_if_supported_with_fallbacks( | ||
&mut config, | ||
&["-flto=thin", "-flto"], | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous bug with lto should be fixed by rust-lang/cc-rs#757
@gyscos I recommend to upgrade to new cc
once it lands.
But still, I want to be safe here by putting them behind feature flags so that users can decide whether to enable fat-lto or thin-lto.
Thanks for the work! |
Hmmm at this moment running |
Hmmm both fat-lto and thin-lto works on my M1 macbook. Well, at least we can override thin-lto with fat-lto, which should work more reliably on more targets. |
It also fails with Indeed, running it on a M1 macbook running macOS, the tests pass. Might be because on the linux machine, |
@gyscos It should get better with rust-lang/cc-rs#757 once cc releases a new version. |
Aaah right I had an explicit override for gcc before. Now it only relies on (Was just trying to understand why it's now working worse for me than before disabling LTO.) |
My fix for I don't know why it didn't check for that but this should improve things a bit, when compiler fails without any stderr output. |
(This post may sound trivial for anyone used to LTO, but I was not, so here's my journey.) Soo I just realized this only works if the C lib is compiled by clang (or another LLVM-based compiler), otherwise the intermediate compiled file will only contain gcc's flavor of IR, which rust cannot use. So at the moment, both In addition, TLDR, In my case, I had to run:
Unsurprisingly, on platforms where It also means that, since this can currently only work with |
Signed-off-by: Jiahao XU [email protected]