Skip to content

[LTO] Avoid assert fail on failed pass plugin load #96691

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

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

jdenny-ornl
Copy link
Collaborator

@jdenny-ornl jdenny-ornl commented Jun 25, 2024

Without this patch, passing -load-pass-plugin=nonexistent.so to llvm-lto2 produces a backtrace because LTOBackend.cpp does not handle the error correctly:

Failed to load passes from 'nonexistant.so'. Request ignored.
Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
Could not load library 'nonexistant.so': nonexistant.so: cannot open shared object file: No such file or directoryPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

Any tool using lto::Config::PassPlugins should suffer similarly.

Based on the message "Request ignored" and the continue statement, the intention was apparently to continue on failure to load a plugin. However, no one appears to rely on that behavior now given that it crashes instead, and terminating is consistent with opt.

Without this patch, passing -load-pass-plugin=nonexistent.so to
llvm-lto2 produces a backtrace because LTOBackend.cpp does not handle
the error correctly:

```
Failed to load passes from 'nonexistant.so'. Request ignored.
Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
Could not load library 'nonexistant.so': nonexistant.so: cannot open shared object file: No such file or directoryPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

Any tool using `lto::Config::PassPlugins` should suffer similarly.

Based on the message "Request ignored" and the continue statement in
the implementation, this patch assumes the intention was not to cause
the program to fail.
@llvmbot llvmbot added the LTO Link time optimization (regular/full LTO or ThinLTO) label Jun 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 25, 2024

@llvm/pr-subscribers-lto

Author: Joel E. Denny (jdenny-ornl)

Changes

Without this patch, passing -load-pass-plugin=nonexistent.so to llvm-lto2 produces a backtrace because LTOBackend.cpp does not handle the error correctly:

Failed to load passes from 'nonexistant.so'. Request ignored.
Expected&lt;T&gt; must be checked before access or destruction.
Unchecked Expected&lt;T&gt; contained error:
Could not load library 'nonexistant.so': nonexistant.so: cannot open shared object file: No such file or directoryPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

Any tool using lto::Config::PassPlugins should suffer similarly.

Based on the message "Request ignored" and the continue statement in the implementation, this patch assumes the intention was not to cause the program to fail.


Full diff: https://github.com/llvm/llvm-project/pull/96691.diff

2 Files Affected:

  • (modified) llvm/lib/LTO/LTOBackend.cpp (+3-2)
  • (modified) llvm/test/Feature/load_plugin_error.ll (+16-3)
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 84a69d9ff1a1f..7931108c0ec99 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -192,8 +192,9 @@ static void RegisterPassPlugins(ArrayRef<std::string> PassPlugins,
   for (auto &PluginFN : PassPlugins) {
     auto PassPlugin = PassPlugin::Load(PluginFN);
     if (!PassPlugin) {
-      errs() << "Failed to load passes from '" << PluginFN
-             << "'. Request ignored.\n";
+      errs() << "Failed to load passes from plugin '" << PluginFN
+             << "' (request ignored): " << toString(PassPlugin.takeError())
+             <<  "\n";
       continue;
     }
 
diff --git a/llvm/test/Feature/load_plugin_error.ll b/llvm/test/Feature/load_plugin_error.ll
index 24a7cce5d8d39..2b860a901ee41 100644
--- a/llvm/test/Feature/load_plugin_error.ll
+++ b/llvm/test/Feature/load_plugin_error.ll
@@ -1,5 +1,18 @@
-; REQUIRES: plugins, examples
+; REQUIRES: plugins
 ; UNSUPPORTED: target={{.*windows.*}}
 
-; RUN: not opt < %s -load-pass-plugin=%t/nonexistant.so -disable-output 2>&1 | FileCheck %s
-; CHECK: Could not load library {{.*}}nonexistant.so
+; RUN: not opt < %s -load-pass-plugin=%t/nonexistent.so -disable-output 2>&1 | FileCheck %s
+
+; RUN: opt %s -o %t.o
+; RUN: llvm-lto2 run -load-pass-plugin=%t/nonexistent.so %t.o -o %t \
+; RUN:     -r %t.o,test 2>&1 | \
+; RUN:   FileCheck %s
+
+; CHECK: Could not load library {{.*}}nonexistent.so
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @test() {
+  ret void
+}

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, we definitely need to consume the error in the failure state for proper behavior.

I wonder if we could make a lint for this in the LLVM codebase.

Copy link
Collaborator

@serge-sans-paille serge-sans-paille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure we shouldn't stop the whole pipeline when the module fails to load. The difference in behavior between opt and llvm-lto2 is probably not a good thing :-/

@jdenny-ornl
Copy link
Collaborator Author

I'm not 100% sure we shouldn't stop the whole pipeline when the module fails to load. The difference in behavior between opt and llvm-lto2 is probably not a good thing :-/

I'm happy to change it to be like opt. After all, stopping on failure to load a plugin is what lto already does without this patch (but it's a crash).

@jhuber6
Copy link
Contributor

jhuber6 commented Jun 25, 2024

Yeah, crashing on an unhandled error is definitely incorrect, whether or not it should be ignored is a different issue but I can see the rationale. I think clang stops as well if -fpass-plugin= doesn't point to a valid library so there's lots of precedent.

@jdenny-ornl
Copy link
Collaborator Author

jdenny-ornl commented Jun 25, 2024

I just mean to point out that apparently no one has been too dependent on its ability to continue given that it currently crashes.

Based on the message "Request ignored" and the continue statement, the
intention was apparently to continue on failure to load a plugin.
However, no one appears to rely on that behavior now given that it
crashes instead, and terminating is consistent with opt.
Copy link
Collaborator

@serge-sans-paille serge-sans-paille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks!

@jdenny-ornl jdenny-ornl merged commit d29fdfb into llvm:main Jun 26, 2024
7 checks passed
@jdenny-ornl
Copy link
Collaborator Author

Thanks for the reviews.

@MaskRay
Copy link
Member

MaskRay commented Jun 26, 2024

LGTM. Ideally LTOBackend.cpp should have a better error reporting mechanism than we do not need so many report_fatal_error

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 26, 2024

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/620

Here is the relevant piece of the build log for the reference:

Step 6 (test) failure: build (failure)
...
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-index-is-used.cpp (1599 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-implicit-const.s (1600 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-line-strp.s (1601 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5_locations.s (1602 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5_tu_index_abbrev_offset.s (1603 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-partial-index.cpp (1604 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-split.s (1605 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwo-not-found-warning.cpp (1606 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwo-type-in-main-file.s (1607 of 1980)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwp-debug-types.s (1608 of 1980)
FAIL: lldb-shell :: SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp (1609 of 1980)
******************** TEST 'lldb-shell :: SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 19: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux -gdwarf-5 -gsplit-dwarf    -fdebug-types-section -gpubnames -c /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp -o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -fdebug-types-section -gpubnames -c /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp -o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o
RUN: at line 21: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -DVARIANT    -fdebug-types-section -gpubnames -c /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp -o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -DVARIANT -fdebug-types-section -gpubnames -c /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp -o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o
RUN: at line 23: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/ld.lld /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o -o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/ld.lld /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o -o /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp
ld.lld: warning: cannot find entry symbol _start; not setting start address
RUN: at line 26: rm -f /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.dwp
+ rm -f /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.dwp
RUN: at line 27: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb --no-lldbinit -S /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/lit-lldb-init-quiet    -o "type lookup IntegerType"    -o "type lookup FloatType"    -o "type lookup CustomType"    -b /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp | /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/FileCheck /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp --check-prefix=NODWP
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb --no-lldbinit -S /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/lit-lldb-init-quiet -o 'type lookup IntegerType' -o 'type lookup FloatType' -o 'type lookup CustomType' -b /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/FileCheck /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp --check-prefix=NODWP
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp:34:16: error: NODWP-NEXT: is not on the line after the previous match
// NODWP-NEXT: unsigned int
               ^
<stdin>:20:10: note: 'next' match was here
 typedef unsigned int IntegerType;
         ^
<stdin>:7:13: note: previous match ended here
unsigned int
            ^
<stdin>:8:1: note: non-matching line after previous match is here
int
^

Input file: <stdin>
Check file: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
         .

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 26, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/744

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Feature/load_plugin_error.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt < /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll -load-pass-plugin=/Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp/nonexistent.so -disable-output 2>&1 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll
+ not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt -load-pass-plugin=/Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp/nonexistent.so -disable-output
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll
RUN: at line 6: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll -o /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp.o
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll -o /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp.o
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt: WARNING: failed to create target machine for 'x86_64-unknown-linux-gnu': unable to get target for 'x86_64-unknown-linux-gnu', see --version and --triple.
RUN: at line 7: not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/llvm-lto2 run -load-pass-plugin=/Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp/nonexistent.so /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp.o -o /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp      -r /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp.o,test 2>&1 |    /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll
+ not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/llvm-lto2 run -load-pass-plugin=/Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp/nonexistent.so /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp.o -o /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp -r /Users/buildbot/buildbot-root/aarch64-darwin/build/test/Feature/Output/load_plugin_error.ll.tmp.o,test
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll
�[1m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll:11:10: �[0m�[0;1;31merror: �[0m�[1mCHECK: expected string not found in input
�[0m; CHECK: Could not load library {{.*}}nonexistent.so
�[0;1;32m         ^
�[0m�[1m<stdin>:1:1: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0mllvm-lto2: LTO::run failed: No available targets are compatible with triple "x86_64-unknown-linux-gnu"
�[0;1;32m^
�[0m�[1m<stdin>:1:83: �[0m�[0;1;30mnote: �[0m�[1mpossible intended match here
�[0mllvm-lto2: LTO::run failed: No available targets are compatible with triple "x86_64-unknown-linux-gnu"
�[0;1;32m                                                                                  ^
�[0m
Input file: <stdin>
Check file: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Feature/load_plugin_error.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
�[1m�[0m�[0;1;30m            1: �[0m�[1m�[0;1;46mllvm-lto2: LTO::run failed: No available targets are compatible with triple "x86_64-unknown-linux-gnu" �[0m
�[0;1;31mcheck:11'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
�[0m�[0;1;35mcheck:11'1                                                                                       ?                     possible intended match
�[0m>>>>>>

--

********************


@jdenny-ornl
Copy link
Collaborator Author

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building llvm at step 6 "test".

This one blamed only me, but it looks irrelevant, and it passed on the next build.

@jdenny-ornl
Copy link
Collaborator Author

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/744

�[1m�[0m�[0;1;30m 1: �[0m�[1m�[0;1;46mllvm-lto2: LTO::run failed: No available targets are compatible with triple "x86_64-unknown-linux-gnu" �[0m

I pushed a commit to hopefully fix that and other bot fails.

lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
Without this patch, passing -load-pass-plugin=nonexistent.so to
llvm-lto2 produces a backtrace because LTOBackend.cpp does not handle
the error correctly:

```
Failed to load passes from 'nonexistant.so'. Request ignored.
Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
Could not load library 'nonexistant.so': nonexistant.so: cannot open shared object file: No such file or directoryPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

Any tool using `lto::Config::PassPlugins` should suffer similarly.

Based on the message "Request ignored" and the continue statement, the
intention was apparently to continue on failure to load a plugin.
However, no one appears to rely on that behavior now given that it
crashes instead, and terminating is consistent with opt.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
Without this patch, passing -load-pass-plugin=nonexistent.so to
llvm-lto2 produces a backtrace because LTOBackend.cpp does not handle
the error correctly:

```
Failed to load passes from 'nonexistant.so'. Request ignored.
Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
Could not load library 'nonexistant.so': nonexistant.so: cannot open shared object file: No such file or directoryPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

Any tool using `lto::Config::PassPlugins` should suffer similarly.

Based on the message "Request ignored" and the continue statement, the
intention was apparently to continue on failure to load a plugin.
However, no one appears to rely on that behavior now given that it
crashes instead, and terminating is consistent with opt.
jdenny-ornl added a commit to jdenny-ornl/llvm-project that referenced this pull request Jul 10, 2024
The original version was introduced here in 2476cd3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTO Link time optimization (regular/full LTO or ThinLTO)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants