Skip to content

Commit

Permalink
Correct wasm2c example Makefiles (#2426)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Rexicon226 committed Jun 3, 2024
1 parent 2c50f59 commit 4beb525
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion wasm2c/examples/callback/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Use implicit rules for compiling C files.
CFLAGS=-I../..
LDLIBS=-lm

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

callback.wasm: callback.wat ../../../bin/wat2wasm
../../../bin/wat2wasm --debug-names $< -o $@
Expand Down
3 changes: 2 additions & 1 deletion wasm2c/examples/fac/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Use implicit rules for compiling C files.
CFLAGS=-I../..
LDLIBS=-lm

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

fac.wasm: fac.wat ../../../bin/wat2wasm
../../../bin/wat2wasm $< -o $@
Expand Down
Binary file removed wasm2c/examples/fac/fac.wasm
Binary file not shown.
11 changes: 7 additions & 4 deletions wasm2c/examples/rot13/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Use implicit rules for compiling C files.
CFLAGS=-I../..
LDLIBS=-lm

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

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
6 changes: 3 additions & 3 deletions wasm2c/examples/threads/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#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
LDLIBS=${SANITIZERS} -pthread -lm

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

sample.wasm: sample.wat ../../../bin/wat2wasm
../../../bin/wat2wasm --debug-names $< -o $@

Expand Down

0 comments on commit 4beb525

Please sign in to comment.