All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tools: Bump minimum LLVM C++ std to GNU++14
@ 2021-10-11 23:24 Ian Rogers
  2021-10-11 23:24 ` [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang Ian Rogers
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2021-10-11 23:24 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Daniel Borkmann, Leo Yan,
	Michael Petlan, Sedat Dilek, linux-kernel, linux-perf-users,
	llvm
  Cc: Ian Rogers

LLVM 9 (current release is LLVM 13) moved the minimum C++ version to
GNU++14. Bump the version numbers in the feature test and perf build.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/build/feature/Makefile | 6 +++---
 tools/perf/Makefile.config   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index d024b5204ba0..19f145a35a43 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -300,7 +300,7 @@ $(OUTPUT)test-jvmti-cmlr.bin:
 	$(BUILD)
 
 $(OUTPUT)test-llvm.bin:
-	$(BUILDXX) -std=gnu++11 				\
+	$(BUILDXX) -std=gnu++14 				\
 		-I$(shell $(LLVM_CONFIG) --includedir) 		\
 		-L$(shell $(LLVM_CONFIG) --libdir)		\
 		$(shell $(LLVM_CONFIG) --libs Core BPF)		\
@@ -308,12 +308,12 @@ $(OUTPUT)test-llvm.bin:
 		> $(@:.bin=.make.output) 2>&1
 
 $(OUTPUT)test-llvm-version.bin:
-	$(BUILDXX) -std=gnu++11 				\
+	$(BUILDXX) -std=gnu++14					\
 		-I$(shell $(LLVM_CONFIG) --includedir)		\
 		> $(@:.bin=.make.output) 2>&1
 
 $(OUTPUT)test-clang.bin:
-	$(BUILDXX) -std=gnu++11 				\
+	$(BUILDXX) -std=gnu++14					\
 		-I$(shell $(LLVM_CONFIG) --includedir) 		\
 		-L$(shell $(LLVM_CONFIG) --libdir)		\
 		-Wl,--start-group -lclangBasic -lclangDriver	\
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 0ae2e3d8b832..86be3f6ec018 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -285,7 +285,7 @@ CORE_CFLAGS += -Wall
 CORE_CFLAGS += -Wextra
 CORE_CFLAGS += -std=gnu99
 
-CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
+CXXFLAGS += -std=gnu++14 -fno-exceptions -fno-rtti
 CXXFLAGS += -Wall
 CXXFLAGS += -fno-omit-frame-pointer
 CXXFLAGS += -ggdb3
-- 
2.33.0.882.g93a45727a2-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang
  2021-10-11 23:24 [PATCH 1/2] tools: Bump minimum LLVM C++ std to GNU++14 Ian Rogers
@ 2021-10-11 23:24 ` Ian Rogers
  2021-10-11 23:35   ` Ian Rogers
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2021-10-11 23:24 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Daniel Borkmann, Leo Yan,
	Michael Petlan, Sedat Dilek, linux-kernel, linux-perf-users,
	llvm
  Cc: Ian Rogers

The parameters to two functions and the location of a variable have
changed in more recent LLVM/clang releases.

Tested with LLVM 6, 8, 9, 10 and 11.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/c++/clang.cpp | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
index c8885dfa3667..756200cb80b1 100644
--- a/tools/perf/util/c++/clang.cpp
+++ b/tools/perf/util/c++/clang.cpp
@@ -44,7 +44,6 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
 		"-triple", "bpf-pc-linux",
 		"-fsyntax-only",
 		"-ferror-limit", "19",
-		"-fmessage-length", "127",
 		"-O2",
 		"-nostdsysteminc",
 		"-nobuiltininc",
@@ -55,7 +54,11 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
 		"-x", "c"};
 
 	CCArgs.append(CFlags.begin(), CFlags.end());
-	CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs);
+	CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs
+#if CLANG_VERSION_MAJOR >= 11
+                                                        ,/*BinaryName=*/nullptr
+#endif
+                                                        );
 
 	FrontendOptions& Opts = CI->getFrontendOpts();
 	Opts.Inputs.clear();
@@ -151,13 +154,16 @@ getBPFObjectFromModule(llvm::Module *Module)
 
 	legacy::PassManager PM;
 	bool NotAdded;
-#if CLANG_VERSION_MAJOR < 7
-	NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
-						      TargetMachine::CGFT_ObjectFile);
+	NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream
+#if CLANG_VERSION_MAJOR >= 7
+                                                      , /*DwoOut=*/nullptr
+#endif
+#if CLANG_VERSION_MAJOR < 10
+                                                      , TargetMachine::CGFT_ObjectFile
 #else
-	NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
-						      TargetMachine::CGFT_ObjectFile);
+                                                      , llvm::CGFT_ObjectFile
 #endif
+                                                      );
 	if (NotAdded) {
 		llvm::errs() << "TargetMachine can't emit a file of this type\n";
 		return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);
-- 
2.33.0.882.g93a45727a2-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang
  2021-10-11 23:24 ` [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang Ian Rogers
@ 2021-10-11 23:35   ` Ian Rogers
  2021-10-11 23:49     ` Fāng-ruì Sòng
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2021-10-11 23:35 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Daniel Borkmann, Leo Yan,
	Michael Petlan, Sedat Dilek, linux-kernel, linux-perf-users,
	llvm

On Mon, Oct 11, 2021 at 4:24 PM Ian Rogers <irogers@google.com> wrote:
>
> The parameters to two functions and the location of a variable have
> changed in more recent LLVM/clang releases.
>
> Tested with LLVM 6, 8, 9, 10 and 11.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/util/c++/clang.cpp | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
> index c8885dfa3667..756200cb80b1 100644
> --- a/tools/perf/util/c++/clang.cpp
> +++ b/tools/perf/util/c++/clang.cpp
> @@ -44,7 +44,6 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
>                 "-triple", "bpf-pc-linux",
>                 "-fsyntax-only",
>                 "-ferror-limit", "19",
> -               "-fmessage-length", "127",

Sorry, missed from the commit message. I removed this flag to format
output down to 127 columns as with clang 11 I see in perf test:

58: builtin clang support                                           :
58.1: builtin clang compile C source to IR                          :
--- start ---
test child forked, pid 279307
error: unknown argument: '-fmessage-length'
1 error generated.
test child finished with -1

The flag isn't necessary for correct operation.

Thanks,
Ian

>                 "-O2",
>                 "-nostdsysteminc",
>                 "-nobuiltininc",
> @@ -55,7 +54,11 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
>                 "-x", "c"};
>
>         CCArgs.append(CFlags.begin(), CFlags.end());
> -       CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs);
> +       CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs
> +#if CLANG_VERSION_MAJOR >= 11
> +                                                        ,/*BinaryName=*/nullptr
> +#endif
> +                                                        );
>
>         FrontendOptions& Opts = CI->getFrontendOpts();
>         Opts.Inputs.clear();
> @@ -151,13 +154,16 @@ getBPFObjectFromModule(llvm::Module *Module)
>
>         legacy::PassManager PM;
>         bool NotAdded;
> -#if CLANG_VERSION_MAJOR < 7
> -       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
> -                                                     TargetMachine::CGFT_ObjectFile);
> +       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream
> +#if CLANG_VERSION_MAJOR >= 7
> +                                                      , /*DwoOut=*/nullptr
> +#endif
> +#if CLANG_VERSION_MAJOR < 10
> +                                                      , TargetMachine::CGFT_ObjectFile
>  #else
> -       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
> -                                                     TargetMachine::CGFT_ObjectFile);
> +                                                      , llvm::CGFT_ObjectFile
>  #endif
> +                                                      );
>         if (NotAdded) {
>                 llvm::errs() << "TargetMachine can't emit a file of this type\n";
>                 return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);
> --
> 2.33.0.882.g93a45727a2-goog
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang
  2021-10-11 23:35   ` Ian Rogers
@ 2021-10-11 23:49     ` Fāng-ruì Sòng
  2021-10-12  2:17       ` Ian Rogers
  0 siblings, 1 reply; 8+ messages in thread
From: Fāng-ruì Sòng @ 2021-10-11 23:49 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Daniel Borkmann, Leo Yan,
	Michael Petlan, Sedat Dilek, linux-kernel, linux-perf-users,
	llvm

On Mon, Oct 11, 2021 at 4:35 PM Ian Rogers <irogers@google.com> wrote:
>
> On Mon, Oct 11, 2021 at 4:24 PM Ian Rogers <irogers@google.com> wrote:
> >
> > The parameters to two functions and the location of a variable have
> > changed in more recent LLVM/clang releases.
> >
> > Tested with LLVM 6, 8, 9, 10 and 11.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/util/c++/clang.cpp | 20 +++++++++++++-------
> >  1 file changed, 13 insertions(+), 7 deletions(-)
> >
> > diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
> > index c8885dfa3667..756200cb80b1 100644
> > --- a/tools/perf/util/c++/clang.cpp
> > +++ b/tools/perf/util/c++/clang.cpp
> > @@ -44,7 +44,6 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
> >                 "-triple", "bpf-pc-linux",
> >                 "-fsyntax-only",
> >                 "-ferror-limit", "19",
> > -               "-fmessage-length", "127",
>
> Sorry, missed from the commit message. I removed this flag to format
> output down to 127 columns as with clang 11 I see in perf test:
>
> 58: builtin clang support                                           :
> 58.1: builtin clang compile C source to IR                          :
> --- start ---
> test child forked, pid 279307
> error: unknown argument: '-fmessage-length'
> 1 error generated.
> test child finished with -1
>
> The flag isn't necessary for correct operation.

Right, I changed the -cc1 option from Separate-form -fmessage-length
to -fmessage-length= in 2020-03.
-ferror-limit can be deleted as well.

> Thanks,
> Ian
>
> >                 "-O2",
> >                 "-nostdsysteminc",
> >                 "-nobuiltininc",
> > @@ -55,7 +54,11 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
> >                 "-x", "c"};
> >
> >         CCArgs.append(CFlags.begin(), CFlags.end());
> > -       CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs);
> > +       CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs
> > +#if CLANG_VERSION_MAJOR >= 11
> > +                                                        ,/*BinaryName=*/nullptr
> > +#endif
> > +                                                        );
> >
> >         FrontendOptions& Opts = CI->getFrontendOpts();
> >         Opts.Inputs.clear();
> > @@ -151,13 +154,16 @@ getBPFObjectFromModule(llvm::Module *Module)
> >
> >         legacy::PassManager PM;
> >         bool NotAdded;
> > -#if CLANG_VERSION_MAJOR < 7
> > -       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
> > -                                                     TargetMachine::CGFT_ObjectFile);
> > +       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream
> > +#if CLANG_VERSION_MAJOR >= 7
> > +                                                      , /*DwoOut=*/nullptr
> > +#endif
> > +#if CLANG_VERSION_MAJOR < 10
> > +                                                      , TargetMachine::CGFT_ObjectFile
> >  #else
> > -       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
> > -                                                     TargetMachine::CGFT_ObjectFile);
> > +                                                      , llvm::CGFT_ObjectFile
> >  #endif
> > +                                                      );
> >         if (NotAdded) {
> >                 llvm::errs() << "TargetMachine can't emit a file of this type\n";
> >                 return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);
> > --
> > 2.33.0.882.g93a45727a2-goog
> >

Related, does it make sense to drop CLANG_VERSION_MAJOR<7 support?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang
  2021-10-11 23:49     ` Fāng-ruì Sòng
@ 2021-10-12  2:17       ` Ian Rogers
  0 siblings, 0 replies; 8+ messages in thread
From: Ian Rogers @ 2021-10-12  2:17 UTC (permalink / raw)
  To: Fāng-ruì Sòng
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Daniel Borkmann, Leo Yan,
	Michael Petlan, Sedat Dilek, linux-kernel, linux-perf-users,
	llvm

On Mon, Oct 11, 2021 at 4:49 PM Fāng-ruì Sòng <maskray@google.com> wrote:
>
> On Mon, Oct 11, 2021 at 4:35 PM Ian Rogers <irogers@google.com> wrote:
> >
> > On Mon, Oct 11, 2021 at 4:24 PM Ian Rogers <irogers@google.com> wrote:
> > >
> > > The parameters to two functions and the location of a variable have
> > > changed in more recent LLVM/clang releases.
> > >
> > > Tested with LLVM 6, 8, 9, 10 and 11.
> > >
> > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > ---
> > >  tools/perf/util/c++/clang.cpp | 20 +++++++++++++-------
> > >  1 file changed, 13 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
> > > index c8885dfa3667..756200cb80b1 100644
> > > --- a/tools/perf/util/c++/clang.cpp
> > > +++ b/tools/perf/util/c++/clang.cpp
> > > @@ -44,7 +44,6 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
> > >                 "-triple", "bpf-pc-linux",
> > >                 "-fsyntax-only",
> > >                 "-ferror-limit", "19",
> > > -               "-fmessage-length", "127",
> >
> > Sorry, missed from the commit message. I removed this flag to format
> > output down to 127 columns as with clang 11 I see in perf test:
> >
> > 58: builtin clang support                                           :
> > 58.1: builtin clang compile C source to IR                          :
> > --- start ---
> > test child forked, pid 279307
> > error: unknown argument: '-fmessage-length'
> > 1 error generated.
> > test child finished with -1
> >
> > The flag isn't necessary for correct operation.
>
> Right, I changed the -cc1 option from Separate-form -fmessage-length
> to -fmessage-length= in 2020-03.
> -ferror-limit can be deleted as well.

Done in v2 (please consider adding Acked-by, Reviewed-by, etc).

> > Thanks,
> > Ian
> >
> > >                 "-O2",
> > >                 "-nostdsysteminc",
> > >                 "-nobuiltininc",
> > > @@ -55,7 +54,11 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
> > >                 "-x", "c"};
> > >
> > >         CCArgs.append(CFlags.begin(), CFlags.end());
> > > -       CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs);
> > > +       CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs
> > > +#if CLANG_VERSION_MAJOR >= 11
> > > +                                                        ,/*BinaryName=*/nullptr
> > > +#endif
> > > +                                                        );
> > >
> > >         FrontendOptions& Opts = CI->getFrontendOpts();
> > >         Opts.Inputs.clear();
> > > @@ -151,13 +154,16 @@ getBPFObjectFromModule(llvm::Module *Module)
> > >
> > >         legacy::PassManager PM;
> > >         bool NotAdded;
> > > -#if CLANG_VERSION_MAJOR < 7
> > > -       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
> > > -                                                     TargetMachine::CGFT_ObjectFile);
> > > +       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream
> > > +#if CLANG_VERSION_MAJOR >= 7
> > > +                                                      , /*DwoOut=*/nullptr
> > > +#endif
> > > +#if CLANG_VERSION_MAJOR < 10
> > > +                                                      , TargetMachine::CGFT_ObjectFile
> > >  #else
> > > -       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
> > > -                                                     TargetMachine::CGFT_ObjectFile);
> > > +                                                      , llvm::CGFT_ObjectFile
> > >  #endif
> > > +                                                      );
> > >         if (NotAdded) {
> > >                 llvm::errs() << "TargetMachine can't emit a file of this type\n";
> > >                 return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);
> > > --
> > > 2.33.0.882.g93a45727a2-goog
> > >
>
> Related, does it make sense to drop CLANG_VERSION_MAJOR<7 support?

Arnaldo can likely best comment. Clang 6.0.1 was released on July 5th
2018 so it may still be in his build tests.

Thanks!
Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang
  2021-11-12 10:24 Ma Xinjian
  2021-11-12 15:35 ` Ian Rogers
@ 2021-11-12 18:43 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-11-12 18:43 UTC (permalink / raw)
  To: Ma Xinjian
  Cc: irogers, alexander.shishkin, daniel, jolsa, leo.yan,
	linux-kernel, linux-perf-users, llvm, mark.rutland, mingo,
	mpetlan, namhyung, nathan, ndesaulniers, peterz, sedat.dilek,
	philip.li

Em Fri, Nov 12, 2021 at 06:24:44PM +0800, Ma Xinjian escreveu:
> Hi
> 
> We build perf with clang also recently, but unlucky that failed with
> following errors:
> 
> 
> ```
> In file included from /usr/lib/llvm-7/include/llvm/ADT/STLExtras.h:21,
>                  from /usr/lib/llvm-7/include/llvm/ADT/StringRef.h:13,
>                  from /usr/lib/llvm-7/include/clang/Basic/Version.h:20,
>                  from test-clang.cpp:2:
> /usr/lib/llvm-7/include/llvm/ADT/SmallVector.h: In instantiation of 'void
> llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T =
> clang::driver::OffloadUnbundlingJobAction::DependentActionInfo]':
> /usr/lib/llvm-7/include/clang/Driver/Action.h:579:61:   required from here
> /usr/lib/llvm-7/include/llvm/ADT/SmallVector.h:313:11: error: 'void*
> memcpy(void*, const void*, size_t)' writing to an object of type 'struct
> clang::driver::OffloadUnbundlingJobAction::DependentActionInfo' with no
> trivial copy-assignment; use copy-initialization instead
> [-Werror=class-memaccess]
>      memcpy(this->end(), &Elt, sizeof(T));
>      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from /usr/lib/llvm-7/include/clang/Driver/Driver.h:15,
>                  from test-clang.cpp:6:
> /usr/lib/llvm-7/include/clang/Driver/Action.h:549:10: note: 'struct
> clang::driver::OffloadUnbundlingJobAction::DependentActionInfo' declared
> here
>    struct DependentActionInfo final {
>           ^~~~~~~~~~~~~~~~~~~
> cc1plus: all warnings being treated as errors
> ```
> 
> llvm version: 7
> rootfs: Debian10
> kernel: v5.8 v5.11 v5.15
> reproduce:
> $ cd linux/tools/perf
> $ make LIBCLANGLLVM=1 ARCH= EXTRA_CFLAGS='-fno-omit-frame-pointer
> -fsanitize=undefined -fsanitize=address'
> 
> Would you please kindly point out what's wrong with our steps? Or can you
> give us your command to make perf with clang?

This is just for building it with clang embedded, is that strictly
required?

I.e. you can still use perf to build bpf by calling clang, etc.

Or are you trying to _build_ perf using clang?

To build perf with clang:

⬢[acme@toolbox perf]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; 
⬢[acme@toolbox perf]$ make -C tools/perf CC=clang O=/tmp/build/perf

End result:

⬢[acme@toolbox perf]$ perf -v
perf version 5.15.gf8b114cfd541

⬢[acme@toolbox perf]$ readelf -wi /tmp/build/perf/perf | grep -m5 DW_AT_producer
    <c>   DW_AT_producer    : (indirect string, offset: 0x0): clang version 13.0.0 (https://github.com/llvm/llvm-project e8991caea8690ec2d17b0b7e1c29bf0da6609076)
    <a6b>   DW_AT_producer    : (indirect string, offset: 0x0): clang version 13.0.0 (https://github.com/llvm/llvm-project e8991caea8690ec2d17b0b7e1c29bf0da6609076)
    <76f0>   DW_AT_producer    : (indirect string, offset: 0x0): clang version 13.0.0 (https://github.com/llvm/llvm-project e8991caea8690ec2d17b0b7e1c29bf0da6609076)
    <823d>   DW_AT_producer    : (indirect string, offset: 0x0): clang version 13.0.0 (https://github.com/llvm/llvm-project e8991caea8690ec2d17b0b7e1c29bf0da6609076)
    <121a8>   DW_AT_producer    : (indirect string, offset: 0x0): clang version 13.0.0 (https://github.com/llvm/llvm-project e8991caea8690ec2d17b0b7e1c29bf0da6609076)
⬢[acme@toolbox perf]$

- Arnaldo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang
  2021-11-12 10:24 Ma Xinjian
@ 2021-11-12 15:35 ` Ian Rogers
  2021-11-12 18:43 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 8+ messages in thread
From: Ian Rogers @ 2021-11-12 15:35 UTC (permalink / raw)
  To: Ma Xinjian
  Cc: acme, alexander.shishkin, daniel, jolsa, leo.yan, linux-kernel,
	linux-perf-users, llvm, mark.rutland, mingo, mpetlan, namhyung,
	nathan, ndesaulniers, peterz, sedat.dilek, philip.li

On Fri, Nov 12, 2021 at 2:34 AM Ma Xinjian <xinjianx.ma@intel.com> wrote:
>
> Hi
>
> We build perf with clang also recently, but unlucky that failed with
> following errors:
>
>
> ```
> In file included from /usr/lib/llvm-7/include/llvm/ADT/STLExtras.h:21,
>                   from /usr/lib/llvm-7/include/llvm/ADT/StringRef.h:13,
>                   from /usr/lib/llvm-7/include/clang/Basic/Version.h:20,
>                   from test-clang.cpp:2:
> /usr/lib/llvm-7/include/llvm/ADT/SmallVector.h: In instantiation of
> 'void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with
> T = clang::driver::OffloadUnbundlingJobAction::DependentActionInfo]':
> /usr/lib/llvm-7/include/clang/Driver/Action.h:579:61:   required from here
> /usr/lib/llvm-7/include/llvm/ADT/SmallVector.h:313:11: error: 'void*
> memcpy(void*, const void*, size_t)' writing to an object of type 'struct
> clang::driver::OffloadUnbundlingJobAction::DependentActionInfo' with no
> trivial copy-assignment; use copy-initialization instead
> [-Werror=class-memaccess]
>       memcpy(this->end(), &Elt, sizeof(T));
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from /usr/lib/llvm-7/include/clang/Driver/Driver.h:15,
>                   from test-clang.cpp:6:
> /usr/lib/llvm-7/include/clang/Driver/Action.h:549:10: note: 'struct
> clang::driver::OffloadUnbundlingJobAction::DependentActionInfo' declared
> here
>     struct DependentActionInfo final {
>            ^~~~~~~~~~~~~~~~~~~
> cc1plus: all warnings being treated as errors
> ```
>
> llvm version: 7
> rootfs: Debian10
> kernel: v5.8 v5.11 v5.15
> reproduce:
> $ cd linux/tools/perf
> $ make LIBCLANGLLVM=1 ARCH= EXTRA_CFLAGS='-fno-omit-frame-pointer
> -fsanitize=undefined -fsanitize=address'
>
> Would you please kindly point out what's wrong with our steps? Or can
> you give us your command to make perf with clang?

Hi Xinjian,

As the bug is in LLVM 7 there is little we can do in Linux perf to fix
the issue. I haven't got LLVM 7 on my machine to test with, but I see
the same problem with LLVM 6 - both of which are of course quite old.
My workaround is to add to the make command line
"CXXFLAGS=-Wno-error=class-memaccess". My full command line is:

make -C tools/perf O=/tmp/perf DESTDIR=/tmp/perf-install  DEBUG=1
LIBPFM4=1 NO_LIBBFD=1 LIBCLANGLLVM=1
LLVM_CONFIG=/usr/lib/llvm-6.0/bin/llvm-config
CXXFLAGS=-Wno-error=class-memaccess

I know Intel is keen on testing. Related to this code are the BPF
tests in "perf test". I frequently see flakes on these tests that
count the number of times a system call is called. The flakes are an
under or over count by 1. The over count by 1 I can explain if during
the test another process happens to use the same system call. The
under counting is harder to explain and is possibly an indication of a
data race. I'd be happy for any suggestions to fix these flakes.

Thanks,
Ian

> Thanks
> Ma Xinjian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang
@ 2021-11-12 10:24 Ma Xinjian
  2021-11-12 15:35 ` Ian Rogers
  2021-11-12 18:43 ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 8+ messages in thread
From: Ma Xinjian @ 2021-11-12 10:24 UTC (permalink / raw)
  To: irogers
  Cc: acme, alexander.shishkin, daniel, jolsa, leo.yan, linux-kernel,
	linux-perf-users, llvm, mark.rutland, mingo, mpetlan, namhyung,
	nathan, ndesaulniers, peterz, sedat.dilek, philip.li

Hi

We build perf with clang also recently, but unlucky that failed with 
following errors:


```
In file included from /usr/lib/llvm-7/include/llvm/ADT/STLExtras.h:21,
                  from /usr/lib/llvm-7/include/llvm/ADT/StringRef.h:13,
                  from /usr/lib/llvm-7/include/clang/Basic/Version.h:20,
                  from test-clang.cpp:2:
/usr/lib/llvm-7/include/llvm/ADT/SmallVector.h: In instantiation of 
'void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with 
T = clang::driver::OffloadUnbundlingJobAction::DependentActionInfo]':
/usr/lib/llvm-7/include/clang/Driver/Action.h:579:61:   required from here
/usr/lib/llvm-7/include/llvm/ADT/SmallVector.h:313:11: error: 'void* 
memcpy(void*, const void*, size_t)' writing to an object of type 'struct 
clang::driver::OffloadUnbundlingJobAction::DependentActionInfo' with no 
trivial copy-assignment; use copy-initialization instead 
[-Werror=class-memaccess]
      memcpy(this->end(), &Elt, sizeof(T));
      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/llvm-7/include/clang/Driver/Driver.h:15,
                  from test-clang.cpp:6:
/usr/lib/llvm-7/include/clang/Driver/Action.h:549:10: note: 'struct 
clang::driver::OffloadUnbundlingJobAction::DependentActionInfo' declared 
here
    struct DependentActionInfo final {
           ^~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
```

llvm version: 7
rootfs: Debian10
kernel: v5.8 v5.11 v5.15
reproduce:
$ cd linux/tools/perf
$ make LIBCLANGLLVM=1 ARCH= EXTRA_CFLAGS='-fno-omit-frame-pointer 
-fsanitize=undefined -fsanitize=address'

Would you please kindly point out what's wrong with our steps? Or can 
you give us your command to make perf with clang?


Thanks
Ma Xinjian

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-12 18:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 23:24 [PATCH 1/2] tools: Bump minimum LLVM C++ std to GNU++14 Ian Rogers
2021-10-11 23:24 ` [PATCH 2/2] perf clang: Fixes for more recent LLVM/clang Ian Rogers
2021-10-11 23:35   ` Ian Rogers
2021-10-11 23:49     ` Fāng-ruì Sòng
2021-10-12  2:17       ` Ian Rogers
2021-11-12 10:24 Ma Xinjian
2021-11-12 15:35 ` Ian Rogers
2021-11-12 18:43 ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.