malloc: Compile with -fno-strict-aliasing
Commit Message
Not sure what the performance impact will be. I think this will be
quite nasty for the heap protector. But I don't see a way around this
with the current malloc.
Thanks,
Florian
malloc does this, among other things:
To simplify use in double-linked lists, each bin header acts
as a malloc_chunk. This avoids special-casing for headers.
But to conserve space and improve locality, we allocate
only the fd/bk pointers of bins, and then use repositioning tricks
to treat these as the fields of a malloc_chunk*.
This violates GCC's strict aliasing rules.
2018-11-13 Florian Weimer <fweimer@redhat.com>
* malloc/Makefile (CFLAGS-malloc.c): Compile malloc.c if
-fno-strict-aliasing due to aliasing violations.
@@ -171,6 +171,9 @@ include ../Rules
CFLAGS-mcheck-init.c += $(PIC-ccflag)
CFLAGS-obstack.c += $(uses-callbacks)
+# malloc.c contains many aliasing violations.
+CFLAGS-malloc.c += -fno-strict-aliasing
+
$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
-rm -f $@
$(patsubst %/,cd % &&,$(objpfx)) \