I just started writing an ebuild for a game using lua, and it fails to configure when --as-needed is specified. I found that, doing the following sed: sed -i -e 's:^\(.*-shared.*\):\1 $(DLLIB) $(EXTRA_LIBS):' Makefile Fixes the problem. It's needed because the -ldl and -lm libraries get a NEEDED entry in the so file. Programs that link against liblua without adding -lm -ldl themselves fail get unresolved symbols, like: /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/../../../../lib64/liblualib.so: undefined reference to `log' /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/../../../../lib64/liblualib.so: undefined reference to `sqrt' /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/../../../../lib64/liblualib.so: undefined reference to `dlerror'
I will attach patches for lua-5.0.2 and its ebuild which do the following: * make lua respect user's LDFLAGS when linking binaries or libs (in addition, the default -Wl,-E is still used for the binaries). * fix unresolved symbols of liblualib by linking it to liblua and the other libs it needs. I don't know much packages to test this, but according to "ldd -r" the libs should be sane now. Does it work for your game too?
Created attachment 86374 [details, diff] files/lua-5.0.2-LDFLAGS_and_as-needed.patch
Created attachment 86375 [details, diff] lua-5.0.2-ebuild.patch patch is for -5.0.2.ebuild, not the masked -r1 (i've not looked at this one)
The game is currently in a broken state so I cannot comment, but looking at lib the ebuild produces, it looks correct
twp allowe3d me to apply this one. It makes xmoto work with as-needed for me, thank you! + 25 Jun 2006; Stefan Schweizer <genstef@gentoo.org> + +files/lua-5.0.2-LDFLAGS_and_as-needed.patch, lua-5.0.2.ebuild: + as-needed patch thanks to TGL <degrenier@easyconnect.fr> in bug 122128 from + Benjamin Schindler <config@gentoo.org>
This patch is wrong; you add "-L$(LIB) -llua" for liblualib.so.50 but the liblua.so symlink to liblua.so.50 is created only after liblualib.so.50 is generated so ld links the static archive, liblua.a; in fact you can check with 'scanelf -n' that liblualib.so has no NEEDED on liblua.so. Do you understand what this imply?
I have disabled the patch in lua-5.0.2, because the right one depends on the libs having an soname; it is already fixed in lua-5.0.3 which will be soon unmasked.