-
Notifications
You must be signed in to change notification settings - Fork 37.7k
build: add linker optimisation flags to gitian & guix (Linux) #17929
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
build: add linker optimisation flags to gitian & guix (Linux) #17929
Conversation
How is this different from #16791? |
@MarcoFalke Despite similar naming, this is not the same thing as LTO. This will optimize the symbol hash tables in binaries, whereas LTO does intermodular optimizations. More info on either: Optimizing Linker Load Times and LTO. |
Concept ACK, good to know that it's different from LTO. Need to look into it more carefully. |
Concept ACK, although would like to see this in Gitian/release builds instead of default configure. At some point we should probably add a doc to the repo of recommended configure flags and what they do. It seems to me that, when supplied with
Perhaps that accounts for the performance differences you're seeing? |
73d1f49
to
a8b0929
Compare
I agree, and I've change this to be a configure flag, |
Concept ACK |
Passing optimization flags to the link stage has been the default for decades in autotools projects (autoconf/automake/libtool). Thus,
|
From #bitcoin-builds meeting notes today: We should switch to just adding the -Wl,-O2 to LDFLAGs in Gitian/Guix, and benchmark to see the differences. |
Gitian builds
|
Any -O argument will enable optimizations in GNU ld. We can use -O2 here, as this matches our compile flags. Note that this would also enable additional optimizations if using the lld or gold linkers, when compared to -O0.
Any -O argument will enable optimizations in GNU ld. We can use -O2 here, as this matches our compile flags. Note that this would also enable additional optimizations if using the lld or gold linkers, when compared to -O0.
a8b0929
to
f2b5b0a
Compare
I've updated this PR as discussed. Add the flags to the guix and gitian descriptors. Also adding additional information to the PR description. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Gitian builds
|
ACK f2b5b0a |
ACK f2b5b0a |
… guix (Linux) f2b5b0a build: add linker optimization flags to guix (fanquake) b8b050a build: add linker optimization flags to gitian descriptors (fanquake) Pull request description: This PR adds `-Wl,O2` to our gitian and guix LDFLAGS. This makes the linker perform certain optimisations (and is different from LTO). Any -O argument will enable optimizations in GNU ld. We can use -O2 here, as this matches our compile flags. Note that this would also enable additional optimizations if using the lld or gold linkers, when compared to -O0. A nice writeup + diagrams of some of these optimizations is available here: http://lwn.net/Articles/192624/. #### master ```bash # bitcoind Histogram for `.gnu.hash' bucket list length (total of 3 buckets) Length Number % of total Coverage 0 1 ( 33.3%) 0.0% 1 0 ( 0.0%) 0.0% 2 1 ( 33.3%) 40.0% 3 1 ( 33.3%) 100.0% ``` ```bash # bitcoin-qt Histogram for `.gnu.hash' bucket list length (total of 3 buckets) Length Number % of total Coverage 0 0 ( 0.0%) 0.0% 1 1 ( 33.3%) 10.0% 2 0 ( 0.0%) 10.0% 3 0 ( 0.0%) 10.0% 4 1 ( 33.3%) 50.0% 5 1 ( 33.3%) 100.0% ``` #### this PR: ```bash # bitcoind Histogram for `.gnu.hash' bucket list length (total of 8 buckets) Length Number % of total Coverage 0 3 ( 37.5%) 0.0% 1 5 ( 62.5%) 100.0% ``` ```bash # bitcoin-qt Histogram for `.gnu.hash' bucket list length (total of 19 buckets) Length Number % of total Coverage 0 9 ( 47.4%) 0.0% 1 10 ( 52.6%) 100.0% ``` #### GNU ld -O > If level is a numeric values greater than zero ld optimizes the output. This might take significantly longer and therefore probably should only be enabled for the final binary. At the moment this option only affects ELF shared library generation. Future releases of the linker may make more use of this option. Also currently there is no difference in the linker’s behaviour for different non-zero values of this option. Again this may change with future releases. #### lld -O > Optimize output file size ACKs for top commit: dongcarl: ACK f2b5b0a laanwj: ACK f2b5b0a Tree-SHA512: e53f3a4338317dbec65d3a93b57b5a6204aabdf9ac82d99447847a3c8627facc53c58c2cf947376f13edd979fc8129a80f18d9ebeccd191a576c83f1dad5c513
Any -O argument will enable optimizations in GNU ld. We can use -O2 here, as this matches our compile flags. Note that this would also enable additional optimizations if using the lld or gold linkers, when compared to -O0. Github-Pull: bitcoin#17929 Rebased-From: b8b050a
This PR adds
-Wl,O2
to our gitian and guix LDFLAGS. This makes the linker perform certain optimisations (and is different from LTO).Any -O argument will enable optimizations in GNU ld. We can use -O2 here, as this matches our compile flags. Note that this would also enable additional optimizations if using the lld or gold linkers, when compared to -O0.
A nice writeup + diagrams of some of these optimizations is available here: http://lwn.net/Articles/192624/.
master
this PR:
GNU ld -O
lld -O