emscripten-core / emscripten-core/emscripten
Proposal: Reduce emcc sanity checking Background
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 109
Description
Emscripten currently runs a sanity check on startup. The purpose of this is two-fold:
1. To warn the user of they are using incompatible version of node/clang
2. To automatically clear the cache if anything changes about the current setup
This check works fairly well but it does have a cost. The most significant of which is that it requires the running of `clang –version` and `node –version` for every compiler invocation.
This proposal is specifically about dropping the check that happens automatically during startup. The explicit sanity check via `--check` can be considered separately.
The sanity check currently performs the following actions:
1. Check llvm version
2. Check llvm for wasm backend support
3. Check node version
4. Check node can run hello world
# Utility
For most users, especially those that use emsdk neither (1) nor (2) are useful since emsdk updates everything atomically. The cache is not preserved between updates and never needs clearing. Therefore it should be impossible for an emsdk user to experience a failed sanity check.
For emscripten developers there is also very little utility here. The llvm version changes very infrequently (~6 months), and breaking changes that might require the cache to be cleared don’t align nicely with version bumps (they happen at some point during a release.. Not once it ships). Another downside of automatically clearing the cache is that it's very conservative. It currently happens whenever the hash of the con.fig file changes. This can be annoying, for example, if a developer modifies the path to a JS engine in the config file, which doesn’t affect the cache.
# Possible Improvements
1. Remove the checks
This would not affect emsdk users but would mean the emscripten developers and those using emscripten directly from source control might not realize they were using the wrong llvm version.
In this case it would be up to the developer to explicitly clear the cache using `--clear-cache` when a breaking llvm change occurs. This seems reasonable since developers already need to explicitly clear the cache when system libraries change (which is much more frequent and the llvm object format changing).
2. Disable sanity checks for emsdk users
This seems like a very safe solution since non-emsdk user’s would not be affected. The downside would be one more way in which using emsdk differs from emscripten during development. I would also limit the potential speedups to just emsdk users.
3. Do sanity checks at link time only
Most compiler invocations don't run the linker, and the linker tends to have a lot more subprocess that it is already running. Doing the sanity check when linking only seems like a good compromise. We could combine it with (a) and still allow emsdk to opt out completely.
4. Move node checks to link time (the only time node is needed)
We already do this for binaryen. Essentially checking at time of first use.
Contributor guide
Assessment
This issue has not been assessed yet.