diff options
author | Rodrigo Kumpera <kumpera@users.noreply.github.com> | 2018-08-17 20:11:42 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-08-17 20:11:42 +0300 |
commit | ddf5ab2f78be8add00cd28def9968ec72f9e5d95 (patch) | |
tree | 2c1bb85a260206f14fac963d52732f4b1ca0e35f /sdks | |
parent | c4d2d34c4fa47149b79e80e1bb813449683762b7 (diff) |
[wasm] Enough scafold to enable AOT work with the SDKs (#10136)
* [wasm] add wasm-aot and wasm-aot-runtime
* [runtime] Add MONO_STRUCT_SIZE that works similarly to MONO_STRUCT_OFFSET and handles mini types.
* [wasm] Add enough scafold for the AOT compiler.
* [wasm] Make some functions available for the interp to satisfy the linker.
* [wasm] Add aot-sample and link-sample helper targets for AOT development.
* [wasm/sdks] Update documentation.
* Update README.md
Diffstat (limited to 'sdks')
-rw-r--r-- | sdks/Make.config.sample | 3 | ||||
-rw-r--r-- | sdks/builds/wasm.mk | 79 | ||||
-rw-r--r-- | sdks/wasm/Makefile | 34 | ||||
-rw-r--r-- | sdks/wasm/README.md | 17 | ||||
-rw-r--r-- | sdks/wasm/driver.c | 3 |
5 files changed, 133 insertions, 3 deletions
diff --git a/sdks/Make.config.sample b/sdks/Make.config.sample index 037063403ae..e71354f3760 100644 --- a/sdks/Make.config.sample +++ b/sdks/Make.config.sample @@ -11,3 +11,6 @@ #Disables building the BCL #DISABLE_BCL = 1 + +#Disables building the Desktop profile +#DISABLE_DESKTOP = 1 diff --git a/sdks/builds/wasm.mk b/sdks/builds/wasm.mk index 934544d342e..68467aef7e0 100644 --- a/sdks/builds/wasm.mk +++ b/sdks/builds/wasm.mk @@ -48,9 +48,86 @@ clean-wasm: .PHONY: clean-wasm-interp clean-wasm-interp: clean-wasm - rm -rf .stamp-wasm-interp-toolchain .stamp-wasm-interp-configure $(TOP)/sdks/builds/wasm $(TOP)/sdks/builds/wasm.config.cache $(TOP)/sdks/out/wasm-interp + rm -rf .stamp-wasm-interp-toolchain .stamp-wasm-interp-configure $(TOP)/sdks/builds/wasm-interp $(TOP)/sdks/builds/wasm.config.cache $(TOP)/sdks/out/wasm-interp TARGETS += wasm-interp +UNAME := $(shell uname -s) +ifeq ($(UNAME),Linux) + CROSS_HOST=i386-unknown-linux +endif +ifeq ($(UNAME),Darwin) + CROSS_HOST=i386-apple-darwin10 +endif +WASM_AOT_CONFIGURE_FLAGS = \ + --cache-file=$(TOP)/sdks/builds/wasm-aot.config.cache \ + --prefix=$(TOP)/sdks/out/wasm-aot \ + --host=$(CROSS_HOST) \ + --target=wasm32 \ + --disable-mcs-build \ + --disable-nls \ + --disable-boehm \ + --disable-btls \ + --disable-support-build \ + --enable-maintainer-mode \ + --enable-llvm \ + --enable-minimal=appdomains,com,remoting + +.stamp-wasm-aot-toolchain: .stamp-wasm-toolchain + touch $@ + +.stamp-wasm-aot-configure: $(TOP)/configure + mkdir -p $(TOP)/sdks/builds/wasm-aot + cd $(TOP)/sdks/builds/wasm-aot && CFLAGS="-g" $(TOP)/configure $(WASM_AOT_CONFIGURE_FLAGS) + touch $@ + +.PHONY: package-wasm-aot +package-wasm-aot: + $(MAKE) -C $(TOP)/sdks/builds/wasm-aot/mono install + +.PHONY: clean-wasm-aot +clean-wasm-aot: clean-wasm + rm -rf .stamp-wasm-aot-toolchain .stamp-wasm-aot-configure $(TOP)/sdks/builds/wasm-aot $(TOP)/sdks/builds/wasm.config.cache $(TOP)/sdks/out/wasm-aot + +TARGETS += wasm-aot + + +WASM_AOT_RUNTIME_CONFIGURE_FLAGS = \ + --cache-file=$(TOP)/sdks/builds/wasm-aot-runtime.config.cache \ + --prefix=$(TOP)/sdks/out/wasm-aot-runtime \ + --enable-llvm-runtime \ + --with-bitcode=yes \ + --host=wasm32 \ + --disable-mcs-build \ + --disable-nls \ + --disable-boehm \ + --disable-btls \ + --with-lazy-gc-thread-creation=yes \ + --with-libgc=none \ + --disable-executables \ + --disable-support-build \ + --disable-visibility-hidden \ + --enable-maintainer-mode \ + --enable-minimal=ssa,com,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,appdomains,security,sgen_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,logging,remoting,shared_perfcounters,sgen_debug_helpers,soft_debug + +.stamp-wasm-aot-runtime-toolchain: .stamp-wasm-toolchain + touch $@ + +.stamp-wasm-aot-runtime-configure: $(TOP)/configure + mkdir -p $(TOP)/sdks/builds/wasm-aot-runtime + cd $(TOP)/sdks/builds/wasm-aot-runtime && source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && CFLAGS="-Os -g" emconfigure $(TOP)/configure $(WASM_AOT_RUNTIME_CONFIGURE_FLAGS) + touch $@ + +build-custom-wasm-aot-runtime: + source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && make -C wasm-aot-runtime + +.PHONY: package-wasm-aot-runtime +package-wasm-aot-runtime: + $(MAKE) -C $(TOP)/sdks/builds/wasm-aot-runtime/mono install + +.PHONY: clean-wasm-aot-runtime +clean-wasm-aot-runtime: clean-wasm + rm -rf .stamp-wasm-aot-runtime-toolchain .stamp-wasm-aot-runtime-configure $(TOP)/sdks/builds/wasm-aot-runtime $(TOP)/sdks/builds/wasm.config.cache $(TOP)/sdks/out/wasm-aot-runtime +TARGETS += wasm-aot-runtime
\ No newline at end of file diff --git a/sdks/wasm/Makefile b/sdks/wasm/Makefile index f09fe4b3f5f..7e584dd7312 100644 --- a/sdks/wasm/Makefile +++ b/sdks/wasm/Makefile @@ -128,8 +128,8 @@ packager.exe: packager.cs Mono.Cecil.dll .stamp-build-debug-sample: $(DRIVER_CONF)/.stamp-build packager.exe bindings.dll sample.dll debug.html runtime.g.js mono packager.exe -debug -out=debug_sample sample.dll cp debug.html debug_sample - touch $@ - + touch $@ + TEST_ASSEMBLIES = $(WASM_BCL_DIR)/nunitlite.dll $(WASM_BCL_DIR)/tests/wasm_corlib_test.dll $(WASM_BCL_DIR)/tests/wasm_System_test.dll $(WASM_BCL_DIR)/tests/wasm_System.Core_test.dll .stamp-build-test-suite: $(DRIVER_CONF)/.stamp-build packager.exe bindings.dll binding_tests.dll mini_tests.dll main.exe runtime.g.js @@ -137,6 +137,36 @@ TEST_ASSEMBLIES = $(WASM_BCL_DIR)/nunitlite.dll $(WASM_BCL_DIR)/tests/wasm_corli cp test.js test-suite/ touch $@ +MINI_BASIC_TEST_FILES= \ + basic-calls.cs \ + basic-float.cs \ + basic-long.cs \ + basic-math.cs \ + basic.cs \ + objects.cs + +MINI_BASIC_TEST_SOURCES= $(patsubst %,$(MINI_PATH)/%,$(MINI_BASIC_TEST_FILES)) + +mini_tests_basic.dll: $(MINI_BASIC_TEST_SOURCES) + $(CSC) $(CSC_FLAGS) /unsafe -target:library -out:$@ -define:__MOBILE__,ARCH_32,NO_BITCODE /r:$(WASM_BCL_DIR)/mscorlib.dll $(MINI_BASIC_TEST_SOURCES) + +.stamp-build-aot-test: $(DRIVER_CONF)/.stamp-build packager.exe mini_tests_basic.dll runtime.g.js + mono packager.exe -out=aot -nobinding mini_tests_basic.dll + touch $@ + +AOT_COMPILER=$(TOP)/sdks/out/wasm-aot/bin/wasm32-mono-sgen +aot-sample: .stamp-build-aot-test + for f in aot/managed/*.dll; do \ + MONO_PATH=aot/managed $(AOT_COMPILER) --aot=llvmonly,asmonly,no-opt,dedup-skip,static,llvm-outfile=$$f.bc $$f; \ + done \ + +link-sample: driver.o library_mono.js binding_support.js dotnet_support.js + $(EMCC) -Os -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s "BINARYEN_TRAP_MODE='clamp'" -s TOTAL_MEMORY=134217728 -s ALIASING_FUNCTION_POINTERS=0 --js-library library_mono.js --js-library binding_support.js --js-library dotnet_support.js -o aot/mono-aot.js -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString']" driver.o $(TOP)/sdks/out/wasm-aot-runtime/lib/libmonosgen-2.0.a aot/managed/*.bc + + + +build-aot-test: .stamp-build-aot-test + build-debug-sample: .stamp-build-debug-sample build-test-suite: .stamp-build-test-suite diff --git a/sdks/wasm/README.md b/sdks/wasm/README.md index 4ba8dd0cb1e..6ffc36b73eb 100644 --- a/sdks/wasm/README.md +++ b/sdks/wasm/README.md @@ -74,6 +74,23 @@ To experiment with the debugger, do the following steps: Beware that the debugger is in active development so bugs and missing features will be present. +# AOT development + +AOT experimentation happens with the following steps: + +1) go to `sdks` and configure it to disable all but WASM and BCL. (See sdks/Make.config.sample) +2) go to `sdks/builds` and hit `make package` +3) go to `sdks/wasm` and hit `make build` + +Now you can experiment with the `aot-sample` and `link-sample` make targets to try the toolchain. The first invokes the AOT compiler and the second links the results. This is experimental, so expect stuff to not work as intended. + +To update the runtimes used use the following target in `sdks/build` + +`package-wasm-interp` for the interpreter-based runtime +`package-wasm-aot` for the aot compiler +`package-wasm-aot-runtime` for the wasm runtime that works with AOT'd code. + + # Notes [1]: https://github.com/kripken/emscripten diff --git a/sdks/wasm/driver.c b/sdks/wasm/driver.c index 64f152c309a..a47d7c1fa7d 100644 --- a/sdks/wasm/driver.c +++ b/sdks/wasm/driver.c @@ -206,6 +206,9 @@ mono_wasm_invoke_js (MonoString *str, int *is_exception) return res; } +// extern const void *mono_aot_module_{0}_info; + + EMSCRIPTEN_KEEPALIVE void mono_wasm_load_runtime (const char *managed_path, int enable_debugging) { |