@@ -95,6 +95,7 @@ update-alternatives --install \
9595update-alternatives --auto cc
9696update-alternatives --auto gcc
9797EOF
98+ # Set the compiler environment variables to point to the GCC binaries.
9899ENV CC=/usr/bin/gcc
99100ENV CXX=/usr/bin/g++
100101
@@ -154,6 +155,21 @@ FROM base AS clang
154155# This is not inherited from base image, ensure no manual interaction needed.
155156ARG DEBIAN_FRONTEND=noninteractive
156157
158+ # Some build dependencies require GCC to be available.
159+ COPY --from=gcc-src /usr/local/ /usr/local/
160+ COPY --from=gcc-src /etc/ld.so.conf.d/*.conf /etc/ld.so.conf.d/
161+ RUN <<EOF
162+ ldconfig -v
163+ dpkg-divert --divert /usr/bin/gcc.orig --rename /usr/bin/gcc
164+ update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc 100
165+ update-alternatives --install \
166+ /usr/bin/gcc gcc /usr/local/bin/gcc 100 \
167+ --slave /usr/bin/g++ g++ /usr/local/bin/g++ \
168+ --slave /usr/bin/gcc-ar gcc-ar /usr/local/bin/gcc-ar \
169+ --slave /usr/bin/gcc-nm gcc-nm /usr/local/bin/gcc-nm \
170+ --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/local/bin/gcc-ranlib
171+ EOF
172+
157173# Install Clang. Use the LLVM apt repository to access the latest versions. We
158174# must repeat the DEBIAN_VERSION argument here, as it is not inherited from the
159175# base or source images.
@@ -178,7 +194,7 @@ update-alternatives --auto cc
178194update-alternatives --auto clang
179195update-alternatives --auto llvm-cov
180196EOF
181-
197+ # Set the compiler environment variables to point to the GCC binaries.
182198ENV CC=/usr/bin/clang-${CLANG_VERSION}
183199ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
184200
0 commit comments