File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1
1
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2
- # RUN: llvm-as %S/Inputs/foo.ll -o %t1.o
3
- # RUN: wasm-ld %t.o %t1.o %p/Inputs/stub.so -o %t.wasm
2
+ # RUN: mkdir -p %t
3
+ # RUN: llvm-as %S/Inputs/foo.ll -o %t/foo.o
4
+ # RUN: rm -f %t/libfoo.a
5
+ # RUN: llvm-ar rcs %t/libfoo.a %t/foo.o
6
+ # RUN: wasm-ld %t.o %t/libfoo.a %p/Inputs/stub.so -o %t.wasm
4
7
# RUN: obj2yaml %t.wasm | FileCheck %s
5
8
6
- # The function `bar` is declared in stub.so and depends on `foo`, which happens
7
- # be in an LTO object.
8
- # This verifies that stub library dependencies (required exports) can be defined
9
- # in LTO objects.
9
+ ## The function `bar` is declared in stub.so and depends on `foo`, which happens
10
+ ## be in an LTO object, in an archive file .
11
+ ## This verifies that stub library dependencies (required exports) can be defined
12
+ ## in LTO objects.
10
13
.functype bar () -> ()
11
14
12
15
.globl _start
Original file line number Diff line number Diff line change @@ -949,6 +949,17 @@ static void processStubLibrariesPreLTO() {
949
949
auto * needed = symtab->find (dep);
950
950
if (needed ) {
951
951
needed->isUsedInRegularObj = true ;
952
+ // Like with handleLibcall we have extract any archive members
953
+ // that might need to be exported due to stub library symbol being
954
+ // used. Without this the LTO object could be extracted during
955
+ // processStubLibraries, which is too late since LTO has already
956
+ // beeing performed at that point.
957
+ if (needed->isLazy () && isa<BitcodeFile>(needed->getFile ())) {
958
+ if (!config->whyExtract .empty ())
959
+ ctx.whyExtractRecords .emplace_back (" <stubdep>" ,
960
+ needed->getFile (), *needed);
961
+ cast<LazySymbol>(needed)->extract ();
962
+ }
952
963
}
953
964
}
954
965
}
Original file line number Diff line number Diff line change @@ -761,7 +761,7 @@ void StubFile::parse() {
761
761
}
762
762
763
763
// Lines starting with # are considered comments
764
- if (line.starts_with (" #" ))
764
+ if (line.starts_with (" #" ) || !line. size () )
765
765
continue ;
766
766
767
767
StringRef sym;
You can’t perform that action at this time.
0 commit comments