Page MenuHomeFreeBSD

Always enable sysroot for buildworld.
AbandonedPublic

Authored by bdrewery on Oct 21 2015, 9:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 31, 8:13 AM
Unknown Object (File)
Apr 12 2024, 8:32 AM
Unknown Object (File)
Dec 20 2023, 1:05 AM
Unknown Object (File)
Nov 13 2023, 10:56 AM
Unknown Object (File)
Oct 24 2023, 9:19 PM
Unknown Object (File)
Oct 10 2023, 9:56 AM
Unknown Object (File)
Sep 5 2023, 4:10 AM
Unknown Object (File)
Jul 25 2023, 4:00 AM
Subscribers

Details

Summary
  • Passing DEFAULT_SYSROOT=${TOOLS_PREFIX} for Clang and PREFIX=${TOOLS_PREFIX}/usr for GCC does work in the build but leads to confusion about whether --sysroot is used or not when it really is. This is about dispelling magic to me since we still call the cross-compiler 'cc' and not 'ARCH-ABI-freebsd11.0-worldtmp-cc', which would at least make it more clear. A suitable alternative to me would be to name the entire cross-toolchain in this pattern with '-worldtmp-' or similar at the end.
    • It also leads to a situation where if the cross-tools stage is manually skipped for some reason then 'cc' will use the one from /usr/bin which is not considered "external" since it didn't start with a '/', thus the build ends up not really using a --sysroot.
    • META_MODE always sets --sysroot when not building for host in share/mk/local.init.mk which has been very nice as I know there is nothing bleeding in from /usr/include.
    • It also leads to problems with the recommended ccache implementation of setting 'CC:=/usr/local/libexec/ccache/world/cc ${CC}', which causes these checks to consider this an external toolchain and add in --sysroot. While that is actually a separate problem and does lead to not building the cross-compiler, it leads to more confusion on whether --sysroot was used before when disabling ccache.
  • The lib32 --sysroot handling was disabled in rS250859 due to GCC issues but was enabled for GCC target when using an external compiler in rS280719 without any complaints. It is possible this is still wrong for building powerpc on powerpc64. I have not yet tested it.
Test Plan

Not tested much yet.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 882
Build 882: arc lint + arc unit

Event Timeline

bdrewery retitled this revision from to Always enable sysroot for buildworld..
bdrewery updated this object.
bdrewery edited the test plan for this revision. (Show Details)
bdrewery added reviewers: imp, brooks, emaste, sjg.
bdrewery added a subscriber: ngie.

I don't know much about the toolchain build yet, but perhaps this can lead to not building the compiler again when TARGET=MACHINE.

I don't know much about the toolchain build yet, but perhaps this can lead to not building the compiler again when TARGET=MACHINE.

Implying not using DEFAULT_SYSROOT and PREFIX.

Makefile.inc1
442–443

Is -B vs --sysroot correct here, i.e. should -B be WORLDTMP and --sysroot be ${LIB32TMP}?

From gcc(1):

-Bprefix
    This option specifies where to find the executables, libraries, include files, and data files of the compiler itself.
Makefile.inc1
442–443

I'm not sure why the 64 bit sysroot is there rather than just the -isystem/-L/-B on LIB32TMP. Brooks can comment on that.

Makefile.inc1
394

Do we really know the TARGET compiler type here?

Makefile.inc1
394

No, it's wrong. I'll see about digging that out of the other code that handles picking gcc or clang, when not using an external toolchain.

Makefile.inc1
394

Makefile.inc1 is a special place wrt knowing the compiler or not since we kick off builds for native binaries, native binaries that target the target, and the target binaries themselves.... The rules always confuse me...

Makefile.inc1
442–443

Our sense of -m32 is broken, as bde keeps on reminding folks on the lists. I'm not sure that we build that cross-compiler properly...

Makefile.inc1
442–443

How so?

Makefile.inc1
442–443

I honestly don't remember the full details. If you ask bde though you'll probably get a dissertation on how it's broken.

Makefile.inc1
442–443

If you can't articulate why it's broken, and only bde can, it's likely not broken.
Years ago, it was broken. Today it works fine. And it does the right thing.
On all the architectures that support it.

Makefile.inc1
442–443

I suspect the -B is allowing the compiler to find *crt*.o, but it might not be doing anything useful.

The --sysroot is probably made mostly or even entirely redundant by the -isystem and -L lines. I suspect I set it to WORLDTMP because that's what the classic cc does via the hardcoding and it worked so I didn't look further.

Makefile.inc1
394

Indeed. That's why I introduced the pseudo machine "host".
The buildworld build being recursive is probably much harder to make determinations,
and while this has nothing to do with meta mode, build, the following migh provide some ideas...

In the meta mode build, if .MAKE.LEVEL > 0 you know nothing is going to change
At level 0 we can do things like
COMPILER_TYPE_common = none
.for m in ${ALL_MACHINE_LIST}
COMPILER_TYPE_$m ?= ${COMPILER_TYPE_default}
.export COMPILER_TYPE_$m
.endfor
and then
COMPILER_TYPE?= ${COMPILER_TYPE_${MACHINE}}

This works quite well.

I have not tested yet, but overall I like this idea.

My new thoughts on this are to combine the logic from meta build cross-compiler/external toolchain logic with the logic in Makefile.inc1. The meta build logic is already using --sysroot and --target.

I need to look at the GCC git history to find the minimum version of --sysroot support as well which may allow us to remove some of the excess checks here too.

I need to look at the GCC git history to find the minimum version of --sysroot support as well which may allow us to remove some of the excess checks here too.

AFAICT it was added in Feb 2003 (git 17acc97af) and so should be available in any relevant compiler, although perhaps there were early bugs that were fixed later on.

I don't know much about the toolchain build yet, but perhaps this can lead to not building the compiler again when TARGET=MACHINE.

TARGET_ARCH = MACHINE_ARCH don't you mean? TARGET / MACHINE are kernel interfaces, not userland ones and aren't appropriate to test for toolchain things.

Most of this patch is wrong. I've fixed the lib32 --sysroot usage and am committing that separately. The only thing this review should be doing though is moving the --sysroot setting out of the external compiler section. That fixes WITHOUT_CROSS_COMPILER to properly use WORLDTMP (PR 196193).

Really I want to eliminate TOOLS_PREFIX too as it causes issues for WITH_META_MODE+buildworld. The passing of it changes between phases for some llvm support libs which don't even need it. This causes rebuilds since the "build command changed". I've worked around it for now by passing TOOLS_PREFIX in earlier phases but it's dirty.

Actually removing TOOLS_PREFIX would potentially cause problems with buildenv, but so long as --sysroot is present in the CROSSENV+=CC="..." CC variable then it should be fine.

An updated patch for this will be coming soon.

This should be closed, --sysroot is always enabled now

This is not what was committed, but --sysroot is now always passed after rS304681