diff options
-rwxr-xr-x | scripts/ci/run-jenkins.sh | 1 | ||||
-rw-r--r-- | sdks/builds/.gitignore | 5 | ||||
-rw-r--r-- | sdks/builds/Makefile | 6 | ||||
-rw-r--r-- | sdks/builds/runtime.mk | 14 | ||||
-rw-r--r-- | sdks/builds/wasm.mk | 171 | ||||
-rw-r--r-- | sdks/wasm/Makefile | 6 |
6 files changed, 122 insertions, 81 deletions
diff --git a/scripts/ci/run-jenkins.sh b/scripts/ci/run-jenkins.sh index 6323603cbaa..e2e71f06f4b 100755 --- a/scripts/ci/run-jenkins.sh +++ b/scripts/ci/run-jenkins.sh @@ -177,6 +177,7 @@ if [[ ${CI_TAGS} == *'webassembly'* ]]; echo "DISABLE_ANDROID=1" > sdks/Make.config echo "DISABLE_IOS=1" >> sdks/Make.config echo "DISABLE_DESKTOP=1" >> sdks/Make.config + echo "ENABLE_WASM_CROSS=1" >> sdks/Make.config if [[ ${CI_TAGS} == *'cxx'* ]]; then echo "ENABLE_CXX=1" >> sdks/Make.config fi diff --git a/sdks/builds/.gitignore b/sdks/builds/.gitignore index 764fe990d46..35244bd5416 100644 --- a/sdks/builds/.gitignore +++ b/sdks/builds/.gitignore @@ -36,8 +36,9 @@ ios-sim32-*/ ios-sim64-*/ ios-simtv-*/ ios-simwatch-*/ -wasm-runtime/ -wasm-cross/ +wasm-runtime-*/ +wasm-cross-*/ +wasm-cross-win-*/ bcl/ desktop-x86/ desktop-x86_64/ diff --git a/sdks/builds/Makefile b/sdks/builds/Makefile index 49e94defef7..12be3487afc 100644 --- a/sdks/builds/Makefile +++ b/sdks/builds/Makefile @@ -16,6 +16,10 @@ ifneq ($(UNAME),Darwin) DISABLE_IOS=1 endif +ifndef ENABLE_WASM_CROSS +DISABLE_WASM_CROSS=1 +endif + include $(TOP)/sdks/versions.mk include $(TOP)/sdks/paths.mk @@ -40,7 +44,7 @@ TARGETS= include runtime.mk ## MXE targets -ifndef DISABLE_ANDROID +ifeq ($(and $(DISABLE_ANDROID),$(DISABLE_WASM_CROSS)),) # FIXME add iOS support(?) include mxe.mk endif diff --git a/sdks/builds/runtime.mk b/sdks/builds/runtime.mk index 73b67a94d10..5bb41f76eda 100644 --- a/sdks/builds/runtime.mk +++ b/sdks/builds/runtime.mk @@ -88,22 +88,14 @@ build-custom-$(1): setup-custom-$(1): mkdir -p $$(TOP)/sdks/out/$(1)-$$(CONFIGURATION) -.PHONY: package-$(1)-$$(CONFIGURATION) -package-$(1)-$$(CONFIGURATION): - $$(MAKE) -C $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION)/mono install - $$(MAKE) -C $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION)/support install - .PHONY: package-$(1) package-$(1): - $$(MAKE) package-$(1)-$$(CONFIGURATION) - -.PHONY: clean-$(1)-$$(CONFIGURATION) -clean-$(1)-$$(CONFIGURATION): - rm -rf .stamp-$(1)-toolchain .stamp-$(1)-$$(CONFIGURATION)-configure $$(TOP)/sdks/builds/toolchains/$(1) $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION) $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION).config.cache $$(TOP)/sdks/out/$(1)-$$(CONFIGURATION) + $$(MAKE) -C $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION)/mono install + $$(MAKE) -C $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION)/support install .PHONY: clean-$(1) clean-$(1): - $$(MAKE) clean-$(1)-$$(CONFIGURATION) + rm -rf .stamp-$(1)-toolchain .stamp-$(1)-$$(CONFIGURATION)-configure $$(TOP)/sdks/builds/toolchains/$(1) $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION) $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION).config.cache $$(TOP)/sdks/out/$(1)-$$(CONFIGURATION) TARGETS += $(1) diff --git a/sdks/builds/wasm.mk b/sdks/builds/wasm.mk index 2814bece9c5..24d535093f3 100644 --- a/sdks/builds/wasm.mk +++ b/sdks/builds/wasm.mk @@ -1,13 +1,24 @@ #emcc has lots of bash'isms SHELL:=/bin/bash +EMSCRIPTEN_VERSION=1.38.11 +EMSCRIPTEN_SDK_DIR=$(TOP)/sdks/builds/toolchains/emsdk + +$(TOP)/sdks/builds/toolchains/emsdk: + git clone https://github.com/juj/emsdk.git $(EMSCRIPTEN_SDK_DIR) + cd $(TOP)/sdks/builds/toolchains/emsdk && ./emsdk install sdk-$(EMSCRIPTEN_VERSION)-64bit + cd $(TOP)/sdks/builds/toolchains/emsdk && ./emsdk activate --embedded sdk-$(EMSCRIPTEN_VERSION)-64bit + -cd $(TOP)/sdks/builds/toolchains/emsdk/emscripten/$(EMSCRIPTEN_VERSION) && patch -p1 < $(TOP)/sdks/builds/emsdk-eh.diff + +.PHONY: provision-wasm +provision-wasm: | $(EMSCRIPTEN_SDK_DIR) + WASM_RUNTIME_AC_VARS= \ ac_cv_func_shm_open_working_with_mmap=no WASM_RUNTIME_CONFIGURE_FLAGS = \ - $(if $(ENABLE_CXX),--enable-cxx) \ - --cache-file=$(TOP)/sdks/builds/wasm-runtime.config.cache \ - --prefix=$(TOP)/sdks/out/wasm-runtime \ + --cache-file=$(TOP)/sdks/builds/wasm-runtime-$(CONFIGURATION).config.cache \ + --prefix=$(TOP)/sdks/out/wasm-runtime-$(CONFIGURATION) \ --disable-mcs-build \ --disable-nls \ --disable-boehm \ @@ -23,91 +34,123 @@ WASM_RUNTIME_CONFIGURE_FLAGS = \ --enable-llvm-runtime \ --enable-icall-export \ --disable-icall-tables \ - --with-bitcode=yes + --with-bitcode=yes \ + $(if $(ENABLE_CXX),--enable-cxx) -EMSCRIPTEN_VERSION=1.38.11 -EMSCRIPTEN_SDK_DIR=$(TOP)/sdks/builds/toolchains/emsdk - -$(TOP)/sdks/builds/toolchains/emsdk: - git clone https://github.com/juj/emsdk.git $(EMSCRIPTEN_SDK_DIR) - cd $(TOP)/sdks/builds/toolchains/emsdk && ./emsdk install sdk-$(EMSCRIPTEN_VERSION)-64bit - cd $(TOP)/sdks/builds/toolchains/emsdk && ./emsdk activate --embedded sdk-$(EMSCRIPTEN_VERSION)-64bit - -cd $(TOP)/sdks/builds/toolchains/emsdk/emscripten/$(EMSCRIPTEN_VERSION) && patch -p1 < $(TOP)/sdks/builds/emsdk-eh.diff - -.stamp-wasm-toolchain: | $(TOP)/sdks/builds/toolchains/emsdk +.stamp-wasm-runtime-toolchain: touch $@ -.stamp-wasm-runtime-toolchain: .stamp-wasm-toolchain +.stamp-wasm-runtime-$(CONFIGURATION)-configure: $(TOP)/configure $(if $(IGNORE_PROVISION_WASM),,provision-wasm) + mkdir -p $(TOP)/sdks/builds/wasm-runtime-$(CONFIGURATION) + cd $(TOP)/sdks/builds/wasm-runtime-$(CONFIGURATION) && source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && CFLAGS="-Os -g" emconfigure $(TOP)/configure $(WASM_RUNTIME_AC_VARS) $(WASM_RUNTIME_CONFIGURE_FLAGS) touch $@ -.stamp-wasm-runtime-configure: $(TOP)/configure - mkdir -p $(TOP)/sdks/builds/wasm-runtime - cd $(TOP)/sdks/builds/wasm-runtime && source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && CFLAGS="-Os -g" emconfigure $(TOP)/configure $(WASM_RUNTIME_AC_VARS) $(WASM_RUNTIME_CONFIGURE_FLAGS) - touch $@ +.PHONY: .stamp-wasm-runtime-configure +.stamp-wasm-runtime-configure: .stamp-wasm-runtime-$(CONFIGURATION)-configure +.PHONY: build-custom-wasm-runtime build-custom-wasm-runtime: - source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && make -C wasm-runtime + source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && $(MAKE) -C wasm-runtime-$(CONFIGURATION) + +.PHONY: setup-custom-wasm-runtime +setup-custom-wasm-runtime: + mkdir -p $(TOP)/sdks/out/wasm-runtime-$(CONFIGURATION) .PHONY: package-wasm-runtime package-wasm-runtime: - $(MAKE) -C $(TOP)/sdks/builds/wasm-runtime/mono install - -.PHONY: clean-wasm -clean-wasm: - rm -rf .stamp-wasm-runtime-toolchain $(TOP)/sdks/builds/toolchains/emsdk + $(MAKE) -C $(TOP)/sdks/builds/wasm-runtime-$(CONFIGURATION)/mono install .PHONY: clean-wasm-runtime clean-wasm-runtime: - rm -rf .stamp-wasm-runtime-configure $(TOP)/sdks/builds/wasm-runtime $(TOP)/sdks/builds/wasm-runtime.config.cache $(TOP)/sdks/out/wasm-runtime + rm -rf .stamp-wasm-runtime-toolchain .stamp-wasm-runtime-$(CONFIGURATION)-configure $(TOP)/sdks/builds/wasm-runtime-$(CONFIGURATION) $(TOP)/sdks/builds/wasm-runtime-$(CONFIGURATION).config.cache $(TOP)/sdks/out/wasm-runtime-$(CONFIGURATION) TARGETS += wasm-runtime -UNAME := $(shell uname -s) -ifeq ($(UNAME),Linux) - CROSS_HOST=i386-unknown-linux - CPP_SHARP_DIR=linux_64 -endif -ifeq ($(UNAME),Darwin) - CROSS_HOST=i386-apple-darwin10 - CPP_SHARP_DIR=osx_64 -endif +## +# Parameters +# $(1): target +# $(2): host arch +# $(3): target arch +# $(4): device target +# $(5): llvm +# $(6): offsets dumper abi +define WasmCrossTemplate -WASM_CROSS_CONFIGURE_FLAGS = \ - $(if $(ENABLE_CXX),--enable-cxx) \ - --cache-file=$(TOP)/sdks/builds/wasm-cross.config.cache \ - --prefix=$(TOP)/sdks/out/wasm-cross \ - --host=$(CROSS_HOST) \ - --target=wasm32 \ - --disable-mcs-build \ - --disable-nls \ +_wasm-$(1)_OFFSETS_DUMPER_ARGS=--emscripten-sdk="$$(EMSCRIPTEN_SDK_DIR)/emscripten/$$(EMSCRIPTEN_VERSION)" + +_wasm-$(1)_CONFIGURE_FLAGS= \ --disable-boehm \ --disable-btls \ + --disable-mcs-build \ + --disable-nls \ --disable-support-build \ - --enable-maintainer-mode \ - --with-llvm=$(TOP)/sdks/out/llvm-llvm32 \ - --enable-minimal=appdomains,com,remoting \ - --with-cross-offsets=wasm-offsets.h + --enable-maintainer-mode \ + --enable-minimal=appdomains,com,remoting -.stamp-wasm-cross-toolchain: .stamp-wasm-toolchain - touch $@ +$$(eval $$(call CrossRuntimeTemplate,wasm-$(1),$$(if $$(filter $$(UNAME),Darwin),$(2)-apple-darwin10,$$(if $$(filter $$(UNAME),Linux),$(2)-linux-gnu,$$(error "Unknown UNAME='$$(UNAME)'"))),$(3)-unknown-none,$(4),$(5),$(6))) -.stamp-wasm-cross-configure: | $(TOP)/configure provision-llvm-llvm32 - mkdir -p $(TOP)/sdks/builds/wasm-cross - cd $(TOP)/sdks/builds/wasm-cross && CFLAGS="-g -m32" CXXFLAGS="-g -m32" $(TOP)/configure $(WASM_CROSS_CONFIGURE_FLAGS) - touch $@ +endef + +ifeq ($(DISABLE_WASM_CROSS),) +$(eval $(call WasmCrossTemplate,cross,i686,wasm32,wasm-runtime,llvm-llvm32,wasm32-unknown-unknown)) +endif -# This needs to be run after the target runtime has been configured -$(TOP)/sdks/builds/wasm-cross/wasm-offsets.h: .stamp-wasm-cross-configure .stamp-wasm-runtime-configure $(TOP)/tools/offsets-tool/MonoAotOffsetsDumper.exe - cd $(TOP)/sdks/builds/wasm-cross && MONO_PATH=$(TOP)/tools/offsets-tool/CppSharp/$(CPP_SHARP_DIR) mono --debug $(TOP)/tools/offsets-tool/MonoAotOffsetsDumper.exe --emscripten-sdk=$(EMSCRIPTEN_SDK_DIR)/emscripten/$(EMSCRIPTEN_VERSION) --abi wasm32-unknown-unknown --outfile $@ --mono $(TOP) --targetdir $(TOP)/sdks/builds/wasm-runtime +## +# Parameters +# $(1): target +# $(2): host arch +# $(3): target arch +# $(4): device target +# $(5): llvm +# $(6): offsets dumper abi +define WasmCrossMXETemplate + +_wasm-$(1)_OFFSETS_DUMPER_ARGS=--emscripten-sdk="$(EMSCRIPTEN_SDK_DIR)/emscripten/$(EMSCRIPTEN_VERSION)" + +_wasm-$(1)_PATH=$$(MXE_PREFIX)/bin + +_wasm-$(1)_AR=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-ar +_wasm-$(1)_AS=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-as +_wasm-$(1)_CC=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-gcc +_wasm-$(1)_CXX=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-g++ +_wasm-$(1)_DLLTOOL=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-dlltool +_wasm-$(1)_LD=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-ld +_wasm-$(1)_OBJDUMP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-objdump +_wasm-$(1)_RANLIB=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-ranlib +_wasm-$(1)_STRIP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $$(UNAME),Darwin),.static)-strip + +_wasm-$(1)_CFLAGS= \ + $$(if $$(RELEASE),,-DDEBUG_CROSS) \ + -static \ + -static-libgcc + +_wasm-$(1)_CXXFLAGS= \ + $$(if $$(RELEASE),,-DDEBUG_CROSS) \ + -static \ + -static-libgcc + +_wasm-$(1)_LDFLAGS= \ + -static \ + -static-libgcc \ + -static-libstdc++ + +_wasm-$(1)_CONFIGURE_FLAGS= \ + --disable-boehm \ + --disable-btls \ + --disable-mcs-build \ + --disable-nls \ + --disable-nls \ + --disable-support-build \ + --enable-maintainer-mode \ + --enable-minimal=appdomains,com,remoting \ + --with-tls=pthread -build-wasm-cross: $(TOP)/sdks/builds/wasm-cross/wasm-offsets.h +.stamp-wasm-$(1)-$$(CONFIGURATION)-configure: | $$(if $$(IGNORE_PROVISION_MXE),,provision-mxe) -.PHONY: package-wasm-cross -package-wasm-cross: - $(MAKE) -C $(TOP)/sdks/builds/wasm-cross/mono install +$$(eval $$(call CrossRuntimeTemplate,wasm-$(1),$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static),$(3)-unknown-none,$(4),$(5),$(6))) -.PHONY: clean-wasm-cross -clean-wasm-cross: - rm -rf .stamp-wasm-aot-toolchain .stamp-wasm-cross-configure $(TOP)/sdks/builds/wasm-cross $(TOP)/sdks/builds/wasm-cross.config.cache $(TOP)/sdks/out/wasm-cross +endef -TARGETS += wasm-cross +ifeq ($(DISABLE_WASM_CROSS),) +$(eval $(call WasmCrossMXETemplate,cross-win,i686,wasm32,wasm-runtime,llvm-llvmwin32,wasm32-unknown-unknown)) +endif
\ No newline at end of file diff --git a/sdks/wasm/Makefile b/sdks/wasm/Makefile index f64526db54e..c07219492ac 100644 --- a/sdks/wasm/Makefile +++ b/sdks/wasm/Makefile @@ -76,14 +76,14 @@ debug/: release/: mkdir -p $@ -MONO_LIBS = $(TOP)/sdks/out/wasm-runtime/lib/libmono-ee-interp.a $(TOP)/sdks/out/wasm-runtime/lib/libmonosgen-2.0.a $(TOP)/sdks/out/wasm-runtime/lib/libmono-ilgen.a $(TOP)/sdks/out/wasm-runtime/lib/libmono-icall-table.a +MONO_LIBS = $(TOP)/sdks/out/wasm-runtime-release/lib/libmono-ee-interp.a $(TOP)/sdks/out/wasm-runtime-release/lib/libmonosgen-2.0.a $(TOP)/sdks/out/wasm-runtime-release/lib/libmono-ilgen.a $(TOP)/sdks/out/wasm-runtime-release/lib/libmono-icall-table.a -debug/.stamp-build: driver.o library_mono.js binding_support.js dotnet_support.js $(TOP)/sdks/out/wasm-runtime/lib/libmonosgen-2.0.a | debug/ +debug/.stamp-build: driver.o library_mono.js binding_support.js dotnet_support.js $(TOP)/sdks/out/wasm-runtime-release/lib/libmonosgen-2.0.a | debug/ $(EMCC) -g4 -Os -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s "BINARYEN_TRAP_MODE='clamp'" -s ALIASING_FUNCTION_POINTERS=0 -s ASSERTIONS=1 --js-library library_mono.js --js-library binding_support.js --js-library dotnet_support.js driver.o $(MONO_LIBS) -o debug/mono.js -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString']" touch $@ # Notice that release/.stamp-build depends on debug/.stamp-build. This is the case as emcc is believed to not work well with parallel builds. -release/.stamp-build: driver.o library_mono.js binding_support.js dotnet_support.js $(TOP)/sdks/out/wasm-runtime/lib/libmonosgen-2.0.a debug/.stamp-build | release/ +release/.stamp-build: driver.o library_mono.js binding_support.js dotnet_support.js $(TOP)/sdks/out/wasm-runtime-release/lib/libmonosgen-2.0.a debug/.stamp-build | release/ $(EMCC) -Oz --llvm-opts 2 --llvm-lto 1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s "BINARYEN_TRAP_MODE='clamp'" -s ALIASING_FUNCTION_POINTERS=0 --js-library library_mono.js --js-library binding_support.js --js-library dotnet_support.js driver.o $(MONO_LIBS) -o release/mono.js -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString']" touch $@ |