a308ea38f3 Emscripten: Fix try_run to run the `.js` file and not the adjacent `.wasm`
ad91bc558a ci: Make node available to Emscripten tests
27cc5d58bf Tests/RunCMake/Emscripten: Add tests covering try_compile COPY_FILE
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11451
Since commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16,
v4.2.0-rc1~607^2~3) we've considered the `.wasm` to be the `try_compile`
output because we need `COPY_FILE` to get it for extracting `INFO:`
strings during our inspection checks. This breaks `try_run` because
`node`, used via `CMAKE_CROSSCOMPILING_EMULATOR`, expects the `.js`.
Revert to considering the `.js` to be the primary output file, but
switch to the `.wasm` in `COPY_FILE`'s implementation.
Fixes: #27421
Compiler inspection relies on `try_compile`'s `COPY_FILE` option to copy
the `.wasm` file because the `.js` does not have the `INFO:size` string.
Issue: #27421
In commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16,
v4.2.0-rc1~607^2~3) this flag was added as part of an attempt to support
shared libraries without requiring projects to set much themselves. That
attempt was reverted by commit d361bf365e (Emscripten: Drop hard-coded
-sMAIN_MODULE and -sSIDE_MODULE flags, 2025-09-18, v4.2.0-rc1~146^2).
Also avoid hard-coding `-fPIC`. `POSITION_INDEPENDENT_CODE` is already
enabled for shared library targets. Projects can enable it themselves
where `-fPIC` is needed outside of shared libraries.
Fixes: #27424
Issue: #27240
These flags are only needed for builds involving shared libraries,
and can cause undesirable behavior when they are not needed.
They also have variants with values like `=2`. For now, just require
projects to add the flags when needed so they have full control.
In the future we may be able to add an abstraction to control them,
and automatically enable them when linking to shared libraries
or creating them.
Fixes: #27232
Issue: #27240
LLD automatically resolves newly encountered symbols using object files
previously encountered. Also, the Emscripten compiler driver invokes
the LLD linker with `--whole-archive ... --no-whole-archive` around all
the libraries. Therefore we should not repeat any.
Issue: #27232
Suggested-by: Marc Chevrier <marc.chevrier@gmail.com>