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

Ensure system libraries are built on demand #19405

Merged
merged 1 commit into from
May 22, 2023

Conversation

kleisauke
Copy link
Collaborator

Previously, when explicitly linking against a system library (e.g. -lc) that had not been built earlier, wasm-ld would raise an error indicating that the library could not be found.

Use the get_link_flag() function to ensure that it triggers a build if the system library is not present in the cache.


Previous behavior:

$ emcc --clear-cache
$ emcc test/hello_world.c -pthread -nodefaultlibs -lc -lbulkmemory -lcompiler_rt -lmalloc
...
wasm-ld: error: unable to find library -lc-mt-debug
wasm-ld: error: unable to find library -lbulkmemory
wasm-ld: error: unable to find library -lcompiler_rt-mt
wasm-ld: error: unable to find library -ldlmalloc-mt

New behavior:

$ emcc --clear-cache
$ emcc test/hello_world.c -pthread -nodefaultlibs -lc -lbulkmemory -lcompiler_rt -lmalloc
...
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libc-mt-debug.a...
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libbulkmemory.a...
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libcompiler_rt-mt.a...
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libdlmalloc-mt.a...

Previously, when explicitly linking against a system library (e.g.
`-lc`) that had not been built earlier, wasm-ld would raise an error
indicating that the library could not be found.

Use the `get_link_flag()` function to ensure that it triggers a
build if the system library is not present in the cache.
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks.

@sbc100 sbc100 merged commit b76fdf4 into emscripten-core:main May 22, 2023
@kleisauke kleisauke deleted the build-system-lib-on-demand branch May 23, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants