Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 466128 - Problem with linker scripts when SYSROOT != /
Summary: Problem with linker scripts when SYSROOT != /
Status: RESOLVED DUPLICATE of bug 446204
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-16 17:06 UTC by Rafal Lalik
Modified: 2013-04-18 15:58 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafal Lalik 2013-04-16 17:06:30 UTC
Glibc installs two linker scripts: /usr/lib/libc.so and /usr/lib/libpthread.so where one can find such entry (example for glibc):

GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a  AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )

which tells to gcc which library should be in fact linked, in this case /lib/libc.so.6.

Problem arise when emerging package with SYSROOT different than / (usually used for CrossCompiling). Then even if proper installation of glibc exists in:
* /usr/ntuple/lib/libc.so.6
* /usr/ntuple/usr/lib/libc.so
linker after finding entry in the latter will try to link against incompatible
/lib/libc.so

New gcc accepts option --sysroot=... which solves this problem. From my tests I found that setting CFLAGS/LDFLAGS with --sysroot would solve problem, but it doesn't work always. For example libtool links shared libraries with following command:
\$CC -shared ...
and doesn't use any of {C,CXX,LD}FLAGS. Thus only proper setting of CC when invoking ./configure (I tested this manually):
CC="ntuple-gcc --sysroot=/usr/ntuple/" ./configure
solves problem.

Unfortunately I could not find proper place in eclass files to change this, I tried to replace line in toolchain-funcs.eclass:
CC=$(tc-getBUILD_CC)
with
CC="$(tc-getBUILD_CC) --sysroot=${SYSROOT}"
but it didn't help at all (it also didn't destroy anything, and after checking logs is see that CC was still set without sysroot).

I would propose then to consider that if SYSROOT is set or is different than '/' then --sysroot is always set for gcc-4

If you dislike this idea pleas at least give me a hint where I should update my local copy of tree to fix this problem for me.

Greetings,
Rafal
Comment 1 SpanKY gentoo-dev 2013-04-18 15:58:17 UTC

*** This bug has been marked as a duplicate of bug 446204 ***