[lld] [lld][WebAssembly] -r: force -Bstatic (PR #108264)
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 18:00:59 PDT 2025
https://github.com/sbc100 updated https://github.com/llvm/llvm-project/pull/108264
>From e952ae3aae8072a9cffedd8a7547e5cbd858f226 Mon Sep 17 00:00:00 2001
From: Sam Clegg <sbc at chromium.org>
Date: Wed, 11 Sep 2024 11:13:56 -0700
Subject: [PATCH] [lld][WebAssembly] -r: force -Bstatic
This is a port of a recent ELF linker change: 8cc6a2469.
---
lld/test/wasm/libsearch.s | 5 +++++
lld/wasm/Driver.cpp | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lld/test/wasm/libsearch.s b/lld/test/wasm/libsearch.s
index 23336510748ce..20f1e9b2bfa3f 100644
--- a/lld/test/wasm/libsearch.s
+++ b/lld/test/wasm/libsearch.s
@@ -93,6 +93,11 @@
// RUN: wasm-ld -pie --experimental-pic --emit-relocs --no-gc-sections -o %t3 %t.o -L%t.dir -Bstatic -call_shared -lls
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
+/// -r implies -Bstatic and has precedence over -Bdynamic.
+// RUN: wasm-ld -r -Bdynamic %t.o -L%t.dir -lls -o %t3.ro
+// RUN: llvm-readobj -s -h %t3.ro | FileCheck --check-prefix=RELOCATABLE %s
+// RELOCATABLE: Name: _static
+
.globl _start, _bar
_start:
.functype _start () -> ()
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 1c5d21c06f5af..b57d77457b83a 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -406,7 +406,8 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
ctx.arg.isStatic = true;
break;
case OPT_Bdynamic:
- ctx.arg.isStatic = false;
+ if (!ctx.arg.relocatable)
+ ctx.arg.isStatic = false;
break;
case OPT_whole_archive:
inWholeArchive = true;
More information about the llvm-commits
mailing list