2023-07-25 15:09:42

by Thomas Richter

[permalink] [raw]
Subject: [PATCH 1/2 Resend] 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)
see 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
#

Signed-off-by: Thomas Richter <[email protected]>
---
tools/build/feature/Makefile | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 2cd6dbbee088..3184f387990a 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -340,7 +340,7 @@ $(OUTPUT)test-jvmti-cmlr.bin:
$(BUILD)

$(OUTPUT)test-llvm.bin:
- $(BUILDXX) -std=gnu++14 \
+ $(BUILDXX) -std=gnu++17 \
-I$(shell $(LLVM_CONFIG) --includedir) \
-L$(shell $(LLVM_CONFIG) --libdir) \
$(shell $(LLVM_CONFIG) --libs Core BPF) \
@@ -348,17 +348,15 @@ $(OUTPUT)test-llvm.bin:
> $(@:.bin=.make.output) 2>&1

$(OUTPUT)test-llvm-version.bin:
- $(BUILDXX) -std=gnu++14 \
+ $(BUILDXX) -std=gnu++17 \
-I$(shell $(LLVM_CONFIG) --includedir) \
> $(@:.bin=.make.output) 2>&1

$(OUTPUT)test-clang.bin:
- $(BUILDXX) -std=gnu++14 \
+ $(BUILDXX) -std=gnu++17 \
-I$(shell $(LLVM_CONFIG) --includedir) \
-L$(shell $(LLVM_CONFIG) --libdir) \
- -Wl,--start-group -lclangBasic -lclangDriver \
- -lclangFrontend -lclangEdit -lclangLex \
- -lclangAST -Wl,--end-group \
+ -Wl,--start-group -lclang-cpp -Wl,--end-group \
$(shell $(LLVM_CONFIG) --libs Core option) \
$(shell $(LLVM_CONFIG) --system-libs) \
> $(@:.bin=.make.output) 2>&1
--
2.41.0



2023-07-25 15:42:13

by Thomas Richter

[permalink] [raw]
Subject: [PATCH 2/2 Resend] 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.

V2: Add Library patch before -lclang-cpp

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
#

Signed-off-by: Thomas Richter <[email protected]>
Cc: Wang Nan <[email protected]>
Cc: Jiri Olsa <[email protected]>

From Ian Rogers
Build tested with LLVM 14 and 15 using:
BUILD_BPF_SKEL=1 LIBCLANGLLVM=1 LLVM_CONFIG=llvm-config-14
BUILD_BPF_SKEL=1 LIBCLANGLLVM=1 LLVM_CONFIG=llvm-config-15

Tested-by: Ian Rogers <[email protected]>
---
tools/perf/Makefile.config | 2 +-
tools/perf/Makefile.perf | 5 +----
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index c5db0de49868..8e1d1fab9b4d 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 097316ef38e6..158a0733fc9d 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -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 += -L$(shell $(LLVM_CONFIG) --libdir) -lclang-cpp
endif

ifeq ($(USE_LLVM), 1)
--
2.41.0


2023-08-02 14:49:54

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 2/2 Resend] perf build: Support llvm and clang support compiled in

Em Tue, Jul 25, 2023 at 05:03:47PM +0200, Thomas Richter escreveu:
> 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.
>
> V2: Add Library patch before -lclang-cpp
>
> 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
> #

Thanks, tested and applied!

- Arnaldo

> Signed-off-by: Thomas Richter <[email protected]>
> Cc: Wang Nan <[email protected]>
> Cc: Jiri Olsa <[email protected]>
>
> From Ian Rogers
> Build tested with LLVM 14 and 15 using:
> BUILD_BPF_SKEL=1 LIBCLANGLLVM=1 LLVM_CONFIG=llvm-config-14
> BUILD_BPF_SKEL=1 LIBCLANGLLVM=1 LLVM_CONFIG=llvm-config-15
>
> Tested-by: Ian Rogers <[email protected]>
> ---
> tools/perf/Makefile.config | 2 +-
> tools/perf/Makefile.perf | 5 +----
> 2 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index c5db0de49868..8e1d1fab9b4d 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -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
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 097316ef38e6..158a0733fc9d 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -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 += -L$(shell $(LLVM_CONFIG) --libdir) -lclang-cpp
> endif
>
> ifeq ($(USE_LLVM), 1)
> --
> 2.41.0
>

--

- Arnaldo

2023-08-02 15:04:23

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 1/2 Resend] perf build: Update feature check for clang and llvm

Em Tue, Jul 25, 2023 at 05:03:46PM +0200, Thomas Richter escreveu:
> 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)
> see 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
> #

Thanks, tested and applied. Added some notes about needing to have
'llvm-devel' and 'clang-devel' installed to do the tests.

- arnaldo

> Signed-off-by: Thomas Richter <[email protected]>
> ---
> tools/build/feature/Makefile | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index 2cd6dbbee088..3184f387990a 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -340,7 +340,7 @@ $(OUTPUT)test-jvmti-cmlr.bin:
> $(BUILD)
>
> $(OUTPUT)test-llvm.bin:
> - $(BUILDXX) -std=gnu++14 \
> + $(BUILDXX) -std=gnu++17 \
> -I$(shell $(LLVM_CONFIG) --includedir) \
> -L$(shell $(LLVM_CONFIG) --libdir) \
> $(shell $(LLVM_CONFIG) --libs Core BPF) \
> @@ -348,17 +348,15 @@ $(OUTPUT)test-llvm.bin:
> > $(@:.bin=.make.output) 2>&1
>
> $(OUTPUT)test-llvm-version.bin:
> - $(BUILDXX) -std=gnu++14 \
> + $(BUILDXX) -std=gnu++17 \
> -I$(shell $(LLVM_CONFIG) --includedir) \
> > $(@:.bin=.make.output) 2>&1
>
> $(OUTPUT)test-clang.bin:
> - $(BUILDXX) -std=gnu++14 \
> + $(BUILDXX) -std=gnu++17 \
> -I$(shell $(LLVM_CONFIG) --includedir) \
> -L$(shell $(LLVM_CONFIG) --libdir) \
> - -Wl,--start-group -lclangBasic -lclangDriver \
> - -lclangFrontend -lclangEdit -lclangLex \
> - -lclangAST -Wl,--end-group \
> + -Wl,--start-group -lclang-cpp -Wl,--end-group \
> $(shell $(LLVM_CONFIG) --libs Core option) \
> $(shell $(LLVM_CONFIG) --system-libs) \
> > $(@:.bin=.make.output) 2>&1
> --
> 2.41.0
>

--

- Arnaldo

2023-08-10 22:34:42

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH 1/2 Resend] perf build: Update feature check for clang and llvm

On Wed, Aug 2, 2023 at 7:28 AM Arnaldo Carvalho de Melo <[email protected]> wrote:
>
> Em Tue, Jul 25, 2023 at 05:03:46PM +0200, Thomas Richter escreveu:
> > 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)
> > see 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
> > #
>
> Thanks, tested and applied. Added some notes about needing to have
> 'llvm-devel' and 'clang-devel' installed to do the tests.
>
> - arnaldo
>
> > Signed-off-by: Thomas Richter <[email protected]>

Note, the libllvm and clang support was needed for BPF events which I
propose removing in:
https://lore.kernel.org/lkml/[email protected]/
(Sorry, forgot to add Thomas to the to/cc line of those changes).

Thanks,
Ian

> > ---
> > tools/build/feature/Makefile | 10 ++++------
> > 1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> > index 2cd6dbbee088..3184f387990a 100644
> > --- a/tools/build/feature/Makefile
> > +++ b/tools/build/feature/Makefile
> > @@ -340,7 +340,7 @@ $(OUTPUT)test-jvmti-cmlr.bin:
> > $(BUILD)
> >
> > $(OUTPUT)test-llvm.bin:
> > - $(BUILDXX) -std=gnu++14 \
> > + $(BUILDXX) -std=gnu++17 \
> > -I$(shell $(LLVM_CONFIG) --includedir) \
> > -L$(shell $(LLVM_CONFIG) --libdir) \
> > $(shell $(LLVM_CONFIG) --libs Core BPF) \
> > @@ -348,17 +348,15 @@ $(OUTPUT)test-llvm.bin:
> > > $(@:.bin=.make.output) 2>&1
> >
> > $(OUTPUT)test-llvm-version.bin:
> > - $(BUILDXX) -std=gnu++14 \
> > + $(BUILDXX) -std=gnu++17 \
> > -I$(shell $(LLVM_CONFIG) --includedir) \
> > > $(@:.bin=.make.output) 2>&1
> >
> > $(OUTPUT)test-clang.bin:
> > - $(BUILDXX) -std=gnu++14 \
> > + $(BUILDXX) -std=gnu++17 \
> > -I$(shell $(LLVM_CONFIG) --includedir) \
> > -L$(shell $(LLVM_CONFIG) --libdir) \
> > - -Wl,--start-group -lclangBasic -lclangDriver \
> > - -lclangFrontend -lclangEdit -lclangLex \
> > - -lclangAST -Wl,--end-group \
> > + -Wl,--start-group -lclang-cpp -Wl,--end-group \
> > $(shell $(LLVM_CONFIG) --libs Core option) \
> > $(shell $(LLVM_CONFIG) --system-libs) \
> > > $(@:.bin=.make.output) 2>&1
> > --
> > 2.41.0
> >
>
> --
>
> - Arnaldo