On Thu, 3 Aug 2017, Joerg Sonnenberger wrote:
On Thu, Aug 03, 2017 at 05:53:43PM +1000, Bruce Evans wrote:
Freestanding versions (static and otherwise) cause problems with builtins.
-ffreestanding turns off all builtins. The static memcpy used to be
ifdefed so as to use __builtin_memcpy instead of the static one if the
compiler is gcc. That apparently broke with gcc-4.2, since the builtin
will call libc memcpy() in some cases, although memcpy() is unavailable
in the freestanding case.
GCC always had a requirement that freestanding environment must provide
certain functions (memcpy, memmove, memset, memcmp). At least memcpy and
memset are regulary used for certain code constructs. While most calls
will be inlined, it is not required.
I had forgotten about that bug. boot2 doesn't have many fancy code
constructs, but it might have struct copying and gcc uses memcpy for
copying large structs. clang-4.0 has the same bug. Testing showed
1 bug nearby: for newer CPUs, it generates large code with several
movups's for small struct copies. The bug is that -Os doesn't turn
this off. But boot2 uses -march=i386 which does turn this off. For
not so new CPUs like core2 where movups is slower than movaps but
movaps is unusable because the structs might not be aligned, it
normally generates large code with moves through integer registers,
but -Os works to turn this off.
The change for gcc-4.2 was apparently to support this. The static
memcpy is not quite compatible, but is close enough and you can check
this in the generated code. The problem is that it should be re-checked
for every change in the source code and compiler.
Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"