How to compile OCaml program on Linux for running on FreeBSD

I’ll mention that the (Linux x86-64 ╳ FreeBSD x86-64) cross doesn’t seem on the surface to present much difficulties. If someone you know understands how to setup a cross-compiler from Linux to FreeBSD in C (preferably with clang and an easy-to-download FreeBSD sysroot), and would be willing to maintain the cross, I can walk them through adding it to dkml-base-compiler.4.14.x. That compiler package supports, among other things, Linux/Darwin x86-64 to Android x86-64. And the first step for FreeBSD … registering it in dkml-c-probe … is already done.

Note: I lost some links to CI jobs that were examples of how to use dkml-base-compiler to cross-compile Android. The next best thing is looking at the more complicated DkHelloWorld CI pipeline and the tail end of its logs to see what dkml-base-compiler can do. You’ll see Android clang cross-compiles, macOS x86-64 to arm64 clang cross-compiles, Linux GCC compilation using dockcross, and MSVC. Search for 1/5 Test #1: DkHelloWorld. GIVEN main-cli WHEN inspect with 'file' THEN get architecture and the line above that will show the native code architecture that was compiled.

3 Likes