Page MenuHomeFreeBSD

Introduce (build|install)sysroot targets.
AbandonedPublic

Authored by brooks on Mar 25 2020, 5:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 2 2024, 11:35 PM
Unknown Object (File)
Dec 20 2023, 7:22 AM
Unknown Object (File)
Dec 13 2023, 2:27 AM
Unknown Object (File)
Dec 9 2023, 6:44 PM
Unknown Object (File)
Sep 23 2023, 11:56 PM
Unknown Object (File)
Sep 21 2023, 5:20 AM
Unknown Object (File)
Jun 6 2023, 12:10 PM
Unknown Object (File)
May 10 2023, 7:11 PM

Details

Summary

These targets build and install libraries and headers in DESTDIR such
that it is usable as a target for a compiler's --sysroot argument. For
software with suitable build systems, this can be used to link against
non-native FreeBSD versions with ease.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 30106
Build 27913: arc lint + arc unit

Event Timeline

This feature was developed by @arichardson in CheriBSD. I've extracted it and tweaked it a bit.

Thanks for upstreaming this! I think there are still a few files that installsysroot installs that aren't really needed (NLS?) but I needs to check whether that's still the case.

Since I originally wrote this, someone else should probably approve it too.

This revision is now accepted and ready to land.Mar 25 2020, 7:38 PM
Makefile.inc1
383–392

Why mimic make everything and not just use the existing WORLDTMP and make libraries mechanisms? I think that would be simpler and less new special case code to maintain. That's exactly what I did in make native-xtools.

The buildsysroot should come down to this and it removes the need for installsysroot:

${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj
# Build the bootstrap/host/cross tools that produce native binaries
${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain
# Populate includes/libraries sysroot that produce native binaries.
# This is split out from 'toolchain' above mostly so that target LLVM
# libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
# polluting the cross-compiler build.  The LLVM/GCC libs are skipped
# here to avoid the problem but are kept in 'toolchain' so that
# needed build tools are built.
${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no
${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no

The installation could be split out if wanted with minimal effort.

Makefile.inc1
383–392

My main problem is these new SUBDIR listings to only be libraries when we already have 1 list to maintain.

I would like to see something like buildsysroot to rework native-xtools as that's all it is really doing but it has a special list of dirs to install. (NXBDIRS) I think those dirs are misplaced too.

Basically I think this change is a layer violation and we should reuse the component targets we already have.

1552–1553

Double traversal could be combined.
What if DESTDIR is empty?

Makefile.inc1
383–392

We want something we can install and keep around rather than relaying on the obj tree to remain stable. The size differences are considerable:

$ du -sh ~/sysroot
310M    /home/bed22/sysroot
$ du -sh ~/obj/home/bed22/git/freebsd/amd64.amd64/tmp/
1.5G    /home/bed22/obj/home/bed22/git/freebsd/amd64.amd64/tmp/

We also rely on having built and installed libcompat bits.

That being said, let me see if I can make this easier to maintain.

Makefile.inc1
383–392

native-xtools seems to be mostly about building things we have no interest in. We don't want a toolchain at all and that seems to be really tied up in the whole thing.

What am I missing?

Makefile.inc1
383–392
# du -sh /usr/obj/usr/src/amd64.amd64/tmp/{lib,usr/lib,usr/lib/debug,usr/include}
 15M    /usr/obj/usr/src/amd64.amd64/tmp/lib
807M    /usr/obj/usr/src/amd64.amd64/tmp/usr/lib
487M    /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/debug
 18M    /usr/obj/usr/src/amd64.amd64/tmp/usr/include

(subtract /usr/lib/debug)

I don't mean to say we should use the OBJDIR version. I just mean to reuse the existing targets that build and install libraries/headers for a sysroot. A lot of WORLDTMP is nested objdirs and the build tools binaries that aren't needed. But make libraries and make includes are minimal pieces that appear useful for sysroot to me.

Yes you're right about native-xtools. The only piece relevant here is the one I pasted above which could be changed to use make build/installsysroot.

make xdev also reuses the libraries and includes pieces with a custom DESTDIR.

  • Use SUBDIR.${MK_FOO} variables to reduce .if clutter.
  • Don't delete empty DESTDIR. Print deleted directories.
This revision now requires review to proceed.Mar 25 2020, 9:38 PM
Makefile.inc1
1568

Is there a parent revision which defines reinstallsysroot or is this review just showing wrong?

This change won't apply to head, there's no SYSROOT_ONLY there, for example.