Closed simonjwright closed 1 year ago
Thanks for the report @simonjwright
My apologies, this is already taken care of in the development branch, see: https://github.com/AdaCore/bb-runtimes/commit/5a37fb3f216a731e73ed353dcbd4f1c9d3e697ec
I will see if can do new FSF builds with that option.
There is a new
strlen
-related optimisation in GCC 12 which results in calls tostrlen()
inlibc
. You wouldn't notice this in a native compilation, but you will see it in the light runtimes, which link with-nolibc
.(Incidentally, as well as
-nolibc
, the embedded runtimes say-Wl,--start-group,-lgnarl,-lgnat,-lc,-lgcc,--end-group
- so why-nolibc
?)Building this:
with
results in
On investigation, if optimising at
-O2
, when the compiler sees thiswhere you would have expected the
Strlen
to be the one at line 201 what actually gets called is juststrlen
which is of course provided as part oflibc
.Also, in the
Strlen
at line 201, the loop is translated as a call tostrlen
.This is fascinating: it seems as though the compiler recognises that the code generated in the local function
Strlen
is the same as ... what__builtin_strlen
would have produced? and generates the call tostrlen
??In fact, at
-O2
,i-cstrin.o
referencesmemcpy
,memset
, andstrlen
, whereas at lower levels it only referencesmemcpy
.Other objects reference
memcpy
andmemset
, but that’s not an issue because the RTS provides them (s-memcop
,s-memset
).Could this be fixed by providing
s-strlen
in the RTS?