-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Emscripten: Drop -lc the emcc driver will add it when it is needed #98303
Conversation
According to sbc100, when linking with emcc we shouldn't pass -lc: > your best bet is to remove any/all explicit additions of -lc, since > the compiler driver (emcc) will add it if/when its needed. > (I don't think this is an emscripten bug BTW, but a rustc driver bug) emscripten-core/emscripten#17191 (comment)
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r=compiler-errors,hoodmane |
📌 Commit d565b20 has been approved by |
I haven't investigated the details here, but what this PR does looks really hacky. Why does rustc pass |
@bors r- @petrochenkov do you have concerns about landing this? happy to let this sit for discussion instead of just r+'ing it. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@bors r- |
That does sounds like a more ideal solution. Otherwise the rust driver will be forever playing catchup with the emcc logic as to which default libraries it should link. |
Closing and reopening to bump bors (hopefully). |
Setting |
@sbc100 based on your comment, could Emscripten just always ignore |
😪 I'm awake I'm awake |
It could, but fixing this on the rust side rather makes more sense to me. |
Could you explain why it makes more sense? I honestly have no clue. I lean in favor of modify-Rust over modify-Emscripten because we are building several hundred dynamic Emscripten libraries with ~5 different build systems and Rust is the only one that is passing What does native code do? I guess if I am using symbols from libc, the linker would recognize them as libc symbols and include them automatically? But surely the normal linker wouldn't cause an error if I explicitly pass |
Is that enough to solve your side module linking issue? |
Yup. |
I believe rustc currently assumes that if dynamic libraries are supported, libc itself is dynamically linked. This is true for every other platform afaik. Why is it not true for emscripten? |
That's something strange, emcc is similar to gcc/clang, so So it looks like emscripten targets are already effectively |
How do output kinds with emscripten targets map on rustc's crate types
|
This looks like something reasonable. What exactly should not be linked to side modules, and how can we recognize it automatically?
|
I think I will close this PR and open an issue. Passing |
I will make a PR that uses |
|
Its partly technical, partly historical, and partly based on the peculiarities of the web, but emscrpiten's dynamic linking support is based on the MAIN_MODULE/SIDE_MODULE split with all the system libraries being linked into the main module. Its not ideal but that is the way it works today. |
|
…etrochenkov Update no_default_libraries handling for emscripten target `@sbc100` says: > `-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]` is almost certainly wrong/out-of-date. This setting defaults to the empty list anyway these days so its redundant. Also we now support `-nodefaultlibs` so you can use that, as with other toolchains. rust-lang#98303 (comment)
…etrochenkov Update no_default_libraries handling for emscripten target ``@sbc100`` says: > `-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]` is almost certainly wrong/out-of-date. This setting defaults to the empty list anyway these days so its redundant. Also we now support `-nodefaultlibs` so you can use that, as with other toolchains. rust-lang#98303 (comment)
…etrochenkov Update no_default_libraries handling for emscripten target ```@sbc100``` says: > `-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]` is almost certainly wrong/out-of-date. This setting defaults to the empty list anyway these days so its redundant. Also we now support `-nodefaultlibs` so you can use that, as with other toolchains. rust-lang#98303 (comment)
…chenkov Implement set_output_kind for Emscripten linker This is on top of rust-lang#98149. See also the earlier discussion on rust-lang#98303. With this PR, a crate that specifies that it is a cdylib will compile to a working Emscripten dynamic library without adding any extra cargo, rustc, or linker flags and without fiddling with environment variables. `@sbc100` r? `@petrochenkov`
…chenkov Implement set_output_kind for Emscripten linker This is on top of rust-lang#98149. See also the earlier discussion on rust-lang#98303. With this PR, a crate that specifies that it is a cdylib will compile to a working Emscripten dynamic library without adding any extra cargo, rustc, or linker flags and without fiddling with environment variables. `@sbc100` r? `@petrochenkov`
See: emscripten-core/emscripten#22742 emscripten-core/emscripten#16680 rust-lang/rust#98155 rust-lang/rust#98303 rust-lang/rust#131885 (backport <rust-lang#4002>) (cherry picked from commit 66e3665)
According to @sbc100, when linking with emcc we shouldn't pass -lc:
emscripten-core/emscripten#17191 (comment)
Resolves #98155.