* [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed
2026-08-10 0:51 [PATCHES v1 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
@ 2026-08-10 0:51 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 0:51 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Two parse-time probes still invoke $(CC) unconditionally:
- LP64 in tools/scripts/Makefile.arch, probing with
$(CC) -E -x c, pulled in twice by tools/perf/Makefile.perf;
- CC_NO_CLANG in tools/scripts/Makefile.include, probing with
$(CC) -dM -E -x c /dev/null.
In the corner case where gcc is not yet installed, the very setup
the install-build-deps target, added in the next patch of this
series, is meant for, these probes make even targets that never
compile parse-time spew errors like:
/bin/sh: 1: gcc: not found
/bin/sh: 1: gcc: not found
/bin/sh: 1: gcc: not found
Guard both probes with 'command -v' using the first word of CC so
a missing compiler is handled silently with the same result as a
failing probe (CC_NO_CLANG and LP64 unset/0), and with no behavior
change when the compiler is installed. Only the first word is
consulted because CC may carry arguments such as 'ccache gcc', and
shell implementations differ in how 'command -v' handles multiple
words (dash only checks the first, bash any of them), so validating
the whole CC value would silently disable both probes on some make
SHELLs.
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/scripts/Makefile.arch | 2 +-
tools/scripts/Makefile.include | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch
index eabfe9f411d914b9..e0bca6808ec44ed8 100644
--- a/tools/scripts/Makefile.arch
+++ b/tools/scripts/Makefile.arch
@@ -38,7 +38,7 @@ ifeq ($(ARCH),loongarch64)
SRCARCH := loongarch
endif
-LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+LP64 := $(shell if command -v $(firstword ${CC}) >/dev/null 2>&1; then echo __LP64__ | ${CC} ${CFLAGS} -E -x c -; fi | tail -n 1)
ifeq ($(LP64), 1)
IS_64_BIT := 1
else
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 46a3872b87624a7b..fff453aac187536e 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -98,7 +98,7 @@ else
$(call allow-override,LLVM_STRIP,llvm-strip)
endif
-CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
+CC_NO_CLANG := $(shell if command -v $(firstword $(CC)) >/dev/null 2>&1; then $(CC) -dM -E -x c /dev/null; fi | grep -Fq "__clang__"; echo $$?)
# Some tools require bpftool
SYSTEM_BPFTOOL ?= bpftool
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf
@ 2026-08-10 15:44 Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed Arnaldo Carvalho de Melo
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
Hi,
This series adds a 'make -C tools/perf install-build-deps' target that
installs the development packages needed to build perf on Fedora,
Ubuntu, Debian, and RHEL family distributions.
Building perf requires many devel packages (libelf, libdw, libunwind,
numactl, libtraceevent, libbpf, etc.). Today users must iteratively
install packages as each feature check fails. The new target installs
the full set in one go.
The first patch makes the compiler probe run at parse time only when the
tool is installed, so a missing C++ compiler or clang no longer fails
the feature tests prematurely. The second patch adds the framework (make
target, distro detection, package manager drivers). The next four
patches add distro-specific package mappings derived from the headers
each feature test requires. The last patch removes leftover feature test
entries for cxx and clang support removed in 56b11a2126bf2f42 ("perf
bpf: Remove support for embedding clang for compiling BPF events (-e
foo.c)").
Supported distros (validated in containers, host never modified):
- Fedora 44 (dnf, 29 packages)
- Ubuntu 26.04 (apt, 29 packages)
- Debian 13 (apt, reuses Ubuntu mapping)
- Centos 10 (dnf, 29 packages)
On all distros, a clean O= build after running the target enabled every
feature the distro provides (excluding deliberately unmapped deprecated
packages). Re-running the target is a no-op.
What changed from v1:
- AlmaLinux is now detected by its actual /etc/os-release ID
("almalinux" instead of "alma") in detect_distro() [sashiko review
of PATCH 7/7];
- packages that no enabled repo provides (e.g. zlib and the versioned
JDK/jvmti packages on the RHEL family) are no longer silently
omitted from the missing packages list, they are reported at the end
of the run, as stated in the commit message [sashiko review of
PATCH 7/7];
- the temporary file used to track those missing packages is now
removed by a trap, so it does not leak if the script is interrupted
[sashiko review of PATCH 7/7];
- the leftover feature test removal patch now carries the suggested
Fixes: tag for 56b11a2126bf2f42, with the author of that commit
Cc'd [Ian Rogers review of PATCH 6/7].
This series was developed with assistance from Opencode
(deepseek-v4-flash-free and glm-4-7-flash-ollama-local) for code
analysis, patch generation, and commit message composition.
Regards,
- Arnaldo
Arnaldo Carvalho de Melo (7):
tools build: Only probe the compiler at parse time when it is installed
perf build: Add install-build-deps framework to install devel packages
perf build: install-build-deps: add Fedora devel package mapping
perf build: install-build-deps: add Ubuntu devel package mapping
perf build: install-build-deps: add Debian devel package mapping
perf build: Remove leftover feature tests for removed cxx and clang support
perf build: install-build-deps: add RHEL family devel package mapping
tools/build/Makefile.feature | 2 -
tools/build/feature/Makefile | 14 -
tools/perf/Makefile.perf | 21 +-
tools/perf/scripts/install-build-deps.sh | 577 +++++++++++++++++++++++++++++++
tools/scripts/Makefile.arch | 2 +-
tools/scripts/Makefile.include | 2 +-
6 files changed, 597 insertions(+), 21 deletions(-)
base-commit: bf10e6ee2ac3034c9068e03eed418fd16961984e
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
@ 2026-08-10 15:44 ` Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 2/7] perf build: Add install-build-deps framework to install devel packages Arnaldo Carvalho de Melo
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Two parse-time probes still invoke $(CC) unconditionally:
- LP64 in tools/scripts/Makefile.arch, probing with
$(CC) -E -x c, pulled in twice by tools/perf/Makefile.perf;
- CC_NO_CLANG in tools/scripts/Makefile.include, probing with
$(CC) -dM -E -x c /dev/null.
In the corner case where gcc is not yet installed, the very setup the
install-build-deps target, added in the next patch of this series, is
meant for, these probes make even targets that never compile parse-time
spew errors like:
/bin/sh: 1: gcc: not found
/bin/sh: 1: gcc: not found
/bin/sh: 1: gcc: not found
Guard both probes with 'command -v' using the first word of CC so a
missing compiler is handled silently with the same result as a failing
probe (CC_NO_CLANG and LP64 unset/0), and with no behavior change when
the compiler is installed.
Only the first word is consulted because CC may carry arguments such as
'ccache gcc', and shell implementations differ in how 'command -v'
handles multiple words (dash only checks the first, bash any of them),
so validating the whole CC value would silently disable both probes on
some make SHELLs.
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/scripts/Makefile.arch | 2 +-
tools/scripts/Makefile.include | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch
index eabfe9f411d914b9..e0bca6808ec44ed8 100644
--- a/tools/scripts/Makefile.arch
+++ b/tools/scripts/Makefile.arch
@@ -38,7 +38,7 @@ ifeq ($(ARCH),loongarch64)
SRCARCH := loongarch
endif
-LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+LP64 := $(shell if command -v $(firstword ${CC}) >/dev/null 2>&1; then echo __LP64__ | ${CC} ${CFLAGS} -E -x c -; fi | tail -n 1)
ifeq ($(LP64), 1)
IS_64_BIT := 1
else
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 46a3872b87624a7b..fff453aac187536e 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -98,7 +98,7 @@ else
$(call allow-override,LLVM_STRIP,llvm-strip)
endif
-CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
+CC_NO_CLANG := $(shell if command -v $(firstword $(CC)) >/dev/null 2>&1; then $(CC) -dM -E -x c /dev/null; fi | grep -Fq "__clang__"; echo $$?)
# Some tools require bpftool
SYSTEM_BPFTOOL ?= bpftool
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/7] perf build: Add install-build-deps framework to install devel packages
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed Arnaldo Carvalho de Melo
@ 2026-08-10 15:44 ` Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 3/7] perf build: install-build-deps: add Fedora devel package mapping Arnaldo Carvalho de Melo
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Installing the development packages needed to build perf is
error-prone on a fresh distro install: the packages are scattered
across the feature tests in tools/build/feature/, each checking for a
specific header/library, and the build only tells you what's missing
after failing a check.
This series adds a 'make -C tools/perf install-build-deps' target to
install them in one go, deriving the package list from the feature tests
themselves.
This commit adds the framework, on top of the parse-time compiler
probe guard from the previous commit:
- the install-build-deps target in tools/perf/Makefile.perf, exempted
from the config/feature detection pass, since it must run in a fresh
container, before gcc or pkg-config exist, to install them;
- the install-build-deps.sh script, with --list, --dry-run and
--distro options, distro detection (Fedora and Ubuntu), dnf and
apt-get drivers, root/passwordless-sudo handling, and the base
packages common to any build: compiler, C++ compiler, make, flex,
bison, libc and kernel headers, python3-setuptools (needed by the
python binding) and rust (checked by the rust feature test);
- the parse-time probes for optional tools, like pkg-config, use
'command -v' with stderr discarded, so a fresh container without
them gets no 'which: no pkg-config in (...)' spew from make;
- the script does not rely on 'set -e': its error paths are explicit,
since the make target runs it via $(SHELL), where a shebang option
would be ignored anyway, so direct and make-driven runs behave the
same.
The per-feature mappings, from each feature test to the devel package
providing its headers on a given distro, are added by the follow-up
patches, one per distro, together with the validation of each mapping
in a fresh container: until then the target installs just the base
toolchain.
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Makefile.perf | 20 ++-
tools/perf/scripts/install-build-deps.sh | 173 +++++++++++++++++++++++
2 files changed, 190 insertions(+), 3 deletions(-)
create mode 100755 tools/perf/scripts/install-build-deps.sh
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index acc6309a84a1eeb1..49a58d714e42dded 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -177,7 +177,7 @@ LD += $(EXTRA_LDFLAGS)
# Some distros provide the command $(CROSS_COMPILE)pkg-config for
# searching packges installed with Multiarch. Use it for cross
# compilation if it is existed.
-ifneq (, $(shell which $(CROSS_COMPILE)pkg-config))
+ifneq (, $(shell command -v $(CROSS_COMPILE)pkg-config 2>/dev/null))
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
else
PKG_CONFIG ?= pkg-config
@@ -214,7 +214,12 @@ AWK = awk
# non-config cases
config := 1
-NON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help
+# install-build-deps runs the install-build-deps.sh script, which
+# derives the package list from the feature test sources in
+# tools/build/feature/, so it needs neither the fixdep build nor a
+# config/feature detection pass: in a fresh container without gcc or
+# pkg-config those would fail before the script could install them.
+NON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help install-build-deps
ifdef MAKECMDGOALS
ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
@@ -748,6 +753,7 @@ help:
@echo ' HINT: use "prefix" or "DESTDIR" to install to a particular'
@echo ' path like "make prefix=/usr/local install install-doc"'
@echo ' install - install compiled binaries'
+ @echo ' install-build-deps - install the development packages needed to build'
@echo ' install-doc - install *all* documentation'
@echo ' install-man - install manpage documentation'
@echo ' install-html - install html documentation'
@@ -892,6 +898,14 @@ install-bin: install-tools install-tests
install: install-bin try-install-man
+# Install the development packages needed to build perf, derived from the
+# feature tests in tools/build/feature/. This first installs just the
+# base toolchain; per-distro package mappings are added by the follow-up
+# commits. INSTALL_BUILD_DEPS_ARGS, when set, is passed to the script, so
+# extra options like --list, --dry-run or --distro can be given from make.
+install-build-deps:
+ $(Q)$(SHELL) $(srctree)/tools/perf/scripts/install-build-deps.sh $(INSTALL_BUILD_DEPS_ARGS)
+
install-python_ext:
$(PYTHON_WORD) util/setup.py $(python_setup_quiet) install --root='/$(DESTDIR_SQ)'
@@ -960,7 +974,7 @@ endif
FORCE:
-.PHONY: all install clean config-clean strip install-gtk
+.PHONY: all install install-build-deps clean config-clean strip install-gtk
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare bpf-skel-prepare
.PHONY: python_perf_target
diff --git a/tools/perf/scripts/install-build-deps.sh b/tools/perf/scripts/install-build-deps.sh
new file mode 100755
index 0000000000000000..6b9a1142f32acf03
--- /dev/null
+++ b/tools/perf/scripts/install-build-deps.sh
@@ -0,0 +1,173 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# No 'set -e': the script uses explicit checks for its error paths, and
+# is also run via '$(SHELL) .../install-build-deps.sh' from the make
+# target in tools/perf/Makefile.perf, where a shebang option would be
+# ignored anyway, so direct and make-driven runs behave the same.
+#
+# Install the development packages needed to build tools/perf.
+#
+# The package set is derived from the feature tests in tools/build/feature/:
+# each feature test that perf may compile is mapped to the devel package
+# that provides the headers/libraries it checks, so that a subsequent
+# 'make -C tools/perf' build enables the corresponding perf features.
+#
+# This initial version installs the base toolchain needed by any build;
+# the per-feature package mapping is added, per supported distro, by the
+# follow-up patches in this series, which also validate each mapping in a
+# fresh container, so the host system is not modified.
+#
+# Usage: install-build-deps.sh [OPTIONS]
+#
+# Options:
+# --list list the packages that would be installed, then exit
+# --dry-run show the install command that would be run, without
+# running it
+# --distro ID force a distro: fedora, ubuntu (default: auto-detect)
+# -h, --help print this help message
+#
+# Requires root (or passwordless sudo) to actually install packages.
+
+set -u
+
+DISTRO=""
+
+help() {
+ cat <<EOF
+Usage: $(basename "$0") [--list] [--dry-run] [--distro ID] [-h|--help]
+
+Install the development packages needed to build tools/perf.
+
+Options:
+ --list list the packages that would be installed, then exit
+ --dry-run show the install command that would be run, without running it
+ --distro ID force a distro: fedora, ubuntu
+ -h, --help print this help message
+EOF
+ exit 0
+}
+
+# ---------------------------------------------------------------------
+# Distro detection. The install command that follows only differs in
+# the package manager, which here is keyed off the distro ID; the
+# per-feature package mapping is added per distro by the follow-up
+# patches.
+# ---------------------------------------------------------------------
+detect_distro() {
+ if [ -n "$DISTRO" ]; then
+ echo "$DISTRO"
+ return
+ fi
+ local id
+ id=$( . /etc/os-release && echo "${ID:-}" )
+ case "$id" in
+ fedora) echo "fedora" ;;
+ ubuntu) echo "ubuntu" ;;
+ # RHEL and its derivatives share most Fedora package names, but the
+ # mapping is only validated on Fedora, so don't auto-detect them.
+ rhel|centos|rocky|alma|ol) echo "" ;;
+ *) echo "" ;;
+ esac
+}
+
+# Base packages needed by any perf build, regardless of feature tests:
+# compiler, libc headers, flex/bison for the parser, kernel headers
+# for UAPI headers with no in-tree copy, e.g. <linux/capability.h>, and
+# gcc-c++ (dnf) / g++ (apt) for the C++-based feature tests
+# (cxa-demangle, llvm, llvm-perf), compiled with $(CXX), and
+# pulls in libstdc++-devel / libstdc++-*-dev.
+# python3-setuptools is needed to build the python binding (perf's
+# util/setup.py uses it; without it binding is skipped with a warning).
+# rust is not a header-based feature test: test-rust.bin just checks
+# "$(RUSTC) --version" (tools/build/feature/Makefile), so it is mapped
+# here like the other toolchain packages.
+fedora_base_pkgs="gcc gcc-c++ make flex bison glibc-devel kernel-headers python3-setuptools rust"
+debian_base_pkgs="gcc g++ make flex bison libc6-dev linux-libc-dev python3-setuptools rustc"
+
+# ---------------------------------------------------------------------
+# Assemble the unique package list. While the per-feature mapping is
+# being added per distro, only the base toolchain above is installed.
+# ---------------------------------------------------------------------
+package_set() {
+ local distro="$1" srcdir="$2"
+ case "$distro" in
+ fedora) echo "$fedora_base_pkgs" ;;
+ ubuntu) echo "$debian_base_pkgs" ;;
+ esac
+}
+
+# ---------------------------------------------------------------------
+# The install command proper for each supported package manager, plus
+# the command massaged for --dry-run.
+# ---------------------------------------------------------------------
+install_cmd() {
+ local distro="$1"; shift
+ case "$distro" in
+ fedora)
+ echo "dnf install -y $*"
+ ;;
+ ubuntu)
+ # a fresh container has no package index, so update first.
+ echo "apt-get update && apt-get install -y $*"
+ ;;
+ esac
+}
+
+main() {
+ local action="install"
+ local srcdir distro pkgs pkg cmd
+
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ --list) action="list"; shift ;;
+ --dry-run) action="dry-run"; shift ;;
+ --distro)
+ [ $# -ge 2 ] || {
+ echo "error: --distro requires an argument (fedora, rhel, ubuntu, debian)" >&2
+ exit 1
+ }
+ DISTRO="$2"; shift 2 ;;
+ -h|--help) help ;;
+ *) echo "error: unknown argument: $1" >&2; exit 1 ;;
+ esac
+ done
+
+ srcdir=$(cd "$(dirname "$0")/../../.." && pwd)
+ distro=$(detect_distro)
+ case "$distro" in
+ fedora|ubuntu) ;;
+ *)
+ echo "error: unsupported distro (got '$distro'); the package mapping is not validated on other distros." >&2
+ exit 1
+ ;;
+ esac
+
+ pkgs=$(package_set "$distro" "$srcdir")
+
+ case "$action" in
+ list)
+ echo "$pkgs" | tr ' ' '\n' | grep -v '^$' | sort
+ exit 0
+ ;;
+ dry-run)
+ install_cmd "$distro" $pkgs
+ exit 0
+ ;;
+ esac
+
+ echo "The following packages will be installed to enable perf features:"
+ echo "$pkgs" | tr ' ' '\n' | grep -v '^$' | sort | sed 's/^/ /'
+ echo
+ cmd=$(install_cmd "$distro" $pkgs)
+ if [ "$(id -u)" -eq 0 ]; then
+ sh -c "$cmd"
+ else
+ sudo sh -c "$cmd"
+ fi || {
+ echo "error: the install command failed, see the output above" >&2
+ exit 1
+ }
+}
+
+main "$@"
\ No newline at end of file
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/7] perf build: install-build-deps: add Fedora devel package mapping
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 2/7] perf build: Add install-build-deps framework to install devel packages Arnaldo Carvalho de Melo
@ 2026-08-10 15:44 ` Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 4/7] perf build: install-build-deps: add Ubuntu " Arnaldo Carvalho de Melo
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
With the framework from the previous commit in place, this patch adds
the per-feature mapping for Fedora/dnf: for each feature test in
tools/build/feature/, the Fedora devel package providing the headers
or library the test compiles against, kept explicit in the script
next to the test that requires it.
Special cases:
- test-libdebuginfod.c includes <elfutils/debuginfod.h>, provided
by elfutils-debuginfod-client-devel, not elfutils-devel;
- the cxa-demangle test links against libstdc++'s builtin demangler,
pulling in libstdc++-devel;
- the BPF-oriented features (bpf, clang-bpf-co-re) get their headers
from the base packages and clang-devel.
Tests with no Fedora equivalent (bionic, compile-32, compile-x32) and
the opt-in/deprecated ones (libbfd disassembler family, GTK2, LIBPERL,
LIBUNWIND, CoreSight, and the tests perf itself doesn't check, like
libcpupower) are deliberately not mapped.
Validated on a fresh Fedora 44 toolbx container, so the host OS is not
modified:
toolbox create fedora:44
toolbox enter fedora:44
make -C tools/perf install-build-deps
which installed the 29 mapped packages; a subsequent clean O= build
enabled every feature with an external dependency Fedora provides
(feature tests went to 1, except bionic/compile-32/compile-x32, which
have no Fedora equivalent, and the libunwind-debug-frame tests, whose
symbols Fedora's libunwind does not export), linking libpfm,
libbabeltrace2-ctf-writer, libcapstone, libtraceevent, libslang and
libnuma, as well as building the BPF skeletons requiring clang/llvm.
Re-running the target is a no-op (dnf reports "Nothing to do").
RHEL and its derivatives share most Fedora package names but are
refused by the script until this mapping is validated on them.
Example of its --list option:
$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Fedora Linux 44 (Toolbx Container Image)"
$ tools/perf/scripts/install-build-deps.sh --list
bison
capstone-devel
clang-devel
elfutils-debuginfod-client-devel
elfutils-devel
elfutils-libelf-devel
flex
gcc
gcc-c++
glibc-devel
java-latest-openjdk-devel
kernel-headers
libbabeltrace2-devel
libbpf-devel
libpfm-devel
libstdc++-devel
libtraceevent-devel
libzstd-devel
llvm-devel
make
numactl-devel
openssl-devel
python3-devel
python3-setuptools
rust
slang-devel
systemtap-sdt-devel
xz-devel
zlib-devel
$
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/scripts/install-build-deps.sh | 179 ++++++++++++++++++++---
1 file changed, 156 insertions(+), 23 deletions(-)
diff --git a/tools/perf/scripts/install-build-deps.sh b/tools/perf/scripts/install-build-deps.sh
index 6b9a1142f32acf03..73caf2934d961d57 100755
--- a/tools/perf/scripts/install-build-deps.sh
+++ b/tools/perf/scripts/install-build-deps.sh
@@ -13,10 +13,13 @@
# that provides the headers/libraries it checks, so that a subsequent
# 'make -C tools/perf' build enables the corresponding perf features.
#
-# This initial version installs the base toolchain needed by any build;
-# the per-feature package mapping is added, per supported distro, by the
-# follow-up patches in this series, which also validate each mapping in a
-# fresh container, so the host system is not modified.
+# Supported distros, each mapping validated in a fresh container, so the
+# host system is not modified:
+#
+# - Fedora, on dnf, validated on Fedora 44, in a toolbx container:
+#
+# toolbox create fedora:44
+# toolbox enter fedora:44
#
# Usage: install-build-deps.sh [OPTIONS]
#
@@ -24,7 +27,7 @@
# --list list the packages that would be installed, then exit
# --dry-run show the install command that would be run, without
# running it
-# --distro ID force a distro: fedora, ubuntu (default: auto-detect)
+# --distro ID force a distro: fedora (default: auto-detect)
# -h, --help print this help message
#
# Requires root (or passwordless sudo) to actually install packages.
@@ -39,20 +42,121 @@ Usage: $(basename "$0") [--list] [--dry-run] [--distro ID] [-h|--help]
Install the development packages needed to build tools/perf.
+The package set is derived from the feature tests in tools/build/feature/,
+mapping each one with an external dependency to the devel package providing
+it, so the corresponding feature gets enabled on a build.
+
Options:
--list list the packages that would be installed, then exit
--dry-run show the install command that would be run, without running it
- --distro ID force a distro: fedora, ubuntu
+ --distro ID force a distro: fedora
-h, --help print this help message
+
+Distro supported: Fedora (dnf), validated on a fresh Fedora 44 toolbx
+container.
EOF
exit 0
}
# ---------------------------------------------------------------------
-# Distro detection. The install command that follows only differs in
-# the package manager, which here is keyed off the distro ID; the
-# per-feature package mapping is added per distro by the follow-up
-# patches.
+# Return the Fedora package(s) providing the devel requirements of a
+# feature test in tools/build/feature/. Multiple packages are separated
+# by spaces; an empty result means the test has no external devel
+# dependency (pure toolchain/glibc, or no equivalent Fedora package).
+#
+# The mapping was built by checking, for each feature test, which Fedora
+# devel package provides the headers the test compiles against.
+# ---------------------------------------------------------------------
+fedora_pkg_for() {
+ local feat="$1"
+ case "$feat" in
+ libelf|libelf-getphdrnum|libelf-gelf_getnote|libelf-getshdrstrndx)
+ echo "elfutils-libelf-devel"
+ ;;
+ libelf-zstd)
+ echo "elfutils-libelf-devel libzstd-devel"
+ ;;
+ libdw)
+ echo "elfutils-devel"
+ ;;
+ # test-libdebuginfod.c includes <elfutils/debuginfod.h>, which is
+ # provided by elfutils-debuginfod-client-devel, not elfutils-devel.
+ libdebuginfod)
+ echo "elfutils-debuginfod-client-devel"
+ ;;
+ libnuma|numa_num_possible_cpus)
+ echo "numactl-devel"
+ ;;
+ libzstd)
+ echo "libzstd-devel"
+ ;;
+ zlib)
+ echo "zlib-devel"
+ ;;
+ lzma)
+ echo "xz-devel"
+ ;;
+ libslang)
+ echo "slang-devel"
+ ;;
+ libcapstone)
+ echo "capstone-devel"
+ ;;
+ libpython)
+ echo "python3-devel"
+ ;;
+ libtraceevent)
+ echo "libtraceevent-devel"
+ ;;
+ cxa-demangle)
+ echo "libstdc++-devel"
+ ;;
+ libbpf)
+ echo "libbpf-devel"
+ ;;
+ babeltrace2-ctf-writer)
+ echo "libbabeltrace2-devel"
+ ;;
+ libopenssl)
+ echo "openssl-devel"
+ ;;
+ libpfm4)
+ echo "libpfm-devel"
+ ;;
+ sdt)
+ echo "systemtap-sdt-devel"
+ ;;
+ clang-bpf-co-re)
+ echo "clang-devel"
+ ;;
+ llvm|llvm-perf)
+ echo "llvm-devel"
+ ;;
+ jvmti|jvmti-cmlr)
+ echo "java-latest-openjdk-devel"
+ ;;
+ esac
+ # Pure toolchain/libc features (backtrace, eventfd, fortify-source,
+ # gettid, glibc, hello, reallocarray, pthread-*, stackprotector-all,
+ # timerfd, scandirat, sched_getcpu, setns, file-handle,
+ # bionic...) need no external package: their
+ # requirements are covered by the base packages below. Features that
+ # perf's own build does not check (libcap, libcheck, libcpupower,
+ # libtracefs, whose feature tests exist for rtla/bpftool/rv) and the
+ # opt-in features, which a default build does not enable: the libbfd
+ # disassembler family (libbfd, libbfd-threadsafe, libbfd-liberty,
+ # disassembler-*, cplus-demangle), only linked on BUILD_NONDISTRO
+ # builds and deprecated in favor of capstone, GTK2, LIBPERL and
+ # LIBUNWIND support (ifdef GTK2 / ifdef LIBPERL / LIBUNWIND=1),
+ # and CoreSight (ifdef CORESIGHT), are deliberately not mapped.
+ # libaio is not mapped either: its
+ # test uses the POSIX AIO API (aio.h, aio_*, -lrt), provided by
+ # glibc headers (pulled in by the glibc-devel base package), not
+ # the native libaio.h/io_submit API that libaio-devel provides.
+}
+
+# ---------------------------------------------------------------------
+# Distro detection
# ---------------------------------------------------------------------
detect_distro() {
if [ -n "$DISTRO" ]; then
@@ -71,30 +175,58 @@ detect_distro() {
esac
}
-# Base packages needed by any perf build, regardless of feature tests:
+# ---------------------------------------------------------------------
+# Feature test enumeration: mirror of the tests checked during a build,
+# from the actual test-*.c / test-*.cpp sources in tools/build/feature/.
+# ---------------------------------------------------------------------
+feature_tests() {
+ local srcdir="$1"
+ local f
+ for f in "$srcdir"/tools/build/feature/test-*.c "$srcdir"/tools/build/feature/test-*.cpp; do
+ [ -e "$f" ] || continue
+ basename "$f" | sed -e 's/^test-//' -e 's/\.\(c\|cpp\)$//'
+ done
+}
+
+# Base packages needed by any build, regardless of feature tests:
# compiler, libc headers, flex/bison for the parser, kernel headers
# for UAPI headers with no in-tree copy, e.g. <linux/capability.h>, and
-# gcc-c++ (dnf) / g++ (apt) for the C++-based feature tests
-# (cxa-demangle, llvm, llvm-perf), compiled with $(CXX), and
-# pulls in libstdc++-devel / libstdc++-*-dev.
-# python3-setuptools is needed to build the python binding (perf's
-# util/setup.py uses it; without it binding is skipped with a warning).
-# rust is not a header-based feature test: test-rust.bin just checks
-# "$(RUSTC) --version" (tools/build/feature/Makefile), so it is mapped
-# here like the other toolchain packages.
+# gcc-c++ is needed by the C++-based feature tests (cxa-demangle, llvm,
+# llvm-perf), which are compiled with $(CXX), pulling in
+# libstdc++-devel. python3-setuptools is needed to build the python
+# (perf's util/setup.py uses it); rust is checked by the rust feature
+# test (test-rust.bin just runs "$(RUSTC) --version").
+
fedora_base_pkgs="gcc gcc-c++ make flex bison glibc-devel kernel-headers python3-setuptools rust"
debian_base_pkgs="gcc g++ make flex bison libc6-dev linux-libc-dev python3-setuptools rustc"
# ---------------------------------------------------------------------
-# Assemble the unique package list. While the per-feature mapping is
-# being added per distro, only the base toolchain above is installed.
+# Assemble the unique package list: the base toolchain plus, for each
+# feature test the distro's package mapping knows about, its package(s).
+# Installing an already-present package is a no-op for both dnf and
+# apt-get, making this idempotent.
# ---------------------------------------------------------------------
package_set() {
local distro="$1" srcdir="$2"
+ local feat pkg pkgs
+
case "$distro" in
- fedora) echo "$fedora_base_pkgs" ;;
- ubuntu) echo "$debian_base_pkgs" ;;
+ fedora) pkgs="$fedora_base_pkgs" ;;
+ ubuntu) pkgs="$debian_base_pkgs" ;;
esac
+
+ if [ "$distro" = "fedora" ]; then
+ for feat in $(feature_tests "$srcdir"); do
+ pkg=$(fedora_pkg_for "$feat")
+ for pkg in $pkg; do
+ case " $pkgs " in
+ *" $pkg "*) ;;
+ *) pkgs="$pkgs $pkg" ;;
+ esac
+ done
+ done
+ fi
+ echo "$pkgs"
}
# ---------------------------------------------------------------------
@@ -139,6 +271,7 @@ main() {
fedora|ubuntu) ;;
*)
echo "error: unsupported distro (got '$distro'); the package mapping is not validated on other distros." >&2
+ echo "Supported and validated: Fedora 44 (fresh toolbx container)." >&2
exit 1
;;
esac
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/7] perf build: install-build-deps: add Ubuntu devel package mapping
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2026-08-10 15:44 ` [PATCH 3/7] perf build: install-build-deps: add Fedora devel package mapping Arnaldo Carvalho de Melo
@ 2026-08-10 15:44 ` Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 5/7] perf build: install-build-deps: add Debian " Arnaldo Carvalho de Melo
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
With the framework and Fedora mapping in place, this patch adds the
Ubuntu (apt) mapping: same feature-to-package correspondence as the
Fedora one, adapted to Debian packaging conventions (libfoo-dev), on
a per-distro dispatch so future distros can pick their own mapping or
reuse one of these (Debian shares the Ubuntu mapping).
Notable differences from Fedora:
- base set: g++ (ships libstdc++-*-dev, covering cxa-demangle),
pkg-config (installed implicitly by Fedora's default toolchain
metapackage, but not by Ubuntu's), linux-libc-dev and libc6-dev
instead of kernel-headers and glibc-devel, and rustc for rust;
- cxa-demangle maps to nothing, covered by g++'s libstdc++;
- the clang-bpf-co-re test needs the clang compiler binary (Fedora's
clang-devel provides it transitively), and llvm-dev, which also
brings llvm-config (deps on the llvm package), used by the
llvm/llvm-perf tests;
- libslang maps to libslang2-dev and jvmti to default-jdk;
- the install command runs 'apt-get update' first since a fresh
container has no package indexes, unlike dnf.
Validated on a fresh Ubuntu 26.04 distrobox container so the host
system is not modified:
distrobox create --image ubuntu:26.04
distrobox enter ubuntu-26-04
make -C tools/perf install-build-deps
which installed the 29 mapped packages; a subsequent clean O= build
enabled every feature with an external dependency Ubuntu has a
package for: perf's build-options then showed all of them [on],
including the BPF skeletons requiring clang/llvm, the python binding
and the C++-based features, with only the deliberately unmapped
(deprecated) libbfd family, libperl and libunwind [OFF], and the
build linked libpfm, libbabeltrace2-ctf-writer, libcapstone,
libtraceevent, libslang, libnuma, libdw and libssl. Re-running the
target is a no-op (apt-get reports "0 newly installed").
Debian (trixie) is the next planned distro: it shares this Ubuntu
mapping, so enabling it reuses it as-is, once it gets validated on a
Debian release.
Example of its --list:
$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Fedora Linux 44 (Toolbx Container Image)"
$ tools/perf/scripts/install-build-deps.sh --list --distro ubuntu
bison
clang
default-jdk
flex
g++
gcc
libbabeltrace2-dev
libbpf-dev
libc6-dev
libcapstone-dev
libdebuginfod-dev
libdw-dev
libelf-dev
liblzma-dev
libnuma-dev
libpfm4-dev
libslang2-dev
libssl-dev
libtraceevent-dev
libzstd-dev
linux-libc-dev
llvm-dev
make
pkg-config
python3-dev
python3-setuptools
rustc
systemtap-sdt-dev
zlib1g-dev
$
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Makefile.perf | 6 +-
tools/perf/scripts/install-build-deps.sh | 178 ++++++++++++++++++-----
2 files changed, 145 insertions(+), 39 deletions(-)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 49a58d714e42dded..e1fc75b4621faed5 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -899,9 +899,9 @@ install-bin: install-tools install-tests
install: install-bin try-install-man
# Install the development packages needed to build perf, derived from the
-# feature tests in tools/build/feature/. This first installs just the
-# base toolchain; per-distro package mappings are added by the follow-up
-# commits. INSTALL_BUILD_DEPS_ARGS, when set, is passed to the script, so
+# feature tests in tools/build/feature/. Currently supported: the Fedora
+# (dnf) and Ubuntu (apt) package mappings, see the script.
+# INSTALL_BUILD_DEPS_ARGS, when set, is passed to the script, so
# extra options like --list, --dry-run or --distro can be given from make.
install-build-deps:
$(Q)$(SHELL) $(srctree)/tools/perf/scripts/install-build-deps.sh $(INSTALL_BUILD_DEPS_ARGS)
diff --git a/tools/perf/scripts/install-build-deps.sh b/tools/perf/scripts/install-build-deps.sh
index 73caf2934d961d57..d725621bd7d70e7f 100755
--- a/tools/perf/scripts/install-build-deps.sh
+++ b/tools/perf/scripts/install-build-deps.sh
@@ -13,21 +13,33 @@
# that provides the headers/libraries it checks, so that a subsequent
# 'make -C tools/perf' build enables the corresponding perf features.
#
-# Supported distros, each mapping validated in a fresh container, so the
-# host system is not modified:
+# Currently supported distros, each validated in a fresh container:
#
# - Fedora, on dnf, validated on Fedora 44, in a toolbx container:
#
# toolbox create fedora:44
# toolbox enter fedora:44
#
+# - Ubuntu, on apt-get, validated on Ubuntu 26.04, in a distrobox
+# container:
+#
+# distrobox create --image ubuntu:26.04
+# distrobox enter ubuntu-26-04
+#
+# Running inside a container keeps the host system unmodified.
+#
+# Debian, which shares the Ubuntu package mapping, is the next planned
+# distro to be enabled once that mapping is validated on a Debian
+# release (trixie), as is RHEL support, once its (largely similar to
+# Fedora) package mapping is validated there.
+#
# Usage: install-build-deps.sh [OPTIONS]
#
# Options:
# --list list the packages that would be installed, then exit
# --dry-run show the install command that would be run, without
# running it
-# --distro ID force a distro: fedora (default: auto-detect)
+# --distro ID force a distro: fedora, ubuntu (default: auto-detect)
# -h, --help print this help message
#
# Requires root (or passwordless sudo) to actually install packages.
@@ -49,11 +61,12 @@ it, so the corresponding feature gets enabled on a build.
Options:
--list list the packages that would be installed, then exit
--dry-run show the install command that would be run, without running it
- --distro ID force a distro: fedora
+ --distro ID force a distro: fedora, ubuntu
-h, --help print this help message
-Distro supported: Fedora (dnf), validated on a fresh Fedora 44 toolbx
-container.
+Distros supported: Fedora (dnf), validated in a toolbx container on
+Fedora 44, and Ubuntu (apt-get), validated in a distrobox container on
+Ubuntu 26.04.
EOF
exit 0
}
@@ -151,10 +164,110 @@ fedora_pkg_for() {
# and CoreSight (ifdef CORESIGHT), are deliberately not mapped.
# libaio is not mapped either: its
# test uses the POSIX AIO API (aio.h, aio_*, -lrt), provided by
- # glibc headers (pulled in by the glibc-devel base package), not
- # the native libaio.h/io_submit API that libaio-devel provides.
+ # glibc headers (pulled in by the libc headers package) in the
+ # base set, not the native libaio.h/io_submit API that
+ # libaio-devel provides.
}
+# ---------------------------------------------------------------------
+# Return the Debian/Ubuntu package(s) providing the devel requirements
+# of a feature test in tools/build/feature/. This mapping is shared by
+# Debian and Ubuntu, whose package names for these devel packages match,
+# and is validated on Ubuntu 26.04; Debian (trixie) will be enabled
+# once the same mapping is validated on it.
+# ---------------------------------------------------------------------
+debian_pkg_for() {
+ local feat="$1"
+ case "$feat" in
+ libelf|libelf-getphdrnum|libelf-gelf_getnote|libelf-getshdrstrndx)
+ echo "libelf-dev"
+ ;;
+ libelf-zstd)
+ echo "libelf-dev libzstd-dev"
+ ;;
+ libdw)
+ echo "libdw-dev"
+ ;;
+ libdebuginfod)
+ echo "libdebuginfod-dev"
+ ;;
+ libnuma|numa_num_possible_cpus)
+ echo "libnuma-dev"
+ ;;
+ libzstd)
+ echo "libzstd-dev"
+ ;;
+ zlib)
+ echo "zlib1g-dev"
+ ;;
+ lzma)
+ echo "liblzma-dev"
+ ;;
+ libslang)
+ echo "libslang2-dev"
+ ;;
+ libcapstone)
+ echo "libcapstone-dev"
+ ;;
+ libpython)
+ echo "python3-dev"
+ ;;
+ libtraceevent)
+ echo "libtraceevent-dev"
+ ;;
+ # The cxa-demangle feature test links against libstdc++ builtin
+ # demangling, so on Debian-derived distros it is covered by the
+ # g++ base package below, which pulls in libstdc++-*-dev.
+ cxa-demangle)
+ ;;
+ libbpf)
+ echo "libbpf-dev"
+ ;;
+ babeltrace2-ctf-writer)
+ echo "libbabeltrace2-dev"
+ ;;
+ libopenssl)
+ echo "libssl-dev"
+ ;;
+ libpfm4)
+ echo "libpfm4-dev"
+ ;;
+ sdt)
+ echo "systemtap-sdt-dev"
+ ;;
+ # test-clang-bpf-co-re.c invokes the clang binary (not libclang-cpp),
+ # so clang suffices; llvm-dev brings llvm-config, needed by the
+ # llvm/llvm-perf tests below.
+ clang-bpf-co-re)
+ echo "clang llvm-dev"
+ ;;
+ llvm|llvm-perf)
+ echo "llvm-dev"
+ ;;
+ jvmti|jvmti-cmlr)
+ echo "default-jdk"
+ ;;
+ esac
+ # Same rationale as in fedora_pkg_for() above for unmapped tests.
+}
+
+# Base packages needed by any perf build, regardless of feature tests:
+# compiler, libc headers, flex/bison for the parser, kernel headers
+# for UAPI headers with no in-tree copy, e.g. <linux/capability.h>, and
+# gcc-c++ (dnf) / g++ (apt) is needed by the C++-based feature tests
+# (cxa-demangle, llvm, llvm-perf), compiled with $(CXX), and
+# pulls in libstdc++-devel / libstdc++-*-dev.
+# python3-setuptools is needed to build the python binding (perf's
+# util/setup.py uses it; without it binding is skipped with a warning).
+# rust is not a header-based feature test: test-rust.bin just checks
+# "$(RUSTC) --version" (tools/build/feature/Makefile), so it is mapped
+# here like the other toolchain packages.
+fedora_base_pkgs="gcc gcc-c++ make flex bison glibc-devel kernel-headers python3-setuptools rust"
+# pkg-config mirrors the pkgconf-pkg-config package that Fedora
+# installs by default, needed by the babeltrace2 feature test and
+# libopenssl's pkg-config checks.
+debian_base_pkgs="gcc g++ make pkg-config flex bison libc6-dev linux-libc-dev python3-setuptools rustc"
+
# ---------------------------------------------------------------------
# Distro detection
# ---------------------------------------------------------------------
@@ -168,6 +281,9 @@ detect_distro() {
case "$id" in
fedora) echo "fedora" ;;
ubuntu) echo "ubuntu" ;;
+ # Debian shares the Ubuntu package mapping, but it is only validated
+ # on Ubuntu so far, so don't auto-detect it yet.
+ debian) echo "" ;;
# RHEL and its derivatives share most Fedora package names, but the
# mapping is only validated on Fedora, so don't auto-detect them.
rhel|centos|rocky|alma|ol) echo "" ;;
@@ -188,44 +304,34 @@ feature_tests() {
done
}
-# Base packages needed by any build, regardless of feature tests:
-# compiler, libc headers, flex/bison for the parser, kernel headers
-# for UAPI headers with no in-tree copy, e.g. <linux/capability.h>, and
-# gcc-c++ is needed by the C++-based feature tests (cxa-demangle, llvm,
-# llvm-perf), which are compiled with $(CXX), pulling in
-# libstdc++-devel. python3-setuptools is needed to build the python
-# (perf's util/setup.py uses it); rust is checked by the rust feature
-# test (test-rust.bin just runs "$(RUSTC) --version").
-
-fedora_base_pkgs="gcc gcc-c++ make flex bison glibc-devel kernel-headers python3-setuptools rust"
-debian_base_pkgs="gcc g++ make flex bison libc6-dev linux-libc-dev python3-setuptools rustc"
-
# ---------------------------------------------------------------------
-# Assemble the unique package list: the base toolchain plus, for each
-# feature test the distro's package mapping knows about, its package(s).
-# Installing an already-present package is a no-op for both dnf and
-# apt-get, making this idempotent.
+# Assemble the unique package list. Since the full feature set is mapped
+# unconditionally, this installs the complete devel environment; installing
+# an already-present package is a no-op for both dnf and apt-get, making
+# this idempotent.
# ---------------------------------------------------------------------
package_set() {
local distro="$1" srcdir="$2"
local feat pkg pkgs
-
case "$distro" in
fedora) pkgs="$fedora_base_pkgs" ;;
ubuntu) pkgs="$debian_base_pkgs" ;;
esac
- if [ "$distro" = "fedora" ]; then
- for feat in $(feature_tests "$srcdir"); do
+ for feat in $(feature_tests "$srcdir"); do
+ if [ "$distro" = "fedora" ]; then
pkg=$(fedora_pkg_for "$feat")
- for pkg in $pkg; do
- case " $pkgs " in
- *" $pkg "*) ;;
- *) pkgs="$pkgs $pkg" ;;
- esac
- done
+ else
+ pkg=$(debian_pkg_for "$feat")
+ fi
+ [ -n "$pkg" ] || continue
+ for pkg in $pkg; do
+ case " $pkgs " in
+ *" $pkg "*) ;;
+ *) pkgs="$pkgs $pkg" ;;
+ esac
done
- fi
+ done
echo "$pkgs"
}
@@ -271,7 +377,7 @@ main() {
fedora|ubuntu) ;;
*)
echo "error: unsupported distro (got '$distro'); the package mapping is not validated on other distros." >&2
- echo "Supported and validated: Fedora 44 (fresh toolbx container)." >&2
+ echo "Supported and validated: Fedora 44 (toolbx container), Ubuntu 26.04 (distrobox container)." >&2
exit 1
;;
esac
@@ -303,4 +409,4 @@ main() {
}
}
-main "$@"
\ No newline at end of file
+main "$@"
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/7] perf build: install-build-deps: add Debian devel package mapping
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
` (3 preceding siblings ...)
2026-08-10 15:44 ` [PATCH 4/7] perf build: install-build-deps: add Ubuntu " Arnaldo Carvalho de Melo
@ 2026-08-10 15:44 ` Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 6/7] perf build: Remove leftover feature tests for removed cxx and clang support Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 7/7] perf build: install-build-deps: add RHEL family devel package mapping Arnaldo Carvalho de Melo
6 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
With the Fedora and Ubuntu mappings in place, this patch adds Debian
support: Debian installs the same devel packages, under the same
names, as the Ubuntu mapping, so it reuses debian_pkg_for() and
debian_base_pkgs as-is, with only auto-detection in detect_distro()
(and the shared apt-get install path) added, keeping the script's
per-distro dispatch ready for distros with their own package names.
Validated on a fresh Debian 13 (trixie) container so the host system
is not modified:
distrobox create --image debian:trixie
distrobox enter debian-trixie
make -C tools/perf install-build-deps
which installed the 29 mapped packages; re-running the target is a
no-op (apt-get reports "0 newly installed"). A subsequent clean build
enabled the same feature set as Ubuntu: 'perf version --build-options'
shows every feature with an external dependency Debian has a package
for [on], including the BPF skeletons compiled with clang/llvm
(libLLVM), the python binding and the C++-based features, with only
the deliberately unmapped libbfd family, libperl, libunwind and the
CoreSight (libopencsd) packages [OFF].
RHEL, whose package mapping is largely similar to Fedora's, is the
remaining planned distro, to be enabled once that mapping is
validated on it.
Example of its --list:
$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Fedora Linux 44 (Toolbx Container Image)"
$ tools/perf/scripts/install-build-deps.sh --list --distro debian
bison
clang
default-jdk
flex
g++
gcc
libbabeltrace2-dev
libbpf-dev
libc6-dev
libcapstone-dev
libdebuginfod-dev
libdw-dev
libelf-dev
liblzma-dev
libnuma-dev
libpfm4-dev
libslang2-dev
libssl-dev
libtraceevent-dev
libzstd-dev
linux-libc-dev
llvm-dev
make
pkg-config
python3-dev
python3-setuptools
rustc
systemtap-sdt-dev
zlib1g-dev
$
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Makefile.perf | 3 +-
tools/perf/scripts/install-build-deps.sh | 37 +++++++++++++-----------
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index e1fc75b4621faed5..29cfd44c427f33ba 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -900,7 +900,8 @@ install: install-bin try-install-man
# Install the development packages needed to build perf, derived from the
# feature tests in tools/build/feature/. Currently supported: the Fedora
-# (dnf) and Ubuntu (apt) package mappings, see the script.
+# (dnf), Ubuntu (apt) and Debian (apt, reusing the Ubuntu mapping)
+# package mappings, see the script.
# INSTALL_BUILD_DEPS_ARGS, when set, is passed to the script, so
# extra options like --list, --dry-run or --distro can be given from make.
install-build-deps:
diff --git a/tools/perf/scripts/install-build-deps.sh b/tools/perf/scripts/install-build-deps.sh
index d725621bd7d70e7f..4a6f4bda49094696 100755
--- a/tools/perf/scripts/install-build-deps.sh
+++ b/tools/perf/scripts/install-build-deps.sh
@@ -26,12 +26,17 @@
# distrobox create --image ubuntu:26.04
# distrobox enter ubuntu-26-04
#
+# - Debian, on apt-get, reusing the Ubuntu mapping, validated on
+# Debian 13 (trixie), in a distrobox container:
+#
+# distrobox create --image debian:trixie
+# distrobox enter debian-trixie
+#
# Running inside a container keeps the host system unmodified.
#
-# Debian, which shares the Ubuntu package mapping, is the next planned
-# distro to be enabled once that mapping is validated on a Debian
-# release (trixie), as is RHEL support, once its (largely similar to
-# Fedora) package mapping is validated there.
+# RHEL support, whose package mapping is largely similar to Fedora's,
+# is the next planned distro, to be enabled once that mapping is
+# validated there.
#
# Usage: install-build-deps.sh [OPTIONS]
#
@@ -39,7 +44,7 @@
# --list list the packages that would be installed, then exit
# --dry-run show the install command that would be run, without
# running it
-# --distro ID force a distro: fedora, ubuntu (default: auto-detect)
+# --distro ID force a distro: fedora, ubuntu, debian (default: auto-detect)
# -h, --help print this help message
#
# Requires root (or passwordless sudo) to actually install packages.
@@ -61,12 +66,13 @@ it, so the corresponding feature gets enabled on a build.
Options:
--list list the packages that would be installed, then exit
--dry-run show the install command that would be run, without running it
- --distro ID force a distro: fedora, ubuntu
+ --distro ID force a distro: fedora, ubuntu, debian
-h, --help print this help message
Distros supported: Fedora (dnf), validated in a toolbx container on
-Fedora 44, and Ubuntu (apt-get), validated in a distrobox container on
-Ubuntu 26.04.
+Fedora 44, Ubuntu (apt-get), validated in a distrobox container on
+Ubuntu 26.04, and Debian (apt-get), reusing the Ubuntu mapping,
+validated in a distrobox container on Debian 13 (trixie).
EOF
exit 0
}
@@ -173,8 +179,7 @@ fedora_pkg_for() {
# Return the Debian/Ubuntu package(s) providing the devel requirements
# of a feature test in tools/build/feature/. This mapping is shared by
# Debian and Ubuntu, whose package names for these devel packages match,
-# and is validated on Ubuntu 26.04; Debian (trixie) will be enabled
-# once the same mapping is validated on it.
+# and is validated on Ubuntu 26.04 and Debian 13 (trixie).
# ---------------------------------------------------------------------
debian_pkg_for() {
local feat="$1"
@@ -281,9 +286,7 @@ detect_distro() {
case "$id" in
fedora) echo "fedora" ;;
ubuntu) echo "ubuntu" ;;
- # Debian shares the Ubuntu package mapping, but it is only validated
- # on Ubuntu so far, so don't auto-detect it yet.
- debian) echo "" ;;
+ debian) echo "debian" ;;
# RHEL and its derivatives share most Fedora package names, but the
# mapping is only validated on Fedora, so don't auto-detect them.
rhel|centos|rocky|alma|ol) echo "" ;;
@@ -315,7 +318,7 @@ package_set() {
local feat pkg pkgs
case "$distro" in
fedora) pkgs="$fedora_base_pkgs" ;;
- ubuntu) pkgs="$debian_base_pkgs" ;;
+ ubuntu|debian) pkgs="$debian_base_pkgs" ;;
esac
for feat in $(feature_tests "$srcdir"); do
@@ -345,7 +348,7 @@ install_cmd() {
fedora)
echo "dnf install -y $*"
;;
- ubuntu)
+ ubuntu|debian)
# a fresh container has no package index, so update first.
echo "apt-get update && apt-get install -y $*"
;;
@@ -374,10 +377,10 @@ main() {
srcdir=$(cd "$(dirname "$0")/../../.." && pwd)
distro=$(detect_distro)
case "$distro" in
- fedora|ubuntu) ;;
+ fedora|ubuntu|debian) ;;
*)
echo "error: unsupported distro (got '$distro'); the package mapping is not validated on other distros." >&2
- echo "Supported and validated: Fedora 44 (toolbx container), Ubuntu 26.04 (distrobox container)." >&2
+ echo "Supported and validated: Fedora 44 (toolbx container), Ubuntu 26.04 and Debian 13 (distrobox containers)." >&2
exit 1
;;
esac
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/7] perf build: Remove leftover feature tests for removed cxx and clang support
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
` (4 preceding siblings ...)
2026-08-10 15:44 ` [PATCH 5/7] perf build: install-build-deps: add Debian " Arnaldo Carvalho de Melo
@ 2026-08-10 15:44 ` Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 7/7] perf build: install-build-deps: add RHEL family devel package mapping Arnaldo Carvalho de Melo
6 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
56b11a2126bf2f42 ("perf bpf: Remove support for embedding clang for
compiling BPF events (-e foo.c)") removed the test-cxx.cpp and
test-clang.cpp sources, but left behind their entries in the feature
test FILES list, the build rules and the cxx and clang entries in
FEATURE_TESTS_EXTRA.
Since the sources no longer exist, those rules would always fail,
making the artificial feature-cxx and feature-clang results to be
perpetually disabled/absent, remove the leftover entries, making the
feature test scripts list match the available sources.
Fixes: 56b11a2126bf2f42 ("perf bpf: Remove support for embedding clang for compiling BPF events (-e foo.c)")
Cc: Ian Rogers <irogers@google.com>
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/build/Makefile.feature | 2 --
tools/build/feature/Makefile | 14 --------------
2 files changed, 16 deletions(-)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index ed1374af31c16838..99eb0ea095375606 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -123,9 +123,7 @@ FEATURE_TESTS_EXTRA := \
libbfd-liberty-z \
libopencsd \
libperl \
- cxx \
llvm \
- clang \
libbpf \
libpfm4 \
libdebuginfod \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 62909a9c799d3338..7d165018116a552f 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -55,7 +55,6 @@ FILES= \
test-bpf.bin \
test-libbpf.bin \
test-sdt.bin \
- test-cxx.bin \
test-gettid.bin \
test-jvmti.bin \
test-jvmti-cmlr.bin \
@@ -63,7 +62,6 @@ FILES= \
test-sched_getcpu.bin \
test-setns.bin \
test-libopencsd.bin \
- test-clang.bin \
test-llvm.bin \
test-llvm-perf.bin \
test-libaio.bin \
@@ -335,9 +333,6 @@ $(OUTPUT)test-libbpf.bin:
$(OUTPUT)test-sdt.bin:
$(BUILD)
-$(OUTPUT)test-cxx.bin:
- $(BUILDXX) -std=gnu++11
-
$(OUTPUT)test-gettid.bin:
$(BUILD)
@@ -363,15 +358,6 @@ $(OUTPUT)test-llvm-perf.bin:
$(shell $(LLVM_CONFIG) --system-libs) \
> $(@:.bin=.make.output) 2>&1
-$(OUTPUT)test-clang.bin:
- $(BUILDXX) -std=gnu++17 \
- -I$(shell $(LLVM_CONFIG) --includedir) \
- -L$(shell $(LLVM_CONFIG) --libdir) \
- -Wl,--start-group -lclang-cpp -Wl,--end-group \
- $(shell $(LLVM_CONFIG) --libs Core option) \
- $(shell $(LLVM_CONFIG) --system-libs) \
- > $(@:.bin=.make.output) 2>&1
-
-include $(OUTPUT)*.d
$(OUTPUT)test-libaio.bin:
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/7] perf build: install-build-deps: add RHEL family devel package mapping
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
` (5 preceding siblings ...)
2026-08-10 15:44 ` [PATCH 6/7] perf build: Remove leftover feature tests for removed cxx and clang support Arnaldo Carvalho de Melo
@ 2026-08-10 15:44 ` Arnaldo Carvalho de Melo
6 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-08-10 15:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo, sashiko-bot, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
With the Fedora mapping in place, this patch extends it to the RHEL
family (RHEL, CentOS Stream, Rocky Linux, AlmaLinux, Oracle Linux),
which shares most Fedora package names and runs dnf (RHEL 8 and
later). The names that differ are handled by probing the enabled
repos:
- zlib.h comes from zlib-ng-compat-devel on the RHEL 10 family,
zlib-devel on RHEL 9 and earlier;
- there is no java-latest-openjdk-devel: the JDK devel package is
versioned per release, java-21-openjdk-devel on the RHEL 10
family, java-17-openjdk-devel on RHEL 9, java-11-openjdk-devel
on RHEL 8;
- libbpf-devel and capstone-devel live in the CRB repo on RHEL and
CentOS Stream 10, in EPEL on RHEL 9 and earlier;
- libbabeltrace2-devel is not packaged on the RHEL 10 family.
Packages not available on the enabled repos are skipped instead of
aborting the dnf transaction, and are listed at the end of the run, with
the repo that provides them pointed out in the header comment and help
text: a distro with CRB/EPEL enabled gets the full set, one without them
still installs what it can.
This also holds for the base set: e.g. 'rust' exists only as the
rust-toolset AppStream module on RHEL 8 and 9, where it is not
installable as a plain package, so it is skipped and noted there instead
of failing the whole dnf transaction.
The base set lists pkgconf-pkg-config instead of pkgconfig: both
families have been on pkgconf since Fedora 26 / RHEL 8, where
'pkgconfig' lives only as a virtual Provides of that subpackage, and
a minimal RHEL-family container may not have it preinstalled.
Validated on a fresh CentOS Stream 10 distrobox container, with the
CRB repo enabled, so the host system is not modified:
distrobox create --image quay.io/centos/centos:stream10
distrobox enter centos-stream10
dnf config-manager --set-enabled crb
make -C tools/perf install-build-deps
which installed the 28 available mapped packages; libbabeltrace2-devel, the
only mapped package with no RHEL 10 package, is reported at the end
of the run.
A subsequent 'make -C tools/perf feature-dump' enabled every feature
with an external dependency the RHEL 10 family provides, including
libbpf and libcapstone from the CRB repo, with only
babeltrace2-ctf-writer left out along with the deliberately unmapped
opt-in features.
Re-running the target is a no-op (dnf reports "Nothing to do"); with the
CRB repo disabled, the skipped packages are instead listed in the
end-of-run note, whose header comment and help text point out which repo
provides them.
Members of the family without dnf (RHEL 7 and earlier, e.g. Oracle
Linux 7, a yum-only distro) are rejected with an explicit error while
the dnf-based members get the full mapping.
Example of its --list:
$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Fedora Linux 44 (Toolbx Container Image)"
$ tools/perf/scripts/install-build-deps.sh --list --distro rhel
bison
capstone-devel
clang-devel
elfutils-debuginfod-client-devel
elfutils-devel
elfutils-libelf-devel
flex
gcc
gcc-c++
glibc-devel
java-latest-openjdk-devel
kernel-headers
libbabeltrace2-devel
libbpf-devel
libpfm-devel
libstdc++-devel
libtraceevent-devel
libzstd-devel
llvm-devel
make
numactl-devel
openssl-devel
pkgconf-pkg-config
python3-devel
python3-setuptools
rust
slang-devel
systemtap-sdt-devel
xz-devel
zlib-ng-compat-devel
$
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/scripts/install-build-deps.sh | 208 ++++++++++++++++++++---
1 file changed, 185 insertions(+), 23 deletions(-)
diff --git a/tools/perf/scripts/install-build-deps.sh b/tools/perf/scripts/install-build-deps.sh
index 4a6f4bda49094696..caf6d8d1e56d15f0 100755
--- a/tools/perf/scripts/install-build-deps.sh
+++ b/tools/perf/scripts/install-build-deps.sh
@@ -32,11 +32,33 @@
# distrobox create --image debian:trixie
# distrobox enter debian-trixie
#
-# Running inside a container keeps the host system unmodified.
+# - RHEL and its variants (RHEL, CentOS Stream, Rocky Linux, AlmaLinux,
+# Oracle Linux), on dnf (RHEL 8 and later), validated on CentOS
+# Stream 10, in a distrobox container:
+#
+# distrobox create --image quay.io/centos/centos:stream10
+# distrobox enter centos-stream10
+#
+# The RHEL family reuses most Fedora package names, with these
+# differences, handled by probing the enabled repos:
#
-# RHEL support, whose package mapping is largely similar to Fedora's,
-# is the next planned distro, to be enabled once that mapping is
-# validated there.
+# - zlib.h comes from zlib-ng-compat-devel on the RHEL 10 family,
+# zlib-devel on RHEL 9 and earlier;
+# - the JDK devel package is versioned, there is no
+# java-latest-openjdk-devel: java-21-openjdk-devel on the RHEL
+# 10 family, java-17-openjdk-devel on RHEL 9, java-11-openjdk-
+# devel on RHEL 8;
+# - libbpf-devel and capstone-devel are in the CRB repo on RHEL
+# and CentOS Stream 10 ('dnf config-manager --set-enabled crb')
+# and in EPEL on RHEL 9 and earlier;
+# - libbabeltrace2-devel is not packaged on the RHEL 10 family.
+#
+# On the RHEL family, packages not available on the enabled repos
+# are skipped and listed at the end of the run, so that a distro
+# with CRB/EPEL enabled gets the full set, and a distro without
+# them still installs what it can.
+#
+# Running inside a container keeps the host system unmodified.
#
# Usage: install-build-deps.sh [OPTIONS]
#
@@ -44,7 +66,8 @@
# --list list the packages that would be installed, then exit
# --dry-run show the install command that would be run, without
# running it
-# --distro ID force a distro: fedora, ubuntu, debian (default: auto-detect)
+# --distro ID force a distro: fedora, rhel, ubuntu, debian
+# (default: auto-detect)
# -h, --help print this help message
#
# Requires root (or passwordless sudo) to actually install packages.
@@ -66,13 +89,19 @@ it, so the corresponding feature gets enabled on a build.
Options:
--list list the packages that would be installed, then exit
--dry-run show the install command that would be run, without running it
- --distro ID force a distro: fedora, ubuntu, debian
+ --distro ID force a distro: fedora, rhel, ubuntu, debian
-h, --help print this help message
Distros supported: Fedora (dnf), validated in a toolbx container on
Fedora 44, Ubuntu (apt-get), validated in a distrobox container on
-Ubuntu 26.04, and Debian (apt-get), reusing the Ubuntu mapping,
-validated in a distrobox container on Debian 13 (trixie).
+Ubuntu 26.04, Debian (apt-get), reusing the Ubuntu mapping, validated
+in a distrobox container on Debian 13 (trixie), and the RHEL family
+(dnf, RHEL 8 and later), validated on CentOS Stream 10 in a distrobox
+container. On the RHEL family, packages not available on the enabled
+repos are skipped and listed at the end; some there, e.g.
+libbpf-devel and capstone-devel, come from the CRB repo on RHEL and
+CentOS Stream 10 ('dnf config-manager --set-enabled crb') and from
+EPEL on RHEL 9 and earlier.
EOF
exit 0
}
@@ -175,6 +204,72 @@ fedora_pkg_for() {
# libaio-devel provides.
}
+# ---------------------------------------------------------------------
+# Check whether the first argument is provided by the enabled repos, or
+# is already installed, returning 0 if so and printing nothing.
+#
+# dnf repoquery exits 0 even when the pattern does not match anything,
+# so availability is judged by the output being non-empty, not by the
+# exit code.
+# ---------------------------------------------------------------------
+pkg_available() {
+ local p out
+ for p in "$@"; do
+ out=$(dnf repoquery --quiet --available "$p" 2>/dev/null)
+ [ -n "$out" ] || out=$(dnf repoquery --quiet --installed "$p" 2>/dev/null)
+ [ -n "$out" ] && return 0
+ done
+ return 1
+}
+
+# ---------------------------------------------------------------------
+# Return the first of its arguments that pkg_available() accepts.
+# ---------------------------------------------------------------------
+pick_available() {
+ local p
+ for p in "$@"; do
+ if pkg_available "$p"; then
+ echo "$p"
+ return 0
+ fi
+ done
+ return 1
+}
+
+# ---------------------------------------------------------------------
+# Return the RHEL-family package(s) providing the devel requirements of
+# a feature test. This family reuses the Fedora mapping, whose names
+# apply to it as well, except for the features whose Fedora package
+# does not exist there, kept in the case below.
+#
+# Whether the resulting package is actually installable is checked in
+# package_set(), as some of these names live in the CRB or EPEL repos,
+# which may not be enabled: on the RHEL 10 family libbpf-devel and
+# capstone-devel come from CRB, and libbabeltrace2-devel is not
+# packaged at all.
+# ---------------------------------------------------------------------
+rhel_pkg_for() {
+ local feat="$1"
+ case "$feat" in
+ zlib)
+ # zlib-ng-compat-devel on the RHEL 10 family, zlib-devel on
+ # RHEL 9 and earlier. If neither is on the enabled repos,
+ # fall back to the first candidate so that package_set()
+ # reports it as missing instead of silently dropping the
+ # feature from the end-of-run note.
+ pick_available zlib-devel zlib-ng-compat-devel || echo "zlib-devel"
+ ;;
+ jvmti|jvmti-cmlr)
+ # No java-latest-openjdk-devel on the RHEL family: the JDK
+ # devel package is versioned per release.
+ pick_available java-latest-openjdk-devel java-21-openjdk-devel java-17-openjdk-devel java-11-openjdk-devel || echo "java-latest-openjdk-devel"
+ ;;
+ *)
+ fedora_pkg_for "$feat"
+ ;;
+ esac
+}
+
# ---------------------------------------------------------------------
# Return the Debian/Ubuntu package(s) providing the devel requirements
# of a feature test in tools/build/feature/. This mapping is shared by
@@ -272,6 +367,11 @@ fedora_base_pkgs="gcc gcc-c++ make flex bison glibc-devel kernel-headers python3
# installs by default, needed by the babeltrace2 feature test and
# libopenssl's pkg-config checks.
debian_base_pkgs="gcc g++ make pkg-config flex bison libc6-dev linux-libc-dev python3-setuptools rustc"
+# pkg-config: like Fedora, on pkgconf since Fedora 26 / RHEL 8, with
+# 'pkgconfig' live only as a virtual Provides of the pkgconf-pkg-config
+# subpackage. List it explicitly because, unlike Fedora, a minimal
+# RHEL-family container may not have it preinstalled.
+rhel_base_pkgs="gcc gcc-c++ make flex bison glibc-devel kernel-headers pkgconf-pkg-config python3-setuptools rust"
# ---------------------------------------------------------------------
# Distro detection
@@ -285,11 +385,12 @@ detect_distro() {
id=$( . /etc/os-release && echo "${ID:-}" )
case "$id" in
fedora) echo "fedora" ;;
+ rhel|centos|rocky|almalinux|ol)
+ # All share the Fedora package names (with the exceptions
+ # handled by rhel_pkg_for()) and dnf.
+ echo "rhel" ;;
ubuntu) echo "ubuntu" ;;
debian) echo "debian" ;;
- # RHEL and its derivatives share most Fedora package names, but the
- # mapping is only validated on Fedora, so don't auto-detect them.
- rhel|centos|rocky|alma|ol) echo "" ;;
*) echo "" ;;
esac
}
@@ -311,33 +412,73 @@ feature_tests() {
# Assemble the unique package list. Since the full feature set is mapped
# unconditionally, this installs the complete devel environment; installing
# an already-present package is a no-op for both dnf and apt-get, making
-# this idempotent.
+# this idempotent. On the RHEL family, packages not available on the
+# enabled repos are skipped and echoed on stderr, reported at the end of
+# the run by the caller (package_set() runs in a subshell, so a variable
+# would not survive it).
# ---------------------------------------------------------------------
package_set() {
local distro="$1" srcdir="$2"
- local feat pkg pkgs
+ local feat pkg pkgs base_pkgs missing_pkgs=""
case "$distro" in
fedora) pkgs="$fedora_base_pkgs" ;;
+ rhel) pkgs="$rhel_base_pkgs" ;;
ubuntu|debian) pkgs="$debian_base_pkgs" ;;
esac
+ # The base set must be checked against the enabled repos as well:
+ # e.g. 'rust' is only shipped as the rust-toolset AppStream module
+ # on RHEL 8 and 9, where dnf would abort the whole transaction
+ # with "No match for argument: rust" instead of skipping it, so
+ # unavailable base packages are skipped and noted like the mapped
+ # ones below.
+ if [ "$distro" = "rhel" ]; then
+ base_pkgs="$pkgs"
+ pkgs=""
+ for pkg in $base_pkgs; do
+ if pkg_available "$pkg"; then
+ pkgs="$pkgs $pkg"
+ else
+ missing_pkgs="$missing_pkgs $pkg"
+ fi
+ done
+ fi
+
for feat in $(feature_tests "$srcdir"); do
- if [ "$distro" = "fedora" ]; then
- pkg=$(fedora_pkg_for "$feat")
- else
- pkg=$(debian_pkg_for "$feat")
- fi
+ case "$distro" in
+ fedora) pkg=$(fedora_pkg_for "$feat") ;;
+ rhel) pkg=$(rhel_pkg_for "$feat") ;;
+ *) pkg=$(debian_pkg_for "$feat") ;;
+ esac
[ -n "$pkg" ] || continue
for pkg in $pkg; do
+ if [ "$distro" = "rhel" ] && ! pkg_available "$pkg"; then
+ missing_pkgs="$missing_pkgs $pkg"
+ continue
+ fi
case " $pkgs " in
*" $pkg "*) ;;
*) pkgs="$pkgs $pkg" ;;
esac
done
done
+ [ -n "$missing_pkgs" ] && echo "$missing_pkgs" >&2
echo "$pkgs"
}
+# ---------------------------------------------------------------------
+# Report the RHEL-family packages that were skipped because the enabled
+# repos do not provide them.
+# ---------------------------------------------------------------------
+note_missing() {
+ [ -n "$1" ] || return 0
+ echo "Note: these packages are not available on the enabled repos" >&2
+ echo "and were not installed, so the features they enable will stay" >&2
+ echo "off in a perf build:" >&2
+ echo "$1" | tr ' ' '\n' | grep -v '^$' | sort -u | sed 's/^/ /' >&2
+ echo >&2
+}
+
# ---------------------------------------------------------------------
# The install command proper for each supported package manager, plus
# the command massaged for --dry-run.
@@ -345,7 +486,7 @@ package_set() {
install_cmd() {
local distro="$1"; shift
case "$distro" in
- fedora)
+ fedora|rhel)
echo "dnf install -y $*"
;;
ubuntu|debian)
@@ -357,7 +498,7 @@ install_cmd() {
main() {
local action="install"
- local srcdir distro pkgs pkg cmd
+ local srcdir distro pkgs pkg cmd missing_file missing_pkgs
while [ $# -gt 0 ]; do
case "$1" in
@@ -377,23 +518,43 @@ main() {
srcdir=$(cd "$(dirname "$0")/../../.." && pwd)
distro=$(detect_distro)
case "$distro" in
- fedora|ubuntu|debian) ;;
+ fedora|rhel|ubuntu|debian) ;;
*)
echo "error: unsupported distro (got '$distro'); the package mapping is not validated on other distros." >&2
- echo "Supported and validated: Fedora 44 (toolbx container), Ubuntu 26.04 and Debian 13 (distrobox containers)." >&2
+ echo "Supported and validated: Fedora 44 (toolbx container), Ubuntu 26.04 and Debian 13 (distrobox containers), and CentOS Stream 10 (distrobox container)." >&2
exit 1
;;
esac
- pkgs=$(package_set "$distro" "$srcdir")
+ # The RHEL family mapping probes the enabled repos with dnf
+ # repoquery and installs with dnf, so reject the yum-only members of
+ # the family (RHEL 7 and earlier, e.g. Oracle Linux 7) with a clear
+ # error instead of silently judging every package as unavailable.
+ if [ "$distro" = "rhel" ] && ! command -v dnf >/dev/null 2>&1; then
+ echo "error: dnf not found, the RHEL family package mapping requires dnf (RHEL 8 and later)." >&2
+ exit 1
+ fi
+
+ missing_file=$(mktemp) || {
+ echo "error: cannot create a temporary file (mktemp failed)" >&2
+ exit 1
+ }
+ # package_set() runs in a subshell, doing dnf repoquery loops that
+ # may be interrupted, so also trap the temp file then.
+ trap 'rm -f "$missing_file"' EXIT INT TERM
+ pkgs=$(package_set "$distro" "$srcdir" 2>"$missing_file")
+ missing_pkgs=$(cat "$missing_file")
+ rm -f "$missing_file"
case "$action" in
list)
echo "$pkgs" | tr ' ' '\n' | grep -v '^$' | sort
+ note_missing "$missing_pkgs"
exit 0
;;
dry-run)
install_cmd "$distro" $pkgs
+ note_missing "$missing_pkgs"
exit 0
;;
esac
@@ -410,6 +571,7 @@ main() {
echo "error: the install command failed, see the output above" >&2
exit 1
}
+ note_missing "$missing_pkgs"
}
main "$@"
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-08-10 15:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-10 15:44 [PATCHES v2 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 2/7] perf build: Add install-build-deps framework to install devel packages Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 3/7] perf build: install-build-deps: add Fedora devel package mapping Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 4/7] perf build: install-build-deps: add Ubuntu " Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 5/7] perf build: install-build-deps: add Debian " Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 6/7] perf build: Remove leftover feature tests for removed cxx and clang support Arnaldo Carvalho de Melo
2026-08-10 15:44 ` [PATCH 7/7] perf build: install-build-deps: add RHEL family devel package mapping Arnaldo Carvalho de Melo
-- strict thread matches above, loose matches on Subject: below --
2026-08-10 0:51 [PATCHES v1 0/7] perf build: Add target to install devel packages needed to build perf Arnaldo Carvalho de Melo
2026-08-10 0:51 ` [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox