build: select a working C++20 compiler for RPM builds

A compiler activated while installing dependencies does not survive in
the caller's shell, so make rpm could fall back to one that can't
compile mergerfs. Route the RPM build through buildtools/run-rpmbuild,
which keeps an explicit compiler and otherwise activates an installed
GCC Toolset when the default can't handle C++20. RPMBUILD and
RPMBUILD_FLAGS override the rpmbuild command.

Rocky 8's toolsets lack the annobin plugin the distribution's RPM
flags load. Test the effective compiler with the RPM flags and pass
--undefine _annotated_build only when that fails, instead of guessing
from the compiler's path in build-mergerfs. Native and container
builds use the same check.
This commit is contained in:
Antonio SJ Musumeci 2026-05-13 13:56:09 -05:00
parent 11e759101d
commit d83e01b40a
4 changed files with 106 additions and 16 deletions

View file

@ -45,10 +45,23 @@ Distributions that enforce RPM signature checking reject the unsigned
local build. When installing a locally built RPM that you built and
trust, pass `--nosignature` to `rpm`.
Rocky Linux container builds activate newer GCC Toolsets when available.
Both the Rocky 10 `/usr/lib/gcc-toolset/<version>-env.source` activation
script and the older `/opt/rh/gcc-toolset-<version>/enable` layout are
supported.
mergerfs requires a C++20 compiler and the system `g++` on RHEL /
Rocky 8 is too old. On RHEL / Rocky `install-build-pkgs` installs the
newest GCC Toolset when it is newer than the system compiler, and the
Rocky Linux container builds use it. When `CXX` is unset and the
default `g++` can't build C++20, `make rpm` activates the newest
installed GCC Toolset automatically. If the selected compiler lacks
the annobin plugin that the RPM build flags load, `make rpm` also
disables RPM's annobin annotations (`--undefine _annotated_build`).
Both the Rocky 10 `/usr/lib/gcc-toolset/<version>-env.source`
activation script and the older `/opt/rh/gcc-toolset-<version>/enable`
layout are supported. To build outside of `make rpm` on such systems
(for example `make` or `make install`) activate the toolset first:
```
# . /opt/rh/gcc-toolset-<version>/enable
# make
```
## Container packages