Skip to contentSkip to conversation

perf tools: LIBCLANGLLVM=1 build broken with llvm 7/clang 6

DISCUSSION Arnaldo Carvalho de Melo 2 participants 5 messages Jun 16, 2018 – Jun 18, 2018 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Wang, Yogong,

While reviewing the BTF patches for pahole, I updated llvm/clang
to HEAD and then building perf with clang embedded I noticed this, will investigate, posting here to document the regression, maybe this is something you came across in other scenario:

 $ make LIBCLANGLLVM=1 -C tools/perf/
 <SNIP>
  CC       /tmp/tmp.t53Qo38zci/tests/kmod-path.o
util/c++/clang.cpp: In function ‘std::unique_ptr<llvm::SmallVectorImpl<char> > perf::getBPFObjectFromModule(llvm::Module*)’:
util/c++/clang.cpp:150:43: error: no matching function for call to ‘llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManager&, llvm::raw_svector_ostream&, llvm::TargetMachine::CodeGenFileType)’
             TargetMachine::CGFT_ObjectFile)) {
                                           ^
In file included from util/c++/clang.cpp:25:0:
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note: candidate: virtual bool llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManagerBase&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::TargetMachine::CodeGenFileType, bool, llvm::MachineModuleInfo*)
   virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &,
                ^~~~~~~~~~~~~~~~~~~
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note:   candidate expects 6 arguments, 3 provided
mv: cannot stat '/tmp/tmp.t53Qo38zci/util/c++/.clang.o.tmp': No such file or directory
make[7]: *** [/home/acme/git/perf/tools/build/Makefile.build:101: /tmp/tmp.t53Qo38zci/util/c++/clang.o] Error 1
make[6]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: c++] Error 2
make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: util] Error 2
make[5]: *** Waiting for unfinished jobs....
  CC       /tmp/tmp.t53Qo38zci/tests/thread-map.o

- Arnaldo

#1 lore raw
Quoted 17 lines · Arnaldo Carvalho de Melo

Hi Wang, Yogong,

While reviewing the BTF patches for pahole, I updated llvm/clang
to HEAD and then building perf with clang embedded I noticed this, will investigate, posting here to document the regression, maybe this is something you came across in other scenario:

  $ make LIBCLANGLLVM=1 -C tools/perf/
  <SNIP>
   CC       /tmp/tmp.t53Qo38zci/tests/kmod-path.o
util/c++/clang.cpp: In function ‘std::unique_ptr<llvm::SmallVectorImpl<char> > perf::getBPFObjectFromModule(llvm::Module*)’:
util/c++/clang.cpp:150:43: error: no matching function for call to ‘llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManager&, llvm::raw_svector_ostream&, llvm::TargetMachine::CodeGenFileType)’
              TargetMachine::CGFT_ObjectFile)) {
                                            ^
In file included from util/c++/clang.cpp:25:0:
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note: candidate: virtual bool llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManagerBase&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::TargetMachine::CodeGenFileType, bool, llvm::MachineModuleInfo*)
    virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &,
Quoted 8 lines
                 ^~~~~~~~~~~~~~~~~~~
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note:   candidate expects 6 arguments, 3 provided
mv: cannot stat '/tmp/tmp.t53Qo38zci/util/c++/.clang.o.tmp': No such file or directory
make[7]: *** [/home/acme/git/perf/tools/build/Makefile.build:101: /tmp/tmp.t53Qo38zci/util/c++/clang.o] Error 1
make[6]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: c++] Error 2
make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: util] Error 2
make[5]: *** Waiting for unfinished jobs....
   CC       /tmp/tmp.t53Qo38zci/tests/thread-map.o

There is an interface change in llvm 7.0 (trunk) for function llvm::TargetMachine::addPassesToEmitFile. The following patch should fix the problem.

-bash-4.2$ git diff

tools/perf/util/c++/clang.cpp +9 -2
index bf31cea..11dee58 100644
@@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
        raw_svector_ostream ostream(*Buffer);
 
        legacy::PassManager PM;
-       if (TargetMachine->addPassesToEmitFile(PM, ostream,
- TargetMachine::CGFT_ObjectFile)) {
+       bool NotAdded;
+#if CLANG_VERSION_MAJOR < 7
+       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
+ TargetMachine::CGFT_ObjectFile);
+#else
+       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
+ TargetMachine::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);;
        }

-bash-4.2$

Will submit a formal patch soon.

Quoted 3 lines

- Arnaldo

author maintainer
#2 lore raw

Em Sat, Jun 16, 2018 at 10:20:21AM -0700, Yonghong Song escreveu:

Quoted 29 lines · Arnaldo Carvalho de Melo
Quoted 17 lines

Hi Wang, Yogong,

While reviewing the BTF patches for pahole, I updated llvm/clang
to HEAD and then building perf with clang embedded I noticed this, will investigate, posting here to document the regression, maybe this is something you came across in other scenario:

  $ make LIBCLANGLLVM=1 -C tools/perf/
  <SNIP>
   CC       /tmp/tmp.t53Qo38zci/tests/kmod-path.o
util/c++/clang.cpp: In function ‘std::unique_ptr<llvm::SmallVectorImpl<char> > perf::getBPFObjectFromModule(llvm::Module*)’:
util/c++/clang.cpp:150:43: error: no matching function for call to ‘llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManager&, llvm::raw_svector_ostream&, llvm::TargetMachine::CodeGenFileType)’
              TargetMachine::CGFT_ObjectFile)) {
                                            ^
In file included from util/c++/clang.cpp:25:0:
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note: candidate: virtual bool llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManagerBase&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::TargetMachine::CodeGenFileType, bool, llvm::MachineModuleInfo*)
    virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &,
Quoted 8 lines
                 ^~~~~~~~~~~~~~~~~~~
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note:   candidate expects 6 arguments, 3 provided
mv: cannot stat '/tmp/tmp.t53Qo38zci/util/c++/.clang.o.tmp': No such file or directory
make[7]: *** [/home/acme/git/perf/tools/build/Makefile.build:101: /tmp/tmp.t53Qo38zci/util/c++/clang.o] Error 1
make[6]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: c++] Error 2
make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: util] Error 2
make[5]: *** Waiting for unfinished jobs....
   CC       /tmp/tmp.t53Qo38zci/tests/thread-map.o
Quoted 3 lines

There is an interface change in llvm 7.0 (trunk) for function llvm::TargetMachine::addPassesToEmitFile. The following patch should fix the problem.

Please submit it, I just tested and the the build finishes Ok.

- Arnaldo

Quoted 32 lines
(quoted diff) +0 -1
-bash-4.2$ git diff
tools/perf/util/c++/clang.cpp +9 -2
index bf31cea..11dee58 100644
@@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
        raw_svector_ostream ostream(*Buffer);
 
        legacy::PassManager PM;
-       if (TargetMachine->addPassesToEmitFile(PM, ostream,
- TargetMachine::CGFT_ObjectFile)) {
+       bool NotAdded;
+#if CLANG_VERSION_MAJOR < 7
+       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
+ TargetMachine::CGFT_ObjectFile);
+#else
+       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
+ TargetMachine::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);;
        }

-bash-4.2$

Will submit a formal patch soon.

Quoted 3 lines

- Arnaldo

#3 lore raw
Quoted 30 lines · Arnaldo Carvalho de Melo

Em Sat, Jun 16, 2018 at 10:20:21AM -0700, Yonghong Song escreveu:

Quoted 29 lines · Arnaldo Carvalho de Melo
Quoted 25 lines

Hi Wang, Yogong,

While reviewing the BTF patches for pahole, I updated llvm/clang
to HEAD and then building perf with clang embedded I noticed this, will investigate, posting here to document the regression, maybe this is something you came across in other scenario:

   $ make LIBCLANGLLVM=1 -C tools/perf/
   <SNIP>
    CC       /tmp/tmp.t53Qo38zci/tests/kmod-path.o
util/c++/clang.cpp: In function ‘std::unique_ptr<llvm::SmallVectorImpl<char> > perf::getBPFObjectFromModule(llvm::Module*)’:
util/c++/clang.cpp:150:43: error: no matching function for call to ‘llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManager&, llvm::raw_svector_ostream&, llvm::TargetMachine::CodeGenFileType)’
               TargetMachine::CGFT_ObjectFile)) {
                                             ^
In file included from util/c++/clang.cpp:25:0:
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note: candidate: virtual bool llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::PassManagerBase&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::TargetMachine::CodeGenFileType, bool, llvm::MachineModuleInfo*)
     virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &,
                  ^~~~~~~~~~~~~~~~~~~
/usr/local/include/llvm/Target/TargetMachine.h:254:16: note:   candidate expects 6 arguments, 3 provided
mv: cannot stat '/tmp/tmp.t53Qo38zci/util/c++/.clang.o.tmp': No such file or directory
make[7]: *** [/home/acme/git/perf/tools/build/Makefile.build:101: /tmp/tmp.t53Qo38zci/util/c++/clang.o] Error 1
make[6]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: c++] Error 2
make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: util] Error 2
make[5]: *** Waiting for unfinished jobs....
    CC       /tmp/tmp.t53Qo38zci/tests/thread-map.o
Quoted 5 lines
Quoted 3 lines

There is an interface change in llvm 7.0 (trunk) for function llvm::TargetMachine::addPassesToEmitFile. The following patch should fix the problem.

Please submit it, I just tested and the the build finishes Ok.

The formal patch is here:
https://lkml.org/lkml/2018/6/16/92

Quoted 35 lines

- Arnaldo

Quoted 32 lines
(quoted diff) +0 -1
-bash-4.2$ git diff
tools/perf/util/c++/clang.cpp +9 -2
index bf31cea..11dee58 100644
@@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
         raw_svector_ostream ostream(*Buffer);
 
         legacy::PassManager PM;
-       if (TargetMachine->addPassesToEmitFile(PM, ostream,
- TargetMachine::CGFT_ObjectFile)) {
+       bool NotAdded;
+#if CLANG_VERSION_MAJOR < 7
+       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
+ TargetMachine::CGFT_ObjectFile);
+#else
+       NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
+ TargetMachine::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);;
         }

-bash-4.2$

Will submit a formal patch soon.

Quoted 3 lines

- Arnaldo

author maintainer
#4 lore raw

Em Mon, Jun 18, 2018 at 08:10:27AM -0700, Yonghong Song escreveu:

Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 6 lines

Em Sat, Jun 16, 2018 at 10:20:21AM -0700, Yonghong Song escreveu:

Quoted 3 lines

There is an interface change in llvm 7.0 (trunk) for function llvm::TargetMachine::addPassesToEmitFile. The following patch should fix the problem.

Please submit it, I just tested and the the build finishes Ok.

The formal patch is here:
https://lkml.org/lkml/2018/6/16/92

Thanks, hadn't noticed, applied,

- Arnaldo