Page MenuHomeFreeBSD

Don't hardcode the TOOLS_PREFIX for the startfiles directories.
ClosedPublic

Authored by jhb on Mar 20 2018, 10:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 18 2024, 1:02 PM
Unknown Object (File)
Jan 18 2024, 1:02 PM
Unknown Object (File)
Jan 18 2024, 1:02 PM
Unknown Object (File)
Jan 18 2024, 10:45 AM
Unknown Object (File)
Jan 9 2024, 3:32 AM
Unknown Object (File)
Dec 20 2023, 5:24 AM
Unknown Object (File)
Dec 4 2023, 12:16 AM
Unknown Object (File)
Oct 26 2023, 4:41 PM
Subscribers
None

Details

Summary

GCC 4.2 prefixes these directories with --sysroot meaning that during the
build they have a double sysroot. This permitted a full tinderbox to
complete using just --sysroot for in-tree GCC without additional flags
for -L, -B, -I, -nostdinc, etc.

Test Plan
  • make tinderbox

This is part of a branch that includes the changes to remove said flags
for the GCC case.

Diff Detail

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

Event Timeline

I tried defining TARGET_SYSTEM_ROOT and some other tricks to make --sysroot for GCC 4.2 work more "correctly" but the bits in GCC 4.2 are a bit hacked up (and we turn off some portions already), so I went with the smallest change that only affects the cross-compiler built during buildworld (the native compiler installed during a world on a platform using GCC 4.2 will have PREFIX set to "/usr" so this is a no-op in that case).

gnu/usr.bin/cc/cc_tools/freebsd-native.h
40 โ†—(On Diff #40524)

Given PREFIX is still used elsewhere, your change feels incomplete. Either other PREFIX lines need updating or PREFIX should not be set to TOOLS_PREFIX.

gnu/usr.bin/cc/cc_tools/freebsd-native.h
40 โ†—(On Diff #40524)

So I tried that and it seems that GCC 4.2 (or our hacks to disable various parts of its sysroot functionality) doesn't properly honor --sysroot for these other paths. If I changed these to use "/usr/" as below then they did not honor --sysroot but tried to use host headers, binaries, etc. I found that only the startle prefixes were the ones truly honoring --sysroot, so what this effectively does is rely on --sysroot to mixup the startfile paths and hardcode the sysroot (in PREFIX) in the other paths. Note that for startfile prefixes, the sysroot is always added, so the result is that you ended up with a -L path of "<sysroot>PREFIX/lib" which had a double sysroot.

I did spend some time digging through gcc's "driver" trying to figure out why --sysroot wasn't being honored for include paths, etc. but then I decided that this change was probably the simplest to make. I think it's ok to use a bandaid approach to help us retire GCC 4.2 as well.

Discussed on IRC, there's 3 cases for the compiler. External (for which you fixed the port to respect --sysroot properly). Interal (bootstrap) from contrib/gcc which you've modified here to respect --sysroot (Except headers which will just work from WORLDTMP). But there's a 3rd case of the installed /usr/bin/cc which is used for WITH_SYSTEM_COMPILER which won't work without the -isystem, etc, flags or a fixed --sysroot.

I think this is fine but we'll need to keep some of the flags to handle the SYSTEM_COMPILER CC=/usr/bin/cc case until we can fix --sysroot fully.

This revision is now accepted and ready to land.Mar 23 2018, 10:19 PM
This revision was automatically updated to reflect the committed changes.