HaxeFoundation / haxe

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

Non-Issue: How to Get Haxe Compiling and Running on FreeBSD 14 #11764

Open bedwardly-down opened 2 months ago

bedwardly-down commented 2 months ago

Hey there. Older Haxe releases used to be supported by the BSD community but were removed awhile back. Here's how I was able to get the latest master to build and run on my system. It's a 2 stage build process that seems to be consistent so far (but could break later on).

Steps

  1. Run git clone --recursive --branch 4.2.4 https://github.com/HaxeFoundation/haxe.git - Version 4.2.4 is the latest release that works with the current ocaml version (anything higher breaks without having to modify the dune project files).
  2. Install the latest version of ocaml along with any other libraries required (will vary per system and release): sudo pkg install ocaml
  3. Follow the ocaml and installing dependencies instructions from the main build guide
  4. Compile: gmake -j$(nproc)
  5. Remove the extra/haxelib_src folder (without removing the haxe and haxelib binaries and _build directory)
  6. Run git checkout <newer haxe release>
  7. Run git submodule update --recursive --init to regenerate extra/haxelib_src
  8. Run opam upgrade to install the new ocaml packages required by the new Haxe version.
  9. Repeat Step 4.
  10. Install the haxe and haxelib binaries where you want.

Logic Behind These Steps

  1. Several required Ocaml packages will fail to build and install due to not supporting the BSDs upstream, causing a platform failure check. Installing the older versions requested by Haxe 4.2.4 and then upgrading them gets around this problem.
  2. Haxe 4.2.4 was the last release to have a dune configuration that properly detected /usr/local/lib (where all of the dependencies it looked for are installed). Newer Haxe releases use a version of dune that's incompatible with FreeBSD and needs manual editing of the dune project files otherwise.
  3. The old _build directory gets reused by gmake to bootstrap the building of the new Haxe versions; there were internal build tools created by ocaml in the earlier steps that work correctly with the current Haxe master, so why not use them?

Caveats

  1. Hashlink seems to compile and work but anything that relies on hxcpp or lime will fail (due to a lack of toolchain configurations for the platform).
  2. HTML5 and Electron support are always in flux and spotty with the BSDs, so expect breakage there but browser libraries should work fine for the most part.

Thanks for reading. I hope this helps people out and support can be improved. :D

EDIT: This is related to #8873

Simn commented 2 months ago

Thank you for this information! Perhaps the wiki would be a good place to put this?

bedwardly-down commented 2 months ago

I'd like to see if others can improve on and add to this before adding there. It's possible that this could break for others, so getting further testing could help immensely. :D