make: build with linker garbage collection#1784
make: build with linker garbage collection#1784thomaseichinger wants to merge 2 commits intoRIOT-OS:masterfrom
Conversation
|
With RIOT/examples/hello-world@et-mbpr [add_gc] % make clean all BOARD=iot-lab_M3
...
text data bss dec hex filename
9528 112 3296 12936 3288 RIOT/examples/hello-world/bin/iot-lab_M3/hello-world.elfWithout RIOT/examples/hello-world@et-mbpr [add_gc] % make clean all BOARD=iot-lab_M3
...
text data bss dec hex filename
12556 112 3296 15964 3e5c RIOT/examples/hello-world/bin/iot-lab_M3/hello-world.elf |
db9d3d8 to
adbb887
Compare
|
+1 |
|
Yes, |
|
+1 here, too! I wonder how we best test this to find out if this could have any side-effects? |
|
@haukepetersen, Like @thomaseichinger said, linker scripts must be adapted. If the linker script adds the object code with something like I guess one more side effect is that there may be unused code in the regression tests that does not trigger a build error wrt any undefined references (e.g. if a function or a global variable has changed name in an API change) since the unused functions are purged during the garbage collection, but this could also be seen as missing test coverage. |
|
@gebart I didn't mean the Linkerscript part - that is quite clear. I was just wondering, if we might have problems from some code that is trying to use code that was dropped by the garbage collector? I actually can't think of any situation - but better think now then look for (hard to find) bugs later... :-) |
|
@haukepetersen Well, if there is some code using parts of what is being dropped by the GC, then that would very likely be either: A linker bug, or the code is broken. The only scenario that I can imagine where code would be using stuff without the actual symbol being detected as used would be if some address is hard coded and the address is used to access the data instead of the symbol itself. |
|
I agree, I can not think of a standard case, where this would happen. So there is nothing speaking against merging this PR, right? |
|
Needs rebase. |
adbb887 to
a112003
Compare
|
rebased |
|
Add newer boards?
|
|
@authmillenon I think we should decide if we go for this or #1927 first. |
|
I think we go for #1927 for now and maybe include this later. |
|
@thomaseichinger Could you rebase this on latest master? Before merging this we need to verify that each of the modified platforms still produce working binaries. Some things to especially look for are:
|
Currently only has the linker flag --gc-sections defined which tells the linker to omit dead code. Depending on the application this leads to significant reduction of code size.
|
@gebart rebased. |
|
some size information on my test builds: |
|
@gebart Does this compare to a normal compile or to a compilation using LTO? |
|
And which application did you compile? |
|
Normal compile of I created a list of all stripped symbols in the Feel free to look through the list to see if any ISRs or other critical functions or variables have been stripped. |
9f184dd to
45554bf
Compare
|
Can this be reviewed during the next Hack'n'ACK? Like I wrote above, I don't have much of the hardware necessary to test this so it would be easier if people with the proper hardware can test this and report the results here rather than having to wade through all the stripped symbols list in order to find if anything crucial is missing. |
|
The last Hack'n'ACK was yesterday (and I did not feel to have the expertise nor awareness to review this PR), so the next one would be in a month from now... |
|
Tried it with the samr21 and the default application. My results: And it ran just fine (i.e. I could use the usual shell commands and they worked). Not sure if that's a proper way to test this, though? |
|
Maybe one can run a small test with rpl on IoT-LAB? If no one has the time, I can do next week. Please ping me. |
|
ping @OlegHahm |
|
Oops, I'm really sorry, but I forgot. Will try to do it today. |
|
Seems not to break anything. ACK if rebased. |
|
I will adopt this and rebase. |
|
See #3163 for a rebase after the Cortex M unification |
Currently only has the linker flag
--gc-sectionsdefined which tellsthe linker to omit dead code. Depending on the application this leads
to significant reduction of code size.