diff --git a/Makefile b/Makefile index 0da12d60bd..25393970bc 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ COBJ = $(CSRC:.c=.o) LUAJIT_O := deps/luajit/src/libluajit.a SYSCALL := src/syscall.lua -LUAJIT_CFLAGS := -DLUAJIT_USE_PERFTOOLS -DLUAJIT_USE_GDBJIT -DLUAJIT_NUMMODE=3 +LUAJIT_CFLAGS := -DLUAJIT_USE_PERFTOOLS -DLUAJIT_USE_GDBJIT -DLUAJIT_NUMMODE=3 -include $(CURDIR)/gcc-preinclude.h all: $(LUAJIT_O) $(SYSCALL) cd src && $(MAKE) diff --git a/gcc-preinclude.h b/gcc-preinclude.h new file mode 100644 index 0000000000..99b4e0cc87 --- /dev/null +++ b/gcc-preinclude.h @@ -0,0 +1,8 @@ +// Force an old symbol version on memcpy. +// See: http://www.win.tue.nl/~aeb/linux/misc/gcc-semibug.html +// https://rjpower9000.wordpress.com/2012/04/09/fun-with-shared-libraries-version-glibc_2-14-not-found/ + +#ifndef __ASSEMBLER__ +__asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); +#endif + diff --git a/src/Makefile b/src/Makefile index a375383f0c..87d2775236 100644 --- a/src/Makefile +++ b/src/Makefile @@ -45,7 +45,7 @@ snabb: $(LUAOBJ) $(HOBJ) $(COBJ) $(ASMOBJ) $(E) "LINK $@" $(Q) gcc -Wl,--no-as-needed -Wl,-E -Werror -Wall -o $@ $^ \ ../deps/luajit/src/libluajit.a \ - -lc -ldl -lm -lrt -lpthread + -lrt -lc -ldl -lm -lpthread @echo -n "Firmware: " @ln -fs snabb snabbswitch @ls -sh snabb @@ -99,7 +99,7 @@ $(LUAOBJ): obj/%_lua.o: %.lua Makefile | $(OBJDIR) $(COBJ): obj/%_c.o: %.c $(CHDR) Makefile | $(OBJDIR) $(E) "C $@" - $(Q) gcc -Wl,-E -I ../deps/luajit/src -I . -c -Wall -Werror -o $@ $< + $(Q) gcc -Wl,-E -I ../deps/luajit/src -I . -include $(CURDIR)/../gcc-preinclude.h -c -Wall -Werror -o $@ $< $(HOBJ): obj/%_h.o: %.h Makefile | $(OBJDIR) $(E) "H $@" diff --git a/src/selftest.sh b/src/selftest.sh new file mode 100755 index 0000000000..764ab1e63f --- /dev/null +++ b/src/selftest.sh @@ -0,0 +1,11 @@ +#!/bin/bash +echo "selftest: ./snabb binary portability" +echo "Scanning for symbols requiring GLIBC > 2.7" +if objdump -T snabb | \ + awk '/GLIBC/ { print $(NF-1), $NF }' | \ + grep -v 'GLIBC_2\.[0-7][\. ]'; then + echo "^^^ Error ^^^" >&2 + echo "(You might just need to 'make clean; make' at the top level.)" + exit 1 +fi +echo "selftest: ok"