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

perf build: Update feature check for clang and llvm

Perf build auto-detects features and packages already installed for its
build. This is done in directory tools/build/feature. This directory
contains small sample programs. When they successfully compile the
necessary prereqs in form of libraries and header files are present.

Such a check is also done for llvm and clang. And the checks fail.

Fix this and update to the latest C++ standard and use the new library
provided by clang (which contains new packaging) s/ee this link for
reference:

https://fedoraproject.org/wiki/Changes/Stop-Shipping-Individual-Component-Libraries-In-clang-lib-Package

Output before:
# rm -f ./test-clang.bin; make test-clang.bin; ./test-clang.bin; \
ll test-clang.make.output
g++ -MD -Wall -Werror -o test-clang.bin test-clang.cpp \
> test-clang.make.output 2>&1 -std=gnu++14 \
-I/usr/include \
-L/usr/lib64 \
-Wl,--start-group -lclangBasic -lclangDriver \
-lclangFrontend -lclangEdit -lclangLex \
-lclangAST -Wl,--end-group \
-lLLVM-16 \
\
> test-clang.make.output 2>&1
make: *** [Makefile:356: test-clang.bin] Error 1
-bash: ./test-clang.bin: No such file or directory
-rw-r--r--. 1 root root 252041 Jul 12 09:56 test-clang.make.output
#

File test-clang.make.output contains many lines of unreferenced
symbols.

Output after:
# rm -f ./test-clang.bin; make test-clang.bin; ./test-clang.bin; \
cat test-clang.make.output
g++ -MD -Wall -Werror -o test-clang.bin test-clang.cpp \
> test-clang.make.output 2>&1 -std=gnu++17 \
-I/usr/include \
-L/usr/lib64 \
-Wl,--start-group -lclang-cpp -Wl,--end-group \
-lLLVM-16 \
\
> test-clang.make.output 2>&1
#

Committer notes:

Test it in the tools/build/feature directory, and have clang-devel and
llvm-devel installed.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lore.kernel.org/r/20230725150347.3479291-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Thomas Richter and committed by
Arnaldo Carvalho de Melo
4e95ed4f c43888e7

+4 -6
+4 -6
tools/build/feature/Makefile
··· 340 340 $(BUILD) 341 341 342 342 $(OUTPUT)test-llvm.bin: 343 - $(BUILDXX) -std=gnu++14 \ 343 + $(BUILDXX) -std=gnu++17 \ 344 344 -I$(shell $(LLVM_CONFIG) --includedir) \ 345 345 -L$(shell $(LLVM_CONFIG) --libdir) \ 346 346 $(shell $(LLVM_CONFIG) --libs Core BPF) \ ··· 348 348 > $(@:.bin=.make.output) 2>&1 349 349 350 350 $(OUTPUT)test-llvm-version.bin: 351 - $(BUILDXX) -std=gnu++14 \ 351 + $(BUILDXX) -std=gnu++17 \ 352 352 -I$(shell $(LLVM_CONFIG) --includedir) \ 353 353 > $(@:.bin=.make.output) 2>&1 354 354 355 355 $(OUTPUT)test-clang.bin: 356 - $(BUILDXX) -std=gnu++14 \ 356 + $(BUILDXX) -std=gnu++17 \ 357 357 -I$(shell $(LLVM_CONFIG) --includedir) \ 358 358 -L$(shell $(LLVM_CONFIG) --libdir) \ 359 - -Wl,--start-group -lclangBasic -lclangDriver \ 360 - -lclangFrontend -lclangEdit -lclangLex \ 361 - -lclangAST -Wl,--end-group \ 359 + -Wl,--start-group -lclang-cpp -Wl,--end-group \ 362 360 $(shell $(LLVM_CONFIG) --libs Core option) \ 363 361 $(shell $(LLVM_CONFIG) --system-libs) \ 364 362 > $(@:.bin=.make.output) 2>&1