Skip to content

Commit

Permalink
Rollup merge of #119637 - aoli-al:master, r=cuviper
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Jan 11, 2024
2 parents 0f2d12e + c9276ea commit b6ef8b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b6ef8b6

Please sign in to comment.