Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
run: |
set -euo pipefail
docker run --rm "${IMAGE}:${GITHUB_SHA}-base" bash -euo pipefail -c '
for tool in gcc g++ gcc-14 g++-14 clang clang++ clang-tidy \
for tool in gcc g++ gcc-14 g++-14 gcc-15 g++-15 clang clang++ clang-tidy qmake \
clang-22 clang++-22 clang-tidy-22 llvm-symbolizer cmake ninja \
pkg-config pace-cc pace-kv gawk make ss lsof fuser jq \
zip unzip shellcheck; do
Expand All @@ -132,7 +132,40 @@ jobs:
printf "#include <cstdio>\nint main(){std::puts(\"ok\");}\n" > "$tmp/t.cpp"
g++ -std=c++23 -o "$tmp/gcc-t" "$tmp/t.cpp"
clang++ -std=c++23 -stdlib=libstdc++ -o "$tmp/clang-t" "$tmp/t.cpp"
"$tmp/gcc-t" && "$tmp/clang-t"
g++-15 -std=c++23 -o "$tmp/gcc15-t" "$tmp/t.cpp"
"$tmp/gcc-t" && "$tmp/clang-t" && "$tmp/gcc15-t"
# gcc and g++ stay GCC 14, and clang stays on GCC 14 libstdc++
# although GCC 15 is installed (the clang config files).
gcc -dumpversion | grep -qx 14 || { echo "gcc is not GCC 14"; exit 1; }
# Captured, not piped: under pipefail, grep -q exiting at its match
# fails the pipeline when clang then dies writing to the closed pipe.
selected="$(clang++ -v -E -x c++ /dev/null 2>&1)"
grep -qx "Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14" <<<"$selected" \
|| { echo "clang does not select GCC 14"; printf "%s\n" "$selected"; exit 1; }
# Qt: every library and the offscreen platform plugin resolve, and a
# CMake project finds this Qt with no hint and runs offscreen.
# Quick3DSpatialAudio comes with qtmultimedia but links Qt Quick 3D,
# which is not installed; nothing here uses it.
for lib in "$QT_ROOT_DIR"/lib/libQt6*.so.6 "$QT_ROOT_DIR"/plugins/platforms/libqoffscreen.so; do
case "$lib" in */libQt6Quick3DSpatialAudio.so.6) continue ;; esac
if ldd "$lib" | grep -q "not found"; then
echo "unresolved libraries in $lib"; ldd "$lib" | grep "not found"; exit 1
fi
done
mkdir -p "$tmp/qt"
printf "%s\n" \
"cmake_minimum_required(VERSION 3.25)" "project(t CXX)" \
"find_package(Qt6 6.8 REQUIRED COMPONENTS Gui WebSockets Multimedia Quick)" \
"add_executable(t t.cpp)" \
"target_link_libraries(t PRIVATE Qt6::Gui Qt6::WebSockets Qt6::Multimedia Qt6::Quick)" \
> "$tmp/qt/CMakeLists.txt"
printf "%s\n" \
"#include <QGuiApplication>" "#include <QWebSocket>" \
"int main(int c, char** v) { QGuiApplication app(c, v); QWebSocket s; return QGuiApplication::platformName() == \"offscreen\" ? 0 : 1; }" \
> "$tmp/qt/t.cpp"
cmake -S "$tmp/qt" -B "$tmp/qt/build" -G Ninja -DCMAKE_CXX_COMPILER=g++ >/dev/null
cmake --build "$tmp/qt/build" >/dev/null
QT_QPA_PLATFORM=offscreen "$tmp/qt/build/t"
'

- uses: docker/login-action@v3
Expand Down
76 changes: 68 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ ARG BASE_IMAGE
# compilers, it carries the command-line tools a GitHub-hosted runner provides
# that projects' tests rely on: gawk (Ubuntu's default awk is mawk, which
# rejects GNU awk scripts), make, ss/lsof/fuser to attribute a listening socket
# to a process, jq, zip, shellcheck and the like. gcc-14 is provided
# by Ubuntu 24.04 (noble) itself; no third-party PPA is needed.
# to a process, jq, zip, shellcheck and the like. gcc-14 is provided by Ubuntu
# 24.04 (noble) itself and stays the default gcc/g++; gcc-15/g++-15 come from the
# ubuntu-toolchain-r PPA for projects that build with GCC 15. The libdbus,
# libegl, libfontconfig, libglib, libopengl, libpulse, libwayland, libxcb and
# libxkbcommon packages are the runtime libraries of the Qt in the `qt` stage
# below: its libraries load without them only on a full desktop.
#
# Installing GCC 15 also installs libstdc++ 15, and clang uses the newest GCC
# installation it finds. The clang config files below pin clang to GCC 14's, so
# that adding a compiler does not change what every clang build compiles against
# (nor re-key its compile cache). A project that wants another libstdc++ passes
# its own --gcc-install-dir, which overrides the config file's.
FROM ${BASE_IMAGE} AS toolchain

ARG LLVM_VERSION=22
Expand All @@ -31,7 +41,27 @@ RUN printf 'Acquire::Retries "5";\n' > /etc/apt/apt.conf.d/80-retries \
gpg \
iproute2 \
jq \
libdbus-1-3 \
libegl1 \
libfontconfig1 \
libgl1-mesa-dev \
libglib2.0-0t64 \
libopengl0 \
libpulse0 \
libwayland-client0 \
libwayland-cursor0 \
libwayland-egl1 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-render-util0 \
libxcb-render0 \
libxcb-shape0 \
libxcb-xkb1 \
libxkbcommon-x11-0 \
libxkbcommon0 \
libxrandr2 \
libsqlite3-dev \
libsqliteodbc \
libssl-dev \
Expand All @@ -46,9 +76,6 @@ RUN printf 'Acquire::Retries "5";\n' > /etc/apt/apt.conf.d/80-retries \
pkg-config \
procps \
psmisc \
qt6-base-dev \
qt6-tools-dev \
qt6-websockets-dev \
shellcheck \
software-properties-common \
unixodbc-dev \
Expand All @@ -63,6 +90,14 @@ RUN printf 'Acquire::Retries "5";\n' > /etc/apt/apt.conf.d/80-retries \
clang-tidy-${LLVM_VERSION} \
llvm-${LLVM_VERSION} \
&& rm llvm.sh \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y --no-install-recommends gcc-15 g++-15 \
&& test -d /usr/lib/gcc/x86_64-linux-gnu/14 \
&& for driver in clang clang++; do \
printf -- '--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/14\n' \
> "/usr/lib/llvm-${LLVM_VERSION}/bin/${driver}.cfg"; \
done \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/bin/gcc-14 /usr/local/bin/gcc \
&& ln -s /usr/bin/g++-14 /usr/local/bin/g++ \
Expand Down Expand Up @@ -91,24 +126,49 @@ RUN git clone https://github.com/LASTRADA-Software/pace.git /src/pace \
&& install -D -m 0755 /build/pace/target/pace-cc /opt/pace/bin/pace-cc \
&& install -D -m 0755 /build/pace/target/pace-kv /opt/pace/bin/pace-kv

# Qt from the Qt Company's online repository (aqtinstall), not Ubuntu's: noble
# ships Qt 6.4, which is out of support and older than consumers require. The
# modules are the ones morph's CI installs.
FROM toolchain AS qt

ARG QT_VERSION=6.8.1
ARG AQTINSTALL_VERSION=3.3.0

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3-venv \
&& python3 -m venv /tmp/aqt \
&& /tmp/aqt/bin/pip install --quiet "aqtinstall==${AQTINSTALL_VERSION}" \
&& /tmp/aqt/bin/aqt install-qt linux desktop "${QT_VERSION}" linux_gcc_64 \
--modules qtwebsockets qtmultimedia --outputdir /opt/Qt \
&& test -f "/opt/Qt/${QT_VERSION}/gcc_64/lib/cmake/Qt6/Qt6Config.cmake"

FROM toolchain

ARG PACE_REF
ARG LLVM_VERSION=22
ARG QT_VERSION=6.8.1

LABEL org.opencontainers.image.source="https://github.com/LASTRADA-Software/cpp-ci-image" \
org.opencontainers.image.description="Pinned Linux C++ CI toolchain with pace compiler cache" \
org.opencontainers.image.licenses="Apache-2.0" \
org.lastrada.pace.ref="${PACE_REF}" \
org.lastrada.llvm.version="${LLVM_VERSION}"
org.lastrada.llvm.version="${LLVM_VERSION}" \
org.lastrada.qt.version="${QT_VERSION}"

COPY --from=builder /opt/pace/bin/pace-cc /opt/pace/bin/pace-kv /opt/pace/bin/
COPY --from=qt /opt/Qt /opt/Qt

# Compile-cache seeds, supplied as the named build context `pace-seed`. The
# publishing workflow passes seed/none, which leaves the seed directory empty,
# and its publish job layers one store per warmed group on top of this image,
# at pace/<group>.cow. See README: "Seed warmer".
COPY --from=pace-seed / /opt/pace/seed-cache/

ENV PATH="/opt/pace/bin:${PATH}" \
PACE_CACHE_SEED_DIR="/opt/pace/seed-cache"
# QT_ROOT_DIR and CMAKE_PREFIX_PATH as jurplel/install-qt-action sets them, so a
# find_package(Qt6) finds this Qt without a project-specific hint. LANG is the
# hosted runner's: Qt warns on a non-UTF-8 locale and switches to C.UTF-8 itself.
ENV PATH="/opt/pace/bin:/opt/Qt/${QT_VERSION}/gcc_64/bin:${PATH}" \
LANG="C.UTF-8" \
PACE_CACHE_SEED_DIR="/opt/pace/seed-cache" \
QT_ROOT_DIR="/opt/Qt/${QT_VERSION}/gcc_64" \
CMAKE_PREFIX_PATH="/opt/Qt/${QT_VERSION}/gcc_64"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
The shared Linux toolchain image for `pace`, `morph`, `Lightweight`, and
`formula-cpp`.

It includes GCC 14, Clang 22, CMake, Ninja, `pace-cc`, and `pace-kv`. It is
It includes GCC 14 (the default `gcc`/`g++`), GCC 15 (`gcc-15`/`g++-15`),
Clang 22 (on GCC 14's libstdc++), Qt 6.8.1 with WebSockets and Multimedia at
`$QT_ROOT_DIR`, CMake, Ninja, `pace-cc`, and `pace-kv`. It is
published to GHCR by `.github/workflows/publish.yml`. Consumers use the moving
`latest` tag, which every successful `master` build advances.

Expand Down
Loading