Trying to compile haxe from source: having trouble with haxelib build

Hello everyone!

I’m new here and would like to start by thanking all the contributors for putting Haxe together. I really like the language and the concepts behind it.

I’m successfully using haxe from linuxbrew right now, but I’d like to build it from source as a little learning exercise. I have zero OCaml experience though.

Using the build instructions [1] and an old forum thread [2], I managed to get semi-far, but I’m stuck at the stage where it compiles haxelib from the extra/haxelib_src subdir of the main haxe repo.

Hopefully, all I require here is a pointer about which is the best commit of haxelib to use when building haxe 4.2.5.

The 4.2.5 tag of the haxe repo from Mar-6 '22 seems to have haxelib_src linked to haxelib_src @ 4b27f91, which seems to be the 4.0.2 tag of haxelib from Nov '19.

Is this the best commit of haxelib to use when making a fresh build of haxe+haxelib now, when one is going for a setup that’s as stable as possible?

If I use that, my build fails with

dune build --workspace dune-workspace.dev src-prebuild/prebuild.exe
_build/default/src-prebuild/prebuild.exe libparams -cclib -lpcre -cclib -lz -cclib -lmbedtls -cclib -lmbedx509 -cclib -lmbedcrypto > lib.sexp
_build/default/src-prebuild/prebuild.exe version "0" "" "" > src/compiler/version.ml
dune build --workspace dune-workspace.dev src/haxe.exe
cp -f _build/default/src/haxe.exe ./"haxe"
(cd /tmp/haxe/haxe-4.2.5/extra/haxelib_src && /tmp/haxe/haxe-4.2.5/haxe client.hxml && nekotools boot run.n)
Type not found : haxe.remoting.Connection
make: *** [Makefile:105: haxelib] Error 1

If I use the most recent commit, it fails with

dune build --workspace dune-workspace.dev src-prebuild/prebuild.exe
_build/default/src-prebuild/prebuild.exe libparams -cclib -lpcre -cclib -lz -cclib -lmbedtls -cclib -lmbedx509 -cclib -lmbedcrypto > lib.sexp
_build/default/src-prebuild/prebuild.exe version "0" "" "" > src/compiler/version.ml
dune build --workspace dune-workspace.dev src/haxe.exe
cp -f _build/default/src/haxe.exe ./"haxe"
(cd /tmp/haxe/haxe-4.2.5/extra/haxelib_src && /tmp/haxe/haxe-4.2.5/haxe client.hxml && nekotools boot run.n)
src/haxelib/api/Installer.hx:329: characters 22-23 : Unexpected ?
make: *** [Makefile:105: haxelib] Error 1

This is also the symptom I get when I try to compile with the a18b403e8d commit that it’s currently pinned to from Apr-21.

If I try to compile the most recent commit of haxe, it doesn’t even get as far as having a working haxe build and trying to build haxelib. It instead fails with this symptom:

File "src/macro/eval/evalLuv.ml", line 95, characters 3-13:
95 |    | `EOVERFLOW -> 78
        ^^^^^^^^^^
Error: This pattern matches values of type [? `EOVERFLOW ]
       but a pattern was expected which matches values of type Luv.Error.t
       The second variant type does not allow tag(s) `EOVERFLOW
make: *** [Makefile:77: haxe] Error 1

How should I proceed?

Many thanks in advance,

Leo

[1] haxe/BUILDING.md at development · HaxeFoundation/haxe · GitHub
[2] Opam switch?

P.S. I also have a pointer that may be useful to future readers trying to build haxe from source: I’m on Gentoo and had to install the following prerequisites which weren’t on my system by default: dev-perl/String-ShellQuote, dev-perl/IPC-System-Simple, net-libs/mbedtls, dev-ml/opam.

When building neko, I had to run cmake with -DWITH_UI=OFF -DWITH_MYSQL=OFF -DWITH_APACHE=OFF -DWITH_SSL=OFF.

Managed to get it working now, thanks to the help of @Zeta on Discord.

For the benefit of anyone running into this forum thread in the future, here is how it got solved.

The issue with Type not found : haxe.remoting.Connection was due to missing hx3compat sources. What I was missing was git submodule update --init --recursive.

So the steps I used to build, were:

PREFIX=/usr/local

rm -rf ~/.opam

opam init \
  --bare \
  --disable-sandboxing \
  --no-setup \
  --disable-shell-hook

eval $(opam env)

opam switch \
  create 4.11.0

eval $(opam env)

B=`mktemp -d`
cd $B

git clone https://github.com/HaxeFoundation/neko.git
cd neko
git checkout ff67a69
mkdir build
cd build
cmake \
    -DWITH_UI=OFF \
    -DWITH_MYSQL=OFF \
    -DWITH_APACHE=OFF \
    -DWITH_SSL=OFF \
    -DCMAKE_INSTALL_PREFIX=$PREFIX/neko-2.3.0 \
    ..
make
make install

cd $B

export PATH=$PREFIX/neko-2.3.0/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/neko-2.3.0/lib:$LD_LIBRARY_PATH

git clone https://github.com/HaxeFoundation/haxe.git
cd haxe
git checkout e5eec31
git submodule update --init --recursive
eval $(opam env)
opam pin add haxe $PWD --kind=path --no-action
eval $(opam env)
opam install haxe --deps-only
eval $(opam env)
make
make INSTALL_DIR=$PREFIX/haxe-4.2.5 install