Skip to content

Commit 465224d

Browse files
committed
Add gcc and g++ to Debian and Ubuntu clang images
1 parent 0f66fe8 commit 465224d

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

docker/debian/Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ update-alternatives --install \
9595
update-alternatives --auto cc
9696
update-alternatives --auto gcc
9797
EOF
98+
# Set the compiler environment variables to point to the GCC binaries.
9899
ENV CC=/usr/bin/gcc
99100
ENV 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.
155156
ARG 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
178194
update-alternatives --auto clang
179195
update-alternatives --auto llvm-cov
180196
EOF
181-
197+
# Set the compiler environment variables to point to the GCC binaries.
182198
ENV CC=/usr/bin/clang-${CLANG_VERSION}
183199
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
184200

docker/debian/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ registry.
7070
DEBIAN_VERSION=bookworm
7171
CLANG_VERSION=17
7272
CONAN_VERSION=2.18.0
73+
GCC_VERSION=12
7374
GCOVR_VERSION=8.3
7475
CONTAINER_IMAGE=xrplf/ci/debian-${DEBIAN_VERSION}:clang-${CLANG_VERSION}
7576

@@ -81,6 +82,7 @@ docker buildx build . \
8182
--build-arg CLANG_VERSION=${CLANG_VERSION} \
8283
--build-arg CONAN_VERSION=${CONAN_VERSION} \
8384
--build-arg DEBIAN_VERSION=${DEBIAN_VERSION} \
85+
--build-arg GCC_VERSION=${GCC_VERSION} \
8486
--build-arg GCOVR_VERSION=${GCOVR_VERSION} \
8587
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
8688
```

docker/rhel/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ update-alternatives \
6464
update-alternatives --auto cc
6565
update-alternatives --auto gcc
6666
EOF
67+
# Set the compiler environment variables to point to the GCC binaries.
6768
ENV CC=/usr/bin/gcc
6869
ENV CXX=/usr/bin/g++
6970

@@ -126,7 +127,7 @@ rm -rf /var/cache/dnf/*
126127
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 999
127128
update-alternatives --auto cc
128129
EOF
129-
130+
# Set the compiler environment variables to point to the GCC binaries.
130131
ENV CC=/usr/bin/clang
131132
ENV CXX=/usr/bin/clang++
132133

docker/ubuntu/Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ update-alternatives \
8282
update-alternatives --auto cc
8383
update-alternatives --auto gcc
8484
EOF
85+
# Set the compiler environment variables to point to the GCC binaries.
8586
ENV CC=/usr/bin/gcc
8687
ENV CXX=/usr/bin/g++
8788

@@ -138,6 +139,21 @@ FROM base AS clang
138139
# This is not inherited from base image, ensure no manual interaction needed.
139140
ARG DEBIAN_FRONTEND=noninteractive
140141

142+
# Some build dependencies require GCC to be available.
143+
ARG GCC_VERSION
144+
RUN <<EOF
145+
apt-get update
146+
apt-get install -y --no-install-recommends \
147+
gcc-${GCC_VERSION} \
148+
g++-${GCC_VERSION} \
149+
debhelper
150+
apt-get clean
151+
rm -rf /var/lib/apt/lists/*
152+
update-alternatives \
153+
--install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 100 \
154+
--slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION}
155+
EOF
156+
141157
# Install Clang.
142158
ARG CLANG_VERSION
143159
RUN <<EOF
@@ -157,7 +173,7 @@ update-alternatives --auto cc
157173
update-alternatives --auto clang
158174
update-alternatives --auto llvm-cov
159175
EOF
160-
176+
# Set the compiler environment variables to point to the GCC binaries.
161177
ENV CC=/usr/bin/clang-${CLANG_VERSION}
162178
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
163179

docker/ubuntu/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ registry.
6666
UBUNTU_VERSION=noble
6767
CLANG_VERSION=18
6868
CONAN_VERSION=2.18.0
69+
GCC_VERSION=14
6970
GCOVR_VERSION=8.3
7071
CONTAINER_IMAGE=xrplf/ci/ubuntu-${UBUNTU_VERSION}:clang-${CLANG_VERSION}
7172

@@ -76,6 +77,7 @@ docker buildx build . \
7677
--build-arg BUILDKIT_INLINE_CACHE=1 \
7778
--build-arg CLANG_VERSION=${CLANG_VERSION} \
7879
--build-arg CONAN_VERSION=${CONAN_VERSION} \
80+
--build-arg GCC_VERSION=${GCC_VERSION} \
7981
--build-arg GCOVR_VERSION=${GCOVR_VERSION} \
8082
--build-arg UBUNTU_VERSION=${UBUNTU_VERSION} \
8183
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}

0 commit comments

Comments
 (0)