Skip to content

Commit a5f19d4

Browse files
committed
scripts/bootstrap-prefix: switch compiler to a properly bootstrapped one
We need include-fixed headers and the machinery around it, besides that it is highly discouraged to skip bootstrapping on "foreign" envs as the one we're in at stage2. Rename USE=bootstrap to USE=system-bootstrap Update coreutils bootstrap to 9.5 Signed-off-by: Fabian Groffen <[email protected]>
1 parent 4b2cc4f commit a5f19d4

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

scripts/bootstrap-prefix.sh

+21-6
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,7 @@ bootstrap_coreutils() {
13371337
# 8.16 is the last version released as tar.gz
13381338
# 8.18 is necessary for macOS High Sierra (darwin17) and converted
13391339
# to tar.gz for this case
1340+
bootstrap_gnu coreutils 9.5 || \
13401341
bootstrap_gnu coreutils 8.32 || bootstrap_gnu coreutils 8.30 || \
13411342
bootstrap_gnu coreutils 8.16 || bootstrap_gnu coreutils 8.17
13421343
}
@@ -1825,7 +1826,7 @@ do_emerge_pkgs() {
18251826
"-qtegrity" # portage-utils
18261827
"-readline" # bash
18271828
"-sanitize"
1828-
"bootstrap"
1829+
"system-bootstrap"
18291830
"clang"
18301831
"internal-glib"
18311832
)
@@ -2041,19 +2042,33 @@ bootstrap_stage2() {
20412042
emerge_pkgs --nodeps "${pkg}" || return 1
20422043
done
20432044

2045+
# GCC doesn't respect CPPFLAGS because of its own meddling as well
2046+
# as toolchain.eclass, so provide a wrapper here to force just
2047+
# installed packages to be found
2048+
mkdir -p "${ROOT}"/tmp/usr/local/bin
2049+
rm -f "${ROOT}"/tmp/usr/local/bin/my{gcc,g++}
2050+
cat > "${ROOT}/tmp/usr/local/bin/mygcc" <<-EOS
2051+
#!/usr/bin/env sh
2052+
exec ${CC} "\$@" ${CPPFLAGS}
2053+
EOS
2054+
cat > "${ROOT}/tmp/usr/local/bin/myg++" <<-EOS
2055+
#!/usr/bin/env sh
2056+
exec ${CXX} "\$@" ${CPPFLAGS}
2057+
EOS
2058+
chmod 755 "${ROOT}/tmp/usr/local/bin/my"{gcc,g++}
2059+
20442060
for pkg in ${compiler_stage1} ; do
20452061
# <glibc-2.5 does not understand .gnu.hash, use
20462062
# --hash-style=both to produce also sysv hash.
20472063
# GCC apparently drops CPPFLAGS at some point, which makes it
20482064
# not find things like gmp which we just installed, so force it
20492065
# to find our prefix
2050-
# For >=gcc-12.2.0, rpath needs to be disabled in stage2 on
2051-
# Darwin, see above.
2052-
EXTRA_ECONF="--disable-bootstrap $(rapx --with-linker-hash-style=both) --with-local-prefix=${ROOT} ${disable_darwin_rpath}" \
2066+
EXTRA_ECONF="$(rapx --with-linker-hash-style=both) --with-local-prefix=${ROOT}" \
20532067
MYCMAKEARGS="-DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=OFF" \
20542068
GCC_MAKE_TARGET=all \
2069+
OVERRIDE_CFLAGS="${CPPFLAGS} ${OVERRIDE_CFLAGS}" \
20552070
OVERRIDE_CXXFLAGS="${CPPFLAGS} ${OVERRIDE_CXXFLAGS}" \
2056-
TPREFIX="${ROOT}" \
2071+
CC=mygcc CXX=myg++ \
20572072
PYTHON_COMPAT_OVERRIDE=python$(python_ver) \
20582073
emerge_pkgs --nodeps "${pkg}" || return 1
20592074

@@ -2134,7 +2149,7 @@ bootstrap_stage3() {
21342149
# At this point, we should have a proper GCC, and don't need to
21352150
# rely on the system wrappers. Let's get rid of them, so that
21362151
# they stop mucking up builds.
2137-
rm -f "${ROOT}"/tmp/usr/local/bin/*
2152+
rm -f "${ROOT}"/tmp/usr/local/bin/{,my,${CHOST}-}{gcc,g++}
21382153

21392154
configure_toolchain || return 1
21402155

0 commit comments

Comments
 (0)