Skip to content

Commit b6bc6aa

Browse files
committed
Install /usr/bin/cc symlink rather than gcc package
1 parent c171fa9 commit b6bc6aa

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

docker/debian/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ ARG DEBIAN_FRONTEND=noninteractive
156156
# Install Clang. Use the LLVM apt repository to access the latest versions. We
157157
# must repeat the DEBIAN_VERSION argument here, as it is not inherited from the
158158
# base or source images.
159-
# Note, gcc is needed for build dependencies.
160159
ARG DEBIAN_VERSION
161160
ARG CLANG_VERSION
162161
RUN <<EOF
@@ -165,13 +164,14 @@ printf "%s\n%s\n" \
165164
"deb [signed-by=/etc/apt/keyrings/llvm.gpg] https://apt.llvm.org/${DEBIAN_VERSION}/ llvm-toolchain-${DEBIAN_VERSION}-${CLANG_VERSION} main" \
166165
| tee /etc/apt/sources.list.d/llvm.list
167166
apt-get update
168-
apt-get install -y --no-install-recommends gcc
169167
apt-get install -t llvm-toolchain-${DEBIAN_VERSION}-${CLANG_VERSION} -y --no-install-recommends clang-${CLANG_VERSION} llvm-${CLANG_VERSION}
170168
apt-get clean
171169
rm -rf /var/lib/apt/lists/*
172170
EOF
173171
ENV CC=/usr/bin/clang-${CLANG_VERSION}
174172
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
173+
# This is required by some build dependencies
174+
RUN update-alternatives --install /usr/bin/cc cc $CC 999
175175

176176
# Check that the installed Clang version matches the expected version.
177177
RUN <<EOF

docker/rhel/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dnf remove -y gcc gcc-c++
5252
dnf install -y --setopt=tsflags=nodocs gcc-toolset-${GCC_VERSION}-gcc gcc-toolset-${GCC_VERSION}-gcc-c++
5353
dnf clean -y all
5454
rm -rf /var/cache/dnf/*
55+
update-alternatives --install /usr/bin/cc cc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc 999
5556
update-alternatives \
5657
--install /usr/bin/gcc gcc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc ${GCC_VERSION} \
5758
--slave /usr/bin/g++ g++ /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/g++ \
@@ -134,14 +135,15 @@ FROM base AS clang
134135

135136
# Install Clang. Note that in the RHEL UBIs, we cannot choose the Clang version
136137
# to install and we get what is available.
137-
# Note, gcc is needed for build dependencies.
138138
RUN <<EOF
139-
dnf install -y --setopt=tsflags=nodocs clang llvm gcc
139+
dnf install -y --setopt=tsflags=nodocs clang llvm
140140
dnf clean -y all
141141
rm -rf /var/cache/dnf/*
142142
EOF
143143
ENV CC=/usr/bin/clang
144144
ENV CXX=/usr/bin/clang++
145+
# This is required by some build dependencies
146+
RUN update-alternatives --install /usr/bin/cc cc $CC 999
145147

146148
# Check that the installed Clang version is not older than the minimum required.
147149
ARG MINIMUM_CLANG_VERSION=16

docker/ubuntu/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ apt-get install -y --no-install-recommends \
6969
g++-${GCC_VERSION}
7070
apt-get clean
7171
rm -rf /var/lib/apt/lists/*
72+
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-${GCC_VERSION} 999
7273
update-alternatives \
7374
--install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} ${GCC_VERSION} \
7475
--slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} \
@@ -151,19 +152,20 @@ FROM base AS clang
151152
# This is not inherited from base image, ensure no manual interaction needed.
152153
ARG DEBIAN_FRONTEND=noninteractive
153154

154-
# Install Clang. Note, gcc is needed for build dependencies
155+
# Install Clang.
155156
ARG CLANG_VERSION
156157
RUN <<EOF
157158
apt-get update
158159
apt-get install -y --no-install-recommends \
159160
clang-${CLANG_VERSION} \
160-
llvm-${CLANG_VERSION} \
161-
gcc
161+
llvm-${CLANG_VERSION}
162162
apt-get clean
163163
rm -rf /var/lib/apt/lists/*
164164
EOF
165165
ENV CC=/usr/bin/clang-${CLANG_VERSION}
166166
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
167+
# This is required by some build dependencies
168+
RUN update-alternatives --install /usr/bin/cc cc $CC 999
167169

168170
# Check that the installed Clang version matches the expected version.
169171
RUN <<EOF

0 commit comments

Comments
 (0)