Page MenuHomeFreeBSD

Don't build the full clang toolchain or debug files in stages 1-3 of buildworld
ClosedPublic

Authored by ngie on Dec 17 2014, 8:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 20, 10:56 AM
Unknown Object (File)
Mar 19 2026, 2:26 PM
Unknown Object (File)
Mar 19 2026, 2:21 PM
Unknown Object (File)
Jan 31 2026, 12:25 AM
Unknown Object (File)
Nov 29 2025, 7:13 PM
Unknown Object (File)
Nov 15 2025, 11:07 AM
Unknown Object (File)
Nov 5 2025, 5:30 AM
Unknown Object (File)
Nov 5 2025, 5:30 AM
Subscribers

Details

Summary

Don't build the full clang toolchain or debug files in stages 1-3 of buildworld

The first piece (not building the entire clang toolchain) speeds up the build
and reduces build footprint by building the minimal set of C++ libraries for
getting clang off the ground in the stages preceding stage 4 (building
everything) in buildworld.

The second piece is a bit more interesting. Turning on MK_DEBUG_FILES via
bsd.mkopt.mk enables debug symbols in C code. However if one specifies
DEBUG_FLAGS+=-g (or some variant thereof) in src.conf, to enable debug symbols
globally, it will add -g to CXXFLAGS as well. This made building buildworld
impossible in low memory footprint scenarios as it compiled clang, binutils,
etc with debug symbols (and it's unnecessary because debug symbols aren't
really required in stages 1 through 3 of the build, unless one's debugging
the bootstrap-tools/cross-tools programs)

Test Plan

make buildworld -> make buildkernel with -j24 __MAKE_CONF=/dev/null,
SRCCONF=/dev/null, and WITH_DEBUG_FILES=yes on an amd64 VM with
TARGET/TARGET_ARCH -> amd64/amd64 and i386/i386 and 4GB of RAM
allocated on UFS

The build was successful in both cases and in the simultaneous build case I
was able to get the build host to build with <3GB of RAM used at all times
(although my mps(4) controller was a bit taxed with open-vm-tools installed
on the host and I was I/O bound :)..).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ngie retitled this revision from to Don't build the full clang toolchain or debug files in stages 1-3 of buildworld.
ngie updated this object.
ngie edited the test plan for this revision. (Show Details)
ngie added reviewers: bdrewery, dim, imp.
ngie added a subscriber: benno.

The first piece (not building the entire clang toolchain) speeds up the build
and reduces build footprint by building the minimal set of C++ libraries for
getting clang off the ground in the stages preceding stage 4 (building
everything) in buildworld.

Note that this part is only true for people that already have turned on WITH_CLANG_EXTRAS, which defaults to off. For the rest, it looks sane to me.

However, the part where you unconditionally turn off the debug information for the initial stages is a bit more debatable: if some crash occurs now during the build, in any of the bootstrap tools or cross tools, how are you going to debug it? There should still be some option to enable debug symbols for everything, including the earlier stages. Of course, normal users will never need to use it, but developers certainly will, at some point.

In D1336#5, @dim wrote:

The first piece (not building the entire clang toolchain) speeds up the build
and reduces build footprint by building the minimal set of C++ libraries for
getting clang off the ground in the stages preceding stage 4 (building
everything) in buildworld.

Note that this part is only true for people that already have turned on WITH_CLANG_EXTRAS, which defaults to off. For the rest, it looks sane to me.

However, the part where you unconditionally turn off the debug information for the initial stages is a bit more debatable: if some crash occurs now during the build, in any of the bootstrap tools or cross tools, how are you going to debug it? There should still be some option to enable debug symbols for everything, including the earlier stages. Of course, normal users will never need to use it, but developers certainly will, at some point.

Something I was thinking about.

What about another option, MK_DEBUG_BOOTSTRAP_TOOLCHAIN , that turns on this support only in bootstrap-tools/cross-tools via Makefile.inc1?

ngie added a reviewer: ngie.

I submitted the clang portion. The MK_DEBUG_FILES portion wasn't committed. I'll send out a new review with MK_DEBUG_FILES=no later if it's necessary.

This revision is now accepted and ready to land.Jan 2 2015, 5:14 AM