-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Undefined symbol _emscripten_memcpy_js linking no object files with -lc
#22758
Comments
-sWASM_BIGINT
emcc -lc -sDISABLE_EXCEPTION_CATCHING=0 -sWASM_BIGINT
emcc -lc -sDISABLE_EXCEPTION_CATCHING=0 -sWASM_BIGINT
-lc
-lc
-lc
It seems that it fails with |
So together
I guess the bug is the fact that |
Clearing out |
Yes, it seems that I believe what is happening is that libbulkmemory is designed to always come before libc so that it can override functiosn in libc, but when you explicitly add libc its putting libc first: emscripten/tools/system_libs.py Lines 2361 to 2369 in f6ed386
Using this technique of overriding libc function always us to ship fewer versions of libc as a whole, but does run into this kind of issue. I'm not sure what the best fix is yet... |
Should we perhaps just a very hacky and ignore explictly |
Right, so injecting the system libs ahead of the other link flag makes the error go away: --- a/tools/link.py
+++ b/tools/link.py
@@ -1850,7 +1850,7 @@ def phase_calculate_system_libraries(linker_arguments, newargs):
# Ports are always linked into the main module, never the side module.
extra_files_to_link += ports.get_libs(settings)
extra_files_to_link += system_libs.calculate(newargs)
- linker_arguments.extend(extra_files_to_link)
+ linker_arguments[0:0] = extra_files_to_link Also this works: --- a/tools/link.py
+++ b/tools/link.py
@@ -2761,6 +2761,8 @@ def process_libraries(state, linker_inputs):
new_flags.append((i, flag))
continue
lib = removeprefix(flag, '-l')
+ if lib == "c":
+ continue
logger.debug('looking for library "%s"', lib) What about if someone passes |
There have been a lot of bugs when the caller passes `-lc` over the years. For example it crashes if we do: ``` emcc -lc -sDISABLE_EXCEPTION_CATCHING=0 -sMIN_SAFARI_VERSION=150000 ``` Rust likes to pass `-lc`. Let's drop it and stop causing trouble for Rust. Resolves emscripten-core#22758, emscripten-core#22742 and would have resolved emscripten-core#16680 if it hadn't disappeared first.
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 rust-lang#131736
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 rust-lang#131736
Edit: To reproduce doesn't require any rust at all:
Similar bug to #22742. If you remove either
-lc
or-sWASM_BIGINT
from the link command the error goes away.Version of emscripten/emsdk:
Failing command line in full:
Full link command and output with
-v
appended:Link command:
Output:
The text was updated successfully, but these errors were encountered: