Skip to content

Commit

Permalink
scripts/bootstrap-prefix: switch compiler to a properly bootstrapped one
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
grobian committed Sep 30, 2024
1 parent 4b2cc4f commit a5f19d4
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions scripts/bootstrap-prefix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@ bootstrap_coreutils() {
# 8.16 is the last version released as tar.gz
# 8.18 is necessary for macOS High Sierra (darwin17) and converted
# to tar.gz for this case
bootstrap_gnu coreutils 9.5 || \
bootstrap_gnu coreutils 8.32 || bootstrap_gnu coreutils 8.30 || \
bootstrap_gnu coreutils 8.16 || bootstrap_gnu coreutils 8.17
}
Expand Down Expand Up @@ -1825,7 +1826,7 @@ do_emerge_pkgs() {
"-qtegrity" # portage-utils
"-readline" # bash
"-sanitize"
"bootstrap"
"system-bootstrap"
"clang"
"internal-glib"
)
Expand Down Expand Up @@ -2041,19 +2042,33 @@ bootstrap_stage2() {
emerge_pkgs --nodeps "${pkg}" || return 1
done

# GCC doesn't respect CPPFLAGS because of its own meddling as well
# as toolchain.eclass, so provide a wrapper here to force just
# installed packages to be found
mkdir -p "${ROOT}"/tmp/usr/local/bin
rm -f "${ROOT}"/tmp/usr/local/bin/my{gcc,g++}
cat > "${ROOT}/tmp/usr/local/bin/mygcc" <<-EOS
#!/usr/bin/env sh
exec ${CC} "\$@" ${CPPFLAGS}
EOS
cat > "${ROOT}/tmp/usr/local/bin/myg++" <<-EOS
#!/usr/bin/env sh
exec ${CXX} "\$@" ${CPPFLAGS}
EOS
chmod 755 "${ROOT}/tmp/usr/local/bin/my"{gcc,g++}

for pkg in ${compiler_stage1} ; do
# <glibc-2.5 does not understand .gnu.hash, use
# --hash-style=both to produce also sysv hash.
# GCC apparently drops CPPFLAGS at some point, which makes it
# not find things like gmp which we just installed, so force it
# to find our prefix
# For >=gcc-12.2.0, rpath needs to be disabled in stage2 on
# Darwin, see above.
EXTRA_ECONF="--disable-bootstrap $(rapx --with-linker-hash-style=both) --with-local-prefix=${ROOT} ${disable_darwin_rpath}" \
EXTRA_ECONF="$(rapx --with-linker-hash-style=both) --with-local-prefix=${ROOT}" \
MYCMAKEARGS="-DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=OFF" \
GCC_MAKE_TARGET=all \
OVERRIDE_CFLAGS="${CPPFLAGS} ${OVERRIDE_CFLAGS}" \
OVERRIDE_CXXFLAGS="${CPPFLAGS} ${OVERRIDE_CXXFLAGS}" \
TPREFIX="${ROOT}" \
CC=mygcc CXX=myg++ \
PYTHON_COMPAT_OVERRIDE=python$(python_ver) \
emerge_pkgs --nodeps "${pkg}" || return 1

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

configure_toolchain || return 1

Expand Down

0 comments on commit a5f19d4

Please sign in to comment.