From 483f74330466b6db509ab7abe86ebb258e650564 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 8 Jan 2022 11:16:57 -0500 Subject: [PATCH] fix some libnh wasm build issues emcc: error: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument] [-Werror] make[1]: *** [Makefile:1306: ../targets/wasm/allmain.o] Error 1 wasm-ld: error: ../targets/wasm/version.o: undefined symbol: nomakedefs These ones look like actual NetHack issues that this particular compile is catching due to default -Wunused-but-set-variable. In the interest of time today, I mostly resorted to using nhUse() on them for now, but a follow-up by someone might be useful. options.c:6069:13: error: variable 'ret' set but not used [-Werror,-Wunused-but-set-variable] boolean ret = FALSE; ^ restore.c:903:9: error: variable 'len' set but not used [-Werror,-Wunused-but-set-variable] int len = 0; ^ uhitm.c:4539:43: error: variable 'nsum' set but not used [-Werror,-Wunused-but-set-variable] int i, tmp, armorpenalty, sum[NATTK], nsum = MM_MISS, ^ --- src/options.c | 2 ++ src/restore.c | 1 + src/uhitm.c | 7 +++++++ sys/unix/hints/include/cross-post.370 | 4 ++-- sys/unix/hints/include/cross-pre.370 | 18 ++++++++++-------- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/options.c b/src/options.c index a2c73e215..1b02cd8bb 100644 --- a/src/options.c +++ b/src/options.c @@ -6074,6 +6074,8 @@ parsebindings(char *bindings) ret |= parsebindings(bind); } + nhUse(ret); + /* parse a single binding: first split around : */ if (! (bind = index(bindings, ':'))) return FALSE; /* it's not a binding */ diff --git a/src/restore.c b/src/restore.c index 03b480201..65e23480c 100644 --- a/src/restore.c +++ b/src/restore.c @@ -927,6 +927,7 @@ rest_stairs(NHFILE* nhfp) if (newst) newst->u_traversed = stway.u_traversed; } + nhUse(len); /* unclear why this variable exists though */ } void diff --git a/src/uhitm.c b/src/uhitm.c index d6851c210..429f43a8e 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -4541,6 +4541,13 @@ hmonas(struct monst *mon) int dieroll, multi_claw = 0; boolean monster_survived; + /* FIXME: One compiler was getting a fatal + variable nsum set but not used [-Werror,-Wunused-but-set-variable] + For now, I'm working around it with nhUse() but it should be + investigated when someone has the time. + */ + nhUse(nsum); + /* not used here but umpteen mhitm_ad_xxxx() need this */ g.vis = (canseemon(mon) || distu(mon->mx, mon->my) <= 2); diff --git a/sys/unix/hints/include/cross-post.370 b/sys/unix/hints/include/cross-post.370 index 3491e9d47..72be3ec6a 100644 --- a/sys/unix/hints/include/cross-post.370 +++ b/sys/unix/hints/include/cross-post.370 @@ -42,10 +42,10 @@ dospkg: $(GAMEBIN) $(TARGETPFX)recover.exe ../dat/nhtiles.bmp endif # CROSS_TO_MSDOS ifdef CROSS_TO_WASM -$(WASM_TARGET): pregame $(HOSTOBJ) $(HOBJ) $(LUACROSSLIB) $(WASM_DATA_DIR) +$(WASM_TARGET): pregame $(TARGETPFX)date.o $(HOSTOBJ) $(HOBJ) $(LUACROSSLIB) $(WASM_DATA_DIR) -rm $@ $(TARGET_CC) $(TARGET_LFLAGS) $(TARGET_CFLAGS) -o $@ \ - $(HOBJ) $(TARGET_LIBS) + $(HOBJ) $(TARGETPFX)date.o $(TARGET_LIBS) $(WASM_DATA_DIR): $(WASM_DATA_DIR)/nhdat touch $(WASM_DATA_DIR)/perm diff --git a/sys/unix/hints/include/cross-pre.370 b/sys/unix/hints/include/cross-pre.370 index 14a870c76..15986b813 100644 --- a/sys/unix/hints/include/cross-pre.370 +++ b/sys/unix/hints/include/cross-pre.370 @@ -232,21 +232,23 @@ EMCC_CFLAGS += -Wall EMCC_CFLAGS += -Werror EMCC_CFLAGS += -DNO_SIGNAL #EMCC_CFLAGS += -s DISABLE_EXCEPTION_CATCHING=0 -#EMCC_DEBUG_CFLAGS += -s ASSERTIONS=1 -EMCC_DEBUG_CFLAGS += -s ASSERTIONS=2 -EMCC_DEBUG_CFLAGS += -s STACK_OVERFLOW_CHECK=2 -EMCC_DEBUG_CFLAGS += -s SAFE_HEAP=1 -EMCC_DEBUG_CFLAGS += -s LLD_REPORT_UNDEFINED=1 -EMCC_DEBUG_CFLAGS += -s EXCEPTION_DEBUG=1 +EMCC_DEBUG_LFLAGS += -s ASSERTIONS=1 +EMCC_DEBUG_LFLAGS += -s ASSERTIONS=2 +EMCC_DEBUG_LFLAGS += -s STACK_OVERFLOW_CHECK=2 +EMCC_DEBUG_LFLAGS += -s SAFE_HEAP=1 +EMCC_DEBUG_LFLAGS += -s LLD_REPORT_UNDEFINED=1 +EMCC_DEBUG_LFLAGS += -s EXCEPTION_DEBUG=1 #EMCC_DEBUG_CFLAGS += -fsanitize=undefined -fsanitize=address -fsanitize=leak -EMCC_DEBUG_CFLAGS += -s NO_EXIT_RUNTIME +EMCC_DEBUG_LFLAGS += -s NO_EXIT_RUNTIME # XXX: if --profiling isn't included then any error dumps 10MB of WASM to the screen rather than a useful message -EMCC_DEBUG_CFLAGS += --profiling +EMCC_DEBUG_LFLAGS += --profiling EMCC_PROD_CFLAGS += -O3 ifdef WASM_DEBUG EMCC_CFLAGS += $(EMCC_DEBUG_CFLAGS) +EMCC_LFLAGS += $(EMCC_DEBUG_LFLAGS) else EMCC_CFLAGS += $(EMCC_PROD_CFLAGS) +EMCC_LFLAGS += $(EMCC_PROD_LFLAGS) endif # # Override the build tools and some obj files to