From nobody Thu Apr 9 21:51:27 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (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 5709A34A3A5 for ; Sat, 4 Apr 2026 05:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775281256; cv=none; b=uPsTgkhvbRFa2+48YKh97uAnLi+yjYMAcIKOiz8nbQV1fRqil2Cut2spwThOrJAZk3yJO0EN9PxeVizjjMWa9fGDfKZnyNbUTNhD0Cn21DW9TNTn0vIbHmKD1rTyGvgtdfwR3HSFZpZ75BZVZZxvNDQ2Gdx+vaqqLwhqQDRcmHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775281256; c=relaxed/simple; bh=hI44vGWtCdCn04CCcup5QmPadpgQO/d62FvKmq6JGdQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mB6HAFCShgm0NEEgk9ynZBBD5UGZIm4fA9jcPGPxmQRKehtr5GTibpaX303Fji5Vvr/QUknEvuKabSYNPVwT1YuRmEakOgFieNHUDBSGnhRQOt7cuX3VLGzk/iCiEkhPluYDEuntYXImSUS4kuBJxuaMmL/e0yLwid/atuVKpp8= 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=hKV01bCr; arc=none smtp.client-ip=74.125.82.201 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="hKV01bCr" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c16233ee11so3577061eec.1 for ; Fri, 03 Apr 2026 22:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775281254; x=1775886054; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NjM/Qu3OIgvMlw6Ybfuzi2HOP0QWKIrv6KqEfslPyd8=; b=hKV01bCr68FC3Z+5xGtt1W4v9Zzn6taEYDhhPW4EF6LbjCKLdBG9kNGnvhDCOlO7Lh u+kyAVLsuqsjHgvXxjhicyZuIbQC4tU3XNesJt8rXGrv/piteHO6GtLgtE3sl10qfNjE ugu+Z+UipthhCXzdg/PpXWqfnsOUbhsCVt/tHTFzglS3yFY1UuKXgulIrxLoaAumf1+g Bu+FO8iqUlXkWZp5TKEOavJDZqsgOzTHfNUyQ/uMG6Fvzqjp54ld6dcrs+FFlfS4lMUW U97qX+38u0f/tS8x9Sz8pKIUIUuC/Sr6WARfw1h75hy8DNXbMMNo9S2n7YPHwxtXMxvL C0uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775281254; x=1775886054; h=cc: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=NjM/Qu3OIgvMlw6Ybfuzi2HOP0QWKIrv6KqEfslPyd8=; b=irurlsFnkOEx9w0FYTVwrqrQhYUgz4mp5aOl27vJfKmH9s126Zf6EpiywWhKm9dd5i 7fmEG8s+LTSyrPibB2UKpW2z7mgC7a1bD2hONJE8e3S1IeDmnH3EKhwdBxOf4UXODOpg Xp91uBz/dhTZ/3je1JigtygTedLVYRmm7/Nzhhmt/p7gFqLhhcxKkFmJL9e/e+kSYNrv 015yu4ABhcDX0pDIYdLdjpU0u7KOE5EBtMHmnz4M179hSmoiGvR6rKn4KltN9tLnmaf9 PcRI9sRbMU1MuFVXQAzXEa+Y8PEOknRR1s0dfrCMDQA4lt97etBJvLo/aexPgWZtNigs L/4g== X-Forwarded-Encrypted: i=1; AJvYcCXKv2CaEhHN72dXAOuvrGwaqcp7g1kdwZxEt45Ld07QSf8k8s7XjQQ0OokwDAlwFmRJ5LClgRqWPvHKv6Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3PwqwDyrhulkwJY8lOfjePU26LYvwrz69KwQSQDH9S96ivfVA QXy60RepOrVtosWs/gntNYL4iVsxgGAVaBdSc3awD59H20LOYM+scveFIFaT0GffC2wd+VNxLAB 4d1F3uD+pIw== X-Received: from dyu4.prod.google.com ([2002:a05:693c:8104:b0:2cb:5486:3ae3]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:fd15:b0:2c6:7f49:a86d with SMTP id 5a478bee46e88-2cbfaaab106mr2503737eec.15.1775281254305; Fri, 03 Apr 2026 22:40:54 -0700 (PDT) Date: Fri, 3 Apr 2026 22:40:28 -0700 In-Reply-To: <20260404054032.1538095-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: <20260305221927.3237145-1-irogers@google.com> <20260404054032.1538095-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260404054032.1538095-5-irogers@google.com> Subject: [PATCH v3 4/8] perf build: Be more programmatic when setting up libunwind variables From: Ian Rogers To: acme@kernel.org Cc: irogers@google.com, 9erthalion6@gmail.com, adrian.hunter@intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, andrew.jones@oss.qualcomm.com, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, howardchu95@gmail.com, james.clark@linaro.org, john.g.garry@oracle.com, jolsa@kernel.org, leo.yan@linux.dev, libunwind-devel@nongnu.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, mingo@redhat.com, namhyung@kernel.org, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, shimin.guo@skydio.com, tglozar@redhat.com, tmricht@linux.ibm.com, will@kernel.org, yuzhuo@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Iterate LIBUNWIND_ARCHS when setting up CONFIG_ and HAVE_ definitions rather than treating each architecture individually. This sets up the libunwind build variables and C definitions beyond x86 and arm/aarch64. The existing naming convention is followed for compatibility. Signed-off-by: Ian Rogers --- tools/perf/Makefile.config | 215 +++++++++++++++---------------------- 1 file changed, 89 insertions(+), 126 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 333ddd0e4bd8..9d31d0f6f52a 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -65,95 +65,83 @@ $(call detected_var,SRCARCH) =20 CFLAGS +=3D -I$(OUTPUT)arch/$(SRCARCH)/include/generated =20 -# Additional ARCH settings for ppc -ifeq ($(SRCARCH),powerpc) - ifndef NO_LIBUNWIND - LIBUNWIND_LIBS :=3D -lunwind -lunwind-ppc64 - endif -endif - # Additional ARCH settings for x86 ifeq ($(SRCARCH),x86) $(call detected,CONFIG_X86) ifeq (${IS_64_BIT}, 1) CFLAGS +=3D -DHAVE_ARCH_X86_64_SUPPORT ARCH_INCLUDE =3D ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/mem= set_64.S - ifndef NO_LIBUNWIND - LIBUNWIND_LIBS =3D -lunwind-x86_64 -lunwind -llzma - endif $(call detected,CONFIG_X86_64) - else - ifndef NO_LIBUNWIND - LIBUNWIND_LIBS =3D -lunwind-x86 -llzma -lunwind - endif endif endif =20 -ifeq ($(SRCARCH),arm) - ifndef NO_LIBUNWIND - LIBUNWIND_LIBS =3D -lunwind -lunwind-arm - endif +ifeq ($(ARCH),s390) + CFLAGS +=3D -fPIC endif =20 -ifeq ($(SRCARCH),arm64) - ifndef NO_LIBUNWIND - LIBUNWIND_LIBS =3D -lunwind -lunwind-aarch64 - endif +ifneq ($(LIBUNWIND),1) + NO_LIBUNWIND :=3D 1 endif =20 -ifeq ($(SRCARCH),loongarch) - ifndef NO_LIBUNWIND +ifndef NO_LIBUNWIND + ifeq ($(SRCARCH),arm) + LIBUNWIND_LIBS =3D -lunwind -lunwind-arm + endif + ifeq ($(SRCARCH),arm64) + LIBUNWIND_LIBS =3D -lunwind -lunwind-aarch64 + endif + ifeq ($(SRCARCH),loongarch) LIBUNWIND_LIBS =3D -lunwind -lunwind-loongarch64 endif -endif - -ifeq ($(ARCH),s390) - CFLAGS +=3D -fPIC -endif - -ifeq ($(ARCH),mips) - ifndef NO_LIBUNWIND + ifeq ($(ARCH),mips) LIBUNWIND_LIBS =3D -lunwind -lunwind-mips endif + ifeq ($(SRCARCH),powerpc) + LIBUNWIND_LIBS :=3D -lunwind -lunwind-ppc64 + endif + ifeq ($(SRCARCH),riscv) + LIBUNWIND_LIBS :=3D -lunwind -lunwind-riscv + endif + ifeq ($(SRCARCH),s390) + LIBUNWIND_LIBS :=3D -lunwind -lunwind-s390x + endif + ifeq ($(SRCARCH),x86) + ifeq (${IS_64_BIT}, 1) + LIBUNWIND_LIBS =3D -lunwind-x86_64 -lunwind -llzma + else + LIBUNWIND_LIBS =3D -lunwind-x86 -lunwind -llzma + endif + endif + ifeq ($(LIBUNWIND_LIBS),) + NO_LIBUNWIND :=3D 1 + endif endif =20 -ifneq ($(LIBUNWIND),1) - NO_LIBUNWIND :=3D 1 -endif - -ifeq ($(LIBUNWIND_LIBS),) - NO_LIBUNWIND :=3D 1 -endif # # For linking with debug library, run like: # # make DEBUG=3D1 LIBUNWIND_DIR=3D/opt/libunwind/ # - -libunwind_arch_set_flags =3D $(eval $(libunwind_arch_set_flags_code)) -define libunwind_arch_set_flags_code - FEATURE_CHECK_CFLAGS-libunwind-$(1) =3D -I$(LIBUNWIND_DIR)/include - FEATURE_CHECK_LDFLAGS-libunwind-$(1) =3D -L$(LIBUNWIND_DIR)/lib -endef - -ifdef LIBUNWIND_DIR - LIBUNWIND_CFLAGS =3D -I$(LIBUNWIND_DIR)/include - LIBUNWIND_LDFLAGS =3D -L$(LIBUNWIND_DIR)/lib - LIBUNWIND_ARCHS =3D x86 x86_64 arm aarch64 debug-frame-arm debug-frame-a= arch64 loongarch - $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_fl= ags,$(libunwind_arch))) -endif +LIBUNWIND_ARCHS:=3Daarch64 arm loongarch64 mips ppc32 ppc64 riscv s390x x8= 6 x86_64 =20 ifndef NO_LIBUNWIND - # Set per-feature check compilation flags FEATURE_CHECK_CFLAGS-libunwind =3D $(LIBUNWIND_CFLAGS) FEATURE_CHECK_LDFLAGS-libunwind =3D $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIB= S) FEATURE_CHECK_CFLAGS-libunwind-debug-frame =3D $(LIBUNWIND_CFLAGS) FEATURE_CHECK_LDFLAGS-libunwind-debug-frame =3D $(LIBUNWIND_LDFLAGS) $(L= IBUNWIND_LIBS) - =20 - FEATURE_CHECK_LDFLAGS-libunwind-arm +=3D -lunwind -lunwind-arm - FEATURE_CHECK_LDFLAGS-libunwind-aarch64 +=3D -lunwind -lunwind-aarch64 - FEATURE_CHECK_LDFLAGS-libunwind-x86 +=3D -lunwind -llzma -lunwind-x86 - FEATURE_CHECK_LDFLAGS-libunwind-x86_64 +=3D -lunwind -llzma -lunwind-x86= _64 + + ifdef LIBUNWIND_DIR + LIBUNWIND_CFLAGS =3D -I$(LIBUNWIND_DIR)/include + LIBUNWIND_LDFLAGS =3D -L$(LIBUNWIND_DIR)/lib + + define libunwind_arch_set_flags + FEATURE_CHECK_CFLAGS-libunwind-$(1) =3D -I$(LIBUNWIND_DIR)/include + FEATURE_CHECK_LDFLAGS-libunwind-$(1) =3D -L$(LIBUNWIND_DIR)/lib + endef + $(foreach arch,$(LIBUNWIND_ARCHS), \ + $(eval $(call libunwind_arch_set_flags,$(arch))) \ + ) + endif endif =20 ifdef CSINCLUDES @@ -638,49 +626,6 @@ ifeq ($(SRCARCH),powerpc) endif endif =20 -ifndef NO_LIBUNWIND - have_libunwind :=3D - - $(call feature_check,libunwind) - - $(call feature_check,libunwind-x86) - ifeq ($(feature-libunwind-x86), 1) - $(call detected,CONFIG_LIBUNWIND_X86) - CFLAGS +=3D -DHAVE_LIBUNWIND_X86_SUPPORT - LDFLAGS +=3D -lunwind-x86 - EXTLIBS_LIBUNWIND +=3D -lunwind-x86 - have_libunwind =3D 1 - endif - - $(call feature_check,libunwind-aarch64) - ifeq ($(feature-libunwind-aarch64), 1) - $(call detected,CONFIG_LIBUNWIND_AARCH64) - CFLAGS +=3D -DHAVE_LIBUNWIND_AARCH64_SUPPORT - LDFLAGS +=3D -lunwind-aarch64 - EXTLIBS_LIBUNWIND +=3D -lunwind-aarch64 - have_libunwind =3D 1 - $(call feature_check,libunwind-debug-frame-aarch64) - ifneq ($(feature-libunwind-debug-frame-aarch64), 1) - $(warning No debug_frame support found in libunwind-aarch64) - CFLAGS +=3D -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64 - endif - endif - - ifneq ($(feature-libunwind), 1) - $(warning No libunwind found. Please install libunwind-dev[el] >=3D 1.= 1 and/or set LIBUNWIND_DIR and set LIBUNWIND=3D1 in the make command line a= s it is opt-in now) - NO_LOCAL_LIBUNWIND :=3D 1 - else - have_libunwind :=3D 1 - $(call detected,CONFIG_LOCAL_LIBUNWIND) - endif - - ifneq ($(have_libunwind), 1) - NO_LIBUNWIND :=3D 1 - endif -else - NO_LOCAL_LIBUNWIND :=3D 1 -endif - ifndef NO_LIBBPF ifneq ($(feature-bpf), 1) $(warning BPF API too old. Please install recent kernel headers. BPF s= upport in 'perf record' is disabled.) @@ -739,6 +684,49 @@ ifndef GEN_VMLINUX_H VMLINUX_H=3D$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h endif =20 +ifndef NO_LIBUNWIND + have_libunwind :=3D + + $(call feature_check,libunwind) + ifneq ($(feature-libunwind), 1) + $(warning No libunwind found. Please install libunwind-dev[el] >=3D 1.= 1 and/or set LIBUNWIND_DIR and set LIBUNWIND=3D1 in the make command line a= s it is opt-in now) + NO_LOCAL_LIBUNWIND :=3D 1 + else + have_libunwind :=3D 1 + $(call detected,CONFIG_LOCAL_LIBUNWIND) + CFLAGS +=3D -DHAVE_LIBUNWIND_SUPPORT + CFLAGS +=3D $(LIBUNWIND_CFLAGS) + LDFLAGS +=3D $(LIBUNWIND_LDFLAGS) + EXTLIBS +=3D $(EXTLIBS_LIBUNWIND) + $(call feature_check,libunwind-debug-frame) + ifneq ($(feature-libunwind-debug-frame), 1) + CFLAGS +=3D -DNO_LIBUNWIND_DEBUG_FRAME + endif + endif + + define PROCESS_REMOTE_LIBUNWIND_ARCH + $(call feature_check,libunwind-$(1)) + + ifeq ($$(feature-libunwind-$(1)), 1) + upper_arch :=3D $$(shell echo $(1) | tr '[:lower:]' '[:upper:]') + $$(call detected,CONFIG_LIBUNWIND_$$(upper_arch)) + + CFLAGS +=3D -DHAVE_LIBUNWIND_$$(upper_arch)_SUPPORT + LDFLAGS +=3D -lunwind-$(1) + EXTLIBS_LIBUNWIND +=3D -lunwind-$(1) + have_libunwind :=3D 1 + + $$(call feature_check,libunwind-debug-frame-$(1)) + ifneq ($$(feature-libunwind-debug-frame-$(1)), 1) + CFLAGS +=3D -DNO_LIBUNWIND_DEBUG_FRAME_$$(upper_arch) + endif + endif + endef + $(foreach arch,$(LIBUNWIND_ARCHS), \ + $(eval $(call PROCESS_REMOTE_LIBUNWIND_ARCH,$(arch))) \ + ) +endif + dwarf-post-unwind :=3D 1 dwarf-post-unwind-text :=3D BUG =20 @@ -761,31 +749,6 @@ ifeq ($(dwarf-post-unwind),1) $(call detected,CONFIG_DWARF_UNWIND) endif =20 -ifndef NO_LIBUNWIND - ifndef NO_LOCAL_LIBUNWIND - ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) - $(call feature_check,libunwind-debug-frame) - ifneq ($(feature-libunwind-debug-frame), 1) - $(warning No debug_frame support found in libunwind) - CFLAGS +=3D -DNO_LIBUNWIND_DEBUG_FRAME - endif - else - # non-ARM has no dwarf_find_debug_frame() function: - CFLAGS +=3D -DNO_LIBUNWIND_DEBUG_FRAME - endif - EXTLIBS +=3D $(LIBUNWIND_LIBS) - LDFLAGS +=3D $(LIBUNWIND_LIBS) - endif - ifeq ($(findstring -static,${LDFLAGS}),-static) - # gcc -static links libgcc_eh which contans piece of libunwind - LIBUNWIND_LDFLAGS +=3D -Wl,--allow-multiple-definition - endif - CFLAGS +=3D -DHAVE_LIBUNWIND_SUPPORT - CFLAGS +=3D $(LIBUNWIND_CFLAGS) - LDFLAGS +=3D $(LIBUNWIND_LDFLAGS) - EXTLIBS +=3D $(EXTLIBS_LIBUNWIND) -endif - ifneq ($(NO_LIBTRACEEVENT),1) $(call detected,CONFIG_TRACE) endif --=20 2.53.0.1213.gd9a14994de-goog