From d7d548d90eddefb439c898e78cb9eaee2f38d773 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Mon, 20 May 2024 22:25:09 -0700 Subject: [PATCH 1/4] correct wasm2c examples - Passing "-lm" into the prereq isn't the correct way add the flag. This correctly adds it to the command. - The "rot13" example incorrectly assumed that the "rot13.h" file would be generated by the time that "main.c" was being compiled, however there is no rule supporting this and it would fail. I've also added "rot13.h" to the clean rule. --- wasm2c/examples/callback/Makefile | 3 ++- wasm2c/examples/fac/Makefile | 3 ++- wasm2c/examples/rot13/Makefile | 7 +++++-- wasm2c/examples/threads/Makefile | 5 +++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wasm2c/examples/callback/Makefile b/wasm2c/examples/callback/Makefile index 81ee53ef8..20ba9f9cb 100644 --- a/wasm2c/examples/callback/Makefile +++ b/wasm2c/examples/callback/Makefile @@ -6,7 +6,8 @@ all: callback clean: rm -rf callback callback.wasm callback.c callback.h *.o -callback: main.o callback.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o -lm +callback: main.o callback.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o + $(CC) $(LDFLAGS) -o $@ $^ -lm callback.wasm: callback.wat ../../../bin/wat2wasm ../../../bin/wat2wasm --debug-names $< -o $@ diff --git a/wasm2c/examples/fac/Makefile b/wasm2c/examples/fac/Makefile index 623fcfc38..d1261f1d0 100644 --- a/wasm2c/examples/fac/Makefile +++ b/wasm2c/examples/fac/Makefile @@ -6,7 +6,8 @@ all: fac clean: rm -rf fac fac.wasm fac.c *.o -fac: main.o fac.o ../../wasm-rt-impl.o -lm +fac: main.o fac.o ../../wasm-rt-impl.o + $(CC) $(LDFLAGS) -o $@ $^ -lm fac.wasm: fac.wat ../../../bin/wat2wasm ../../../bin/wat2wasm $< -o $@ diff --git a/wasm2c/examples/rot13/Makefile b/wasm2c/examples/rot13/Makefile index 1d46b3a9f..7d165719b 100644 --- a/wasm2c/examples/rot13/Makefile +++ b/wasm2c/examples/rot13/Makefile @@ -4,9 +4,12 @@ CFLAGS=-I../.. all: rot13 clean: - rm -rf rot13 rot13.wasm rot13.c *.o + rm -rf rot13 rot13.wasm rot13.c rot13.h *.o -rot13: main.o rot13.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o -lm +rot13: main.o rot13.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o + $(CC) $(LDFLAGS) -o $@ $^ -lm + +main.o: rot13.c rot13.wasm: rot13.wat ../../../bin/wat2wasm ../../../bin/wat2wasm $< -o $@ diff --git a/wasm2c/examples/threads/Makefile b/wasm2c/examples/threads/Makefile index f6eb99986..f43ea0157 100644 --- a/wasm2c/examples/threads/Makefile +++ b/wasm2c/examples/threads/Makefile @@ -4,11 +4,12 @@ LDFLAGS=${SANITIZERS} -pthread all: threads -threads: threads.o sample.o ../../wasm-rt-impl.o ../../wasm-rt-exceptions-impl.o -lm - clean: rm -rf threads sample.wasm sample.c sample.h *.o ../../*.o +threads: threads.o sample.o ../../wasm-rt-impl.o ../../wasm-rt-exceptions-impl.o + $(CC) $(LDFLAGS) -o $@ $^ -lm + sample.wasm: sample.wat ../../../bin/wat2wasm ../../../bin/wat2wasm --debug-names $< -o $@ From 07fcea5305831a8d9e802821258974bd1d9146e1 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Tue, 21 May 2024 08:11:13 -0700 Subject: [PATCH 2/4] use "rot13.h" as the prereq for "main.o" --- wasm2c/examples/rot13/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wasm2c/examples/rot13/Makefile b/wasm2c/examples/rot13/Makefile index 7d165719b..4bda9b76a 100644 --- a/wasm2c/examples/rot13/Makefile +++ b/wasm2c/examples/rot13/Makefile @@ -9,12 +9,12 @@ clean: rot13: main.o rot13.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o $(CC) $(LDFLAGS) -o $@ $^ -lm -main.o: rot13.c +main.o: rot13.h rot13.wasm: rot13.wat ../../../bin/wat2wasm ../../../bin/wat2wasm $< -o $@ -rot13.c: rot13.wasm ../../../bin/wasm2c - ../../../bin/wasm2c $< -o $@ --disable-simd +rot13.c rot13.h: rot13.wasm ../../../bin/wasm2c + ../../../bin/wasm2c $< -o rot13.c --disable-simd .PHONY: all clean From 34d8b44d78824fc1cab3a654b475c6d5a3755bfc Mon Sep 17 00:00:00 2001 From: David Rubin Date: Tue, 21 May 2024 09:21:09 -0700 Subject: [PATCH 3/4] pass "-lm" through "LDFLAGS" --- wasm2c/examples/callback/Makefile | 3 ++- wasm2c/examples/fac/Makefile | 3 ++- wasm2c/examples/rot13/Makefile | 3 ++- wasm2c/examples/threads/Makefile | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/wasm2c/examples/callback/Makefile b/wasm2c/examples/callback/Makefile index 20ba9f9cb..8b8c3e60e 100644 --- a/wasm2c/examples/callback/Makefile +++ b/wasm2c/examples/callback/Makefile @@ -1,5 +1,6 @@ # Use implicit rules for compiling C files. CFLAGS=-I../.. +LDFLAGS=-lm all: callback @@ -7,7 +8,7 @@ clean: rm -rf callback callback.wasm callback.c callback.h *.o callback: main.o callback.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o - $(CC) $(LDFLAGS) -o $@ $^ -lm + $(CC) -o $@ $^ $(LDFLAGS) callback.wasm: callback.wat ../../../bin/wat2wasm ../../../bin/wat2wasm --debug-names $< -o $@ diff --git a/wasm2c/examples/fac/Makefile b/wasm2c/examples/fac/Makefile index d1261f1d0..5f43d0f7d 100644 --- a/wasm2c/examples/fac/Makefile +++ b/wasm2c/examples/fac/Makefile @@ -1,5 +1,6 @@ # Use implicit rules for compiling C files. CFLAGS=-I../.. +LDFLAGS=-lm all: fac @@ -7,7 +8,7 @@ clean: rm -rf fac fac.wasm fac.c *.o fac: main.o fac.o ../../wasm-rt-impl.o - $(CC) $(LDFLAGS) -o $@ $^ -lm + $(CC) -o $@ $^ $(LDFLAGS) fac.wasm: fac.wat ../../../bin/wat2wasm ../../../bin/wat2wasm $< -o $@ diff --git a/wasm2c/examples/rot13/Makefile b/wasm2c/examples/rot13/Makefile index 4bda9b76a..42e3c1941 100644 --- a/wasm2c/examples/rot13/Makefile +++ b/wasm2c/examples/rot13/Makefile @@ -1,5 +1,6 @@ # Use implicit rules for compiling C files. CFLAGS=-I../.. +LDFLAGS=-lm all: rot13 @@ -7,7 +8,7 @@ clean: rm -rf rot13 rot13.wasm rot13.c rot13.h *.o rot13: main.o rot13.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o - $(CC) $(LDFLAGS) -o $@ $^ -lm + $(CC) -o $@ $^ $(LDFLAGS) main.o: rot13.h diff --git a/wasm2c/examples/threads/Makefile b/wasm2c/examples/threads/Makefile index f43ea0157..4c932df32 100644 --- a/wasm2c/examples/threads/Makefile +++ b/wasm2c/examples/threads/Makefile @@ -1,6 +1,6 @@ #SANITIZERS=-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all CFLAGS=-I../.. -g -O2 -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -fno-optimize-sibling-calls -frounding-math -fsignaling-nans ${SANITIZERS} -pthread -LDFLAGS=${SANITIZERS} -pthread +LDFLAGS=${SANITIZERS} -pthread -lm all: threads @@ -8,7 +8,7 @@ clean: rm -rf threads sample.wasm sample.c sample.h *.o ../../*.o threads: threads.o sample.o ../../wasm-rt-impl.o ../../wasm-rt-exceptions-impl.o - $(CC) $(LDFLAGS) -o $@ $^ -lm + $(CC) -o $@ $^ $(LDFLAGS) sample.wasm: sample.wat ../../../bin/wat2wasm ../../../bin/wat2wasm --debug-names $< -o $@ From 42b1de570f3e40fea218da244d980f24928612f2 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Sun, 2 Jun 2024 22:50:35 -0700 Subject: [PATCH 4/4] use "LDLIBS" instead of "LDFLAGS" --- wasm2c/examples/callback/Makefile | 3 +-- wasm2c/examples/fac/Makefile | 3 +-- wasm2c/examples/fac/fac.wasm | Bin 56 -> 0 bytes wasm2c/examples/rot13/Makefile | 3 +-- wasm2c/examples/threads/Makefile | 3 +-- 5 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 wasm2c/examples/fac/fac.wasm diff --git a/wasm2c/examples/callback/Makefile b/wasm2c/examples/callback/Makefile index 8b8c3e60e..ef7abf76a 100644 --- a/wasm2c/examples/callback/Makefile +++ b/wasm2c/examples/callback/Makefile @@ -1,6 +1,6 @@ # Use implicit rules for compiling C files. CFLAGS=-I../.. -LDFLAGS=-lm +LDLIBS=-lm all: callback @@ -8,7 +8,6 @@ clean: rm -rf callback callback.wasm callback.c callback.h *.o callback: main.o callback.o ../../wasm-rt-impl.o ../../wasm-rt-mem-impl.o - $(CC) -o $@ $^ $(LDFLAGS) callback.wasm: callback.wat ../../../bin/wat2wasm ../../../bin/wat2wasm --debug-names $< -o $@ diff --git a/wasm2c/examples/fac/Makefile b/wasm2c/examples/fac/Makefile index 5f43d0f7d..a14a4a6c8 100644 --- a/wasm2c/examples/fac/Makefile +++ b/wasm2c/examples/fac/Makefile @@ -1,6 +1,6 @@ # Use implicit rules for compiling C files. CFLAGS=-I../.. -LDFLAGS=-lm +LDLIBS=-lm all: fac @@ -8,7 +8,6 @@ clean: rm -rf fac fac.wasm fac.c *.o fac: main.o fac.o ../../wasm-rt-impl.o - $(CC) -o $@ $^ $(LDFLAGS) fac.wasm: fac.wat ../../../bin/wat2wasm ../../../bin/wat2wasm $< -o $@ diff --git a/wasm2c/examples/fac/fac.wasm b/wasm2c/examples/fac/fac.wasm deleted file mode 100644 index 711421b606e3c5aec61d1afee5311fbdeeb78eb4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 56 zcmZQbEY4+QU|?WmV@zPIXRK#tVq{=vXJk%GOlDx