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 11# 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
47# RUN: obj2yaml %t.wasm | FileCheck %s
58
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.
1013.functype bar () -> ()
1114
1215.globl _start
Original file line number Diff line number Diff line change @@ -949,6 +949,17 @@ static void processStubLibrariesPreLTO() {
949949 auto * needed = symtab->find (dep);
950950 if (needed ) {
951951 needed->isUsedInRegularObj = true ;
952+ // Like with handleLibcall we have extract any LTO 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 (toString (stub_file),
960+ needed->getFile (), *needed);
961+ cast<LazySymbol>(needed)->extract ();
962+ }
952963 }
953964 }
954965 }
Original file line number Diff line number Diff line change @@ -761,7 +761,7 @@ void StubFile::parse() {
761761 }
762762
763763 // Lines starting with # are considered comments
764- if (line.starts_with (" #" ))
764+ if (line.starts_with (" #" ) || !line. size () )
765765 continue ;
766766
767767 StringRef sym;
You can’t perform that action at this time.
0 commit comments