Skip to content

Commit e3823a6

Browse files
authored
[lld][WebAssembly] -r: force -Bstatic (llvm#108264)
This is a port of a recent ELF linker change: 8cc6a24.
1 parent a088dbd commit e3823a6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lld/test/wasm/libsearch.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@
9393
// RUN: wasm-ld -pie --experimental-pic --emit-relocs --no-gc-sections -o %t3 %t.o -L%t.dir -Bstatic -call_shared -lls
9494
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
9595

96+
/// -r implies -Bstatic and has precedence over -Bdynamic.
97+
// RUN: wasm-ld -r -Bdynamic %t.o -L%t.dir -lls -o %t3.ro
98+
// RUN: llvm-readobj -s -h %t3.ro | FileCheck --check-prefix=RELOCATABLE %s
99+
// RELOCATABLE: Name: _static
100+
96101
.globl _start, _bar
97102
_start:
98103
.functype _start () -> ()

lld/wasm/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
406406
ctx.arg.isStatic = true;
407407
break;
408408
case OPT_Bdynamic:
409-
ctx.arg.isStatic = false;
409+
if (!ctx.arg.relocatable)
410+
ctx.arg.isStatic = false;
410411
break;
411412
case OPT_whole_archive:
412413
inWholeArchive = true;

0 commit comments

Comments
 (0)