@@ -42,12 +42,15 @@ RUN pip install --no-cache conan==${CONAN_VERSION} gcovr==${GCOVR_VERSION}
4242# ====================== GCC IMAGE ======================
4343FROM base AS gcc
4444
45+ # These are not inherited from the base image.
46+ ARG GCC_VERSION
47+ ARG RHEL_VERSION
48+
4549# Install GCC. Red Hat installs GCC as a Software Collection (SCL) package,
4650# where typically you would run `scl enable gcc-toolset-X` to open another Bash
4751# shell with the GCC toolset enabled. To avoid having to do so, we delete the
4852# default GCC packages first, and then reference the GCC toolset binaries
4953# directly.
50- ARG GCC_VERSION
5154RUN <<EOF
5255dnf remove -y gcc gcc-c++
5356dnf install -y --setopt=tsflags=nodocs gcc-toolset-${GCC_VERSION}-gcc gcc-toolset-${GCC_VERSION}-gcc-c++
@@ -100,10 +103,14 @@ conan profile detect
100103rm -rf /tmp/*
101104EOF
102105
103- # Explicitly set the compiler flags.
106+ # Explicitly set the compiler flags, as well as a custom flag that specifies the
107+ # distribution name and version. This is important to avoid conflicts between
108+ # builds using the same compiler but different distribution versions.
104109RUN <<EOF
105110cat >> $(conan config home)/global.conf <<EOT
106111tools.build:compiler_executables={"c" : "${CC}" , "cpp" : "${CXX}" }
112+ user.package:distro="rhel-${RHEL_VERSION}"
113+ tools.info.package_id:confs=["user.package:distro" ]
107114EOT
108115EOF
109116
121128# ===================== CLANG IMAGE =====================
122129FROM base AS clang
123130
131+ # This is not inherited from the base image.
132+ ARG RHEL_VERSION
133+
124134# Install Clang. Note that in the RHEL UBIs, we cannot choose the Clang version
125135# to install and we get what is available. Some build dependencies require GCC
126136# to be also available.
@@ -168,10 +178,14 @@ conan profile detect
168178rm -rf /tmp/*
169179EOF
170180
171- # Explicitly set the compiler flags.
181+ # Explicitly set the compiler flags, as well as a custom flag that specifies the
182+ # distribution name and version. This is important to avoid conflicts between
183+ # builds using the same compiler but different distribution versions.
172184RUN <<EOF
173185cat >> $(conan config home)/global.conf <<EOT
174186tools.build:compiler_executables={"c" : "${CC}" , "cpp" : "${CXX}" }
187+ user.package:distro="rhel-${RHEL_VERSION}"
188+ tools.info.package_id:confs=["user.package:distro" ]
175189EOT
176190EOF
177191
0 commit comments