Skip to content

Commit 8e9d026

Browse files
committed
[lld][WebAssembly] Always search *.so for -Bdynamic
Search *.so libraries regardless of -pie to make it a bit more straightforward to build non-pie dynamic-linked executables. Flip the default to -Bstatic as I think it's what most users expect for the default as of today. The assumption here is that, because dynamic-linking is not widely used for WebAssembly, the most users do not specify -Bdynamic or -Bstatic, expecting static link.
1 parent 9f15aa0 commit 8e9d026

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

lld/wasm/Config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct Configuration {
7272
bool stripAll;
7373
bool stripDebug;
7474
bool stackFirst;
75-
bool isStatic = false;
75+
bool isStatic = true;
7676
bool trace;
7777
uint64_t globalBase;
7878
uint64_t initialHeap;

lld/wasm/Driver.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,7 @@ static std::optional<std::string> findFromSearchPaths(StringRef path) {
341341
// search paths.
342342
static std::optional<std::string> searchLibraryBaseName(StringRef name) {
343343
for (StringRef dir : config->searchPaths) {
344-
// Currently we don't enable dynamic linking at all unless -shared or -pie
345-
// are used, so don't even look for .so files in that case..
346-
if (ctx.isPic && !config->isStatic)
344+
if (!config->isStatic)
347345
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".so"))
348346
return s;
349347
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".a"))

lld/wasm/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ multiclass B<string name, string help1, string help2> {
3838
// The following flags are shared with the ELF linker
3939
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
4040

41-
def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries (default)">;
41+
def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
4242

43-
def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
43+
def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries (default)">;
4444

4545
def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;
4646

0 commit comments

Comments
 (0)