media-sound/shell-fm-0.7 fails compilation if linked if --as-needed, with an error like: i686-pc-linux-gnu-gcc -o shell-fm -march=native -O2 -pipe -fomit-frame-pointer -march=native -O2 -pipe -fomit-frame-pointer -Wall -W -I./include/ -DLIBAO main.c -Wl,--as-needed -lmad -lm -lao -lpthread -ldl libshellfm.a libshellfm.a(play.o): In function `input': play.c:(.text+0x26a): undefined reference to `mad_stream_buffer' libshellfm.a(play.o): In function `playback': play.c:(.text+0x57d): undefined reference to `ao_default_driver_id' [.. other linking problems ...] As suggested in http://www.gentoo.org/proj/en/qa/asneeded.xml#doc_chap2 , I have reordered the linker parameters and now the package compiles fine. I'll attach the Makefile and the ebuild patches in a few minutes.
Created attachment 205374 [details, diff] Patch the Makefile to allow compilation with --as-needed
Created attachment 205375 [details, diff] Patch shell-fm-0.7.ebuild to use the previous patch
Comment on attachment 205374 [details, diff] Patch the Makefile to allow compilation with --as-needed This patch is wrong, please read the asneeded fixing guide ( http://www.gentoo.org/proj/en/qa/asneeded.xml ) for the proper order of parameters: ldflags should _not_ be at the end!
The problem is that the package Makefile handles $LDFLAGS and libraries together. I therefore suggest another, bigger patch that might solve the problem more cleanly.
Created attachment 205521 [details, diff] Revised patch to allow compilation with --as-needed
Yup, that's the correct one; although I would suggest for the future (and to send this upstream) to use the LDLIBS variable (it's a default in make for the libraries).
Created attachment 205574 [details, diff] Patch to allow compilation with --as-needed, using standard naming conventions OK :) A little sed magic (not that difficult) and the patch uses LDLIBS...
The patch has been accepted upstream, so the correct behavior should show up with the next release.
Thanks Marco, committed now.