HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.14k stars 655 forks source link

Building haxe on FreeBSD broken #8873

Open pixelsyntax opened 4 years ago

pixelsyntax commented 4 years ago

I believe building from source on FreeBSD is broken. Attempting to build HEAD on FreeBSD using the instructions given at https://haxe.org/documentation/introduction/building-haxe.html

$ gmake
...
dune build --workspace dune-workspace.dev src/haxe.exe
      ocamlc libs/pcre/pcre_stubs.o (exit 2)
(cd _build/default/libs/pcre && /usr/local/bin/ocamlc.opt -g -ccopt -O2 -ccopt -fno-strict-aliasing -ccopt -fwrapv -ccopt -D_FILE_OFFSET_BITS=64 -ccopt -D_REENTRANT -ccopt -D_THREAD_SAFE -ccopt -fPIC -ccopt -g -o pcre_stubs.o pcre_stubs.c)
pcre_stubs.c:56:10: fatal error: 'pcre.h' file not found
#include "pcre.h"
         ^~~~~~~~
1 error generated.

This appears to be addressed by @andyli's comment here https://github.com/HaxeFoundation/haxe/issues/6146#issuecomment-295161446, however

$ gmake "CFLAGS=-I /usr/local/include/"
...
dune build --workspace dune-workspace.dev src/haxe.exe
      ocamlc libs/pcre/pcre_stubs.o (exit 2)
(cd _build/default/libs/pcre && /usr/local/bin/ocamlc.opt -g -ccopt -O2 -ccopt -fno-strict-aliasing -ccopt -fwrapv -ccopt -D_FILE_OFFSET_BITS=64 -ccopt -D_REENTRANT -ccopt -D_THREAD_SAFE -ccopt -fPIC -ccopt -g -o pcre_stubs.o pcre_stubs.c)
pcre_stubs.c:56:10: fatal error: 'pcre.h' file not found
#include "pcre.h"
         ^~~~~~~~
1 error generated.

After learning way more about dune than I'd care to know, I have been able to work around the problem by modifying /haxe/dune from

(data_only_dirs extra lib std tests)

to

(env
        (release
                (ocamlopt_flags (:standard -ccopt -L/usr/local/lib))
                (c_flags ("-I/usr/local/include"))
        )
)
(data_only_dirs extra lib std tests)
$ gmake
...
cp -f _build/default/src/haxe.exe ./haxe
(cd /usr/home/voxel/Src/External/haxe/extra/haxelib_src && /usr/home/voxel/Src/External/haxe/haxe client.hxml && nekotools boot run.n)
mv extra/haxelib_src/run haxelib

Which now allows gmake to run the build as expected. I'm not sure what a cleaner way to fix this issue would be.

Simn commented 4 years ago

Right, I suppose we have to allow injecting custom CFLAGS somehow. I did that with LIB_PARAMS in what feels like a really hacky way: The makefile runs prebuild.exe which writes out lib.sexp, which is then used in the dune file as (link_flags (:include ../lib.sexp)).

We could do the same for CFLAGS, but I wonder if there's an easier approach.

tcdude commented 3 years ago

Is this still being considered? I managed to build HEAD with the changes described by @pixelsyntax, would be nice to get this a bit more streamlined so I could get this to build in a github action.