Skip to content

Commit 206dcfc

Browse files
james-c-linaroacmel
authored andcommitted
perf build: Autodetect minimum required llvm-dev version
The new LLVM addr2line feature requires a minimum version of 13 to compile. Add a feature check for the version so that NO_LLVM=1 doesn't need to be explicitly added. Leave the existing llvm feature check intact because it's used by tools other than Perf. This fixes the following compilation error when the llvm-dev version doesn't match: util/llvm-c-helpers.cpp: In function 'char* llvm_name_for_code(dso*, const char*, u64)': util/llvm-c-helpers.cpp:178:21: error: 'std::remove_reference_t<llvm::DILineInfo>' {aka 'struct llvm::DILineInfo'} has no member named 'StartAddress' 178 | addr, res_or_err->StartAddress ? *res_or_err->StartAddress : 0); Fixes: c3f8644 ("perf report: Support LLVM for addr2line()") Signed-off-by: James Clark <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Bill Wendling <[email protected]> Cc: Changbin Du <[email protected]> Cc: Guilherme Amadio <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Justin Stitt <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Manu Bretelle <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Quentin Monnet <[email protected]> Cc: Steinar H. Gunderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 375f926 commit 206dcfc

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

tools/build/Makefile.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ FEATURE_DISPLAY ?= \
136136
libunwind \
137137
libdw-dwarf-unwind \
138138
libcapstone \
139-
llvm \
139+
llvm-perf \
140140
zlib \
141141
lzma \
142142
get_cpuid \

tools/build/feature/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ FILES= \
7373
test-libopencsd.bin \
7474
test-clang.bin \
7575
test-llvm.bin \
76+
test-llvm-perf.bin \
7677
test-llvm-version.bin \
7778
test-libaio.bin \
7879
test-libzstd.bin \
@@ -388,6 +389,14 @@ $(OUTPUT)test-llvm.bin:
388389
$(shell $(LLVM_CONFIG) --system-libs) \
389390
> $(@:.bin=.make.output) 2>&1
390391

392+
$(OUTPUT)test-llvm-perf.bin:
393+
$(BUILDXX) -std=gnu++17 \
394+
-I$(shell $(LLVM_CONFIG) --includedir) \
395+
-L$(shell $(LLVM_CONFIG) --libdir) \
396+
$(shell $(LLVM_CONFIG) --libs Core BPF) \
397+
$(shell $(LLVM_CONFIG) --system-libs) \
398+
> $(@:.bin=.make.output) 2>&1
399+
391400
$(OUTPUT)test-llvm-version.bin:
392401
$(BUILDXX) -std=gnu++17 \
393402
-I$(shell $(LLVM_CONFIG) --includedir) \
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include "llvm/Support/ManagedStatic.h"
3+
#include "llvm/Support/raw_ostream.h"
4+
5+
#if LLVM_VERSION_MAJOR < 13
6+
# error "Perf requires llvm-devel/llvm-dev version 13 or greater"
7+
#endif
8+
9+
int main()
10+
{
11+
llvm::errs() << "Hello World!\n";
12+
llvm::llvm_shutdown();
13+
return 0;
14+
}

tools/perf/Makefile.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,8 @@ ifdef BUILD_NONDISTRO
981981
endif
982982

983983
ifndef NO_LIBLLVM
984-
$(call feature_check,llvm)
985-
ifeq ($(feature-llvm), 1)
984+
$(call feature_check,llvm-perf)
985+
ifeq ($(feature-llvm-perf), 1)
986986
CFLAGS += -DHAVE_LIBLLVM_SUPPORT
987987
CFLAGS += $(shell $(LLVM_CONFIG) --cflags)
988988
CXXFLAGS += -DHAVE_LIBLLVM_SUPPORT
@@ -992,7 +992,7 @@ ifndef NO_LIBLLVM
992992
EXTLIBS += -lstdc++
993993
$(call detected,CONFIG_LIBLLVM)
994994
else
995-
$(warning No libllvm found, slower source file resolution, please install llvm-devel/llvm-dev)
995+
$(warning No libllvm 13+ found, slower source file resolution, please install llvm-devel/llvm-dev)
996996
NO_LIBLLVM := 1
997997
endif
998998
endif

0 commit comments

Comments
 (0)