From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: [PATCH v1 1/3] perf build: Unconditionally set up libunwind feature build flags
Date: Thu, 21 May 2026 00:24:27 -0700 [thread overview]
Message-ID: <20260521072429.1283423-2-irogers@google.com> (raw)
In-Reply-To: <20260521072429.1283423-1-irogers@google.com>
A "make feature-dump" build does not specify LIBUNWIND=1 because it is
run with the default configuration to detect system-wide capabilities.
This sets NO_LIBUNWIND := 1, causing Makefile.config to skip setting
LIBUNWIND_LIBS and FEATURE_CHECK_LDFLAGS-libunwind.
Consequently, when Makefile.feature is included and attempts to run
all feature checks (via FEATURE_TESTS := all), the local feature test
test-libunwind.bin compiles without the required architecture-specific
library flags (-lunwind-x86_64) and fails to link on x86_64. This
results in a corrupted cached BUILD_TEST_FEATURE_DUMP showing
feature-libunwind=0 even when the host supports it.
Subsequent test builds (like make_libunwind_O in the build-test suite)
which reuse the feature dump and specify LIBUNWIND=1 will fail to
compile due to a mismatch where CONFIG_LIBUNWIND is set (via remote
architecture checks which are self-contained) but HAVE_LIBUNWIND_SUPPORT
is disabled, causing compiler errors due to missing maps__e_machine
definitions in maps.h.
Fix this by unconditionally setting up the libunwind library lists
and feature check LDFLAGS in Makefile.config so they are always
populated and available to the feature detection engine regardless
of whether LIBUNWIND=1 is opted-in for the current run.
Fixes: 444508cd7c7b ("perf build: Be more programmatic when setting up libunwind variables")
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/Makefile.config | 103 +++++++++++++++++++------------------
1 file changed, 52 insertions(+), 51 deletions(-)
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index b56fa8419f7d..c531b9315609 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -79,42 +79,43 @@ ifeq ($(ARCH),s390)
CFLAGS += -fPIC
endif
+# Unconditionally set up the libunwind feature build flags as a
+# feature-dump build doesn't specify LIBUNWIND=1. This means that
+# dumping the libunwind features will be broken that can impact later
+# builds that use the feature dump.
+ifeq ($(SRCARCH),arm)
+ LIBUNWIND_LIBS = -lunwind -lunwind-arm
+endif
+ifeq ($(SRCARCH),arm64)
+ LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
+endif
+ifeq ($(SRCARCH),loongarch)
+ LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
+endif
+ifeq ($(ARCH),mips)
+ LIBUNWIND_LIBS = -lunwind -lunwind-mips
+endif
+ifeq ($(SRCARCH),powerpc)
+ LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
+endif
+ifeq ($(SRCARCH),riscv)
+ LIBUNWIND_LIBS := -lunwind -lunwind-riscv
+endif
+ifeq ($(SRCARCH),s390)
+ LIBUNWIND_LIBS := -lunwind -lunwind-s390x
+endif
+ifeq ($(SRCARCH),x86)
+ ifeq (${IS_64_BIT}, 1)
+ LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
+ else
+ LIBUNWIND_LIBS = -lunwind-x86 -lunwind -llzma
+ endif
+endif
ifneq ($(LIBUNWIND),1)
NO_LIBUNWIND := 1
endif
-
-ifndef NO_LIBUNWIND
- ifeq ($(SRCARCH),arm)
- LIBUNWIND_LIBS = -lunwind -lunwind-arm
- endif
- ifeq ($(SRCARCH),arm64)
- LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
- endif
- ifeq ($(SRCARCH),loongarch)
- LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
- endif
- ifeq ($(ARCH),mips)
- LIBUNWIND_LIBS = -lunwind -lunwind-mips
- endif
- ifeq ($(SRCARCH),powerpc)
- LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
- endif
- ifeq ($(SRCARCH),riscv)
- LIBUNWIND_LIBS := -lunwind -lunwind-riscv
- endif
- ifeq ($(SRCARCH),s390)
- LIBUNWIND_LIBS := -lunwind -lunwind-s390x
- endif
- ifeq ($(SRCARCH),x86)
- ifeq (${IS_64_BIT}, 1)
- LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
- else
- LIBUNWIND_LIBS = -lunwind-x86 -lunwind -llzma
- endif
- endif
- ifeq ($(LIBUNWIND_LIBS),)
- NO_LIBUNWIND := 1
- endif
+ifeq ($(LIBUNWIND_LIBS),)
+ NO_LIBUNWIND := 1
endif
#
@@ -124,24 +125,24 @@ endif
#
LIBUNWIND_ARCHS:=aarch64 arm loongarch64 mips ppc32 ppc64 riscv s390x x86 x86_64
-ifndef NO_LIBUNWIND
- FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
- FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
- FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
- FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
-
- ifdef LIBUNWIND_DIR
- LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
- LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
-
- define libunwind_arch_set_flags
- FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
- FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib -lunwind -lunwind-$(1)
- endef
- $(foreach arch,$(LIBUNWIND_ARCHS), \
- $(eval $(call libunwind_arch_set_flags,$(arch))) \
- )
- endif
+# "Local" (no arch specified) feature test flags.
+FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
+FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
+FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
+FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
+
+# Add directory into the "remote" (build for a a specific arch) feature tests.
+ifdef LIBUNWIND_DIR
+ LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
+ LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
+
+ define libunwind_arch_set_flags
+ FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
+ FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib -lunwind -lunwind-$(1)
+ endef
+ $(foreach arch,$(LIBUNWIND_ARCHS), \
+ $(eval $(call libunwind_arch_set_flags,$(arch))) \
+ )
endif
ifdef CSINCLUDES
--
2.54.0.746.g67dd491aae-goog
next prev parent reply other threads:[~2026-05-21 7:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 7:24 [PATCH v1 0/3] perf: Fix kwork memory sanitization and libunwind test builds Ian Rogers
2026-05-21 7:24 ` Ian Rogers [this message]
2026-05-21 7:24 ` [PATCH v1 2/3] perf kwork: Fix address sanitizer issues Ian Rogers
2026-05-21 7:24 ` [PATCH v1 3/3] perf kwork: Fix memory management of kwork_work Ian Rogers
2026-05-22 21:33 ` [PATCH v1 0/3] perf: Fix kwork memory sanitization and libunwind test builds Ian Rogers
2026-05-22 23:52 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260521072429.1283423-2-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®