%global gcc_version 14.4.0 %global glibc_version 2.40 %global toolchain_release 2 %global custom_gcc_root /usr/lib64/custom-gcc14 %global custom_glibc_root /usr/lib64/custom-glibc Name: cuda12-toolchain Version: 1.0 Release: %{toolchain_release}%{?dist} Summary: Bootstrap GCC 14 and glibc 2.40 toolchain for CUDA 12.9 License: GPL-3.0-or-later AND LGPL-2.1-or-later URL: https://gcc.gnu.org/ Source0: https://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.xz Source1: https://ftp.gnu.org/gnu/glibc/glibc-%{glibc_version}.tar.xz ExclusiveArch: x86_64 BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: glibc-devel BuildRequires: binutils BuildRequires: make BuildRequires: bison BuildRequires: flex BuildRequires: gawk BuildRequires: grep BuildRequires: sed BuildRequires: diffutils BuildRequires: findutils BuildRequires: python3 BuildRequires: perl BuildRequires: texinfo BuildRequires: kernel-headers BuildRequires: gmp-devel BuildRequires: mpfr-devel BuildRequires: libmpc-devel BuildRequires: isl-devel BuildRequires: zlib-ng-compat-devel %global debug_package %{nil} %global _debugsource_packages 0 %description Bootstrap-only source package used to build a private GCC 14.4 and glibc 2.40 toolchain for CUDA 12.x. Installed files are emitted only by the custom-gcc14 and custom-glibc subpackages. %package -n custom-gcc14 Version: %{gcc_version} Release: %{toolchain_release}%{?dist} Summary: GCC 14.4 toolchain built against private glibc 2.40 License: GPL-3.0-or-later WITH GCC-exception-3.1 AutoProv: no Requires: custom-glibc = %{glibc_version}-%{toolchain_release}%{?dist} %description -n custom-gcc14 Private GCC 14.4 toolchain intended for CUDA 12.x. The target runtime libraries are built against the private glibc 2.40 sysroot installed in %{custom_glibc_root}. The compiler is installed in %{custom_gcc_root} and does not replace the Fedora system compiler. %package -n custom-glibc Version: %{glibc_version} Release: %{toolchain_release}%{?dist} Summary: Private glibc 2.40 sysroot for CUDA 12.x License: LGPL-2.1-or-later AutoReqProv: no %description -n custom-glibc Private GNU C Library 2.40 sysroot intended for the CUDA 12.x compatibility toolchain. It contains glibc headers, libraries, startup objects and Linux UAPI headers beneath %{custom_glibc_root}. It does not replace or modify the Fedora system glibc. %prep %setup -q -c -T tar -xf %{SOURCE0} tar -xf %{SOURCE1} %build set -e TOP="$(pwd)" GCC_SRC="${TOP}/gcc-%{gcc_version}" GLIBC_SRC="${TOP}/glibc-%{glibc_version}" STAGE0_GCC="${TOP}/stage0-gcc14" STAGE1_GLIBC="${TOP}/stage1-glibc" STAGE2_GCC="${TOP}/stage2-gcc14" STAGE3_GLIBC="${TOP}/stage3-glibc" GCC_BUILD0="${TOP}/build-gcc-stage0" GLIBC_BUILD1="${TOP}/build-glibc-stage1" GCC_BUILD2="${TOP}/build-gcc-stage2" GLIBC_BUILD3="${TOP}/build-glibc-stage3" GCC_BUILD4="${TOP}/build-gcc-stage4" FINAL_GCC_ROOT="%{custom_gcc_root}" FINAL_GLIBC_ROOT="%{custom_glibc_root}" JOBS="$(nproc)" # Do not inherit Fedora annobin/hardening/LTO flags into the private # bootstrap toolchain. These conservative flags match the policy that # made the standalone GCC/glibc builds usable. export CFLAGS="-O2 -g" export CXXFLAGS="-O2 -g" export LDFLAGS="" unset FFLAGS || : unset FCFLAGS || : copy_kernel_uapi() { SYSROOT="$1" rpm -ql kernel-headers | while IFS= read -r P; do case "$P" in /usr/include/*) if [ -d "$P" ] && [ ! -L "$P" ]; then mkdir -p "${SYSROOT}${P}" elif [ -e "$P" ] || [ -L "$P" ]; then mkdir -p "${SYSROOT}$(dirname "$P")" cp -a "$P" "${SYSROOT}${P}" fi ;; esac done } # ============================================================ # stage0: GCC 14 C-only + libgcc # Fedora GCC16/glibc is used only to bootstrap the compiler. # ============================================================ echo "=== stage0: GCC %{gcc_version} C-only bootstrap ===" rm -rf "$GCC_BUILD0" "$STAGE0_GCC" mkdir -p "$GCC_BUILD0" "$STAGE0_GCC" pushd "$GCC_BUILD0" "$GCC_SRC/configure" \ --prefix="$STAGE0_GCC" \ --enable-languages=c \ --disable-bootstrap \ --disable-multilib \ --disable-nls make -j"$JOBS" all-gcc make -j"$JOBS" all-target-libgcc make install-gcc make install-target-libgcc popd test -x "$STAGE0_GCC/bin/gcc" "$STAGE0_GCC/bin/gcc" --version # ============================================================ # stage1: first glibc 2.40 built by stage0 GCC14 # ============================================================ echo "=== stage1: glibc %{glibc_version} bootstrap ===" rm -rf "$GLIBC_BUILD1" "$STAGE1_GLIBC" mkdir -p "$GLIBC_BUILD1" "$STAGE1_GLIBC" pushd "$GLIBC_BUILD1" CC="$STAGE0_GCC/bin/gcc" \ BUILD_CC=/usr/bin/gcc \ CFLAGS="-O2 -g" \ LDFLAGS="" \ "$GLIBC_SRC/configure" \ --prefix=/usr \ --libdir=/usr/lib64 \ --includedir=/usr/include \ --disable-werror make -j"$JOBS" make install install_root="$STAGE1_GLIBC" popd copy_kernel_uapi "$STAGE1_GLIBC" rm -f "$STAGE1_GLIBC/etc/ld.so.cache" rm -f "$STAGE1_GLIBC/etc/ld.so.conf" test -f "$STAGE1_GLIBC/usr/include/features.h" test -f "$STAGE1_GLIBC/usr/include/linux/limits.h" test -e "$STAGE1_GLIBC/lib64/libc.so.6" test -e "$STAGE1_GLIBC/lib64/ld-linux-x86-64.so.2" test -f "$STAGE1_GLIBC/usr/lib64/crt1.o" test -f "$STAGE1_GLIBC/usr/lib64/crti.o" test -f "$STAGE1_GLIBC/usr/lib64/crtn.o" # ============================================================ # stage2: first complete GCC14 against stage1 glibc 2.40 # ============================================================ echo "=== stage2: complete GCC %{gcc_version} ===" rm -rf "$GCC_BUILD2" "$STAGE2_GCC" mkdir -p "$GCC_BUILD2" "$STAGE2_GCC" pushd "$GCC_BUILD2" CC=/usr/bin/gcc \ CXX=/usr/bin/g++ \ CFLAGS="-O2 -g" \ CXXFLAGS="-O2 -g" \ LDFLAGS="" \ "$GCC_SRC/configure" \ --prefix="$STAGE2_GCC" \ --with-sysroot="$FINAL_GLIBC_ROOT" \ --with-build-sysroot="$STAGE1_GLIBC" \ --with-native-system-header-dir=/usr/include \ --with-glibc-version=%{glibc_version} \ --enable-languages=c,c++ \ --disable-bootstrap \ --disable-multilib \ --disable-nls make -j"$JOBS" \ CFLAGS_FOR_TARGET="-O2 -g" \ CXXFLAGS_FOR_TARGET="-O2 -g" \ LDFLAGS_FOR_TARGET="" make install popd test -x "$STAGE2_GCC/bin/gcc" test -x "$STAGE2_GCC/bin/g++" "$STAGE2_GCC/bin/gcc" --version "$STAGE2_GCC/bin/g++" --version # ============================================================ # stage3: rebuild glibc 2.40 with complete stage2 GCC14 # ============================================================ echo "=== stage3: final glibc %{glibc_version} ===" rm -rf "$GLIBC_BUILD3" "$STAGE3_GLIBC" mkdir -p "$GLIBC_BUILD3" "$STAGE3_GLIBC" pushd "$GLIBC_BUILD3" CC="$STAGE2_GCC/bin/gcc --sysroot=$STAGE1_GLIBC -B$STAGE1_GLIBC/usr/lib64/" \ BUILD_CC=/usr/bin/gcc \ CFLAGS="-O2 -g" \ LDFLAGS="" \ "$GLIBC_SRC/configure" \ --prefix=/usr \ --libdir=/usr/lib64 \ --includedir=/usr/include \ --disable-werror make -j"$JOBS" make install install_root="$STAGE3_GLIBC" popd copy_kernel_uapi "$STAGE3_GLIBC" rm -f "$STAGE3_GLIBC/etc/ld.so.cache" rm -f "$STAGE3_GLIBC/etc/ld.so.conf" test -f "$STAGE3_GLIBC/usr/include/features.h" test -f "$STAGE3_GLIBC/usr/include/linux/limits.h" test -e "$STAGE3_GLIBC/lib64/libc.so.6" test -e "$STAGE3_GLIBC/lib64/ld-linux-x86-64.so.2" test -f "$STAGE3_GLIBC/usr/lib64/crt1.o" test -f "$STAGE3_GLIBC/usr/lib64/crti.o" test -f "$STAGE3_GLIBC/usr/lib64/crtn.o" # ============================================================ # stage4: final GCC14 against stage3 glibc 2.40 # # stage2 GCC builds host-side GCC programs against the Fedora host # (--sysroot=/), while target libraries use stage3 through # --with-build-sysroot. # ============================================================ echo "=== stage4: final GCC %{gcc_version} ===" rm -rf "$GCC_BUILD4" mkdir -p "$GCC_BUILD4" pushd "$GCC_BUILD4" CC="$STAGE2_GCC/bin/gcc --sysroot=/" \ CXX="$STAGE2_GCC/bin/g++ --sysroot=/" \ CFLAGS="-O2 -g" \ CXXFLAGS="-O2 -g" \ LDFLAGS="" \ "$GCC_SRC/configure" \ --prefix="$FINAL_GCC_ROOT" \ --with-sysroot="$FINAL_GLIBC_ROOT" \ --with-build-sysroot="$STAGE3_GLIBC" \ --with-native-system-header-dir=/usr/include \ --with-glibc-version=%{glibc_version} \ --enable-languages=c,c++ \ --disable-bootstrap \ --disable-multilib \ --disable-nls make -j"$JOBS" \ CFLAGS_FOR_TARGET="-O2 -g" \ CXXFLAGS_FOR_TARGET="-O2 -g" \ LDFLAGS_FOR_TARGET="" popd %install set -e # RPM 6 uses a *-build directory; use the actual section working # directory rather than reconstructing it from %{_builddir}. TOP="$(pwd)" STAGE3_GLIBC="${TOP}/stage3-glibc" GCC_BUILD4="${TOP}/build-gcc-stage4" rm -rf %{buildroot}%{custom_gcc_root} rm -rf %{buildroot}%{custom_glibc_root} rm -rf %{buildroot}%{_libexecdir}/custom-gcc14 mkdir -p %{buildroot}%{custom_glibc_root} cp -a "$STAGE3_GLIBC"/. %{buildroot}%{custom_glibc_root}/ pushd "$GCC_BUILD4" make install DESTDIR=%{buildroot} popd mkdir -p %{buildroot}%{_libexecdir}/custom-gcc14 cat > %{buildroot}%{_libexecdir}/custom-gcc14/env.sh <<'EOF' CUSTOM_GCC14_ROOT=/usr/lib64/custom-gcc14 CUSTOM_GLIBC_ROOT=/usr/lib64/custom-glibc export CUSTOM_GCC14_ROOT export CUSTOM_GLIBC_ROOT export CC="${CUSTOM_GCC14_ROOT}/bin/gcc" export CXX="${CUSTOM_GCC14_ROOT}/bin/g++" export PATH="${CUSTOM_GCC14_ROOT}/bin:${PATH}" EOF chmod 0755 %{buildroot}%{_libexecdir}/custom-gcc14/env.sh rm -f %{buildroot}%{custom_glibc_root}/etc/ld.so.cache rm -f %{buildroot}%{custom_glibc_root}/etc/ld.so.conf %check test -f %{buildroot}%{custom_glibc_root}/usr/include/features.h test -f %{buildroot}%{custom_glibc_root}/usr/include/linux/limits.h test -e %{buildroot}%{custom_glibc_root}/lib64/libc.so.6 test -e %{buildroot}%{custom_glibc_root}/lib64/ld-linux-x86-64.so.2 test -f %{buildroot}%{custom_glibc_root}/usr/lib64/crt1.o test -f %{buildroot}%{custom_glibc_root}/usr/lib64/crti.o test -f %{buildroot}%{custom_glibc_root}/usr/lib64/crtn.o test -x %{buildroot}%{custom_gcc_root}/bin/gcc test -x %{buildroot}%{custom_gcc_root}/bin/g++ %{buildroot}%{custom_gcc_root}/bin/gcc --version %{buildroot}%{custom_gcc_root}/bin/g++ --version test "$(%{buildroot}%{custom_gcc_root}/bin/gcc -print-sysroot)" = "%{custom_glibc_root}" CRT1="$( %{buildroot}%{custom_gcc_root}/bin/gcc \ --sysroot=%{buildroot}%{custom_glibc_root} \ -B%{buildroot}%{custom_glibc_root}/usr/lib64/ \ -print-file-name=crt1.o )" echo "crt1.o resolved as: $CRT1" test "$CRT1" != "crt1.o" test -f "$CRT1" %files -n custom-gcc14 %{custom_gcc_root} %{_libexecdir}/custom-gcc14 %files -n custom-glibc %{custom_glibc_root} %changelog * Tue Sep 15 2026 Moacyr Prado - 1.0-2 - Align build dependencies with previously working GCC14 build - Remove invalid zstd-devel dependency - Add main package description - Preserve conservative bootstrap flags - Use actual RPM build working directory during install - Bootstrap GCC14 C-only, glibc 2.40, complete GCC14, final glibc and final GCC14 * Tue Sep 15 2026 Moacyr Prado - 1.0-1 - Initial unified CUDA 12 compatibility toolchain bootstrap