Kyrylo Tkachov <[email protected]> writes:

[Just writing here what I said on IRC so far, I didn't do research on
tests yet.]

> Hi all,
>
> A native "make bootstrap" runs every subdirectory's autoconf configure
> three times, once per stage, because each stage is built in a fresh
> directory (stageN-MODULE is created empty and renamed to MODULE), so the
> per-directory config.cache that the build system already requests with
> --cache-file=./config.cache starts out empty in every stage.  The
> configure scripts are serial, and the host-module configures are
> serialized with respect to each other, so on a machine with many cores
> the configure phases leave it almost completely idle.
>
> Measured on a large multi-core aarch64 machine, a --enable-languages=c,c++
> bootstrap spends about 30% of its wall time in configure and is
> configure-bound at under 15% machine utilization for about 41% of the
> build; the single largest contributor is stage 2 gcc/configure, which
> compiles its test programs with the not-yet-optimized stage 1 compiler.
>
> For a native bootstrap build == host == target, so a module's configure
> test results do not change between stages.  This makes the bootstrapped
> host modules whose configure only probes the host system reuse a
> per-module config.cache across the three stages instead of recomputing
> everything.

Including stage1 may be problematic here. The stage1 compiler may be
buggy, e.g. if built by Clang, -march=native won't work on x86
(PR117952). Perhaps we can view this as analogous to STAGE1_CFLAGS where
we default to something conservative for stage1 but allow overriding it.

The unfortunate part is that as you mention, you get the most benefit
from stage1 as the compiler as at its slowest then :(

IMO we definitely want >=stage2 caching though.

> The cache file is an absolute path under the build tree
> (stage-config-cache/MODULE.cache) shared by every stage's build
> directory; because the stages run sequentially and each module has its
> own file there is never a concurrent writer.  The ac_cv_env_* environment
> snapshot is stripped before each load so that autoconf's "environment
> changed" check does not abort when CC/CXX/... legitimately differ between
> stages.
>
> Only modules flagged bootstrap_cache in Makefile.def are cached, and only
> for a native build (the recipe compares build/host/target aliases).  The
> in-tree prerequisite libraries (gmp, mpfr, mpc, isl) and gettext are
> intentionally excluded: their configure runs perform cross-library ABI
> link tests and record the compiler version, which do change once the
> bootstrap compiler replaces the system one.  Target libraries are not
> bootstrapped host modules and are unaffected; --disable-bootstrap is
> unaffected as the non-bootstrap configure recipe is untouched.
>
> This roughly halves the time spent in configure (about a 43% reduction)
> and cuts the overall bootstrap wall time by about 15%, with no change in
> the generated configuration: the produced config headers are identical to
> a non-cached build and the stage 2 / stage 3 comparison still succeeds.
> Verified with "make bootstrap”; cross, Canadian and
> --disable-bootstrap builds should be unaffected.

This has long been something people complain about :)

>
> Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux.
> I’d appreciate wider testing on configuration others care about.

I will.

thanks,
sam

> [...]

Attachment: signature.asc
Description: PGP signature

Reply via email to