Open vl-ms opened 1 year ago
Thanks for the report! Happy to update wasm3 once fixed there. DO you have any suggestions for the Makefile?
Not yet
Instructions from here https://github.com/wasm3/wasm3/blob/main/docs/Development.md work perfectly fine for me:
mkdir -p build
cd build
cmake ..
make -j8
But seems like your Makefile tries to build it by using cmake directly without the make step:
BUILD_DIR=build
BUILDTYPE?=Release
...
$(BUILD_DIR)/Makefile:
@mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR); cmake ../ -DCMAKE_BUILD_TYPE=$(BUILDTYPE)
I'm not skilled in writing Makefiles, but basically there should be an exception for wasm3. I might dig into this myself, but probably not today, sadly.
Basically, the
-j $(shell nproc)
parts are Linux-specific. I don't think that there is an equivalent on OpenBSD or Unices in general.
BSD-flavoured make(1)
implementations can use !=
assignments to store the result of a shell command (though this doesn't work in GNU Make):
OS_NAME != uname -v
all:
@ echo "You are running $(OS_NAME)."
However, there's no good reason for your Makefile to use $(shell …)
instead of ordinary command substitution. Try this instead:
build: $(BUILD_DIR)/Makefile
- cmake --build $(BUILD_DIR) -j $(shell nproc)
+ cmake --build $(BUILD_DIR) -j "`nproc`"
$(…)
may be used instead of `…`
, but the dollar-sign requires escaping:
build: $(BUILD_DIR)/Makefile
- cmake --build $(BUILD_DIR) -j $(shell nproc)
+ cmake --build $(BUILD_DIR) -j "$$(nproc)"
Your makefile includes other constructs which aren't portable between Make implementations, so it might be wise to rename it GNUmakefile
and add a BSDmakefile
to either invoke GNU Make or bail with a meaningful error, depending on whether gnumake
exists in the user's $PATH:
BSDmakefile:
# -*- makefile-bsdmake -*- vim: ft=make
make != \
unset exe; \
for cmd in gnumake gmake gnu-make; do \
exe=`command -v "$$cmd" 2>&1 || :`; \
[ ! "$$exe" ] || break; \
done; \
[ "$$exe" ] && [ -x "$$exe" ] || \
exe='echo >&2 "GNU Make is required to build this project." && exit 2'\ \#; \
printf %s "$$exe"
.DEFAULT:
@ ${make} $@
Interesting! Thanks for sharing this!
Basically, the "-j $(shell nproc)" parts are Linux-specific. I don't think that there is an equivalent on OpenBSD or Unices in general. After removing these parts, there is a new problem:
This is the problem with the upstream wasm3, though. I will report it there & probably suggest to use https://man.openbsd.org/arc4random.3 instead. Will keep you updated once that is fixed!