Page MenuHomeFreeBSD

Fix ld not respecting --sysroot.
ClosedPublic

Authored by bdrewery on Nov 23 2015, 11:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 8:10 AM
Unknown Object (File)
Wed, Apr 17, 8:08 AM
Unknown Object (File)
Feb 16 2024, 7:38 PM
Unknown Object (File)
Jan 28 2024, 4:24 PM
Unknown Object (File)
Jan 24 2024, 11:51 PM
Unknown Object (File)
Jan 22 2024, 9:04 PM
Unknown Object (File)
Jan 19 2024, 1:13 PM
Unknown Object (File)
Jan 9 2024, 6:16 AM
Subscribers

Details

Summary

ld(1) uses the /usr/libdata/ldscripts when linking. These scripts add in the
default search paths of /lib and /usr/lib via 'SEARCH_DIR("DIR")'. These
need to be prefixed by '=' so that the --sysroot flag is respected. This
is not a problem with buildworld since the TOOLS_PREFIX is baked into the
cross-ld. However it is a problem when trying to use ld(1) with --sysroot
anywhere else as it ends up still reading /lib and /usr/lib despite --sysroot.

Our default --sysroot (TARGET_SYSTEM_ROOT) is '/'.

I found this while building with META MODE with uses only --sysroot with
/usr/bin/ld, and found that libraries that I had not built in its sysroot
directory were leaking in. This didn't happen with ports binutils either.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bdrewery retitled this revision from to Fix ld not respecting --sysroot..
bdrewery updated this object.
bdrewery edited the test plan for this revision. (Show Details)
bdrewery added reviewers: bapt, emaste, brooks, imp.
bdrewery added a subscriber: jhb.

This modifies these files:

/usr/libdata/ldscripts/elf_x86_64_fbsd.x:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xbn:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xc:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xd:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xdc:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xdw:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xn:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xs:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xsc:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xsw:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/usr/libdata/ldscripts/elf_x86_64_fbsd.xw:SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");

bapt edited edge metadata.
This revision is now accepted and ready to land.Nov 23 2015, 11:37 PM

I went into the same issue while working on making world sysroot friendly!

brooks edited edge metadata.

Looks good.

This revision was automatically updated to reflect the committed changes.