@@ -90,26 +90,31 @@ ARG RHEL_VERSION
9090# where typically you would run `scl enable gcc-toolset-X` to open another Bash
9191# shell with the GCC toolset enabled. To avoid having to do so, we delete the
9292# default GCC packages first, and then reference the GCC toolset binaries
93- # directly.
93+ # directly. Note: we only do so for RHEL 9, as no toolsets are available for
94+ # RHEL 10 at the moment, and the default GCC 14 is sufficient.
9495RUN <<EOF
95- dnf remove -y gcc gcc-c++
96- dnf install -y --setopt=tsflags=nodocs gcc-toolset-${GCC_VERSION}-gcc gcc-toolset-${GCC_VERSION}-gcc-c++
96+ if [ "${RHEL_VERSION}" -eq "9" ]; then
97+ dnf remove -y gcc gcc-c++
98+ dnf install -y --setopt=tsflags=nodocs gcc-toolset-${GCC_VERSION}-gcc gcc-toolset-${GCC_VERSION}-gcc-c++
99+ update-alternatives \
100+ --install /usr/bin/cc cc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc 999
101+ update-alternatives \
102+ --install /usr/bin/c++ c++ /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/g++ 999
103+ update-alternatives \
104+ --install /usr/bin/gcc gcc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc 100 \
105+ --slave /usr/bin/g++ g++ /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/g++ \
106+ --slave /usr/bin/cpp cpp /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/cpp \
107+ --slave /usr/bin/gcov gcov /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov \
108+ --slave /usr/bin/gcov-dump gcov-dump /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov-dump-${GCC_VERSION} \
109+ --slave /usr/bin/gcov-tool gcov-tool /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov-tool-${GCC_VERSION}
110+ update-alternatives --auto cc
111+ update-alternatives --auto c++
112+ update-alternatives --auto gcc
113+ else
114+ dnf install -y --setopt=tsflags=nodocs gcc gcc-c++
115+ fi
97116dnf clean -y all
98117rm -rf /var/cache/dnf/*
99- update-alternatives \
100- --install /usr/bin/cc cc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc 999
101- update-alternatives \
102- --install /usr/bin/c++ c++ /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/g++ 999
103- update-alternatives \
104- --install /usr/bin/gcc gcc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc 100 \
105- --slave /usr/bin/g++ g++ /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/g++ \
106- --slave /usr/bin/cpp cpp /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/cpp \
107- --slave /usr/bin/gcov gcov /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov \
108- --slave /usr/bin/gcov-dump gcov-dump /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov-dump-${GCC_VERSION} \
109- --slave /usr/bin/gcov-tool gcov-tool /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov-tool-${GCC_VERSION}
110- update-alternatives --auto cc
111- update-alternatives --auto c++
112- update-alternatives --auto gcc
113118EOF
114119# Set the compiler environment variables to point to the GCC binaries.
115120ENV CC=/usr/bin/gcc
0 commit comments