Skip to content

Commit f25e450

Browse files
committed
Show "LTO plugin missing" error correctly
Fixes #1403
1 parent 1fbc6f3 commit f25e450

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/lto-unix.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ create_plugin_input_file(Context<E> &ctx, MappedFile *mf) {
598598

599599
template <typename E>
600600
ObjectFile<E> *read_lto_object(Context<E> &ctx, MappedFile *mf) {
601+
if (ctx.arg.plugin.empty())
602+
Fatal(ctx) << mf->name << ": don't know how to handle this LTO object file "
603+
<< "because no -plugin option was given. Please make sure you "
604+
<< "added -flto not only for creating object files but also for "
605+
<< "creating the final executable.";
606+
601607
load_lto_plugin(ctx);
602608

603609
// V0 API's claim_file is not thread-safe.
@@ -606,12 +612,6 @@ ObjectFile<E> *read_lto_object(Context<E> &ctx, MappedFile *mf) {
606612
if (!is_gcc_linker_api_v1)
607613
lock.lock();
608614

609-
if (ctx.arg.plugin.empty())
610-
Fatal(ctx) << mf->name << ": don't know how to handle this LTO object file "
611-
<< "because no -plugin option was given. Please make sure you "
612-
<< "added -flto not only for creating object files but also for "
613-
<< "creating the final executable.";
614-
615615
// Create mold's object instance
616616
ObjectFile<E> *obj = new ObjectFile<E>;
617617
ctx.obj_pool.emplace_back(obj);

test/lto-no-plugin.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
. $(dirname $0)/common.inc
3+
4+
[ $MACHINE = $(uname -m) ] || skip
5+
6+
echo 'int main() {}' | clang -B. -flto -o /dev/null -xc - >& /dev/null || skip
7+
8+
echo 'int main() {}' | clang -c -o $t/a.o -xc -
9+
echo 'void foo() {}' | clang -c -o $t/b.o -xc - -flto
10+
11+
! ./mold -o /dev/null $t/a.o $t/b.o >& $t/log
12+
grep -q "b.o: don't know how to handle this LTO object file" $t/log

0 commit comments

Comments
 (0)