summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordivanorama <divanorama@gmail.com>2022-09-29 23:35:59 +0200
committerQi Wang <interwq@gmail.com>2022-10-03 10:39:13 -0700
commit3de0c24859f4413bf03448249078169bb50bda0f (patch)
tree111e7f438209f0485446118a677c1c0c4d9569db
parentc0c9783ec9289e6d1de749ff20081af65bdd78b8 (diff)
downloadjemalloc-3de0c24859f4413bf03448249078169bb50bda0f.tar.gz
Disable builtin malloc in tests
With `--with-jemalloc-prefix=` and without `-fno-builtin` or `-O1` both clang and gcc may optimize out `malloc` calls whose result is unused. Comparing result to NULL also doesn't necessarily count as being used. This won't be a problem in most client programs as this only concerns really unused pointers, but in tests it's important to actually execute allocations. `-fno-builtin` should disable this optimization for both gcc and clang, and applying it only to tests code shouldn't hopefully be an issue. Another alternative is to force "use" of result but that'd require more changes and may miss some other optimization-related issues. This should resolve https://github.com/jemalloc/jemalloc/issues/2091
-rw-r--r--Makefile.in2
1 files changed, 2 insertions, 0 deletions
diff --git a/Makefile.in b/Makefile.in
index 6809fb29..a964f07e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -458,6 +458,8 @@ $(TESTS_OBJS): $(objroot)test/%.$(O): $(srcroot)test/%.c
$(TESTS_CPP_OBJS): $(objroot)test/%.$(O): $(srcroot)test/%.cpp
$(TESTS_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include
$(TESTS_CPP_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include
+$(TESTS_OBJS): CFLAGS += -fno-builtin
+$(TESTS_CPP_OBJS): CPPFLAGS += -fno-builtin
ifneq ($(IMPORTLIB),$(SO))
$(CPP_OBJS) $(C_SYM_OBJS) $(C_OBJS) $(C_JET_SYM_OBJS) $(C_JET_OBJS): CPPFLAGS += -DDLLEXPORT
endif