diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9d19010..ec44737 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -132,7 +132,40 @@ jobs: printf "#include \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 " "#include " \ + "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 diff --git a/Dockerfile b/Dockerfile index 844c57e..4c6b93d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 \ @@ -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 \ @@ -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++ \ @@ -91,18 +126,37 @@ 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, @@ -110,5 +164,11 @@ COPY --from=builder /opt/pace/bin/pace-cc /opt/pace/bin/pace-kv /opt/pace/bin/ # at pace/.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" diff --git a/README.md b/README.md index 71b8319..a8f9efd 100644 --- a/README.md +++ b/README.md @@ -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.