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

Don't pass -lc to Emscripten, it breaks #4002

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

hoodmane
Copy link
Contributor

@hoodmane hoodmane commented Nov 1, 2024

Before this patch,

echo "fn main(){}" > a.rs
rustc -Copt-level=z a.rs -o a.js --target=wasm32-unknown-emscripten

fails with:

error: undefined symbol: _emscripten_memcpy_js (referenced by root reference (e.g. compiled C/C++ code))
warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: __emscripten_memcpy_js may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/home/rchatham/Documents/programming/emsdk/node/18.20.3_64bit/bin/node /home/rchatham/Documents/programming/emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmpogw1glcz.json' failed (returned 1)          

There are quite a few other sets of linker arguments that trigger this problem, but this is the shortest. Applying this patch to rust-libc and overriding the version of libc used in library/Crates.toml to use the patched version, I have verified locally that the crash goes away.

See:
emscripten-core/emscripten#22742
emscripten-core/emscripten#16680
rust-lang/rust#98155
rust-lang/rust#98303
rust-lang/rust#131885

cc @workingjubilee @sbc100

@rustbot
Copy link
Collaborator

rustbot commented Nov 1, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Nov 1, 2024
@tgross35 tgross35 added this pull request to the merge queue Nov 1, 2024
Merged via the queue into rust-lang:main with commit 9ab13fd Nov 1, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants