Commit 32f7aa27 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf clang: Fixes for more recent LLVM/clang

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

Remove the unneecessary -fmessage-length and -ferror-limit flags, the
former causes failures like:

  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

Tested with LLVM 6, 8, 9, 10 and 11.
Reviewed-by: default avatarFangrui Song <maskray@google.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sedat Dilek <sedat.dilek@gmail.com>,
Cc: llvm@lists.linux.dev
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d0d0f0c1
...@@ -43,8 +43,6 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path, ...@@ -43,8 +43,6 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
"-cc1", "-cc1",
"-triple", "bpf-pc-linux", "-triple", "bpf-pc-linux",
"-fsyntax-only", "-fsyntax-only",
"-ferror-limit", "19",
"-fmessage-length", "127",
"-O2", "-O2",
"-nostdsysteminc", "-nostdsysteminc",
"-nobuiltininc", "-nobuiltininc",
...@@ -55,7 +53,11 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path, ...@@ -55,7 +53,11 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
"-x", "c"}; "-x", "c"};
CCArgs.append(CFlags.begin(), CFlags.end()); 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(); FrontendOptions& Opts = CI->getFrontendOpts();
Opts.Inputs.clear(); Opts.Inputs.clear();
...@@ -151,13 +153,16 @@ getBPFObjectFromModule(llvm::Module *Module) ...@@ -151,13 +153,16 @@ getBPFObjectFromModule(llvm::Module *Module)
legacy::PassManager PM; legacy::PassManager PM;
bool NotAdded; bool NotAdded;
#if CLANG_VERSION_MAJOR < 7 NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream
NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, #if CLANG_VERSION_MAJOR >= 7
TargetMachine::CGFT_ObjectFile); , /*DwoOut=*/nullptr
#endif
#if CLANG_VERSION_MAJOR < 10
, TargetMachine::CGFT_ObjectFile
#else #else
NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr, , llvm::CGFT_ObjectFile
TargetMachine::CGFT_ObjectFile);
#endif #endif
);
if (NotAdded) { if (NotAdded) {
llvm::errs() << "TargetMachine can't emit a file of this type\n"; llvm::errs() << "TargetMachine can't emit a file of this type\n";
return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr); return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment