Skip to content

Commit a8aee09

Browse files
committed
tools features: Don't check for libunwind devel files by default
JIRA: https://issues.redhat.com/browse/RHEL-77935 upstream ======== commit 176c9d1 Author: Arnaldo Carvalho de Melo <acme@redhat.com> Date: Tue Dec 3 17:52:33 2024 -0300 description =========== Since 13e17c9 ("perf build: Make libunwind opt-in rather than opt-out"), so we shouldn't by default be testing for its availability at build time in tools/build/features/test-all.c. That test was designed to test the features we expect to be the most common ones in most builds, so if we test build just that file, then we assume the features there are present and will not test one by one. Removing it from test-all.c gets rid of the first impediment for test-all.c to build successfully: $ cat /tmp/build/perf-tools-next/feature/test-all.make.output In file included from test-all.c:62: test-libunwind.c:2:10: fatal error: libunwind.h: No such file or directory 2 | #include <libunwind.h> | ^~~~~~~~~~~~~ compilation terminated. $ We then get to: $ cat /tmp/build/perf-tools-next/feature/test-all.make.output /usr/bin/ld: cannot find -lunwind-x86_64: No such file or directory /usr/bin/ld: cannot find -lunwind: No such file or directory collect2: error: ld returned 1 exit status $ So make all the logic related to setting CFLAGS, LDFLAGS, etc for libunwind to be conditional on NO_LIBWUNWIND=1, which is now the default, now we get a faster build: $ cat /tmp/build/perf-tools-next/feature/test-all.make.output $ ldd /tmp/build/perf-tools-next/feature/test-all.bin linux-vdso.so.1 (0x00007fef04cde000) libdw.so.1 => /lib64/libdw.so.1 (0x00007fef04a49000) libpython3.12.so.1.0 => /lib64/libpython3.12.so.1.0 (0x00007fef04478000) libm.so.6 => /lib64/libm.so.6 (0x00007fef04394000) libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007fef0436c000) libtracefs.so.1 => /lib64/libtracefs.so.1 (0x00007fef04345000) libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007fef03e95000) libz.so.1 => /lib64/libz.so.1 (0x00007fef03e72000) libelf.so.1 => /lib64/libelf.so.1 (0x00007fef03e56000) libnuma.so.1 => /lib64/libnuma.so.1 (0x00007fef03e48000) libslang.so.2 => /lib64/libslang.so.2 (0x00007fef03b65000) libperl.so.5.38 => /lib64/libperl.so.5.38 (0x00007fef037c6000) libc.so.6 => /lib64/libc.so.6 (0x00007fef035d5000) liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fef035a0000) libzstd.so.1 => /lib64/libzstd.so.1 (0x00007fef034e1000) libbz2.so.1 => /lib64/libbz2.so.1 (0x00007fef034cd000) /lib64/ld-linux-x86-64.so.2 (0x00007fef04ce0000) libcrypt.so.2 => /lib64/libcrypt.so.2 (0x00007fef03495000) $ Fixes: 13e17c9 ("perf build: Make libunwind opt-in rather than opt-out") Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/lkml/Z09zTztD8X8qIWCX@x1 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent ce129ca commit a8aee09

File tree

2 files changed

+49
-39
lines changed

2 files changed

+49
-39
lines changed

tools/build/feature/test-all.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@
5858
# include "test-libelf-getshdrstrndx.c"
5959
#undef main
6060

61-
#define main main_test_libunwind
62-
# include "test-libunwind.c"
63-
#undef main
64-
6561
#define main main_test_libslang
6662
# include "test-libslang.c"
6763
#undef main
@@ -184,7 +180,6 @@ int main(int argc, char *argv[])
184180
main_test_libelf_getphdrnum();
185181
main_test_libelf_gelf_getnote();
186182
main_test_libelf_getshdrstrndx();
187-
main_test_libunwind();
188183
main_test_libslang();
189184
main_test_libbfd();
190185
main_test_libbfd_buildid();

tools/perf/Makefile.config

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ endif
4343
# Additional ARCH settings for ppc
4444
ifeq ($(SRCARCH),powerpc)
4545
CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
46-
LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
46+
ifndef NO_LIBUNWIND
47+
LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
48+
endif
4749
endif
4850

4951
# Additional ARCH settings for x86
@@ -53,25 +55,35 @@ ifeq ($(SRCARCH),x86)
5355
ifeq (${IS_64_BIT}, 1)
5456
CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
5557
ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
56-
LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
58+
ifndef NO_LIBUNWIND
59+
LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
60+
endif
5761
$(call detected,CONFIG_X86_64)
5862
else
59-
LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
63+
ifndef NO_LIBUNWIND
64+
LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
65+
endif
6066
endif
6167
endif
6268

6369
ifeq ($(SRCARCH),arm)
64-
LIBUNWIND_LIBS = -lunwind -lunwind-arm
70+
ifndef NO_LIBUNWIND
71+
LIBUNWIND_LIBS = -lunwind -lunwind-arm
72+
endif
6573
endif
6674

6775
ifeq ($(SRCARCH),arm64)
6876
CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
69-
LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
77+
ifndef NO_LIBUNWIND
78+
LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
79+
endif
7080
endif
7181

7282
ifeq ($(SRCARCH),loongarch)
7383
CFLAGS += -I$(OUTPUT)arch/loongarch/include/generated
74-
LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
84+
ifndef NO_LIBUNWIND
85+
LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
86+
endif
7587
endif
7688

7789
ifeq ($(ARCH),s390)
@@ -80,7 +92,9 @@ endif
8092

8193
ifeq ($(ARCH),mips)
8294
CFLAGS += -I$(OUTPUT)arch/mips/include/generated
83-
LIBUNWIND_LIBS = -lunwind -lunwind-mips
95+
ifndef NO_LIBUNWIND
96+
LIBUNWIND_LIBS = -lunwind -lunwind-mips
97+
endif
8498
endif
8599

86100
ifeq ($(ARCH),riscv)
@@ -121,16 +135,18 @@ ifdef LIBUNWIND_DIR
121135
$(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
122136
endif
123137

124-
# Set per-feature check compilation flags
125-
FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
126-
FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
127-
FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
128-
FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
129-
130-
FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
131-
FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
132-
FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
133-
FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
138+
ifndef NO_LIBUNWIND
139+
# Set per-feature check compilation flags
140+
FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
141+
FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
142+
FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
143+
FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
144+
145+
FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
146+
FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
147+
FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
148+
FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
149+
endif
134150

135151
FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
136152

@@ -734,26 +750,25 @@ ifeq ($(dwarf-post-unwind),1)
734750
$(call detected,CONFIG_DWARF_UNWIND)
735751
endif
736752

737-
ifndef NO_LOCAL_LIBUNWIND
738-
ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
739-
$(call feature_check,libunwind-debug-frame)
740-
ifneq ($(feature-libunwind-debug-frame), 1)
741-
$(warning No debug_frame support found in libunwind)
753+
ifndef NO_LIBUNWIND
754+
ifndef NO_LOCAL_LIBUNWIND
755+
ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
756+
$(call feature_check,libunwind-debug-frame)
757+
ifneq ($(feature-libunwind-debug-frame), 1)
758+
$(warning No debug_frame support found in libunwind)
759+
CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
760+
endif
761+
else
762+
# non-ARM has no dwarf_find_debug_frame() function:
742763
CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
743764
endif
744-
else
745-
# non-ARM has no dwarf_find_debug_frame() function:
746-
CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
765+
EXTLIBS += $(LIBUNWIND_LIBS)
766+
LDFLAGS += $(LIBUNWIND_LIBS)
767+
endif
768+
ifeq ($(findstring -static,${LDFLAGS}),-static)
769+
# gcc -static links libgcc_eh which contans piece of libunwind
770+
LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
747771
endif
748-
EXTLIBS += $(LIBUNWIND_LIBS)
749-
LDFLAGS += $(LIBUNWIND_LIBS)
750-
endif
751-
ifeq ($(findstring -static,${LDFLAGS}),-static)
752-
# gcc -static links libgcc_eh which contans piece of libunwind
753-
LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
754-
endif
755-
756-
ifndef NO_LIBUNWIND
757772
CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
758773
CFLAGS += $(LIBUNWIND_CFLAGS)
759774
LDFLAGS += $(LIBUNWIND_LDFLAGS)

0 commit comments

Comments
 (0)