From nobody Thu Apr 9 21:50:48 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 6331337267D for ; Sat, 4 Apr 2026 05:40:53 +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=1775281254; cv=none; b=ZNccS7fHGhjNR7/ocw1ttgcMEeSxCdD7BdsR4Qfu/szSGFfcRFfEv/Fw1swc4YfAvCo+Q21FXlaB3+mcjAzH/kZxhD7ObkVvMLB5G7/GjNyFfqO63G4UsI94hZfF6NZ4Uo968Kjg2Dfe7BIYXYMbXJY6I7p1ZmklvLyPqNsUOpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775281254; c=relaxed/simple; bh=lOpEGFFC2KgK1joOptPcmvB7OTBEM3ldVX7W72IFDtg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=W1AuxrAJ4K5QqqjN+ggHR1Bz4giHd4hEf5I1zKBUx4TzLBMwLsWSnFrhNoZ/onveUeatY86SosJNXwv+ohyxIhkXlAp2kJnVDQSyVPDJviYazit8UAf0QmBS52Anqcz7J7f+NWZdLs+u64oOisr+6D7iKhWEMN3gfHa0BrcT0wE= 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=kSlhkqVm; 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="kSlhkqVm" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c3b8880ca9so3171716eec.1 for ; Fri, 03 Apr 2026 22:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775281252; x=1775886052; 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=bxZ0oIiJdlv9VJ3sh0ouWp3Sf/nz5L7jc5er/WUpbQI=; b=kSlhkqVmPDc6ucWfgTrq3nj98prPq9P1huqoznMKlzMMQT4O013VWEgQzSW/R6sa6w iTjF0pto+iA2GroXyJG5w/Wu5L12RwK+VRa08ePTyMKeZfAdqxVUnOQFDZF2KsJQE/s+ A+kn0z3vYa4grBJSb2zGZN+NTc5estQtrgfRogV1GUPMBHjJKJIY/s+3HZSFzr3pZt1o q0eeWjWByJ2NuyHMNNb6Fy42reHxQab81lBU5jEu51AVqqQ/pqmyOjqRIEfUSxvQserN AfcGdyUwE/oZl0f0DjZRSR02/zNcD+W7VD6awZ3XgTn6VCXXFGODZK/lmwowqJ7IDpC3 50sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775281252; x=1775886052; 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=bxZ0oIiJdlv9VJ3sh0ouWp3Sf/nz5L7jc5er/WUpbQI=; b=GfrtbOrhe6SSuFlYBGLaN52uU/BH4OP1TPUwexckD1hfMkzV3FGClm2mzcbDJKwK3X Ira8m+6DO9g6lB/fwbrxX8LDFe6/05HA4GaD1+ITdSPfgXhXkKXOom19fzHVtJI52y6x BhVT/Ky0zTkDuf8Zohv43y0tkTVDsKwI370NP8L9ghgWbAFfpfNUfYwpN/B+DeyxmgpL 4p0a87YGwyLnfYsPvdgE9peABc0kbts2SqMrnb37KPP88NPcIrg2qWNj4ix/i3zwZot9 09AXYQz3g652x3q7kHHnb2Pby7A6j+NJbKs9GUamTTQEDdAN0tzrQC9eyPBKXaleX1p8 cBAw== X-Forwarded-Encrypted: i=1; AJvYcCVtAg6vyJOWVUQplvUK81x2lYbu7x5eYocotF6PNHDTyH5bTMUzXL6BhnTnsfxZcOtY5Fv2d47Jjg9Q1Dw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9EYkmNGy9kJpLfFQN1lqGo+toNRzb1pw6Sji8eddhouRiKW4W biah0qwQLm6orNpjL5jdGN48IGwyR3zjRIED6lKIYwVJdhygtZTVOZ7gDIZpXiPihVUUKhtxG// DrcJBjN3DfA== X-Received: from dlbrl19.prod.google.com ([2002:a05:7022:f513:b0:12a:c3aa:1a1e]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:4585:b0:128:d5bd:357f with SMTP id a92af1059eb24-12bfb7653e6mr2415112c88.30.1775281252333; Fri, 03 Apr 2026 22:40:52 -0700 (PDT) Date: Fri, 3 Apr 2026 22:40:27 -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-4-irogers@google.com> Subject: [PATCH v3 3/8] tools build: Deduplicate test-libunwind for different architectures 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" The separate test files only exist to pass a different #include, instead have a single source file and pass -include to $(CC) to include the relevant header file for the architecture being tested. Generate the rules using a foreach loop. Include tests for all current libunwind architectures. Signed-off-by: Ian Rogers --- tools/build/feature/Makefile | 38 +++++++++---------- tools/build/feature/test-libunwind-aarch64.c | 27 ------------- tools/build/feature/test-libunwind-arm.c | 28 -------------- .../test-libunwind-debug-frame-aarch64.c | 17 --------- .../feature/test-libunwind-debug-frame-arm.c | 17 --------- .../feature/test-libunwind-debug-frame.c | 1 - tools/build/feature/test-libunwind-x86.c | 28 -------------- tools/build/feature/test-libunwind-x86_64.c | 28 -------------- tools/build/feature/test-libunwind.c | 1 - 9 files changed, 19 insertions(+), 166 deletions(-) delete mode 100644 tools/build/feature/test-libunwind-aarch64.c delete mode 100644 tools/build/feature/test-libunwind-arm.c delete mode 100644 tools/build/feature/test-libunwind-debug-frame-aarch64.c delete mode 100644 tools/build/feature/test-libunwind-debug-frame-arm.c delete mode 100644 tools/build/feature/test-libunwind-x86.c delete mode 100644 tools/build/feature/test-libunwind-x86_64.c diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index f163a245837a..bda8ef868e44 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -210,27 +210,27 @@ $(OUTPUT)test-numa_num_possible_cpus.bin: $(BUILD) -lnuma =20 $(OUTPUT)test-libunwind.bin: - $(BUILD) -lelf -llzma + $(BUILD) -include libunwind.h -lelf -llzma -lunwind =20 $(OUTPUT)test-libunwind-debug-frame.bin: - $(BUILD) -lelf -llzma -$(OUTPUT)test-libunwind-x86.bin: - $(BUILD) -lelf -llzma -lunwind-x86 - -$(OUTPUT)test-libunwind-x86_64.bin: - $(BUILD) -lelf -llzma -lunwind-x86_64 - -$(OUTPUT)test-libunwind-arm.bin: - $(BUILD) -lelf -llzma -lunwind-arm - -$(OUTPUT)test-libunwind-aarch64.bin: - $(BUILD) -lelf -llzma -lunwind-aarch64 - -$(OUTPUT)test-libunwind-debug-frame-arm.bin: - $(BUILD) -lelf -llzma -lunwind-arm - -$(OUTPUT)test-libunwind-debug-frame-aarch64.bin: - $(BUILD) -lelf -llzma -lunwind-aarch64 + $(BUILD) -include libunwind.h -lelf -llzma -lunwind + +LIBUNWIND_ARCHS:=3Daarch64 arm loongarch64 mips ppc32 ppc64 riscv s390x x8= 6 x86_64 +define LIBUNWIND_RULE +$$(OUTPUT)test-libunwind-$(1).bin: + $$(CC) $$(CFLAGS) -MD -Wall -Werror -include libunwind-$(1).h -o $$@ \ + test-libunwind.c $$(LDFLAGS) -lelf -llzma -lunwind-$(1) \ + > $$(@:.bin=3D.make.output) 2>&1 + +$$(OUTPUT)test-libunwind-debug-frame-$(1).bin: + $$(CC) $$(CFLAGS) -MD -Wall -Werror -include libunwind-$(1).h -o $$@ \ + test-libunwind-debug-frame.c $$(LDFLAGS) -lelf -llzma -lunwind-$(1) \ + > $$(@:.bin=3D.make.output) 2>&1 + +endef +$(foreach arch,$(LIBUNWIND_ARCHS), \ + $(eval $(call LIBUNWIND_RULE,$(arch))) \ +) =20 $(OUTPUT)test-libslang.bin: $(BUILD) -lslang diff --git a/tools/build/feature/test-libunwind-aarch64.c b/tools/build/fea= ture/test-libunwind-aarch64.c deleted file mode 100644 index 323803f49212..000000000000 --- a/tools/build/feature/test-libunwind-aarch64.c +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); - -#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) - -static unw_accessors_t accessors; - -int main(void) -{ - unw_addr_space_t addr_space; - - addr_space =3D unw_create_addr_space(&accessors, 0); - if (addr_space) - return 0; - - unw_init_remote(NULL, addr_space, NULL); - dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); - - return 0; -} diff --git a/tools/build/feature/test-libunwind-arm.c b/tools/build/feature= /test-libunwind-arm.c deleted file mode 100644 index cb378b7d6866..000000000000 --- a/tools/build/feature/test-libunwind-arm.c +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); - - -#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) - -static unw_accessors_t accessors; - -int main(void) -{ - unw_addr_space_t addr_space; - - addr_space =3D unw_create_addr_space(&accessors, 0); - if (addr_space) - return 0; - - unw_init_remote(NULL, addr_space, NULL); - dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); - - return 0; -} diff --git a/tools/build/feature/test-libunwind-debug-frame-aarch64.c b/too= ls/build/feature/test-libunwind-debug-frame-aarch64.c deleted file mode 100644 index 36d6646c185e..000000000000 --- a/tools/build/feature/test-libunwind-debug-frame-aarch64.c +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -extern int -UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug, - unw_word_t ip, unw_word_t segbase, - const char *obj_name, unw_word_t start, - unw_word_t end); - -#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame) - -int main(void) -{ - dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0); - return 0; -} diff --git a/tools/build/feature/test-libunwind-debug-frame-arm.c b/tools/b= uild/feature/test-libunwind-debug-frame-arm.c deleted file mode 100644 index 8696e48e1268..000000000000 --- a/tools/build/feature/test-libunwind-debug-frame-arm.c +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -extern int -UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug, - unw_word_t ip, unw_word_t segbase, - const char *obj_name, unw_word_t start, - unw_word_t end); - -#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame) - -int main(void) -{ - dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0); - return 0; -} diff --git a/tools/build/feature/test-libunwind-debug-frame.c b/tools/build= /feature/test-libunwind-debug-frame.c index efb55cdd8d01..4c57e37004b3 100644 --- a/tools/build/feature/test-libunwind-debug-frame.c +++ b/tools/build/feature/test-libunwind-debug-frame.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include #include =20 extern int diff --git a/tools/build/feature/test-libunwind-x86.c b/tools/build/feature= /test-libunwind-x86.c deleted file mode 100644 index e5e0f6c89637..000000000000 --- a/tools/build/feature/test-libunwind-x86.c +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); - - -#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) - -static unw_accessors_t accessors; - -int main(void) -{ - unw_addr_space_t addr_space; - - addr_space =3D unw_create_addr_space(&accessors, 0); - if (addr_space) - return 0; - - unw_init_remote(NULL, addr_space, NULL); - dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); - - return 0; -} diff --git a/tools/build/feature/test-libunwind-x86_64.c b/tools/build/feat= ure/test-libunwind-x86_64.c deleted file mode 100644 index 62ae4db597dc..000000000000 --- a/tools/build/feature/test-libunwind-x86_64.c +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); - - -#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) - -static unw_accessors_t accessors; - -int main(void) -{ - unw_addr_space_t addr_space; - - addr_space =3D unw_create_addr_space(&accessors, 0); - if (addr_space) - return 0; - - unw_init_remote(NULL, addr_space, NULL); - dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); - - return 0; -} diff --git a/tools/build/feature/test-libunwind.c b/tools/build/feature/tes= t-libunwind.c index 53fd26614ff0..5af5dc3a73d4 100644 --- a/tools/build/feature/test-libunwind.c +++ b/tools/build/feature/test-libunwind.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include #include =20 extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, --=20 2.53.0.1213.gd9a14994de-goog