Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
akai-hana opened this issue Jul 13, 2024 · 2 comments
Closed

Comments

@akai-hana
Copy link

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
Copy link
Owner

xarblu commented Jul 15, 2024

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 #345 (comment) 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...

xarblu added a commit that referenced this issue Jul 24, 2024
This has always been a hack and there's no proper way to build
a polly enabled llvm and clang seperately.

Recently this hack also started causing runtime issues like
#477

Please just move to using the plugin directly in CFLAGS

Signed-off-by: Xarblu <[email protected]>
@xarblu xarblu closed this as completed Jul 24, 2024
@Username404-59
Copy link
Contributor

Username404-59 commented Aug 9, 2024

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");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants