Bug 111523

Summary: Clover - radeonsi: Mesa git - broken compilation with current LLVM 10.0.0
Product: Mesa Reporter: Dieter Nützel <Dieter>
Component: Gallium/StateTracker/CloverAssignee: mesa-dev
Status: CLOSED FIXED QA Contact: mesa-dev
Severity: critical    
Priority: not set CC: lonewolf
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: build failure log with patch applied

Description Dieter Nützel 2019-08-29 22:41:05 UTC
../src/gallium/state_trackers/clover/llvm/invocation.cpp: In function ‘std::unique_ptr<clang::CompilerInstance> {anonymous}::create_compiler_instance(const clover::device&, const std::vector<std::__cxx11::basic_string<char> >&, std::string&)’:
../src/gallium/state_trackers/clover/llvm/invocation.cpp:203:81: error: no matching function for call to ‘clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, const char* const*, const char* const*, clang::DiagnosticsEngine&)’
  203 |              c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
      |                                                                                 ^
In file included from /usr/local/include/clang/Frontend/CompilerInstance.h:15,
                 from ../src/gallium/state_trackers/clover/llvm/codegen.hpp:37,
                 from ../src/gallium/state_trackers/clover/llvm/invocation.cpp:49:
/usr/local/include/clang/Frontend/CompilerInvocation.h:157:15: note: candidate: ‘static bool clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, llvm::ArrayRef<const char*>, clang::DiagnosticsEngine&)’
  157 |   static bool CreateFromArgs(CompilerInvocation &Res,
      |               ^~~~~~~~~~~~~~
/usr/local/include/clang/Frontend/CompilerInvocation.h:157:15: note:   candidate expects 3 arguments, 4 provided
../src/gallium/state_trackers/clover/llvm/invocation.cpp: In function ‘std::unique_ptr<llvm::Module> {anonymous}::link(llvm::LLVMContext&, const clang::CompilerInstance&, const std::vector<clover::module>&, std::string&)’:
../src/gallium/state_trackers/clover/llvm/invocation.cpp:360:23: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
  360 |       return std::move(mod);
      |              ~~~~~~~~~^~~~~
../src/gallium/state_trackers/clover/llvm/invocation.cpp:360:23: note: remove ‘std::move’ call
Comment 1 Aaron Watry 2019-08-31 19:28:20 UTC
In theory, the following should be enough to get things going again, but it'd need to be wrapped in some logic to do clang version detection to keep the older versions working:

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 0a677ce2eaa..0ce3e970303 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -200,7 +200,7 @@ namespace {
       const std::string &device_clc_version = dev.device_clc_version();
 
       if (!clang::CompilerInvocation::CreateFromArgs(
-             c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
+             c->getInvocation(), copts, diag))
          throw invalid_build_options_error();
 
       diag_buffer->FlushDiagnostics(diag);


Haven't tested it yet though beyond just building and running clinfo.
Comment 2 Aaron Watry 2019-08-31 19:29:13 UTC
Caused by clang commit (1fac68b0dc19b03fd2c5e9856f0f2c5a11691348):
https://reviews.llvm.org/D66797
Comment 3 Aaron Watry 2019-08-31 19:30:01 UTC
I might be able to get to this tonight if no one else has by then.

Gotta go do family things first.
Comment 4 Laurent carlier 2019-09-01 05:41:10 UTC
See https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1794
Comment 5 Dieter Nützel 2019-09-01 17:40:58 UTC
(In reply to Laurent carlier from comment #4)
> See https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1794

Thank you Laurent and Aaron,

Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>

/opt/opencl-example> ./run_tests.sh

[snip]

Running ./vec-load
Passed
71 passes, 0 fails
Comment 6 LoneVVolf 2019-09-02 13:06:59 UTC
*** Bug 111510 has been marked as a duplicate of this bug. ***
Comment 7 LoneVVolf 2019-09-02 13:11:48 UTC
Created attachment 145235 [details]
build failure log with patch applied

After applying the change in the patch I get other clang realted errors that break clover build, log attached.
Comment 8 Dieter Nützel 2019-09-02 13:49:34 UTC
(In reply to LoneVVolf from comment #7)
> Created attachment 145235 [details]
> build failure log with patch applied
> 
> After applying the change in the patch I get other clang realted errors that
> break clover build, log attached.

With a very quick look over your log, it seems to be a configuration problem on your site.
Do you have old libs around?

/usr/xxx vs /usr/local/xxx ?

Fully removed old LLVM ~/build tree?
Comment 9 Dieter Nützel 2019-09-02 21:07:06 UTC
(In reply to Dieter Nützel from comment #8)
> (In reply to LoneVVolf from comment #7)
> > Created attachment 145235 [details]
> > build failure log with patch applied
> > 
> > After applying the change in the patch I get other clang realted errors that
> > break clover build, log attached.
> 
> With a very quick look over your log, it seems to be a configuration problem
> on your site.
> Do you have old libs around?
> 
> /usr/xxx vs /usr/local/xxx ?
> 
> Fully removed old LLVM ~/build tree?

Oh, I had another look.

Do you build libclc before Mesa git with the same LLVM version yourself, too?
libMesaOpenCL.so.1.0.0 is OLD and if I'm right obsolete.
Maybe try without
OSMesa:          libOSMesa(Gallium)
I don't need and have it in my devel git tree.

Sorry, I do not have much more time currently 'cause I'm involved in the funeral of my best friend on Wednesday.
Comment 10 Dieter Nützel 2019-09-02 21:15:16 UTC
(In reply to Dieter Nützel from comment #9)
> (In reply to Dieter Nützel from comment #8)
> > (In reply to LoneVVolf from comment #7)
> > > Created attachment 145235 [details]
> > > build failure log with patch applied
> > > 
> > > After applying the change in the patch I get other clang realted errors that
> > > break clover build, log attached.
> > 
> > With a very quick look over your log, it seems to be a configuration problem
> > on your site.
> > Do you have old libs around?
> > 
> > /usr/xxx vs /usr/local/xxx ?
> > 
> > Fully removed old LLVM ~/build tree?
> 
> Oh, I had another look.
> 
> Do you build libclc before Mesa git with the same LLVM version yourself, too?
> libMesaOpenCL.so.1.0.0 is OLD and if I'm right obsolete.
> Maybe try without
> OSMesa:          libOSMesa(Gallium)
> I don't need and have it in my devel git tree.
> 
> Sorry, I do not have much more time currently 'cause I'm involved in the
> funeral of my best friend on Wednesday.

Old ~/.ccache dir?
Comment 11 LoneVVolf 2019-09-03 00:01:16 UTC
nothing in /usr/local or usr , cleaning ~/.ccache dir and building against libclc-git also gave same error .

I then checked the log more thoroughly, noticed this was the first time it went wrong :
/usr/bin/ld: /usr/lib/libclangAST.a(ASTContext.cpp.o): in function `clang::ASTContext::getInterpContext()':


Looked up history for ASTContext.cpp here https://github.com/llvm/llvm-project/commits/master/clang/lib/AST/ASTContext.cpp

My most recent llvm trunk build was between those last 2 commits.

Building fresh llvm trunk now, will report later.
Comment 12 LoneVVolf 2019-09-03 01:29:54 UTC
Problem was indeed with llvm/clang commits, everything works now.

I'm not good with feelings, but loosing someone you're close to is never easy.
You have my best wishes, Dieter.
Comment 13 Aaron Watry 2019-09-05 03:40:41 UTC
Should be fixed with: https://cgit.freedesktop.org/mesa/mesa/commit/?id=55c912883c9b3624ee060fe1a0232cf71e329d80

Sorry to hear about your friend Dieter. Best wishes to you and their family.
Comment 14 Dieter Nützel 2019-09-05 04:09:46 UTC
Fixed with: https://cgit.freedesktop.org/mesa/mesa/commit/?id=55c912883c9b3624ee060fe1a0232cf71e329d80

Thanks.

Even for your condolence.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.