Skip to content

Commit

Permalink
Merge pull request #359 from lukego/portable_binary
Browse files Browse the repository at this point in the history
Make ./snabb binary more portable
  • Loading branch information
lukego committed Feb 20, 2015
2 parents 22f8b85 + 946dbd9 commit 2a204bb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions gcc-preinclude.h
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $@"
Expand Down
11 changes: 11 additions & 0 deletions src/selftest.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 2a204bb

Please sign in to comment.