Page MenuHomeFreeBSD

Introduce (build|install)sysroot targets.
Needs ReviewPublic

Authored by brooks on Wed, Mar 25, 5:01 PM.



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 OK
No Unit Test Coverage
Build Status
Buildable 30106
Build 27913: arc lint + arc unit

Event Timeline

brooks created this revision.Wed, Mar 25, 5:01 PM

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

arichardson accepted this revision.Wed, Mar 25, 7:38 PM

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.Wed, Mar 25, 7:38 PM
swills added a subscriber: swills.Wed, Mar 25, 8:45 PM
bdrewery added inline comments.Wed, Mar 25, 8:50 PM

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.

bdrewery added inline comments.Wed, Mar 25, 9:03 PM

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.


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

brooks added inline comments.Wed, Mar 25, 9:10 PM

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.

brooks added inline comments.Wed, Mar 25, 9:25 PM

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?

bdrewery added inline comments.Wed, Mar 25, 9:38 PM
# 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.

brooks updated this revision to Diff 69872.Wed, Mar 25, 9:38 PM
  • Use SUBDIR.${MK_FOO} variables to reduce .if clutter.
  • Don't delete empty DESTDIR. Print deleted directories.
This revision now requires review to proceed.Wed, Mar 25, 9:38 PM
brooks marked an inline comment as done.Wed, Mar 25, 9:38 PM