From 206dcfca1f5cfac344bd88e5ed4b6a095014b91f Mon Sep 17 00:00:00 2001 From: James Clark Date: Tue, 10 Sep 2024 15:04:00 +0100 Subject: 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' {aka 'struct llvm::DILineInfo'} has no member named 'StartAddress' 178 | addr, res_or_err->StartAddress ? *res_or_err->StartAddress : 0); Fixes: c3f8644c21df9b7d ("perf report: Support LLVM for addr2line()") Signed-off-by: James Clark Tested-by: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Bill Wendling Cc: Changbin Du Cc: Guilherme Amadio Cc: Ian Rogers Cc: Ingo Molnar Cc: Jiri Olsa Cc: Justin Stitt Cc: Kan Liang Cc: Leo Yan Cc: Manu Bretelle Cc: Mark Rutland Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Peter Zijlstra Cc: Quentin Monnet Cc: Steinar H. Gunderson Link: https://lore.kernel.org/r/20240910140405.568791-1-james.clark@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/build/Makefile.feature | 2 +- tools/build/feature/Makefile | 9 +++++++++ tools/build/feature/test-llvm-perf.cpp | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tools/build/feature/test-llvm-perf.cpp (limited to 'tools/build') diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 0717e96d6a0e..427a9389e26c 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -136,7 +136,7 @@ FEATURE_DISPLAY ?= \ libunwind \ libdw-dwarf-unwind \ libcapstone \ - llvm \ + llvm-perf \ zlib \ lzma \ get_cpuid \ diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 12796808f07a..d6a98b3854f8 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -73,6 +73,7 @@ FILES= \ test-libopencsd.bin \ test-clang.bin \ test-llvm.bin \ + test-llvm-perf.bin \ test-llvm-version.bin \ test-libaio.bin \ test-libzstd.bin \ @@ -388,6 +389,14 @@ $(OUTPUT)test-llvm.bin: $(shell $(LLVM_CONFIG) --system-libs) \ > $(@:.bin=.make.output) 2>&1 +$(OUTPUT)test-llvm-perf.bin: + $(BUILDXX) -std=gnu++17 \ + -I$(shell $(LLVM_CONFIG) --includedir) \ + -L$(shell $(LLVM_CONFIG) --libdir) \ + $(shell $(LLVM_CONFIG) --libs Core BPF) \ + $(shell $(LLVM_CONFIG) --system-libs) \ + > $(@:.bin=.make.output) 2>&1 + $(OUTPUT)test-llvm-version.bin: $(BUILDXX) -std=gnu++17 \ -I$(shell $(LLVM_CONFIG) --includedir) \ diff --git a/tools/build/feature/test-llvm-perf.cpp b/tools/build/feature/test-llvm-perf.cpp new file mode 100644 index 000000000000..a8cbb67e335e --- /dev/null +++ b/tools/build/feature/test-llvm-perf.cpp @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/raw_ostream.h" + +#if LLVM_VERSION_MAJOR < 13 +# error "Perf requires llvm-devel/llvm-dev version 13 or greater" +#endif + +int main() +{ + llvm::errs() << "Hello World!\n"; + llvm::llvm_shutdown(); + return 0; +} -- cgit v1.2.3