[PATCH] include LDFLAGS when linking unit tests

Tom Guilderson tguilder at akamai.com
Wed Jan 30 09:43:10 PST 2013

When building and running 32 bit x86 unit tests on x86_64 host, linker throws

lib/libjemalloc.so: could not read symbols: File in wrong format

This is caused by LDFLAGS not being passed to unit test linking step, the
following patch fixes this issue.

--- jemalloc-3.2.0/Makefile.in  2012-11-09 19:44:45.000000000 +0000
+++ jemalloc-3.2.0/Makefile.in  2013-01-16 19:02:39.000000000 +0000
@@ -190,7 +190,7 @@
 $(objroot)test/%$(EXE): $(objroot)test/%.$(O) $(objroot)src/util.$(O) $(DSOS)
                         @mkdir -p $(@D)
-                        $(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(filter -lpthread,$(LIBS)) $(EXTRA_LDFLAGS)
+                        $(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter -lpthread,$(LIBS)) $(EXTRA_LDFLAGS)
 build_lib_shared: $(DSOS)
 build_lib_static: $(STATIC_LIBS)

More information about the jemalloc-discuss mailing list