about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-01-11 03:02:40 +0100
committerGitHub <noreply@github.com>2024-01-11 03:02:40 +0100
commitb6ef8b6d94ea1722c745b1046bb74ceacbcf8dde (patch)
treee734df098b8058262461770db47981162198a203
parent0f2d12ebc14f73c84cea242fecdcfc79242e4125 (diff)
parentc9276ea042bda9f11e4ca26428d57ea3701f7bc0 (diff)
downloadrust-b6ef8b6d94ea1722c745b1046bb74ceacbcf8dde.tar.gz
rust-b6ef8b6d94ea1722c745b1046bb74ceacbcf8dde.zip
Rollup merge of #119637 - aoli-al:master, r=cuviper
Pass LLVM error message back to pass wrapper.

When rustc fails to load a plugin, it should provide more detailed error message. Before this PR, rustc prints:

```
error: failed to run LLVM passes: Failed to load pass pluginPLUGIN_NAME.so
```

This PR passes LLVM errors back to rustc. After this PR, rustc prints:

```
error: failed to run LLVM passes: Could not load library 'PLUGIN_NAME.so': PLUGIN_NAME.so: undefined symbol: _ZN4llvm9DebugFlagE
```

This PR only contains usability improvements and does not change any functionality. Thus, no new unit test is implemented.
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index cf3f526400d..76eb6bfaef7 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -787,7 +787,9 @@ LLVMRustOptimize(
     for (auto PluginPath: Plugins) {
       auto Plugin = PassPlugin::Load(PluginPath.str());
       if (!Plugin) {
-        LLVMRustSetLastError(("Failed to load pass plugin" + PluginPath.str()).c_str());
+        auto Err = Plugin.takeError();
+        auto ErrMsg = llvm::toString(std::move(Err));
+        LLVMRustSetLastError(ErrMsg.c_str());
         return LLVMRustResult::Failure;
       }
       Plugin->registerPassBuilderCallbacks(PB);