Skip to content
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

Enable cross-lang-fat-lto on Linux #817

Merged
merged 12 commits into from
Feb 19, 2023
Merged

Enable cross-lang-fat-lto on Linux #817

merged 12 commits into from
Feb 19, 2023

Conversation

NobodyXu
Copy link
Member

@NobodyXu NobodyXu commented Feb 18, 2023

Fixed #806

  • Add new feature flag cross-lang-fat-lto and enable it on release for linux
  • Enable -C linker-plugin-lto for linux
  • Only use -Z gcc-ld=lld on non-windows targets when cargo-zigbuild is not enabled

Signed-off-by: Jiahao XU [email protected]

@NobodyXu NobodyXu changed the title Enable cross lang fat lto Enable cross-lang-fat-lto on Linu Feb 19, 2023
@NobodyXu NobodyXu changed the title Enable cross-lang-fat-lto on Linu Enable cross-lang-fat-lto on Linux Feb 19, 2023
Signed-off-by: Jiahao XU <[email protected]>
@NobodyXu NobodyXu requested a review from passcod February 19, 2023 02:27
@NobodyXu NobodyXu merged commit 3f01076 into main Feb 19, 2023
@NobodyXu NobodyXu deleted the cross-lang-fat-lto branch February 19, 2023 04:19
@NobodyXu
Copy link
Member Author

before
after

It seems that enabling cross-lang-fat-lto is extremely effective at reducing binary size.
It reduces the size by at least 50% or even more.

I suppose that the linker is able to remove the code related to zstd compression support, since that is probably not used.

@passcod Seems like we should also do this for macos and windows, but they seems to be much harder than linux.
Enabling this on macos gives strange link time error like --plugin-opt not supported and on windows they use msvc by default.

@NobodyXu
Copy link
Member Author

NobodyXu commented Feb 19, 2023

I've tested the aarch64-unknown-linux-{gnu, musl} inside docker desktop on MacOS and they somehow stuck at "Looking up crate information".

htop shows that one of the thread is running forever, so it could be deadlock or could it be a miscompilation?

I will investigate on this latter.
@passcod It would be great if you could help me on this.

@NobodyXu
Copy link
Member Author

I will investigate on this latter.

I've submit PR #818 to test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable cross-language LTO for linux, windows and macos
2 participants