From 579c05feeabceaa3af4044bdeef3e0fe11a49c98 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Wed, 22 Jul 2026 13:59:40 +0000 Subject: [PATCH] build: WASM --embed-file paths per source/build tree (out-of-tree) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Emscripten link embedded data files via magic-relative paths (../scmos, ../windows/...), which only resolve when the build dir is the source dir. Split them by which tree the data lives in: * generated scmos tech files -> ${MAGICDIR}/scmos (the build tree, where `make techs` writes them); * verbatim window glyphs -> ${MAGICSRC}/windows/... (the source tree). Out-of-tree, ../windows/windows7.glyphs pointed at build/windows/ (which holds only objects) and the link would fail to embed it. In-tree the two trees coincide, so the resulting .wasm is unchanged. (Static edit; not runtime-verified — emscripten is not available here.) Co-Authored-By: Claude Opus 4.8 (1M context) --- toolchains/emscripten/defs.mak | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/toolchains/emscripten/defs.mak b/toolchains/emscripten/defs.mak index 95455aed..2f612c72 100644 --- a/toolchains/emscripten/defs.mak +++ b/toolchains/emscripten/defs.mak @@ -26,8 +26,11 @@ MAKE_WASM = 1 LINK = $(LD) -r $(LDFLAGS) # Emscripten linker flags. -# The link step runs from the magic/ subdirectory, so embed-file paths -# are relative to that directory (../scmos, ../windows/...). +# The link step runs from the magic/ build subdirectory. Embed-file inputs +# must name the *right tree*: generated data (the scmos tech files, produced by +# `make techs`) lives in the build tree, so use ${MAGICDIR} (the build top); +# verbatim data (the window glyphs, shipped as source) lives in the source tree, +# so use ${MAGICSRC}. In-tree the two coincide. # # INCOMING_MODULE_JS_API is emscripten's default list plus `wasmBinary`. # Our JS loaders (npm/examples/*.js) pass Module.wasmBinary to embed the .wasm, @@ -52,6 +55,6 @@ TOP_EXTRA_LIBS += \ -sENVIRONMENT=node,web,worker \ -sFORCE_FILESYSTEM=1 \ ${TOP_EXTRA_LIBS_WASM} \ - --embed-file ../scmos@/magic/sys/current \ - --embed-file ../windows/windows7.glyphs@/magic/sys/windows7.glyphs \ - --embed-file ../windows/windows7.glyphs@/magic/sys/bw.glyphs + --embed-file ${MAGICDIR}/scmos@/magic/sys/current \ + --embed-file ${MAGICSRC}/windows/windows7.glyphs@/magic/sys/windows7.glyphs \ + --embed-file ${MAGICSRC}/windows/windows7.glyphs@/magic/sys/bw.glyphs