specs file problem with *link and -Wl,-rpath

Sal Paradise mr94rnp02@sneakemail.com
Wed Jan 11 01:51:00 GMT 2006


I am building gcc 3.3.5 from source on my system (x86 Linux).  I am attempting to modify the specs file in order to give gcc a default rpath on my system.  However, I do not want gcc to insert this default rpath if the user specifies -Wl,-rpath,/whatever on the command line.

I attempted to do this in the specs file:
%{!static:--eh-frame-hdr} -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:         %{rdynamic:-export-dynamic}         %{!dynamic-linker:-dynamic-linker /mylib/ld-linux.so.2}         %{!Wl,-rpath*:-rpath /mylib}} %{static:-static}}}

Unfortunately, strace -f reveals that the "-rpath /mylib" is always passed to ld (regardless of the presence of the -Wl,-rpath argument on the gcc command line).  This is bad because this default rpath gets precedence over the one the user specifies (the user's choice gets concatenated after the default by ld).

Am I missing something here?  Is the this option treated specially in the specs file language?  For what it is worth, the conditionality of the dynamic linker option also seems broken (and that part is from the stock file; not my modification).  It gets passed to ld even when users specify -Wl,--dynamic-linker (but it ends up working inadvertently because ld takes the second one which is the one from the command line).

Please cc: me on the reply (I am not subscribed to this list).


More information about the Gcc-help mailing list