Skip to content

Comments

Fix emscripten build warnings#247

Open
justjake wants to merge 5 commits intomainfrom
fix-emcc-warnings
Open

Fix emscripten build warnings#247
justjake wants to merge 5 commits intomainfrom
fix-emcc-warnings

Conversation

@justjake
Copy link
Owner

Summary

  • Separate compiler flags (CFLAGS_COMPILE) from linker flags (LDFLAGS_WASM) to eliminate ~160+ warnings about linker settings being ignored during compilation
  • Fix malformed -s -lccall.js flag (changed to -lccall.js)
  • Move MIN_NODE_VERSION to node-specific targets only
  • Add -Wno-js-compiler to suppress HEAPU8 export warnings
  • Only add -gsource-map for debug builds with separate wasm files (incompatible with SINGLE_FILE)
  • Exclude trivial functions from asyncify-remove list that get optimized away by LTO
  • Remove unused HEAP types, keep only HEAPU8 which is actually used

Test plan

  • Full clean build completes without warnings
  • All 69 tests pass

🤖 Generated with Claude Code

justjake and others added 5 commits February 16, 2026 10:43
Refactored the Emscripten build system to properly separate compiler flags
(used during .c -> .o compilation) from linker flags (used during .o -> .js
linking). This eliminates hundreds of "linker setting ignored during
compilation" warnings.

Changes:
- Split CFLAGS_WASM into CFLAGS_COMPILE and LDFLAGS_WASM in templates/Variant.mk
- Split flag constants in scripts/prepareVariants.ts into *CompileFlags and
  *LinkFlags variants
- Fixed malformed `-s -lccall.js` flag to `-lccall.js`
- Moved MIN_NODE_VERSION and NODEJS_CATCH_EXIT to node-specific targets only
- Added scripts/validate-emcc-flags.ts for testing flag classification

Compiler flags (CFLAGS_COMPILE): optimization (-Oz, -O0, -flto), defines
(-DQTS_DEBUG_MODE, etc.), debug info (-gsource-map), sanitizers (-fsanitize)

Linker flags (LDFLAGS_WASM): -s settings (MODULARIZE, ENVIRONMENT, etc.),
--closure, --pre-js, library flags (-lccall.js, -lasync.js)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add -Wno-js-compiler to suppress HEAPU8/HEAP8 warnings (these exports
  are needed but marked "invalid" by emscripten)
- Only add -gsource-map for debug builds with separate wasm files
  (source maps are incompatible with SINGLE_FILE mode)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These functions (QTS_BuildIsSanitizeLeak, QTS_BuildIsDebug, QTS_TestStringArg)
are so simple they get inlined/eliminated by LTO, causing Asyncify warnings
about non-existing functions. Since they can't call async code anyway, there's
no need to include them in the removelist.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove HEAP8 and other unused HEAP types from emscripten exports
- Update context.ts to use HEAPU8.buffer instead of HEAP8.buffer
- Remove unused heap type definitions from emscripten-types.ts
- Add QTS_RecoverableLeakCheck and QTS_GetDebugLogEnabled to asyncify exclusion list

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant