Skip to contentSkip to conversation

perf build: Support llvm and clang support compiled in

PATCH Superseded Thomas Richter 2 participants 2 messages Jul 12, 2023 – Jul 13, 2023 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf build: Support llvm and clang support compiled in

Perf build suports llvm and clang support compiled in. Test case 56 builtin clang support provides a test case which is always skipped.

Link perf with the latest llvm and clang libraries and enable this test case.

Use 'make LIBCLANGLLVM=1' to include this support.

Output before:

 # ./perf test 56
 56: builtin clang support                  :
 56.1: builtin clang compile C source to IR : Skip (not compiled in)
 56.2: builtin clang compile C source to ELF object: \
	 				Skip (not compiled in)

Output after:

 # ./perf test 56
 56: builtin clang support                          :
 56.1: builtin clang compile C source to IR         : Ok
 56.2: builtin clang compile C source to ELF object : Ok
 #
---
 tools/perf/Makefile.config | 2 +-
 tools/perf/Makefile.perf   | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)
tools/perf/Makefile.config +1 -1
index 0609c19caabd..a90af438261c 100644
@@ -325,7 +325,7 @@ CORE_CFLAGS += -Wall
 CORE_CFLAGS += -Wextra
 CORE_CFLAGS += -std=gnu11
 
-CXXFLAGS += -std=gnu++14 -fno-exceptions -fno-rtti
+CXXFLAGS += -std=gnu++17 -fno-exceptions -fno-rtti
 CXXFLAGS += -Wall
 CXXFLAGS += -fno-omit-frame-pointer
 CXXFLAGS += -ggdb3
tools/perf/Makefile.perf +1 -4
index 097316ef38e6..d417d3fea818 100644
@@ -426,10 +426,7 @@ EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
 LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
 
 ifeq ($(USE_CLANG), 1)
-  CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
-  CLANGLIBS_NOEXT_LIST = $(foreach l,$(CLANGLIBS_LIST),$(shell $(LLVM_CONFIG) --libdir)/libclang$(l))
-  LIBCLANG = $(foreach l,$(CLANGLIBS_NOEXT_LIST),$(wildcard $(l).a $(l).so))
-  LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group
+  LIBS += -lclang-cpp
 endif
 
 ifeq ($(USE_LLVM), 1)
Signature · 1 line
2.41.0
reviewer
#1 lore raw
Quoted 50 lines · Thomas Richter

Perf build suports llvm and clang support compiled in. Test case 56 builtin clang support provides a test case which is always skipped.

Link perf with the latest llvm and clang libraries and enable this test case.

Use 'make LIBCLANGLLVM=1' to include this support.

Output before:

 # ./perf test 56
 56: builtin clang support                  :
 56.1: builtin clang compile C source to IR : Skip (not compiled in)
 56.2: builtin clang compile C source to ELF object: \
                                        Skip (not compiled in)

Output after:

 # ./perf test 56
 56: builtin clang support                          :
 56.1: builtin clang compile C source to IR         : Ok
 56.2: builtin clang compile C source to ELF object : Ok
 #
---
 tools/perf/Makefile.config | 2 +-
 tools/perf/Makefile.perf   | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)
tools/perf/Makefile.config +1 -1
index 0609c19caabd..a90af438261c 100644
@@ -325,7 +325,7 @@ CORE_CFLAGS += -Wall
 CORE_CFLAGS += -Wextra
 CORE_CFLAGS += -std=gnu11
 
-CXXFLAGS += -std=gnu++14 -fno-exceptions -fno-rtti
+CXXFLAGS += -std=gnu++17 -fno-exceptions -fno-rtti
 CXXFLAGS += -Wall
 CXXFLAGS += -fno-omit-frame-pointer
 CXXFLAGS += -ggdb3
tools/perf/Makefile.perf +0 -0
index 097316ef38e6..d417d3fea818 100644

tools/perf/Makefile.perf EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS)) · line 429

Quoted 8 lines
tools/perf/Makefile.perf +1 -4
@@ -426,10 +426,7 @@ EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
 LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
 
 ifeq ($(USE_CLANG), 1)
-  CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
-  CLANGLIBS_NOEXT_LIST = $(foreach l,$(CLANGLIBS_LIST),$(shell $(LLVM_CONFIG) --libdir)/libclang$(l))
-  LIBCLANG = $(foreach l,$(CLANGLIBS_NOEXT_LIST),$(wildcard $(l).a $(l).so))
-  LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group
+  LIBS += -lclang-cpp

This failed for:

```
  LINK    /tmp/perf/perf
/usr/bin/ld: cannot find -lclang-cpp: No such file or directory
collect2: error: ld returned 1 exit status
```

but adding the library directory fixed it:

```
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -426,7 +426,7 @@ EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS)
-Wl,--no-whole-archive -Wl,--start-group $
(EXTLIBS) -Wl,--end-group

ifeq ($(USE_CLANG), 1)
-  LIBS += -lclang-cpp
+  LIBS += -L/usr/lib/llvm-15/lib -lclang-cpp
endif

ifeq ($(USE_LLVM), 1)
```

This is on a Debian installation:

```
$ dpkg -L libclang-cpp15
/.
/usr
/usr/lib
/usr/lib/llvm-15
/usr/lib/llvm-15/lib
/usr/lib/llvm-15/lib/libclang-cpp.so.15
/usr/lib/x86_64-linux-gnu
/usr/share
/usr/share/doc
/usr/share/doc/libclang-cpp15
/usr/share/doc/libclang-cpp15/NEWS.Debian.gz
/usr/share/doc/libclang-cpp15/changelog.Debian.gz
/usr/share/doc/libclang-cpp15/copyright
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.15
```

Thanks,
Ian

Quoted 6 lines
tools/perf/Makefile.perf +0 -1
 endif
 
 ifeq ($(USE_LLVM), 1)
--

2.41.0