Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools features: Don't check for libunwind devel files by default

Since 13e17c9ff49119aa ("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: 13e17c9ff49119aa ("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>

+49 -39
-5
tools/build/feature/test-all.c
··· 58 58 # include "test-libelf-getshdrstrndx.c" 59 59 #undef main 60 60 61 - #define main main_test_libunwind 62 - # include "test-libunwind.c" 63 - #undef main 64 - 65 61 #define main main_test_libslang 66 62 # include "test-libslang.c" 67 63 #undef main ··· 180 184 main_test_libelf_getphdrnum(); 181 185 main_test_libelf_gelf_getnote(); 182 186 main_test_libelf_getshdrstrndx(); 183 - main_test_libunwind(); 184 187 main_test_libslang(); 185 188 main_test_libbfd(); 186 189 main_test_libbfd_buildid();
+49 -34
tools/perf/Makefile.config
··· 43 43 # Additional ARCH settings for ppc 44 44 ifeq ($(SRCARCH),powerpc) 45 45 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 47 49 endif 48 50 49 51 # Additional ARCH settings for x86 ··· 55 53 ifeq (${IS_64_BIT}, 1) 56 54 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT 57 55 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 58 - LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma 56 + ifndef NO_LIBUNWIND 57 + LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma 58 + endif 59 59 $(call detected,CONFIG_X86_64) 60 60 else 61 - LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind 61 + ifndef NO_LIBUNWIND 62 + LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind 63 + endif 62 64 endif 63 65 endif 64 66 65 67 ifeq ($(SRCARCH),arm) 66 - LIBUNWIND_LIBS = -lunwind -lunwind-arm 68 + ifndef NO_LIBUNWIND 69 + LIBUNWIND_LIBS = -lunwind -lunwind-arm 70 + endif 67 71 endif 68 72 69 73 ifeq ($(SRCARCH),arm64) 70 74 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated 71 - LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 75 + ifndef NO_LIBUNWIND 76 + LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 77 + endif 72 78 endif 73 79 74 80 ifeq ($(SRCARCH),loongarch) 75 81 CFLAGS += -I$(OUTPUT)arch/loongarch/include/generated 76 - LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64 82 + ifndef NO_LIBUNWIND 83 + LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64 84 + endif 77 85 endif 78 86 79 87 ifeq ($(ARCH),s390) ··· 92 80 93 81 ifeq ($(ARCH),mips) 94 82 CFLAGS += -I$(OUTPUT)arch/mips/include/generated 95 - LIBUNWIND_LIBS = -lunwind -lunwind-mips 83 + ifndef NO_LIBUNWIND 84 + LIBUNWIND_LIBS = -lunwind -lunwind-mips 85 + endif 96 86 endif 97 87 98 88 ifeq ($(ARCH),riscv) ··· 135 121 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch))) 136 122 endif 137 123 138 - # Set per-feature check compilation flags 139 - FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) 140 - FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 141 - FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) 142 - FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 143 - 144 - FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm 145 - FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64 146 - FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86 147 - FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64 124 + ifndef NO_LIBUNWIND 125 + # Set per-feature check compilation flags 126 + FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) 127 + FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 128 + FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) 129 + FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 130 + 131 + FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm 132 + FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64 133 + FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86 134 + FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64 135 + endif 148 136 149 137 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto 150 138 ··· 750 734 $(call detected,CONFIG_DWARF_UNWIND) 751 735 endif 752 736 753 - ifndef NO_LOCAL_LIBUNWIND 754 - ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) 755 - $(call feature_check,libunwind-debug-frame) 756 - ifneq ($(feature-libunwind-debug-frame), 1) 757 - $(warning No debug_frame support found in libunwind) 737 + ifndef NO_LIBUNWIND 738 + ifndef NO_LOCAL_LIBUNWIND 739 + ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) 740 + $(call feature_check,libunwind-debug-frame) 741 + ifneq ($(feature-libunwind-debug-frame), 1) 742 + $(warning No debug_frame support found in libunwind) 743 + CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 744 + endif 745 + else 746 + # non-ARM has no dwarf_find_debug_frame() function: 758 747 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 759 748 endif 760 - else 761 - # non-ARM has no dwarf_find_debug_frame() function: 762 - CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 749 + EXTLIBS += $(LIBUNWIND_LIBS) 750 + LDFLAGS += $(LIBUNWIND_LIBS) 763 751 endif 764 - EXTLIBS += $(LIBUNWIND_LIBS) 765 - LDFLAGS += $(LIBUNWIND_LIBS) 766 - endif 767 - ifeq ($(findstring -static,${LDFLAGS}),-static) 768 - # gcc -static links libgcc_eh which contans piece of libunwind 769 - LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition 770 - endif 771 - 772 - ifndef NO_LIBUNWIND 752 + ifeq ($(findstring -static,${LDFLAGS}),-static) 753 + # gcc -static links libgcc_eh which contans piece of libunwind 754 + LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition 755 + endif 773 756 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT 774 757 CFLAGS += $(LIBUNWIND_CFLAGS) 775 758 LDFLAGS += $(LIBUNWIND_LDFLAGS)