embench / embench-iot

The main Embench repository
https://www.embench.org/
GNU General Public License v3.0
248 stars 101 forks source link

EMB2.0: Automatic stdlib size overhead adjustment #191

Open I-mikan-I opened 4 months ago

I-mikan-I commented 4 months ago

We try to subtract the size overhead for libraries, startup files, crt when calculating the size of benchmarks. Currently this is done as follows:

Issues with the current approach

New approach (planned for embench-iot 2.0)

I-mikan-I commented 4 months ago

addressed in ace099eefb4fcc

I-mikan-I commented 4 months ago

There are some issues i see with the new approach:

Perhaps it would be a better idea to compile each benchmark as a shared library with -nostartupfiles -nostdlib -c?

jeremybennett commented 4 months ago

I'm not sure that shared libraries help if you are going to compile down for a small embedded device.

One option is to use attributes to force particular functions and symbols to be retained. Would adding __attribute__ ((noinline)) __attribute__ ((externally_visible)) to the declaration of the relevant functions do the trick?

I-mikan-I commented 4 months ago

I'm not sure that shared libraries help if you are going to compile down for a small embedded device.

It wouldn't be possible to run them as dylibs, i just thought if you compile them as such, you remove any libraries and startup files from the elf/macho and can get an accurate size measurement for the code size. If we want to run the same file that we measured the size of then this isn't viable.

One option is to use attributes to force particular functions and symbols to be retained. Would adding __attribute__ ((noinline)) __attribute__ ((externally_visible)) to the declaration of the relevant functions do the trick?

Thanks, I'll try this attribute. This should improve --export-dynamic by also preventing inlining.

I-mikan-I commented 4 months ago

I compared the results of either using __attribute__ ((noinline)) __attribute__ ((externally_visible)), or using -Wl,--export-all.

The --export-all variant seems to be more accurate: for tarfind it reports a size of 265 bytes, the actual size of the benchmark_body code being 260 bytes.

simonpcook commented 4 months ago

I thought it was previously discussed that embench was moving away from library subtraction in part because of issues like the ones you’ve raised, did this now change?