Skip to content

Commit

Permalink
Do not pass -lc to the Emscripten linker
Browse files Browse the repository at this point in the history
Hack: drop -lc to work around buggy Emscripten behaviors when -lc
is passed. This can be removed when the problems are resolved in Emscripten and
we drop support for the currently existing versions of Emscripten.
See
emscripten-core/emscripten#22758

Unblocks
#131736
  • Loading branch information
hoodmane committed Oct 18, 2024
1 parent 06d261d commit 2f6f2b2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,21 @@ impl<'a> Linker for EmLinker<'a> {
}

fn link_staticlib_by_name(&mut self, name: &str, _verbatim: bool, _whole_archive: bool) {
if name == "c" {
// Hack: drop -lc to work around buggy Emscripten behaviors when -lc
// is passed. See
// https://github.com/emscripten-core/emscripten/issues/22758
//
// Question: Does this bug affect any other libraries? Why this
// special case for libc?
//
// Answer: We think it's specific to libc. Emscripten can link
// binaries with many different ABIs and it has to build an
// appropriate libc depending on the target ABI. Passing -lc
// explicitly causes bugs in this process. If we find out other
// libraries are affected, we can reevaluate this approach.
return;
}
self.link_or_cc_args(&["-l", name]);
}

Expand Down

0 comments on commit 2f6f2b2

Please sign in to comment.