Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 284d96a4 authored by Michael Ellerman's avatar Michael Ellerman Committed by Matthew Wilcox
Browse files

radix tree test suite: Fix build with --as-needed



Currently the radix tree test suite doesn't build with toolchains that
use --as-needed by default, for example Ubuntu's:

  cc -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE -fsanitize=address -lpthread -lurcu main.o ... -o main
  /usr/bin/ld: regression1.o: undefined reference to symbol 'pthread_join@@GLIBC_2.17'
  /lib/powerpc64le-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
  collect2: error: ld returned 1 exit status

This is caused by the custom makefile rules placing LDFLAGS before the
.o files that need the libraries.

We could fix it by using --no-as-needed, or rewriting the custom rules.
But we can also just drop the custom rules and move the libraries to
LDLIBS, and then the default rules work correctly - with the one caveat
that we need to add -fsanitize=address to LDFLAGS because that must be
passed to the linker as well as the compiler.

Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
parent c4634b08
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line


CFLAGS += -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE -fsanitize=address
CFLAGS += -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE -fsanitize=address
LDFLAGS += -lpthread -lurcu
LDFLAGS += -fsanitize=address
LDLIBS+= -lpthread -lurcu
TARGETS = main idr-test multiorder
TARGETS = main idr-test multiorder
CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o
CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
@@ -17,13 +18,10 @@ endif
targets: mapshift $(TARGETS)
targets: mapshift $(TARGETS)


main:	$(OFILES)
main:	$(OFILES)
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o main


idr-test: idr-test.o $(CORE_OFILES)
idr-test: idr-test.o $(CORE_OFILES)
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o idr-test


multiorder: multiorder.o $(CORE_OFILES)
multiorder: multiorder.o $(CORE_OFILES)
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o multiorder


clean:
clean:
	$(RM) $(TARGETS) *.o radix-tree.c idr.c generated/map-shift.h
	$(RM) $(TARGETS) *.o radix-tree.c idr.c generated/map-shift.h