Skip to content

Commit 262c884

Browse files
authored
Install gcc-toolset-11 from pre-built source instead of RPM (#7882)
AlmaLinux 8's gcc-toolset-11 RPM only provides GCC 11.2.1, but PyTorch requires >= 11.3. Switch to downloading a pre-built GCC 11.4.0 tarball from S3 (built by the build-gcc.yml workflow) that installs into /opt/rh/gcc-toolset-11/ as a drop-in replacement. There is also a small tweak in ldconfig for clang. We only need this for the newer clang 18. --------- Signed-off-by: Huy Do <huydhn@gmail.com>
1 parent f3d68e5 commit 262c884

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

docker/Dockerfile

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,25 @@ RUN dnf install -y \
3333
# The manylinux_2_28 base image (AlmaLinux 8) ships with GCC 8 as the system
3434
# default and bundles gcc-toolset-12 under /usr/local/bin. Install the
3535
# additional toolset versions that PyTorch CI requires.
36+
#
37+
# gcc-toolset-11: Pre-built from source (GCC 11.4.0) because the RPM only
38+
# provides 11.2.1, but PyTorch requires >= 11.3. The artifact is built by the
39+
# build-gcc.yml workflow and uploaded to S3. It installs into
40+
# /opt/rh/gcc-toolset-11/ with a compatible enable script.
41+
# Also register its libstdc++.so.6 with ldconfig — the system /lib64/libstdc++.so.6
42+
# is from GCC 8 and too old (missing GLIBCXX_3.4.26+). Clang uses libstdc++ at
43+
# runtime, so binaries built with clang need a newer one visible to the linker.
44+
RUN ARCH=$(uname -m) && PLATFORM="linux-${ARCH}" && \
45+
S3_URL="https://gha-artifacts.s3.amazonaws.com/gcc/${PLATFORM}/gcc-toolset-11/gcc-toolset-11-${PLATFORM}.tar.gz" && \
46+
echo "Installing gcc-toolset-11 from ${S3_URL}" && \
47+
curl -fsSL "${S3_URL}" -o /tmp/gcc-toolset-11.tar.gz && \
48+
mkdir -p /opt/rh/gcc-toolset-11 && \
49+
tar xzf /tmp/gcc-toolset-11.tar.gz -C /opt/rh/gcc-toolset-11 && \
50+
rm -f /tmp/gcc-toolset-11.tar.gz && \
51+
echo "/opt/rh/gcc-toolset-11/root/usr/lib64" > /etc/ld.so.conf.d/gcc-toolset-11.conf && \
52+
ldconfig
53+
3654
RUN dnf install -y \
37-
gcc-toolset-11-gcc \
38-
gcc-toolset-11-gcc-c++ \
39-
gcc-toolset-11-gcc-gfortran \
4055
gcc-toolset-13-gcc \
4156
gcc-toolset-13-gcc-c++ \
4257
gcc-toolset-13-gcc-gfortran \
@@ -58,15 +73,14 @@ RUN ARCH=$(uname -m) && PLATFORM="linux-${ARCH}" && \
5873
rm -f /tmp/clang.tar.gz; \
5974
done
6075

61-
# Register clang runtime library directories so the linker can find libclang_rt.asan.so
62-
# etc. without needing LD_LIBRARY_PATH hacks at CI time.
63-
RUN for CLANG_VERSION in 15 18; do \
64-
INSTALL_DIR="/opt/clang-${CLANG_VERSION}" && \
65-
CLANG_RT_DIR=$("${INSTALL_DIR}/bin/clang" --print-runtime-dir 2>/dev/null || true) && \
66-
if [ -n "${CLANG_RT_DIR}" ] && [ -d "${CLANG_RT_DIR}" ]; then \
67-
echo "${CLANG_RT_DIR}" > "/etc/ld.so.conf.d/clang-${CLANG_VERSION}.conf"; \
68-
fi; \
69-
done && ldconfig
76+
# Register only clang-15 runtime library directory with ldconfig so the linker
77+
# can find libclang_rt.asan.so for ASAN builds. Until we upgrade to RHEL 9, we
78+
# can only use clang-15 for ASAN
79+
RUN CLANG_RT_DIR=$("/opt/clang-15/bin/clang" --print-runtime-dir 2>/dev/null || true) && \
80+
if [ -n "${CLANG_RT_DIR}" ] && [ -d "${CLANG_RT_DIR}" ]; then \
81+
echo "${CLANG_RT_DIR}" > /etc/ld.so.conf.d/clang-15.conf; \
82+
fi && \
83+
ldconfig
7084

7185
# Install uv (Python package manager) — needed before CUDA install for uv run
7286
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

0 commit comments

Comments
 (0)