wasm: emit debugging symbol source-map by default

This commit is contained in:
Darryl L. Miles 2026-07-20 12:04:01 +01:00 committed by R. Timothy Edwards
parent 665f65d61f
commit adf5457eca
4 changed files with 32 additions and 5 deletions

View File

@ -60,9 +60,9 @@ ifneq (${TCL_LIB_DIR},)
# the stub-bootstrap archive (-ltclstub). Both are required: magic's objects
# use USE_TCL_STUBS macros (resolved by tclStubsPtr from libtclstub.a), and
# tclStubsPtr itself must point into the real TCL implementation (libtcl9.x.a).
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS} ${LIB_SPECS_NOSTUB} -L${TCL_LIB_DIR} -ltclstub
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${LDFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS} ${LIB_SPECS_NOSTUB} -L${TCL_LIB_DIR} -ltclstub
else
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS}
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${LDFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS}
endif
endif

View File

@ -95,8 +95,21 @@ sed_strip_cr() {
if [ $OPT_RELEASE -eq 1 ]; then
EXTRA_CFLAGS="-O2"
EXTRA_LDFLAGS=""
else
EXTRA_CFLAGS="-g"
EXTRA_LDFLAGS="-gsource-map"
# Exists to document some options maybe placement sensitive on linker command
# line and need to appear first.
# See toolchains/emscripten/defs.mak this is just picked up from the environment during make
#export TOP_FIRST_LIBS_WASM="-g3 -fsanitize=address"
# Exists to document maybe you need both these to get the intended effect
# but expect the performance hit / larger codegen at runtime when you do.
# See toolchains/emscripten/defs.mak this is just picked up from the environment during make
#EXTRA_CONFIGURE_ARGS="--enable-assertions"
#export TOP_EXTRA_LIBS_WASM="-sASSERTIONS=1" # emscripten default value: 1
fi
# --- TCL fork: clone and prebuild (TCL variant only) ------------------------
@ -163,6 +176,7 @@ build_variant() {
if [ "$variant" = "tcl" ]; then
ensure_tcl_built
CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1 ${EXTRA_CFLAGS}" \
LDFLAGS="${EXTRA_LDFLAGS}" \
emconfigure ./configure \
--without-cairo --without-opengl --without-x --without-tk \
--with-tcl="$TCL_WASM_PREFIX/lib" \
@ -170,19 +184,27 @@ build_variant() {
--with-tcllibs="$TCL_WASM_PREFIX/lib" \
--disable-readline --disable-compression \
--host=asmjs-unknown-emscripten \
--target=asmjs-unknown-emscripten
--target=asmjs-unknown-emscripten \
${EXTRA_CONFIGURE_ARGS:-}
else
CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1 ${EXTRA_CFLAGS}" \
LDFLAGS="${EXTRA_LDFLAGS}" \
emconfigure ./configure \
--without-cairo --without-opengl --without-x \
--without-tk --without-tcl \
--disable-readline --disable-compression \
--host=asmjs-unknown-emscripten \
--target=asmjs-unknown-emscripten
--target=asmjs-unknown-emscripten \
${EXTRA_CONFIGURE_ARGS:-}
fi
cat toolchains/emscripten/defs.mak >> defs.mak
#
echo "===== defs.mak ====="
cat defs.mak
echo "===== defs.mak ====="
emmake make depend
emmake make -j"$(ncpu)" modules libs
emmake make techs
@ -191,6 +213,7 @@ build_variant() {
mkdir -p "$out_dir"
cp magic/magic.js "$out_dir/"
cp magic/magic.wasm "$out_dir/"
test -f magic/magic.wasm.map && cp magic/magic.wasm.map "$out_dir/"
echo "Copied magic.js + magic.wasm into npm/$variant/"
}

View File

@ -17,8 +17,10 @@
"notcl.js",
"tcl/magic.js",
"tcl/magic.wasm",
"tcl/magic.wasm.map",
"notcl/magic.js",
"notcl/magic.wasm",
"notcl/magic.wasm.map",
"examples/",
"LICENSE",
"README.md"

View File

@ -4,6 +4,7 @@
#
# source <emsdk>/emsdk_env.sh
# CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1 -g" \
# LDFLAGS="-gsource-maps" \
# emconfigure ./configure --without-cairo --without-opengl --without-x \
# --without-tk --without-tcl \
# --disable-readline --disable-compression \
@ -30,6 +31,7 @@ MAKE_WASM = 1
# consumers passing locateFile/arguments/etc. keep working) and re-add
# wasmBinary. Keep this in sync with emscripten's default if it grows.
TOP_EXTRA_LIBS += \
${TOP_FIRST_LIBS_WASM} \
-sWASM=1 \
-sMODULARIZE=1 \
-sEXPORT_ES6=1 \
@ -40,9 +42,9 @@ TOP_EXTRA_LIBS += \
-sALLOW_MEMORY_GROWTH=1 \
-sINITIAL_MEMORY=67108864 \
-Wl,-z,stack-size=10485760 \
-sASSERTIONS=1 \
-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