]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf build: Unconditionally set up libunwind feature build flags
authorIan Rogers <irogers@google.com>
Thu, 21 May 2026 07:24:27 +0000 (00:24 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 22 May 2026 23:50:18 +0000 (20:50 -0300)
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: 444508cd7c7b4f05 ("perf build: Be more programmatic when setting up libunwind variables")
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Makefile.config

index b56fa8419f7d021a3f21c85f396c27b56c224a83..c531b93156099d6fb33c1842a25b355547f73062 100644 (file)
@@ -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