From 6045cc7b07166830f2da751ab953b52e4dc1c4a3 Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Thu, 25 Jun 2026 10:40:14 -0700 Subject: [PATCH] Use C++20-capable toolchains in the deb/rpm package build images The scalable-topics SDK (pulsar::st) requires C++20 -- concepts, coroutines and `using enum` -- which needs GCC 11+. The package-build images shipped older compilers, so the RPM (rockylinux:8 / GCC 8.5) and Deb (debian:11 / GCC 10, no `using enum`) builds failed compiling the st examples. - deb: bump debian:11 -> debian:12 (default GCC 12). - rpm: keep rockylinux:8 to preserve the el8 / glibc-2.28 ABI (so the RPM still runs on RHEL/Rocky/CentOS 8) and install gcc-toolset-12 (GCC 12), enabled in the spec %build via 'source /opt/rh/gcc-toolset-12/enable'. The toolset ships its own static libstdc++ for libpulsar.a. - apk (alpine:3.19) already provides GCC 13; unchanged. Verified by building both images and compiling the st examples with -std=c++20 under debian:12 and gcc-toolset-12 on rockylinux:8. Signed-off-by: Matteo Merli --- pkg/deb/Dockerfile | 2 +- pkg/rpm/Dockerfile | 5 +++++ pkg/rpm/SPECS/pulsar-client.spec | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/deb/Dockerfile b/pkg/deb/Dockerfile index 4d0212dc..6be59115 100644 --- a/pkg/deb/Dockerfile +++ b/pkg/deb/Dockerfile @@ -19,7 +19,7 @@ # Build pulsar client library in Centos with tools to -FROM debian:11 +FROM debian:12 ARG PLATFORM diff --git a/pkg/rpm/Dockerfile b/pkg/rpm/Dockerfile index d3475cfe..6fcb26fd 100644 --- a/pkg/rpm/Dockerfile +++ b/pkg/rpm/Dockerfile @@ -23,9 +23,14 @@ FROM rockylinux:8 ARG PLATFORM +# gcc-toolset-12 supplies GCC 12 for the C++20 scalable-topics code (concepts, +# coroutines, `using enum`) while keeping the el8 / glibc 2.28 ABI, so the produced +# RPM still runs on RHEL/Rocky/CentOS 8. It is enabled in the spec %build via +# `source /opt/rh/gcc-toolset-12/enable`. RUN yum update -y && \ yum install -y \ gcc-c++ \ + gcc-toolset-12 \ make \ rpm-build \ which \ diff --git a/pkg/rpm/SPECS/pulsar-client.spec b/pkg/rpm/SPECS/pulsar-client.spec index 425eec5f..ff5a6ff4 100644 --- a/pkg/rpm/SPECS/pulsar-client.spec +++ b/pkg/rpm/SPECS/pulsar-client.spec @@ -53,6 +53,10 @@ static library. %setup -q -n apache-pulsar-client-cpp-%{pom_version} %build +# Build with GCC 12 from gcc-toolset-12 (installed in the build image) for C++20 +# support, while keeping the el8 ABI. Sets PATH/LD_LIBRARY_PATH to the toolset for +# the cmake build below. +source /opt/rh/gcc-toolset-12/enable git clone https://github.com/microsoft/vcpkg.git cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON