From b78e1d0750478d9a7edd0f2380d3a323d54c8835 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Fri, 1 Sep 2023 09:43:33 +0200 Subject: [PATCH 1/4] Fix and clean up Makefile --- interpreter/Makefile | 113 +++++++++++--------- interpreter/dune | 5 - interpreter/{tests => unittest}/smallint.ml | 0 3 files changed, 62 insertions(+), 56 deletions(-) rename interpreter/{tests => unittest}/smallint.ml (100%) diff --git a/interpreter/Makefile b/interpreter/Makefile index d67882b29..fe6accd93 100644 --- a/interpreter/Makefile +++ b/interpreter/Makefile @@ -1,6 +1,6 @@ # This Makefile uses dune but does not rely on ocamlfind or the Opam # package manager to build. However, Opam package management is available -# optionally through the check/install/uninstall targets. +# optionally through the install target. # # The $(JSLIB).js target requires Js_of_ocaml (using ocamlfind). # @@ -9,80 +9,90 @@ # Configuration -NAME = wasm -OPT = $(NAME).exe -ZIP = $(NAME).zip +NAME = wasm +LIB = $(NAME) JSLIB = wast.js +ZIP = $(NAME).zip -BUILDDIR = _build/default +BUILDDIR = _build/default JS = # set to JS shell command to run JS tests, empty to skip # Main targets -.PHONY: default opt jslib all zip smallint +.PHONY: default all ci jslib zip + +default: $(NAME) +all: default test +ci: all jslib zip -default: $(OPT) jslib: $(JSLIB) -all: $(OPT) test zip: $(ZIP) -smallint: smallint.exe -ci: all jslib -# Building executable -.PHONY: $(NAME).exe -$(NAME).exe: - rm -f $(NAME) - dune build $@ - cp $(BUILDDIR)/$(OPT) $(NAME) -.PHONY: smallint.exe -smallint.exe: - dune build $@ +# Building + +$(NAME): + rm -f $@ + dune build $@.exe + ln $(BUILDDIR)/$@.exe $@ + +$(JSLIB): + rm -f $@ + dune build $(@:%.js=%.bc.js) + ln $(BUILDDIR)/$(@:%.js=%.bc.js) $@ + + +# Unit tests + +UNITTESTDIR = unittest +UNITTESTFILES = $(shell cd $(UNITTESTDIR); ls *.ml) +UNITTESTS = $(UNITTESTFILES:%.ml=%) -# Building JavaScript library +.PHONY: unittest -$(JSLIB): $(BUILDDIR)/$(JSLIB) - cp $< $@ +unittest: $(UNITTESTS:%=unittest/%) -$(BUILDDIR)/$(JSLIB): - dune build $(JSLIB) +unittest/%: + dune build $(@F).exe + dune exec ./$(@F).exe -# Executing test suite + +# Test suite TESTDIR = ../test/core -# Skip _output directory, since that's a tmp directory, and list all other wast files. TESTFILES = $(shell cd $(TESTDIR); ls *.wast; ls [a-z]*/*.wast) TESTS = $(TESTFILES:%.wast=%) -.PHONY: test partest dune-test +.PHONY: test partest quiettest + +test: $(NAME) unittest + $(TESTDIR)/run.py --wasm `pwd`/$(NAME) $(if $(JS),--js '$(JS)',) -test: $(OPT) smallint - $(TESTDIR)/run.py --wasm `pwd`/$(BUILDDIR)/$(OPT) $(if $(JS),--js '$(JS)',) - dune exec ./smallint.exe +test/%: $(NAME) + $(TESTDIR)/run.py --wasm `pwd`/$(NAME) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast -test/%: $(OPT) - $(TESTDIR)/run.py --wasm `pwd`/$(BUILDDIR)/$(OPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast +run/%: $(NAME) + ./$(NAME) $(TESTDIR)/$*.wast -run/%: $(OPT) - ./$(OPT) $(TESTDIR)/$*.wast +partest: $(NAME) + make -j10 quiettest -partest: $(TESTS:%=quiettest/%) - @echo All tests passed. +quiettest: $(TESTS:%=quiettest/%) + @echo All tests passed. -quiettest/%: $(OPT) - @ ( \ - $(TESTDIR)/run.py 2>$(@F).out --wasm `pwd`/$(BUILDDIR)/$(OPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast && \ - rm $(@F).out \ - ) || \ - cat $(@F).out || rm $(@F).out || exit 1 +quiettest/%: $(NAME) + @ ( \ + $(TESTDIR)/run.py 2>$(@F).out --wasm `pwd`/$(NAME) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast && \ + rm $(@F).out \ + ) || \ + cat $(@F).out || rm $(@F).out || exit 1 -smallinttest: smallint - dune exec ./smallint.exe -dunetest: - dune test +# Packaging + +.PHONY: install install: dune build -p $(NAME) @install @@ -101,15 +111,16 @@ opam-release/%: rm opam-$*.zip @echo Created file ./opam, submit to github opam-repository/packages/wasm/wasm.$*/opam -# Miscellaneous targets - -.PHONY: clean - $(ZIP): git archive --format=zip --prefix=$(NAME)/ -o $@ HEAD + +# Cleanup + +.PHONY: clean distclean + clean: dune clean distclean: clean - rm -f $(NAME) $(JSLIB) + rm -f $(NAME) $(JSLIB) $(ZIP) diff --git a/interpreter/dune b/interpreter/dune index c0e9c292f..9a853921d 100644 --- a/interpreter/dune +++ b/interpreter/dune @@ -34,11 +34,6 @@ (deps main/main.ml) (action (copy main/main.ml wasm.ml))) -(rule - (targets wast.js) - (deps wast.bc.js) - (action (copy wast.bc.js wast.js))) - (subdir text (rule diff --git a/interpreter/tests/smallint.ml b/interpreter/unittest/smallint.ml similarity index 100% rename from interpreter/tests/smallint.ml rename to interpreter/unittest/smallint.ml From 6ef660e9897a968c044429409107acb4a1c97a08 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Fri, 1 Sep 2023 09:49:14 +0200 Subject: [PATCH 2/4] Make partest the default --- interpreter/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interpreter/Makefile b/interpreter/Makefile index fe6accd93..9d345cb46 100644 --- a/interpreter/Makefile +++ b/interpreter/Makefile @@ -24,7 +24,7 @@ JS = # set to JS shell command to run JS tests, empty to skip .PHONY: default all ci jslib zip default: $(NAME) -all: default test +all: default partest ci: all jslib zip jslib: $(JSLIB) @@ -87,7 +87,7 @@ quiettest/%: $(NAME) $(TESTDIR)/run.py 2>$(@F).out --wasm `pwd`/$(NAME) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast && \ rm $(@F).out \ ) || \ - cat $(@F).out || rm $(@F).out || exit 1 + (cat $(@F).out && rm $(@F).out && exit 1) # Packaging From 5c96167c22c1ba2fdf032df9877a1fcc3ff2e4a4 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Wed, 6 Sep 2023 08:02:38 -0700 Subject: [PATCH 3/4] [spec] Clarify that elements are given as expressions (#1676) --- document/core/syntax/instructions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/core/syntax/instructions.rst b/document/core/syntax/instructions.rst index e22c42002..ddb51d7ee 100644 --- a/document/core/syntax/instructions.rst +++ b/document/core/syntax/instructions.rst @@ -707,7 +707,7 @@ the callee is dynamically checked against the :ref:`function type ` bodies, initialization values for :ref:`globals `, and offsets of :ref:`element ` or :ref:`data ` segments are given as expressions, which are sequences of :ref:`instructions ` terminated by an |END| marker. +:ref:`Function ` bodies, initialization values for :ref:`globals `, elements and offsets of :ref:`element ` segments, and offsets of :ref:`data ` segments are given as expressions, which are sequences of :ref:`instructions ` terminated by an |END| marker. .. math:: \begin{array}{llll} From 5cf98bcf3b7609d2154f7f65afe8fd25774c54e6 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 8 Sep 2023 20:00:20 +0900 Subject: [PATCH 4/4] [test] Fix typos (#1678) --- test/core/unreachable.wast | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/unreachable.wast b/test/core/unreachable.wast index 3074847a3..19f661be1 100644 --- a/test/core/unreachable.wast +++ b/test/core/unreachable.wast @@ -6,8 +6,8 @@ (func $dummy3 (param i32 i32 i32)) (func (export "type-i32") (result i32) (unreachable)) - (func (export "type-i64") (result i32) (unreachable)) - (func (export "type-f32") (result f64) (unreachable)) + (func (export "type-i64") (result i64) (unreachable)) + (func (export "type-f32") (result f32) (unreachable)) (func (export "type-f64") (result f64) (unreachable)) (func (export "as-func-first") (result i32)