musllibc: workaround -Os breaks memcpy on riscv32
When memcpy is built with -Os the use of __may_alias__ does not work
as intended; expressions like
typedef uint32_t __attribute__((__may_alias__)) u32;
x = *(u32 *)(s+2);
emit code that does the equivalent of: x = *(u32 *)(s+0);
This results in unaligned accesses that crash capdl-loader (when built
with ZF_LOG enabled). Workaround this by forcing CFLAGS_MEMOPS to include
-O3. This has minimal effect on the memory footprint:
$ diff /tmp/libc-sizes /tmp/libc-sizes-with-change
962,963c962,963
< 38 0 0 38 26 memcmp.o (ex libc.a)
< 866 0 0 866 362 memcpy.o (ex libc.a)
Change-Id: I012b30f90a85d73e919438ce3afde8f12616e630
---
> 36 0 0 36 24 memcmp.o (ex libc.a)
> 1008 0 0 1008 3f0 memcpy.o (ex libc.a)
965c965
< 238 0 0 238 ee memmove.o (ex libc.a)
---
> 396 0 0 396 18c memmove.o (ex libc.a)
968c968
< 186 0 0 186 ba memset.o (ex libc.a)
---
> 198 0 0 198 c6 memset.o (ex libc.a)
Change-Id: Ic47a075b830b0b2d0f66d8904f2cb461b904c5aa
1 file changed