Skip to content

[lld][WebAssembly] Always search *.so for -Bdynamic #84288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lld/wasm/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ struct Configuration {
bool stripAll;
bool stripDebug;
bool stackFirst;
bool isStatic = false;
// Because dyamanic linking under Wasm is still experimental we default to
// static linking
bool isStatic = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a comment: "Because dyamanic linking under Wasm is still experimental we default to static linking"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

bool trace;
uint64_t globalBase;
uint64_t initialHeap;
Expand Down
8 changes: 5 additions & 3 deletions lld/wasm/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,7 @@ static std::optional<std::string> findFromSearchPaths(StringRef path) {
// search paths.
static std::optional<std::string> searchLibraryBaseName(StringRef name) {
for (StringRef dir : config->searchPaths) {
// Currently we don't enable dynamic linking at all unless -shared or -pie
// are used, so don't even look for .so files in that case..
if (ctx.isPic && !config->isStatic)
if (!config->isStatic)
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".so"))
return s;
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".a"))
Expand Down Expand Up @@ -556,6 +554,10 @@ static void readConfigs(opt::InputArgList &args) {
config->zStackSize =
args::getZOptionValue(args, OPT_z, "stack-size", WasmPageSize);

// -Bdynamic by default if -pie or -shared is specified.
if (config->pie || config->shared)
config->isStatic = false;

if (config->maxMemory != 0 && config->noGrowableMemory) {
// Erroring out here is simpler than defining precedence rules.
error("--max-memory is incompatible with --no-growable-memory");
Expand Down
4 changes: 2 additions & 2 deletions lld/wasm/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ multiclass B<string name, string help1, string help2> {
// The following flags are shared with the ELF linker
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;

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

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

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

Expand Down