Tezos on NetBSD

Some notes on getting Octez to compile on NetBSD. Work in progress.

Problems with possible solutions

  1. Opam package doesn't include solver properly.

Three ways:

OCaml builds in pkgsrc. Submit our pkgsrc patches back to OCaml team?

# [...]
# In file included from /usr/include/ctype.h:100,
#                  from sak.c:29:
# sak.c: In function 'add_stdlib_prefix':
# sak.c:126:26: warning: array subscript has type 'char' [-Wchar-subscripts]
#   126 |       *name = toupper_os(*name);
#       |                          ^
# sak.c:126:15: note: in expansion of macro 'toupper_os'
#   126 |       *name = toupper_os(*name);
#       |               ^~~~~~~~~~
# gcc -O2 -fno-strict-aliasing -fwrapv -pthread -Wall -Wdeclaration-after-statement -fno-common -fexcess-precision=standard -g  -Wl,-E  -o sak sak.o
# gmake[1]: Leaving directory '/disc/tezos/_opam/.opam-switch/build/ocaml-base-compiler.4.14.1/runtime'
# Makefile:988: *** The native-code compiler is not supported on this platform.  Stop.
  1. HACL Star library explicitly excludes NetBSD Patch done. FreeBSD settings work. Sent to vdum.

  2. GMP fix

Cannot find GMP where it expects.

zen: {343} setenv CFLAGS -I/usr/pkg/include
zen: {344} opam install conf-gmp --verbose
zen: {345} eval `opam env`
  1. Zarith 1.12

Zarith hackery 1.13 works out of the box. We seem to require 1.12?

cd ../
mkdir zarith-1.12
ftp -a https://github.com/ocaml/Zarith/archive/release-1.13.tar.gz
cd zarith-1.12/
tar zxvf ../release-1.13.tar.gz
zen: {363} cd ../../tezos/
zen: {364} pwd
zen: {365} opam install ../zarith-1.12/Zarith-release-1.13

mirage-crypto-rng FreeBSD definition line in sources - needs NetBSD too! Add -DFreeBSD as a workaround

pringo.1.3 popcount function conflicts with native one I worked around by renaming it - what is the best way normally?

pyml pyml_arch.ml.c checks for unix. We have unix Pull request submitted to pyml https://github.com/thierry-martinez/pyml/pull/99

parsexp SEG FAULT


  1. disc space error in /tmp. /tmp needs at least 906M free drwxrwxrwt 6 root wheel 384 Jan 27 15:32 tmp

  2. error[E0412]: cannot find type QueryIter in module os --> /home/cjep/src/tezos/_opam/.opam-switch/build/tezos-rust-libs.1.6/vendor/region/src/qu ery.rs:7:24 | 7 | iterator: Option, | ^^^^^^^^^ not found in os | help: consider importing this struct

Repeatedly wanting to install autoconf. Has to be a path issue


I will update this as I go.

  1. Make sure /tmp has at least 1G available otherwise tezos-rust-libs cannot start to compile. On older machines /tmp is often in RAM to speed up.

  2. Install prerequisites pkgin install gmake ocaml-opam jq git libev libhidapi autoconf

  3. Get Rust

  4. Get the Tezos sources

setenv C_INCLUDE_PATH /usr/pkg/include:/usr/pkg/include/ev setenv LIBRARY_PATH /usr/pkg/lib:/usr/pkg/lib/ev

setenv CFLAGS "-I/usr/pkg/include -DFreeBSD -fPIC"

setenv CFLAGS -I/usr/pkg/include

  1. init --bare gmake build-deps

Fix ups: opam install ../fixed up - hacl-star-raw needs the patch - pringo function fix - pyml - mirage-crypto-rng -DFreeBSD - zarith (install 13 instead of 12)

gmake build-deps