Skip to content

[cmake] Use STATIC_LIBRARY in CheckTypeSize.cmake - #27934

Merged
sbc100 merged 2 commits into
emscripten-core:mainfrom
sbc100:fix-checktypesize-shared-memory
Oct 9, 2026
Merged

sbc100 merged 2 commits into
emscripten-core:mainfrom
sbc100:fix-checktypesize-shared-memory

Conversation

@sbc100

@sbc100 sbc100 commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #22304.

Instead of linking an executable with --oformat=wasm or
--oformat=bare, set CMAKE_TRY_COMPILE_TARGET_TYPE to
STATIC_LIBRARY so try_compile only compiles and archives the object
file without running the linker.

Pass -fno-lto so that even when -flto is present in CFLAGS, a
standard Wasm object file (containing the plain ASCII INFO:size[...]
string) is emitted rather than LLVM bitcode.

Also add -sWASM_WORKERS, -sEXIT_RUNTIME, and -flto coverage to
test_cmake_check_type_size.

Fixes: #27932

@sbc100
sbc100 force-pushed the fix-checktypesize-shared-memory branch from 30651d7 to c4845a9 Compare October 9, 2026 05:24
@sbc100
sbc100 marked this pull request as ready for review October 9, 2026 05:31
@sbc100
sbc100 requested a review from kripken October 9, 2026 05:31
Comment thread cmake/Modules/CheckTypeSize.cmake Outdated
m4burns and others added 2 commits October 9, 2026 14:07
Supersedes emscripten-core#22304.

Instead of linking an executable with `--oformat=wasm` or
`--oformat=bare`, set `CMAKE_TRY_COMPILE_TARGET_TYPE` to
`STATIC_LIBRARY` so `try_compile` only compiles and archives the object
file without running the linker.

Pass `-fno-lto` so that even when `-flto` is present in `CFLAGS`, a
standard Wasm object file (containing the plain ASCII `INFO:size[...]`
string) is emitted rather than LLVM bitcode.

Also add `-sWASM_WORKERS`, `-sEXIT_RUNTIME`, and `-flto` coverage to
`test_cmake_check_type_size`.

Fixes: emscripten-core#27932
@sbc100

sbc100 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

Ok, I re-worked to avoid --oformat and instead just linked a static lib

@sbc100
sbc100 requested a review from kripken October 9, 2026 21:07
@sbc100
sbc100 force-pushed the fix-checktypesize-shared-memory branch from c4845a9 to c0b8fa3 Compare October 9, 2026 21:08
@sbc100 sbc100 changed the title [cmake] Fix CheckTypeSize when using --oformat=wasm-incompatible flags [cmake] Use STATIC_LIBRARY in CheckTypeSize.cmake Oct 9, 2026
@sbc100
sbc100 enabled auto-merge (squash) October 9, 2026 21:50
@sbc100
sbc100 disabled auto-merge October 9, 2026 23:07
@sbc100
sbc100 merged commit ac0c905 into emscripten-core:main Oct 9, 2026
19 of 23 checks passed
@sbc100
sbc100 deleted the fix-checktypesize-shared-memory branch October 9, 2026 23:07
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.

CheckTypeSize fails when -sEXIT_RUNTIME=1 is in LDFLAGS

3 participants