-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sdk] Add wasm interpreter support. #5924
Changes from all commits
55cae50
80a2087
6f229c1
675b190
db00ae8
a0687c1
d1349d2
01e7674
5ed0fab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
WASM_INTERP_CONFIGURE_FLAGS = \ | ||
--cache-file=$(TOP)/sdks/builds/wasm-interp.config.cache \ | ||
--prefix=$(TOP)/sdks/out/wasm-interp \ | ||
--enable-wasm \ | ||
--enable-interpreter \ | ||
--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-minimal=ssa,com,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,appdomains,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,remoting,shared_perfcounters \ | ||
--host=i386-apple-darwin10 | ||
|
||
#toolchain code | ||
.stamp-wasm-toolchain: | ||
git clone https://github.com/juj/emsdk.git $(TOP)/sdks/builds/toolchains/emsdk | ||
cd $(TOP)/sdks/builds/toolchains/emsdk && ./emsdk install latest && ./emsdk activate --embedded latest | ||
touch $@ | ||
|
||
.stamp-wasm-interp-toolchain: .stamp-wasm-toolchain | ||
touch $@ | ||
|
||
#configure step | ||
.stamp-wasm-interp-configure: $(TOP)/configure .stamp-wasm-interp-toolchain | ||
mkdir -p $(TOP)/sdks/builds/wasm-interp | ||
cd $(TOP)/sdks/builds/wasm-interp && source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && CFLAGS="-Os -g" emconfigure $(TOP)/configure $(WASM_INTERP_CONFIGURE_FLAGS) | ||
touch $@ | ||
|
||
package-wasm-interp: | ||
$(MAKE) -C $(TOP)/sdks/builds/wasm-interp/mono install | ||
|
||
|
||
#custom build rule | ||
CUSTOM_BUILD_TARGETS += build-wasm-interp | ||
build-wasm-interp: .stamp-wasm-interp-configure | ||
source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && make -C wasm-interp | ||
|
||
|
||
|
||
.PHONY: clean-wasm-interp clean-wasm | ||
clean-wasm:: | ||
rm -rf .stamp-wasm-toolchain | ||
clean-wasm-interp:: clean-wasm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please unify both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a reason for this. This is the only one ready for merging and I feel like keeping the bits for the others made sense. |
||
rm -rf .stamp-wasm-configure $(TOP)/sdks/builds/toolchains/emcc $(TOP)/sdks/builds/wasm $$(TOP)/sdks/builds/wasm.config.cache | ||
|
||
TARGETS += wasm-interp | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
TOP=$(realpath $(CURDIR)/../..) | ||
include $(TOP)/sdks/paths.mk | ||
|
||
EMCC=source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && emcc | ||
D8=$(TOP)/sdks/wasm/v8/out.gn/x64.release/d8 | ||
WASM_BCL_DIR=$(TOP)/sdks/out/bcl/wasm | ||
MANAGED_DEPLOY_DIR=$(TOP)/sdks/wasm/managed | ||
MINI_PATH=$(TOP)/mono/mini | ||
|
||
BCL_ASSEMBLIES= \ | ||
mscorlib.dll \ | ||
System.dll \ | ||
System.Core.dll | ||
|
||
DEPS_ASSEMBLIES= \ | ||
nunitlite.dll | ||
|
||
MINI_TEST_FILES= \ | ||
TestDriver.cs \ | ||
aot-tests.cs \ | ||
arrays.cs \ | ||
basic-calls.cs \ | ||
basic-float.cs \ | ||
basic-long.cs \ | ||
basic-math.cs \ | ||
basic.cs \ | ||
exceptions.cs \ | ||
generics.cs \ | ||
gshared.cs \ | ||
objects.cs \ | ||
builtin-types.cs \ | ||
devirtualization.cs \ | ||
mixed.cs \ | ||
gc-test.cs | ||
|
||
|
||
BCL_INPUT_ASM = $(patsubst %,$(WASM_BCL_DIR)/%,$(BCL_ASSEMBLIES)) | ||
BCL_OUTPUT_ASM = $(patsubst %,$(MANAGED_DEPLOY_DIR)/%,$(BCL_ASSEMBLIES)) | ||
DEPS_FILES = $(patsubst %,$(MANAGED_DEPLOY_DIR)/%,$(DEPS_ASSEMBLIES)) | ||
|
||
MINI_TEST_SOURCES= $(patsubst %,$(MINI_PATH)/%,$(MINI_TEST_FILES)) | ||
MINI_TEST_DEPS= $(patsubst %,-r:%,$(BCL_OUTPUT_ASM) $(DEPS_FILES)) | ||
|
||
.stamp-depot-tools: | ||
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_tools | ||
touch $@ | ||
|
||
.stamp-v8: .stamp-depot-tools | ||
PATH=$(TOP)/sdks/wasm/depot_tools:$$PATH fetch v8 | ||
cd v8 && tools/dev/v8gen.py x64.release | ||
cd v8 && $(TOP)/sdks/wasm/depot_tools/ninja -C out.gn/x64.release | ||
touch $@ | ||
|
||
.PHONY: toolchain | ||
toolchain: .stamp-v8 | ||
|
||
driver.o: driver.c | ||
$(EMCC) -g -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 driver.c -c -o driver.o | ||
|
||
mono.js: driver.o library_mono.js $(TOP)/sdks/out/wasm-interp/lib/libmonosgen-2.0.a | ||
$(EMCC) -g4 -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 driver.o $(TOP)/sdks/out/wasm-interp/lib/libmonosgen-2.0.a -o mono.js | ||
|
||
build-native: mono.js | ||
|
||
#FIXME some Make magic here would be appreciated | ||
.stamp-copy-bcl: $(TOP)/sdks/wasm/managed $(BCL_INPUT_ASM) | ||
mkdir -p managed/ | ||
cp $(BCL_INPUT_ASM) managed/ | ||
touch $@ | ||
|
||
managed/main.exe: main.cs .stamp-copy-bcl managed/nunitlite.dll | ||
mcs /nostdlib /unsafe main.cs -r:managed/nunitlite.dll $(MINI_TEST_DEPS) -out:managed/main.exe | ||
|
||
managed/mini_tests.dll: $(MINI_TEST_SOURCES) mini-test-runner.cs .stamp-copy-bcl managed/nunitlite.dll | ||
mcs /nostdlib /unsafe -target:library -out:managed/mini_tests.dll -define:__MOBILE__,ARCH_32 $(MINI_TEST_DEPS) $(MINI_TEST_SOURCES) mini-test-runner.cs | ||
|
||
managed/nunitlite.dll: $(TOP)/mcs/class/lib/wasm/nunitlite.dll | ||
cd $(TOP)/mcs/tools/nunit-lite && make PROFILE=wasm | ||
cp $< $@ | ||
|
||
build-managed: .stamp-copy-bcl managed/nunitlite.dll managed/mini_tests.dll managed/main.exe | ||
|
||
build: build-native build-managed | ||
|
||
|
||
run: toolchain build | ||
$(D8) --expose_wasm test.js | ||
|
||
clean: | ||
|
||
package: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have a
wasm
while all other targets arewasm-interp
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuz the other wasm targets require their own toolchains.