From a482d4ada84d6a1036d046f5f1fa97c68a86a4da Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Wed, 7 Aug 2019 18:33:15 -0400 Subject: [PATCH 1/3] Fix issues with Makefile --- ports/javascript/Makefile | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/ports/javascript/Makefile b/ports/javascript/Makefile index b9ca948c0..6443a92d3 100644 --- a/ports/javascript/Makefile +++ b/ports/javascript/Makefile @@ -6,9 +6,6 @@ QSTR_DEFS = qstrdefsport.h include $(TOP)/py/py.mk -CC = emcc -LD = emcc - INC += -I. INC += -I$(TOP) INC += -I$(BUILD) @@ -27,8 +24,13 @@ else CFLAGS += -Oz -g0 -DNDEBUG endif -CFLAGS += -Wall -Werror $(INC) -std=c99 $(COPT) -CFLAGS += -fdata-sections -ffunction-sections +CFLAGS += -Wall -Werror $(INC) -std=gnu11 $(COPT) +CFLAGS += -fdata-sections -ffunction-sections -Wno-error=unused-function + +JSFLAGS += -s WASM=0 +JSFLAGS += --memory-init-file 0 --js-library library.js +JSFLAGS += -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" +JSFLAGS += -s EXPORTED_FUNCTIONS="['_mp_js_init', '_mp_js_init_repl', '_mp_js_do_str', '_mp_js_process_char', '_mp_hal_get_interrupt_char', '_mp_keyboard_interrupt' ]" ifdef EMSCRIPTEN # only for profiling, remove -s EMTERPRETIFY_ADVISE=1 when your EMTERPRETIFY_WHITELIST is ok @@ -45,10 +47,11 @@ ifdef EMSCRIPTEN LDFLAGS += -Wl,-Map=$@.map,--cref endif - CC = emcc - CPP = clang -E -undef -D__CPP__ -D__EMSCRIPTEN__ + CC = emcc $(JSFLAGS) + LD = emcc $(JSFLAGS) + CPP = clang -E -undef -D__CPP__ -D__EMSCRIPTEN__ -U__STDC_VERSION__ CPP += --sysroot $(EMSCRIPTEN)/system - CPP += -include $(BUILD)/clang_predefs.h + CPP += -include $(BUILD)/clang_predefs.h CPP += $(addprefix -isystem, $(shell env LC_ALL=C $(CC) $(CFLAGS_EXTRA) -E -x c++ /dev/null -v 2>&1 |sed -e '/^\#include <...>/,/^End of search/{ //!b };d')) else ifdef CLANG @@ -72,16 +75,15 @@ SRC_C = \ mphalport.c \ modutime.c \ -SRC_QSTR += $(SRC_C) + +SRC_C += $(SRC_MOD) + +SRC_QSTR += $(BUILD)/clang_predefs.h $(SRC_C) $(SRC_LIB) OBJ = $(PY_O) OBJ += $(addprefix $(BUILD)/, $(SRC_LIB:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) -JSFLAGS += --memory-init-file 0 --js-library library.js -JSFLAGS += -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" -JSFLAGS += -s EXPORTED_FUNCTIONS="['_mp_js_init', '_mp_js_init_repl', '_mp_js_do_str', '_mp_js_process_char', '_mp_hal_get_interrupt_char', '_mp_keyboard_interrupt']" - $(BUILD)/clang_predefs.h: $(Q)mkdir -p $(dir $@) $(Q)emcc $(CFLAGS) $(CFLAGS_EXTRA) $(JSFLAGS) -E -x c /dev/null -dM > $@ From a9d01eca86bbeaa0f909455e9e16f55be8c02a57 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 7 Aug 2019 18:42:58 -0400 Subject: [PATCH 2/3] Add CFLAGS_MOD --- ports/javascript/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/javascript/Makefile b/ports/javascript/Makefile index 6443a92d3..e84b861f9 100644 --- a/ports/javascript/Makefile +++ b/ports/javascript/Makefile @@ -26,6 +26,7 @@ endif CFLAGS += -Wall -Werror $(INC) -std=gnu11 $(COPT) CFLAGS += -fdata-sections -ffunction-sections -Wno-error=unused-function +CFLAGS += $(CFLAGS_MOD) JSFLAGS += -s WASM=0 JSFLAGS += --memory-init-file 0 --js-library library.js From 465983ed747c282a239074f91d2fb2ebe4c5166e Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 7 Aug 2019 18:43:54 -0400 Subject: [PATCH 3/3] Make unused function warning produce error --- ports/javascript/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/javascript/Makefile b/ports/javascript/Makefile index e84b861f9..6872b0399 100644 --- a/ports/javascript/Makefile +++ b/ports/javascript/Makefile @@ -25,7 +25,7 @@ CFLAGS += -Oz -g0 -DNDEBUG endif CFLAGS += -Wall -Werror $(INC) -std=gnu11 $(COPT) -CFLAGS += -fdata-sections -ffunction-sections -Wno-error=unused-function +CFLAGS += -fdata-sections -ffunction-sections CFLAGS += $(CFLAGS_MOD) JSFLAGS += -s WASM=0