Closed rmn30 closed 3 months ago
With the recent changes to rts.c related to setting the coverage file I get a compilation error if I try to use link time optimisation. To reproduce using one of the tests in the test directory:
rts.c
sail -c ./test/c/struct.sail > struct.c gcc -flto -I lib/ struct.c lib/rts.c lib/sail.c lib/elf.c -lgmp -lz
which results in:
lib/rts.c:81:13: error: variable ‘sail_rts_set_coverage_file’ redeclared as function 81 | extern void sail_rts_set_coverage_file(char *output_file); | ^ struct.c:4:8: note: previously declared here 4 | void (*sail_rts_set_coverage_file)(char *) = NULL; | ^ lto1: fatal error: errors during merging of translation units compilation terminated. lto-wrapper: fatal error: gcc returned 1 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status
Without -flto the gcc command succeeds. I guess sail doesn't need to emit the function pointer anymore?
-flto
As an aside: it's a very good idea to use link time optimisation due to many calls from generated C to small functions in rts.c.
Should be fixed by https://github.com/rems-project/sail/pull/510
With the recent changes to
rts.c
related to setting the coverage file I get a compilation error if I try to use link time optimisation. To reproduce using one of the tests in the test directory:which results in:
Without
-flto
the gcc command succeeds. I guess sail doesn't need to emit the function pointer anymore?