Skip to content

Commit 13ecaff

Browse files
committed
Fix WebAssembly build requiring DTB dependencies
The emscripten build for SYSTEM mode embeds build/minimal.dtb via --embed-file in CFLAGS_emcc, but after commit c6638da which fixed DTB compilation to be conditional, the DTB was not being built before the linker tried to embed it. Root cause: The $(BIN) target (linking stage) uses CFLAGS_emcc which contains --embed-file build/minimal.dtb, but had no dependency on the DTB files. Adding DTB to deps_emcc only affects .o file compilation, not the final linking step. Solution: 1. Add $(BUILD_DTB) and $(BUILD_DTB2C) to deps_emcc for .o compilation 2. Add explicit $(BIN) dependency on DTB files for the linking stage 3. Guard both with: CC_IS_EMCC=1 AND SYSTEM=1 AND ELF_LOADER=0 The CC_IS_EMCC guard prevents DTB from being built during `make distclean ENABLE_SYSTEM=1` when CC is not emcc (e.g., macOS workflow running distclean between builds with different compilers). Fixes emscripten build errors: error: build/minimal.dtb@/minimal.dtb does not exist emcc: error: 'file_packager ... --embed build/minimal.dtb ...' failed Fixes macOS workflow regression where `make distclean ENABLE_SYSTEM=1` incorrectly triggered DTB compilation when CC was not emcc.
1 parent c6638da commit 13ecaff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mk/wasm.mk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ $(OUT)/elf_list.js: artifact tools/gen-elf-list-js.py
6565
# used to download all dependencies of elf executable and bundle into single wasm
6666
deps_emcc += artifact $(OUT)/elf_list.js $(DOOM_DATA) $(QUAKE_DATA) $(TIMIDITY_DATA)
6767

68+
# For SYSTEM mode, emscripten needs the DTB file to embed
69+
# DTB is only built when SYSTEM=1 and ELF_LOADER=0
70+
ifeq ("$(CC_IS_EMCC)", "1")
71+
ifeq ($(call has, SYSTEM), 1)
72+
ifeq ($(call has, ELF_LOADER), 0)
73+
# Add DTB as dependency for both compilation and linking
74+
deps_emcc += $(BUILD_DTB) $(BUILD_DTB2C)
75+
# Make the final binary depend on DTB files (for linking stage)
76+
$(BIN): $(BUILD_DTB) $(BUILD_DTB2C)
77+
endif
78+
endif
79+
endif
80+
6881
# check browser version if supports TCO
6982
CHROME_MAJOR :=
7083
CHROME_MAJOR_VERSION_CHECK_CMD :=

0 commit comments

Comments
 (0)