make: add -ffunction-sections -fdata-sections to LINKFLAGS if LTO=1#16789
make: add -ffunction-sections -fdata-sections to LINKFLAGS if LTO=1#16789fjmolinas merged 2 commits intoRIOT-OS:masterfrom
Conversation
|
@fjmolinas could you do a test run with |
What do you want me to check? that it builds? Or the sizes? |
no, whether the LTO=1 binaries are working. Murdock can't (easily) do that. |
we could enable LTO by default and run tests |
yeah, not that difficult, done. |
😢 |
weird. I tried some of the tests, they work locally and when sending a locally compiled image to the test pi. |
|
Maybe the GCC version on CI is just too old? |
seems like, with building in docker I can reproduce. |
|
Is the ci required update addressed now @kaspar030? |
no, this needs a toolchain upgrade. |
98ae2f6 to
7aa21da
Compare
|
Unrelated failure, addressed in #17641 |
|
Didn't see there was a REMOVEME commit, I removed the label to not re-build but everything passed except for the unrelated test. |
7aa21da to
812b273
Compare
|
I ran some tests on a subset of hardware with LTO=1. Micropython and rust are a setup issue, z1 failures are expected and documented. Malloc failures are because of corrupted stdout, but the test ran fine. Since in any case LTO is never tested we really don't have a compare point against it, what I see is most tests passing and the hardfault is no longer present. For detailes results see https://ci.inria.fr/ci-riot-tribe/job/build-pipeline.jk/313/artifact/ |
|
There are also other failures than the reported one (which is probably related to permissions in /data/riotbuild/.cargo and how that is set up and cached outside docker), at least when trying to build locally here, but that appears to be a failure of the Rust side, and to be fixed there independently of this issue. Great to see this go ahead! (Tempted to already push the merge button as all is green, but not being familiar with the history I'll leave that to you). |
|
... and even the failures I've seen here were purely local errors, and after the adequate adjustments (as in: use the right nightly and remove erroneous bin content), the Rust test and applications with this and LTO=1 worked (on native and microbit-v2), and also built for nrf52dk (which I can't test). |
|
Thanks everyone! |
Contribution description
#14754 broke LTO as it created significantly larger binaries (instead of smaller) with LTO enabled. Our micro benchmarks showed increased performance, so LTO still worked partially.
I tracked this down to
-ffunction-sections -fdata-sectionsmissing for the linker invocation.This PR fixes that by adding those flags to LINKFLAGS if LTO is enabled.
binary (text) sizes for examples/hello-world on nrf52840dk:
Testing procedure
non-LTO binaries should be identical. lto binaries should be smaller and still work.
I did not enable "run tests" as no LTO tests are run on CI.
Issues/PRs references
#14754
fixes #16202