This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: lions and tigers and LDFLAGS, oh my! (SOLVED)


>From: Marc Glisse <marc.glisse@normalesup.org>
...
>On Fri, 22 May 2009, Poor Yorick wrote:
>
>> I'd like to embed an RPATH/RUNPATH into all gcc binaries.  It isn't enough
>> to just set LDFLAGS and BOOT_LDFLAGS in the environment; those two variables
>> must also be passed explicitly as part of the make command:
>>
>>    make LDFLAGS="$LDFLAGS", BOOT_LDFLAGS="$BOOT_LDFLAGS"
>>
>> So far, so good.  However, I'd also trying to use the magic word, '$ORIGIN',
>> with a literal dollar sign, in the embedded RPATH.  LDFLAGS currently looks
>> like this:
>[...]
>> The problem is that the top-level Makefile specifies enough layers of
>> recursive calls to make and the shell that I haven't found a way to quote
>> the dollar sign so that it stays quoted throughout the process.  Any hints?
>
>One usual trick to simplify the problem a bit with the shell is:
>export 'ORIGIN=$ORIGIN'
>You could try:
>export 'O=$$O' or something similar to help with make ('O=$O' is not
>accepted).
...
>An other trick is to use a wrapper to the linker, that either adds the
>$ORIGIN thing, or replaces MYRECOGNIZABLESTRINGWITHOUTDOLLAR with $ORIGIN.

Numerous attempts finally yielded an LDFLAGS in the top-level Makefile with
sufficient quoting:

LDFLAGS = -Wl,-rpath-link,'/path/to/gcc-4.4.0/lib64' -Wl,-rpath-link,'/path/to/gcc-4.4.0/lib' -Wl,-rpath-link,'/path/to/lib64' -Wl,-rpath-link,'/path/to/lib' -Wl,-rpath-link,'/path/to/glibc/lib' -Wl,-rpath,'\\\\\\\$$\$$\\\$$\$$\\\\\\\$$\$$\\\$$\$$ORIGIN/../lib64' -Wl,-rpath,'\\\\\\\$$\$$\\\$$\$$\\\\\\\$$\$$\\\$$\$$ORIGIN/../lib' -Wl,-rpath,'\\\\\\\$$\$$\\\$$\$$\\\\\\\$$\$$\\\$$\$$ORIGIN/../../lib64' -Wl,-rpath,'\\\\\\\$$\$$\\\$$\$$\\\\\\\$$\$$\\\$$\$$ORIGIN/../../lib' -Wl,-rpath,'\\\\\\\$$\$$\\\$$\$$\\\\\\\$$\$$\\\$$\$$ORIGIN/../../glibc/lib' -L/path/to/lib -L/path/to/lib64 -L/path/to/glibc/lib -Wl,--dynamic-linker,/path/to/glibc/lib/ld-linux.so.2 -Wl,-z,origin -Wl,--enable-new-dtags

My build script starts out with this (only the relevant option is shown):

    LDFLAGS="-Wl,-rpath,'\$ORIGIN'/../lib"

and then, for gcc, transforms it like this:

    LDFLAGS="${LDFLAGS//\$ORIGIN/\\\\\\\\\\\\\\\$\$\\\$\$\\\\\\\$\$\\\$\$\\\\\\\\\\\\\\\$\$\\\$\$\\\\\\\$\$\\\$\$ORIGIN}"

yielding the needed result in the Makefile (hopefully that showed up as a
single line after going through my email system)

Not exactly convenient for the common hominid.  Perhaps a "--with-rpath" option
is in order.

Notes here:

    https://www.pooryorick.com/secure/wiki/Pub/TheTroubleWithOrigin

-- 
Yorick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]