Bug 16792 - $tooldir/lib is sysrooted when built --with-sysroot
Summary: $tooldir/lib is sysrooted when built --with-sysroot
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-01 16:43 UTC by Yaakov Selkowitz
Modified: 2017-10-02 01:06 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
possible patch (335 bytes, patch)
2014-04-01 16:43 UTC, Yaakov Selkowitz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yaakov Selkowitz 2014-04-01 16:43:50 UTC
Created attachment 7515 [details]
possible patch

Commit 0f70b6b is causing *all* search paths to be prefixed with '='.  AFAICS though, this is incorrect for $exec_prefix/$target_alias/lib* and $exec_prefix/$TOOL_LIB/lib*; these directories generally exist in the real root and not in the sysroot.

Steps to reproduce:

1) configure binutils with a non-native --target and --with-sysroot

2) make

3) ./ld/ld-new --verbose | grep SEARCH_DIR

You will see entries such as SEARCH_DIR("=/usr/$target/lib") and (on multilib targets) SEARCH_DIR("=/usr/$target/lib64").  IIUC these should not be sysroot-prefixed.

There is probably a much better way of fixing this, but I'm attaching a possible patch.
Comment 1 Hans-Peter Nilsson 2014-05-20 01:31:46 UTC
I believe the sysroot general equivalent should be "=/lib".
(Adjustable by target emulparams script to e.g. "=/lib32", "=/lib64" etc.)
Comment 2 Yaakov Selkowitz 2014-05-20 01:44:13 UTC
When a sysroot is in use, libraries usually end up in =/lib and =/usr/lib (or =/mingw/lib for *-*-mingw*), but $exec_prefix/$target_alias/lib has still been scanned.  Not only is that not happening at the moment, but sysrooting that directory really doesn't make sense.
Comment 3 Hans-Peter Nilsson 2014-05-20 01:59:34 UTC
(In reply to Cygwin/X maintainer from comment #2)
> When a sysroot is in use, libraries usually end up in =/lib and =/usr/lib
> (or =/mingw/lib for *-*-mingw*), but $exec_prefix/$target_alias/lib has
> still been scanned.  Not only is that not happening at the moment, but
> sysrooting that directory really doesn't make sense.

I'm not sure whether you agree or disagree. :)

To wit, I'm saying 'don't scan "$exec_prefix/$target_alias/lib", scan the target-adjusted equivalent of "=/lib"; i.e. "=/mingw/lib" for *-*-mingw*'.  ...maybe also "=/usr/lib" where that isn't a capital offence, e.g. *-*-gnu...

IIUC (I'm certainly not sure) sysroot targets don't have (*should* not have) anything in $exec_prefix/$target_alias/lib but everything in "=/lib" or "=/usr/lib" so  $exec_prefix/$target_alias/lib should not be scanned at all (as such, that is).
Comment 4 Alan Modra 2017-10-02 01:06:29 UTC
I'm not sure how I came to be assigned to this bug, possibly with the original submission due to being responsible for commit 0f70b6b.  I don't think there should be any change to $tooldir.  Firstly, sysroot really does mean the dir structure ought to be the same as native (non-sysroot) but under the sysroot.  Secondly, it's unclear what should be done about $tooldir in the Canadian cross case.