From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABBE539A4A7 for ; Thu, 21 May 2026 07:24:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779348286; cv=none; b=oryvmy10K3UKrX0zxxZRYWae42/C9tV5mNQr6eEcw1c+74ZLrL/4A/0ZBAxFEzQ85XrQnTZYrxS7p+lQNssqZuSkWJ3d/FX9XZq7wVe1BQ2Dy4b5oLwa9Cg41Ss1F2SPq4+xybyIJ7HCPjNI6FUnHUynVYrkuEyxw1joYS5cmV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779348286; c=relaxed/simple; bh=2tq54+G1DHd3j5mugKeaTTS/fpsXiXue33lWment8Pw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=o6xQAngu8hNEbFSFNELbhTtu7TO7yRyVxTk/PVzy2nEHjwIqhVkhDOEf5qHVJvfqrQb5Zqd7tdlKyfQQWXfdCYsiYdLbAfcvyvsw6xMLk5LoQMKM2VdzP8kKuvmeT6UGhg29oh2azqAeN7Wp3oYVfJx86tIuclNRCg+arnzWp/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ukahJsZa; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ukahJsZa" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1361d52b3a0so2020893c88.0 for ; Thu, 21 May 2026 00:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779348282; x=1779953082; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=f7gtESKLXiPD0tkvR99qaYWajcafSY5Lz8pSfIu9ikg=; b=ukahJsZaPp8zVXWoAcnxx/H/lLm5IERNFsZfV5qOC6CGAaEepUduwxHvH+w3r0/8c/ Bop/DFRfZJHUE5mlRLokMST2KXwoV+Oj9NpOUyXNEg+GqgV/UEQecPtyKiLrkPord1Ma BuyGkxs/jBIFaVkj8bEAVMBzudpSNpi9MorMTeW1LLK8DEyqRVclCaZP7kABLnoiUXMA re2TMKmGvBBrJHuYvUto6FmcRULnW5ik1FfZ+icNq1a38ABTuGE68rhSwQUMDqTv6lm/ tWVPJzdj3+KYM8gkLA021dgX2wU3BrpQietImwWpkN6Jao3wgLIymVEK/IfyRz/D+ysR afZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779348282; x=1779953082; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f7gtESKLXiPD0tkvR99qaYWajcafSY5Lz8pSfIu9ikg=; b=LaSVWNgZTZPyQ2TeoiF6GtOtDlButNZL/JNUYLhIW3bSyKoNHKFQP5ufMdu/0vdqpx qwXUhlm4wBHtY994sBz2zWa9SMyfEewPIzqqtX9V3q47K2MP6mZeQpsMZFKRQr8cJ7pn Q50QZjBJTo5bWq8XCUZQt93B8RS0jN0k+uiWaMts05+RTq1cC75/K8nbrBzOjIGO8uZS D3/SKdO6463WZWwmh077EjDpmUcdKbmffeEguql0n3tXYwZEVky4f7yM2yxppHUnFUgZ 8BHaGuY8sPKISng68z7Zh3D9XFGRH/fZTMYqBJBiFIEBzl8OzKvf5NHwZjGvSZfDRA81 OBqg== X-Forwarded-Encrypted: i=1; AFNElJ98FGhgo+JQHj+CcrFw6T2xVvY8Ph1/YPHWn/HgYqo0XIdFhh8NW7EvVnyyPeo2HSrqb90ZRwBsYH6BW0o=@vger.kernel.org X-Gm-Message-State: AOJu0YyAW9VROLHruA7T4xIEDpsKmN3q2L8RQ4d7ZJeGp3qLSVZCjBlo OBZp+W7YZiCrRg8dAUtUCCWeFqg9K+U8BIup6ygduFCgWUXOUgDgsUyhBZ0MzwVlar3GFTh0fM3 6+FeOhUB+iw== X-Received: from dlbrh26.prod.google.com ([2002:a05:7022:f31a:b0:135:ebea:dc20]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:4b:b0:130:ab68:2b5e with SMTP id a92af1059eb24-136326e9d5amr855125c88.4.1779348281773; Thu, 21 May 2026 00:24:41 -0700 (PDT) Date: Thu, 21 May 2026 00:24:27 -0700 In-Reply-To: <20260521072429.1283423-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260521072429.1283423-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog Message-ID: <20260521072429.1283423-2-irogers@google.com> Subject: [PATCH v1 1/3] perf build: Unconditionally set up libunwind feature build flags From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 --- 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