Skip to content
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

driver/linker-gcc.cpp: Don't pass -rpath to linker on wasm targets #4849

Merged
merged 1 commit into from
Mar 3, 2025
Merged
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
7 changes: 4 additions & 3 deletions driver/linker-gcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void ArgsBuilder::addCppStdlibLinkFlags(const llvm::Triple &triple) {
void ArgsBuilder::addObjcStdlibLinkFlags(const llvm::Triple &triple) {
if (linkNoObjc)
return;

args.push_back("-lobjc");
}

Expand Down Expand Up @@ -613,7 +613,8 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
}

// -rpath if linking against shared default libs or ldc-jit
if (linkAgainstSharedDefaultLibs() || opts::enableDynamicCompile) {
if ((linkAgainstSharedDefaultLibs() || opts::enableDynamicCompile)
&& !triple.isOSBinFormatWasm()) { // wasm-ld doesn't recognize -rpath
Copy link
Member

Choose a reason for hiding this comment

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

Really needed? wasm will most likely never support shared druntime/Phobos, nor dynamic-compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passing -link-defaultlib-shared when compiling with -defaultlib= or -betterC still passes -rpath making it fail. + it makes #4848 fail because I no longer strip the -link-defaultlib-shared that comes from -DBUILD_SHARED_LIBS=... in the wasm switches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course I could add it back but it seems more reasonable to ignore -link-defaultlib-shared, in my opinion at least

llvm::StringRef rpath = ConfigFile::instance.rpath();
if (!rpath.empty())
addLdFlag("-rpath", rpath);
Expand Down Expand Up @@ -745,7 +746,7 @@ void ArgsBuilder::addDefaultPlatformLibs() {
}

if (triple.isOSDarwin()) {

// libobjc is more or less required, so we link against it here.
// This could be prettier, though.
addObjcStdlibLinkFlags(triple);
Expand Down
Loading