txiki.js
txiki.js copied to clipboard
Build problems on OpenBSD
; make
cd build; cmake ../ -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Building in Release mode
-- Building with Clang 13.0.0 on OpenBSD-7.2
-- C flags:
-- C Debug flags: -g -ggdb -O0 -fno-omit-frame-pointer
-- C Release flags: -O3 -DNDEBUG -g
-- BUILD_WITH_ASAN: OFF
-- USE_EXTERNAL_FFI: OFF
-- Performing Test UV_LINT_W4
-- Performing Test UV_LINT_W4 - Failed
-- Performing Test UV_LINT_NO_UNUSED_PARAMETER_MSVC
-- Performing Test UV_LINT_NO_UNUSED_PARAMETER_MSVC - Failed
-- Performing Test UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC
-- Performing Test UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC - Failed
-- Performing Test UV_LINT_NO_NONSTANDARD_MSVC
-- Performing Test UV_LINT_NO_NONSTANDARD_MSVC - Failed
-- Performing Test UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC
-- Performing Test UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC - Failed
-- Performing Test UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC
-- Performing Test UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC - Failed
-- Performing Test UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC
-- Performing Test UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC - Failed
-- Performing Test UV_LINT_NO_HIDES_LOCAL
-- Performing Test UV_LINT_NO_HIDES_LOCAL - Failed
-- Performing Test UV_LINT_NO_HIDES_PARAM
-- Performing Test UV_LINT_NO_HIDES_PARAM - Failed
-- Performing Test UV_LINT_NO_HIDES_GLOBAL
-- Performing Test UV_LINT_NO_HIDES_GLOBAL - Failed
-- Performing Test UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC
-- Performing Test UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC - Failed
-- Performing Test UV_LINT_NO_UNSAFE_MSVC
-- Performing Test UV_LINT_NO_UNSAFE_MSVC - Failed
-- Performing Test UV_LINT_WALL
-- Performing Test UV_LINT_WALL - Success
-- Performing Test UV_LINT_NO_UNUSED_PARAMETER
-- Performing Test UV_LINT_NO_UNUSED_PARAMETER - Success
-- Performing Test UV_LINT_STRICT_PROTOTYPES
-- Performing Test UV_LINT_STRICT_PROTOTYPES - Success
-- Performing Test UV_LINT_EXTRA
-- Performing Test UV_LINT_EXTRA - Success
-- Performing Test UV_LINT_UTF8_MSVC
-- Performing Test UV_LINT_UTF8_MSVC - Failed
-- Performing Test UV_F_STRICT_ALIASING
-- Performing Test UV_F_STRICT_ALIASING - Success
-- summary of build options:
Install prefix: /usr/local
Target system: OpenBSD
Compiler:
C compiler: /usr/bin/cc (Clang)
CFLAGS:
-- The CXX compiler identification is Clang 13.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
----
Generator: Unix Makefiles
Compiler: Clang
Build Type: Release
LTO: ON
Flags: -Dd_m3HasTracer -Wall -Wextra -Wparentheses -Wundef -Wpointer-arith -Wstrict-aliasing=2 -Werror=implicit-function-declaration -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -Dd_m3HasWASI
Debug flags: -g -ggdb -O0 -fno-omit-frame-pointer -ggdb -O0
Release flags: -O3 -Wfatal-errors -fomit-frame-pointer -fno-stack-check -fno-stack-protector -march=native
----
-- Found CURL: /usr/local/lib/libcurl.so.26.17 (found version "7.86.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/unix/software/txiki.js/build
cmake --build build -j
make: option requires an argument -- j
usage: make [-BeiknpqrSst] [-C directory] [-D variable] [-d flags] [-f mk]
[-I directory] [-j max_processes] [-m directory] [-V variable]
[NAME=value] [target ...]
*** Error 2 in /home/unix/software/txiki.js (Makefile:7 'build')
;
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:
; make
cmake --build build
[ 0%] Building C object deps/wasm3/source/CMakeFiles/m3.dir/m3_api_libc.c.o
[ 1%] Building C object deps/wasm3/source/CMakeFiles/m3.dir/m3_api_wasi.c.o
/home/unix/software/txiki.js/deps/wasm3/source/m3_api_wasi.c:47:16: fatal error: 'sys/random.h' file not found
# include <sys/random.h>
^~~~~~~~~~~~~~
1 error generated.
*** Error 1 in build (deps/wasm3/source/CMakeFiles/m3.dir/build.make:90 'deps/wasm3/source/CMakeFiles/m3.dir/m3_api_wasi.c.o': cd /home/unix...)
*** Error 2 in build (CMakeFiles/Makefile2:1121 'deps/wasm3/source/CMakeFiles/m3.dir/all': /usr/bin/make -s -f deps/wasm3/source/CMakeFiles/...)
*** Error 2 in build (Makefile:136 'all': /usr/bin/make -s -f CMakeFiles/Makefile2 all)
*** Error 2 in /home/unix/software/txiki.js (Makefile:7 'build')
;
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!
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!