xarblu / xarblu-overlay

My personal overlay of Gentoo GNU/Linux ebuilds
10 stars 2 forks source link

"MESA-LOADER: failed to open radeonsi" when using LLVM & polly USE flag. #477

Closed akai-hana closed 1 month ago

akai-hana commented 1 month ago

When opening the game "Milk Outside a Bag of Milk" using Wine and LLVM 18 compiled with the -polly USE flag, the program will fail, outputting the following error:

MESA-LOADER: failed to open radeonsi: /usr/lib/llvm/18/lib64/LLVMPolly.so: undefined symbol: _ZN4llvm16MetadataTracking5trackEPvRNS_8MetadataENS_12PointerUnionIJPNS_15MetadataAsValueEPS2_PNS_14DebugValueUserEEEE (search paths /usr/lib64/dri, suffix _dri)
failed to load driver: radeonsi

(full logs)

The program will then freeze indefinitely until I force stop it. Switching to LLVM 18 without polly, from the official Gentoo repo, solves the issue. I guessed LLVMPolly.so had something to do with the crash, but I lack the skill to diagnose this further.

I'm running Gentoo on an AMD CPU & GPU. I use mesa for my graphic drivers, and my VIDEO_CARDS setting is as following: VIDEO_CARDS="amdgpu radeonsi radeon".

If I'm missing any key info, or you would want a copy of the game to test it, LMK.

I couldn't find this error anywhere. Sorry if it's a mistake by my part, or if I'm missing anything. TY!

xarblu commented 1 month ago

To be completely honest sys-devel/llvm[polly] has been in a rather poor state for a while now. It always was a hack and likely always will be unless there are some major changes in LLVM.

I personally don't even use it anymore in favour of just passing -fplugin=LLVMPolly.so -mllvm=-polly ... to clang where needed and leaving LLVM alone.

This has some minor drawbacks (e.g. no Polly in rustc, extra flag to manage, occasional build issues if -fplugin* is filtered) but it's definitely the less hacky way of doing things and avoids loading Polly everywhere LLVM is loaded.

Like I already said in https://github.com/xarblu/xarblu-overlay/issues/345#issuecomment-2020755947 I mainly just keep it around because people use it but seeing it might cause actual harm like here... it might be time to pull the trigger and finally drop this huge hack from the repo...

Username404-59 commented 2 weeks ago

If anyone wants to use POLLY without build issues here's a patch I made for sys-devel/clang in order to force -fplugin=LLVMPolly.so (overkill + probably not the best way to do it, but it works™ and doesn't have the issues I had with patchelf)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
--- a/clang/lib/Driver/ToolChains/Clang.cpp (revision HEAD)
+++ b/clang/lib/Driver/ToolChains/Clang.cpp (revision Staged)
@@ -64,6 +64,7 @@
 #include "llvm/TargetParser/RISCVISAInfo.h"
 #include "llvm/TargetParser/RISCVTargetParser.h"
 #include <cctype>
+#include <filesystem>

 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -7549,6 +7550,11 @@
   // Forward -fparse-all-comments to -cc1.
   Args.AddAllArgs(CmdArgs, options::OPT_fparse_all_comments);

+  if (std::filesystem::exists(std::string("/usr/lib/llvm/") + CLANG_VERSION_MAJOR_STRING + "/lib64/LLVMPolly.so")) {
+    CmdArgs.push_back("-load");
+    CmdArgs.push_back("LLVMPolly.so");
+  }
+
   // Turn -fplugin=name.so into -load name.so
   for (const Arg *A : Args.filtered(options::OPT_fplugin_EQ)) {
     CmdArgs.push_back("-load");