Implement native clang launcher#27401
Conversation
198f9c8 to
c5fd0d6
Compare
c5fd0d6 to
3d058e6
Compare
470205f to
bac6b35
Compare
|
Here are some high level comments:
|
06b94ef to
9fec6c9
Compare
9fec6c9 to
b5f76dc
Compare
9ac1ab1 to
c94e316
Compare
0abdc68 to
b7f2e37
Compare
|
Benchmark results for are in.. libc builds are much faster on all platforms! Yay |
|
I think once we land this and we start using it everywhere we can just remove the old shell/bat/ps1/pylauncher launchers. |
b7f2e37 to
f9bb2cb
Compare
3a2cafc to
ac011fa
Compare
Implement Phase 1 of the native launcher design document. Provides high-performance native C++ compiler drivers (emcc, em++) using C++20 that directly invoke Clang for compile steps (-c, -S, -E) and seamlessly fall back to python (emcc.py / em++.py) for link steps or complex post-processing options. Output executables are placed in ./bin using CMake and Ninja. Adds CI matrix testing for Linux, macOS, and Windows. These new binaries are currently 100% optional and the python versions can still be used without building them. Tested using `embuilder build libc --force` on Linux CI (compiling 1,075 files sequentially with `EMCC_CORES=1`, `EMCC_USE_NINJA=0`, and `EMCC_BATCH_BUILD=0`): | Metric | Before (Python Baseline) | After (Native Launcher) | Improvement | | :--- | :---: | :---: | :---: | | **Total Time** | **181.96 s** (3m 2s) | **64.82 s** (1m 5s) | **-117.14 s (64.4% faster)** | | **Time per File** | 169.3 ms | 60.3 ms | **-109.0 ms / invocation** | | **Speedup Factor** | 1.0x | **2.81x** | — | **Key Takeaways:** * **64.4% Reduction in Build Time:** Bypassing Python interpreter startup shaves off **~109.0 ms of overhead per compiler invocation** on Linux CI (a **2.81x speedup**). * **Windows Impact:** Because process spawning and `python.exe` startup carry significantly higher overhead on Windows than on Linux, the percentage speedup on Windows CI is expected to be even larger. See: emscripten-core#26453
ac011fa to
bc1e09d
Compare
| return f.startswith(('-l', '-sEXPORT_ES6', '-sGL_TESTING', '-sPROXY_TO_PTHREAD', | ||
| '-sENVIRONMENT=', '--pre-js=', '--post-js=', '-sPTHREAD_POOL_SIZE=', | ||
| '--profiling-funcs')) | ||
| '--profiling-funcs', '--closure')) |
There was a problem hiding this comment.
This code seems unrelated, or am I not seeing it?
|
|
||
| namespace emscripten { | ||
|
|
||
| inline const std::unordered_set<std::string> LINK_ONLY_FLAGS = { |
There was a problem hiding this comment.
These can use std::string_view instead of std::string, and can be backed by the static C strings used in the initializers.
Gemini suggested even going further and using std::array instead of unordered_set, keeping them sorted, and use std::binary_search for the lookups. Not sure that's worth it though, it seems error-prone.
|
|
||
| } // namespace | ||
|
|
||
| void test_config_parsing() { |
There was a problem hiding this comment.
I guess another advantage if we eventually move to building this against LLVM is that we could use gtest.
| add_executable(native_tests tests/test_native.cpp) | ||
| target_link_libraries(native_tests PRIVATE native_launcher_lib) | ||
|
|
||
| add_test(NAME native_tests COMMAND native_tests) |
There was a problem hiding this comment.
we should verify that even when CMake is configured in release mode, that the tests don't get compiled with -DNDEBUG because they are using raw assert(). We'd silently be just not testing anything!
Implement Phase 1 of the native launcher design document. Provides
high-performance native C++ compiler drivers (
emcc,em++) using C++20that directly invoke Clang for compile steps (-c, -S, -E) and seamlessly
fall back to python (
emcc.py/em++.py) for link steps or complexpost-processing options.
Output executables are placed in
./binusing CMake and Ninja. Adds CImatrix testing for Linux, macOS, and Windows.
These new binaries are currently 100% optional and the python versions
can still be used without building them.
Tested using
embuilder build libc --force(compiling 1,075files sequentially with
EMCC_CORES=1,EMCC_USE_NINJA=0, andEMCC_BATCH_BUILD=0). Note that this is likely an outlier sinceits perfectly suited to demonstrating to speedup from this change (i.e.
lots of small source files and no linking).
See: #26453