From 80dc28f140cc6977f099e0fb050afa8e81eb5f62 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Wed, 22 Jan 2025 16:39:21 +0100 Subject: [PATCH 01/15] Reorganise the examples Rename the examples, so that there are no longer `main.xyz.ml`, just `xyz.ml` Extract the common C modules into a library so that all the tests can be compiled (and executed) in one run of `dune` Set up a `dune_gen` to avoid the boilerplate of all the options (in particular since putting the manifest in a library requires an explicit option to link it in) --- example/dune | 32 ++++++++------ example/dune.inc | 46 ++++++++++++++++++++ example/dune_gen.ml | 56 +++++++++++++++++++++++++ example/{main.hello.ml => hello.ml} | 0 example/{main.sysfail.ml => sysfail.ml} | 0 5 files changed, 122 insertions(+), 12 deletions(-) create mode 100644 example/dune.inc create mode 100644 example/dune_gen.ml rename example/{main.hello.ml => hello.ml} (100%) rename example/{main.sysfail.ml => sysfail.ml} (100%) diff --git a/example/dune b/example/dune index 95bfd815..2bcf60f9 100644 --- a/example/dune +++ b/example/dune @@ -1,26 +1,34 @@ (executable - (name main) - (link_flags :standard -cclib "-z solo5-abi=%{env:MODE=hvt}") + (name dune_gen) + (modules dune_gen)) + +(rule + (alias runtest) + (mode promote) + (action + (with-stdout-to + dune.inc + (run ./dune_gen.exe)))) + +(include dune.inc) + +; As we add the manifest to a library, we'll need to explicitly ask for it to be +; linked in (for instance by telling the compiler / linker that the +; `__solo5_mft1_note` symbol is undefined) otherwise we'll end up with errors such +; as: `solo5-hvt: ...: Invalid or unsupported executable` +(library + (name solo5os) + (modules) (foreign_stubs (language c) (names startup manifest))) -(rule - (copy main.%{env:SOLO5TEST=hello}.ml main.ml)) - (rule (targets manifest.c) (deps manifest.json) (action (run solo5-elftool gen-manifest manifest.json manifest.c))) -(rule - (alias runtest) - (enabled_if - (= %{context_name} solo5)) - (action - (run "solo5-%{env:MODE=hvt}" "%{dep:main.exe}"))) - (alias (name default) (enabled_if diff --git a/example/dune.inc b/example/dune.inc new file mode 100644 index 00000000..caaab978 --- /dev/null +++ b/example/dune.inc @@ -0,0 +1,46 @@ +(executable + (name hello) + (enabled_if + (= %{context_name} solo5)) + (modules hello) + (link_flags + :standard + -cclib + "-z solo5-abi=%{env:MODE=hvt}" + ; Force linking the manifest in + -cclib + "-u __solo5_mft1_note") + (libraries solo5os) + (modes native)) + +(rule + (alias runtest) + (enabled_if + (= %{context_name} solo5)) + (action + (run "solo5-%{env:MODE=hvt}" "%{dep:hello.exe}"))) + +(executable + (name sysfail) + (enabled_if + (= %{context_name} solo5)) + (modules sysfail) + (link_flags + :standard + -cclib + "-z solo5-abi=%{env:MODE=hvt}" + ; Force linking the manifest in + -cclib + "-u __solo5_mft1_note") + (libraries solo5os) + (modes native)) + +(rule + (alias runtest) + (enabled_if + (= %{context_name} solo5)) + (action + (with-accepted-exit-codes + 2 + (run "solo5-%{env:MODE=hvt}" "%{dep:sysfail.exe}")))) + diff --git a/example/dune_gen.ml b/example/dune_gen.ml new file mode 100644 index 00000000..fe416ef3 --- /dev/null +++ b/example/dune_gen.ml @@ -0,0 +1,56 @@ +let print_rule test exitcode extraifs extralibs = + let enabled_if out extraifs = + Printf.fprintf out {|(enabled_if + %a(= %%{context_name} solo5)%a)|} + (fun out ifs -> + match ifs with + | [] -> () + | _ -> + Printf.fprintf out {|(and + |}; + List.iter (Printf.fprintf out {|%s + |}) ifs) + extraifs + (fun out ifs -> match ifs with [] -> () | _ -> Printf.fprintf out ")") + extraifs + in + Printf.printf + {|(executable + (name %s) + %a + (modules %s) + (link_flags + :standard + -cclib + "-z solo5-abi=%%{env:MODE=hvt}" + ; Force linking the manifest in + -cclib + "-u __solo5_mft1_note") + (libraries solo5os%a) + (modes native)) + +(rule + (alias runtest) + %a + (action + %a(run "solo5-%%{env:MODE=hvt}" "%%{dep:%s.exe}")%a)) + +|} + test enabled_if extraifs test + (fun out -> List.iter (Printf.fprintf out " %s")) + extralibs enabled_if extraifs + (fun out exitcode -> + match exitcode with + | None -> () + | Some code -> + Printf.fprintf out {|(with-accepted-exit-codes + %d + |} code) + exitcode test + (fun out exitcode -> + match exitcode with None -> () | Some _ -> Printf.fprintf out ")") + exitcode + +let _ = + print_rule "hello" None [] []; + print_rule "sysfail" (Some 2) [] [] diff --git a/example/main.hello.ml b/example/hello.ml similarity index 100% rename from example/main.hello.ml rename to example/hello.ml diff --git a/example/main.sysfail.ml b/example/sysfail.ml similarity index 100% rename from example/main.sysfail.ml rename to example/sysfail.ml From a69103fa97d77e09287fec6a47438bac7f41e794 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Wed, 22 Jan 2025 16:42:09 +0100 Subject: [PATCH 02/15] Add new examples, testing the config and the compiler libs --- example/compilerlibsx86.ml | 6 +++++ example/config.ml | 3 +++ example/dune.inc | 50 ++++++++++++++++++++++++++++++++++++++ example/dune_gen.ml | 6 ++++- 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 example/compilerlibsx86.ml create mode 100644 example/config.ml diff --git a/example/compilerlibsx86.ml b/example/compilerlibsx86.ml new file mode 100644 index 00000000..f57f65b3 --- /dev/null +++ b/example/compilerlibsx86.ml @@ -0,0 +1,6 @@ +(* Access fields provided by the (x86_64) compiler libs *) +(* Requires patches in 5.3+ *) + +let _ = + Printf.printf "allow_unaligned_access = %b\n" Arch.allow_unaligned_access; + Printf.printf "win64 = %b\n" Arch.win64 diff --git a/example/config.ml b/example/config.ml new file mode 100644 index 00000000..1dcacaf4 --- /dev/null +++ b/example/config.ml @@ -0,0 +1,3 @@ +let _ = + Printf.printf "Version: %s\nOS: %s\nUnix: %b\nWin: %b\nCygwin: %b\n" + Sys.ocaml_version Sys.os_type Sys.unix Sys.win32 Sys.cygwin diff --git a/example/dune.inc b/example/dune.inc index caaab978..b885dfbd 100644 --- a/example/dune.inc +++ b/example/dune.inc @@ -44,3 +44,53 @@ 2 (run "solo5-%{env:MODE=hvt}" "%{dep:sysfail.exe}")))) +(executable + (name config) + (enabled_if + (= %{context_name} solo5)) + (modules config) + (link_flags + :standard + -cclib + "-z solo5-abi=%{env:MODE=hvt}" + ; Force linking the manifest in + -cclib + "-u __solo5_mft1_note") + (libraries solo5os) + (modes native)) + +(rule + (alias runtest) + (enabled_if + (= %{context_name} solo5)) + (action + (run "solo5-%{env:MODE=hvt}" "%{dep:config.exe}"))) + +(executable + (name compilerlibsx86) + (enabled_if + (and + (>= %{ocaml_version} 5.3.0) + (= %{architecture} amd64) + (= %{context_name} solo5))) + (modules compilerlibsx86) + (link_flags + :standard + -cclib + "-z solo5-abi=%{env:MODE=hvt}" + ; Force linking the manifest in + -cclib + "-u __solo5_mft1_note") + (libraries solo5os compiler-libs.optcomp) + (modes native)) + +(rule + (alias runtest) + (enabled_if + (and + (>= %{ocaml_version} 5.3.0) + (= %{architecture} amd64) + (= %{context_name} solo5))) + (action + (run "solo5-%{env:MODE=hvt}" "%{dep:compilerlibsx86.exe}"))) + diff --git a/example/dune_gen.ml b/example/dune_gen.ml index fe416ef3..508ad818 100644 --- a/example/dune_gen.ml +++ b/example/dune_gen.ml @@ -53,4 +53,8 @@ let print_rule test exitcode extraifs extralibs = let _ = print_rule "hello" None [] []; - print_rule "sysfail" (Some 2) [] [] + print_rule "sysfail" (Some 2) [] []; + print_rule "config" None [] []; + print_rule "compilerlibsx86" None + [ "(>= %{ocaml_version} 5.3.0)"; "(= %{architecture} amd64)" ] + [ "compiler-libs.optcomp" ] From daacec0988dca11ff2369ea122e66512c54dadea Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Wed, 22 Jan 2025 10:47:29 +0100 Subject: [PATCH 03/15] Update CI to compile (and run) all the examples --- .github/workflows/test.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc44d7fd..93aa7c8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,20 +17,15 @@ jobs: !ocaml-solo5-cross-aarch64.opam - name: Install ocaml-solo5 and dune run: opam install ocaml-solo5 conf-libseccomp dune - - name: Compile example with hvt + - name: Compile examples with hvt run: MODE=hvt opam exec -- dune build --root example - - name: Compile example with spt + - name: Compile examples with spt run: MODE=spt opam exec -- dune build --root example - - name: Run example with spt - run: opam exec -- solo5-spt example/_build/solo5/main.exe - - name: Compile a failing example with spt - run: MODE=spt SOLO5TEST=sysfail opam exec -- dune build --root example - - name: Run a failing example with spt - run: | - ! opam exec -- solo5-spt example/_build/solo5/main.exe - - name: Compile example with virtio + - name: Run examples with spt + run: MODE=spt opam exec -- dune runtest --root example + - name: Compile examples with virtio run: MODE=virtio opam exec -- dune build --root example - - name: Compile example with muen + - name: Compile examples with muen run: MODE=muen opam exec -- dune build --root example - - name: Compile example with xen + - name: Compile examples with xen run: MODE=xen opam exec -- dune build --root example From f6636c17d39ceb4c7b08176333cc8d7f43415d75 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 10:20:35 +0100 Subject: [PATCH 04/15] Add patches for 5.3.0 Those patches are extracted from (only keeping what is relevant for OCaml/Solo5): - PR 13526 (merged upstream) (10 commits) - PR 13674 (merged upstream) (1 commit) - PR 13719 (merged upstream) (1 commit) - PR 13735 (merged upstream) (7 commits) - a not-opened-yet PR to support freestanding targets (2 commits) - plus a not-to-be-upstreamed commit to fix the maximum number of domains to 1 --- ...ad-of-host-to-detect-the-C-toolchain.patch | 142 ++++ ...ad-of-host-when-relevant-in-configur.patch | 619 ++++++++++++++++++ ...t-a-_build_-C-toolchain-to-build-sak.patch | 321 +++++++++ ...Caml-versions-are-compatible-for-a-c.patch | 54 ++ ...DIR-configure-variable-instead-of-wi.patch | 85 +++ ...igurable-library-directory-on-target.patch | 102 +++ ...ct-flexlink-only-on-relevant-targets.patch | 43 ++ ...ross-with-rules-to-build-a-cross-com.patch | 117 ++++ ...ping-flexdll-in-the-cross-compiler-s.patch | 99 +++ ...10-Fix-static-builds-of-the-compiler.patch | 49 ++ ..._debugger_saved_instruction-when-HAS.patch | 39 ++ ...t-the-beginning-of-assembler-sources.patch | 112 ++++ ...for-the-GNU-note-for-non-executable-.patch | 113 ++++ ...iable-for-the-need-of-the-GNU-non-ex.patch | 72 ++ ....GNU-stack-section-based-on-configur.patch | 302 +++++++++ ...or-.size-and-.type-assembler-directi.patch | 143 ++++ ...iable-for-the-.size-and-.type-assemb.patch | 70 ++ ...-and-.type-directives-based-on-confi.patch | 481 ++++++++++++++ ...eestanding-targets-at-configure-time.patch | 68 ++ ...-triplet-target-to-build-freestandin.patch | 63 ++ .../0021-Set-Max_domains_-def-max-to-1.patch | 44 ++ 21 files changed, 3138 insertions(+) create mode 100644 patches/5.3.0/0001-Use-target-instead-of-host-to-detect-the-C-toolchain.patch create mode 100644 patches/5.3.0/0002-Use-target-instead-of-host-when-relevant-in-configur.patch create mode 100644 patches/5.3.0/0003-Detect-a-_build_-C-toolchain-to-build-sak.patch create mode 100644 patches/5.3.0/0004-Check-that-the-OCaml-versions-are-compatible-for-a-c.patch create mode 100644 patches/5.3.0/0005-Use-a-TARGET_BINDIR-configure-variable-instead-of-wi.patch create mode 100644 patches/5.3.0/0006-Add-a-configurable-library-directory-on-target.patch create mode 100644 patches/5.3.0/0007-Detect-flexlink-only-on-relevant-targets.patch create mode 100644 patches/5.3.0/0008-Add-a-Makefile.cross-with-rules-to-build-a-cross-com.patch create mode 100644 patches/5.3.0/0009-Enable-bootstrapping-flexdll-in-the-cross-compiler-s.patch create mode 100644 patches/5.3.0/0010-Fix-static-builds-of-the-compiler.patch create mode 100644 patches/5.3.0/0011-Add-a-dummy-caml_debugger_saved_instruction-when-HAS.patch create mode 100644 patches/5.3.0/0012-Include-asm.h-at-the-beginning-of-assembler-sources.patch create mode 100644 patches/5.3.0/0013-Detect-the-need-for-the-GNU-note-for-non-executable-.patch create mode 100644 patches/5.3.0/0014-Add-a-Config-variable-for-the-need-of-the-GNU-non-ex.patch create mode 100644 patches/5.3.0/0015-Output-the-.note.GNU-stack-section-based-on-configur.patch create mode 100644 patches/5.3.0/0016-Detect-support-for-.size-and-.type-assembler-directi.patch create mode 100644 patches/5.3.0/0017-Add-a-Config-variable-for-the-.size-and-.type-assemb.patch create mode 100644 patches/5.3.0/0018-Output-the-.size-and-.type-directives-based-on-confi.patch create mode 100644 patches/5.3.0/0019-Accept-native-freestanding-targets-at-configure-time.patch create mode 100644 patches/5.3.0/0020-Allow-ocaml-in-a-triplet-target-to-build-freestandin.patch create mode 100644 patches/5.3.0/0021-Set-Max_domains_-def-max-to-1.patch diff --git a/patches/5.3.0/0001-Use-target-instead-of-host-to-detect-the-C-toolchain.patch b/patches/5.3.0/0001-Use-target-instead-of-host-to-detect-the-C-toolchain.patch new file mode 100644 index 00000000..38fa3e70 --- /dev/null +++ b/patches/5.3.0/0001-Use-target-instead-of-host-to-detect-the-C-toolchain.patch @@ -0,0 +1,142 @@ +From b422dae44596575fc7b4114009ca44a026821ba5 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Thu, 22 Feb 2024 13:37:28 +0100 +Subject: [PATCH 01/21] Use `target` instead of `host` to detect the C + toolchain + +Recall that the only currently officially supported configurations are +when `build` ~ `host` = `target`, where '~' means that the code +generated for `host` runs on `build` even when they differ (such as when +`build` is `x86_64-pc-cygwin` and `host` is `x86_64-pc-windows` (MSVC) +or `x86_64-w64-mingw32`). + +Still, many projects use OCaml cross compilers. All those projects +generate a cross compiler by assuming a non-cross OCaml compiler is +available in `PATH` (where non-cross means generating code that will run +on `host`). For the cross compiler, a C compiler and binutils for +`target` are necessary to build the target runtime. (Note that the +non-cross compiler will link its own (`build`/`host`) runtime into the +generated `.opt` cross compilers rather than the just-compiled target +runtime.) + +In that setup the runtime that will be compiled to create a cross +compiler will run only on the `target` so this commit: + +- sets `cross_compiling` by comparing `build` to `target` (rather than + to `host`), as this variable will be used later, +- uses `target` to set up the tool prefix, +- temporarily assigns `host*` values to `target*` values during the + libtool configuration, as this detects a `build` to `host` toolchain. + +Note that all these changes are transparent when `host` = `target`. +--- + configure | Bin 659478 -> 660523 bytes + configure.ac | 26 ++++++++++++++++++++++++++ + 2 files changed, 26 insertions(+) + +diff --git a/configure b/configure +index 401b94298e4f34946677a409560ce1832c5bbbbc..e407887556f95b1a0cf36e89b4801af172231845 100755 +GIT binary patch +delta 2466 +zcmZ`(eQXp(6wl2^uRV%@6xy^gW@)cr(2*KIA8H65fy2-ou`Fp?j +z-n`W_^}`RQw(s__uC}_R)VB2~B@x?loN&a7Cv-zMn}}vci53aFmSuz!HjU}6WT|HB +zTBAW7;^=0C61SO>TH<*`nl;@dx)TVJq(h@ZN1CWfZOs*4n%zWQ60t;)mS$>_#-wgU +zQzb}bwpUfyysFd=3<6PYS^+&qT2-`K=T+Cf&g#n53>&iyMNvRQET@AT5-b)FX2c&4S!iHz`A! +zlQv=}O;?Xo;#eY1 +z&Gib1R0-QkP~mgSoCQcTrZ**R8Z9SJTJFo~!fV<*cJKtC9x`!Hvh#u6*)K +zpet9(dkj!JDkB9GDW>t&t3dI%T*;H*Kd!MQ?fxQm?{VN~N4i0=j62s2mavb0$}Z@I8t +zLTDNePnAh|?t`#Qxw}cOs^qm0pEgC0r4AkGv^wr&r51p6q6YJfNN?F?vD4Wm!8bwrXq1F8|X53-4 +zMbYuqx9IV-nh9|dzwbL#MHI#hXqLjb>k>Mxa&5efUdRolk2buNno-OC|8|M^^WIc> +zzpi*T#6`1FIjH2*S$MD7t}6j-$hx6CT*B84!&_8;Lh*;J#q!7Eza^Xz`8U=4p8}kt +zpy49iakunY7s4U69ebzYg>q7SR3*-rm&MEG;ET$qcpk1%c^c>AsFDvofoDsZ1?uo~ +zBW1VZ8H^gya>rs57vLa^Ex?!gnx}B5f;;?KJb{Jl@d!R=0Y0b*6WV@N@#lJcK9(s`Lz|eUk$sj16Qd5qc`yC>5?h&?&R~H{dlh0@iTq+yo^85k9(wg?aHHAd|Bf2 +Oi!Yn6JesrV(fd9N46$P!i&!L@2gCYSk87c~nIdJt1P$(;R?R)gnyH;O3L1kd9?s{c~qTcWGwD&)&H{BK%{3us7+_KHkCFw$ZNir+FA`nez +z%qQl#!&S}te1k}*F6v&pSQw6~oDQ*#K#644o6R1abL)i-3dB)jEZWz*D!OdW+NJ@vik(d%{Q6qeCJynhhNo5q%bw +ze1BWie!yM685M;w3=@LlxRc>xgqfV$XoEOLhwN~QI;!ttpq_MY#=xCyRqS-e>48E> +z<-EtA!5@<-{L3OpBDcz*eEnnzj5^fj`!>72QwpgO1C8sz2daOM!=+^n{6+?vb>22; +zjd)r1BP@-;+$N}rz|0otioo)AC~%R2G77P}_fP0%E8ZSB7)MsDi!ddMP|8&(n;On` +ztKH9Gc9>Haomx!OZV*QGCIF574t +zmk+qs_gYrc*HFWNY4rMF22`DomRUMg;$Kca`J>5L#fK?(p>{B7V1l|i1zqZ75@zUi +zNvQZzCX#WSy1z-m$K2>)8b +Date: Tue, 9 Jul 2024 19:17:14 +0200 +Subject: [PATCH 02/21] Use `target` instead of `host` when relevant in + configuration + +As the C toolchain being configured is generating code for `target`, use +`target` in every test that is done according to the toolchain. + +Note that all these changes are transparent when `host` = `target`. +--- + aclocal.m4 | 12 ++--- + configure | Bin 660523 -> 668791 bytes + configure.ac | 142 +++++++++++++++++++++++++++------------------------ + 3 files changed, 81 insertions(+), 73 deletions(-) + +diff --git a/aclocal.m4 b/aclocal.m4 +index 7353e09a96..242a0e6638 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -369,27 +369,27 @@ AC_DEFUN([OCAML_TEST_WINPTHREADS_PTHREAD_H], [ + OCAML_CC_RESTORE_VARIABLES + ]) + +-AC_DEFUN([OCAML_HOST_IS_EXECUTABLE], [ +- AC_MSG_CHECKING([whether host executables can be run in the build]) ++AC_DEFUN([OCAML_TARGET_IS_EXECUTABLE], [ ++ AC_MSG_CHECKING([whether target executables can be run in the build]) + old_cross_compiling="$cross_compiling" + cross_compiling='no' + AC_RUN_IFELSE( + [AC_LANG_PROGRAM], + [AC_MSG_RESULT([yes]) +- host_runnable=true], ++ target_runnable=true], + [AC_MSG_RESULT([no]) +- host_runnable=false], ++ target_runnable=false], + # autoconf displays a warning if this parameter is missing, but + # cross-compilation mode was disabled above. + [assert=false]) + cross_compiling="$old_cross_compiling" + ]) + +-# This is AC_RUN_IFELSE but taking $host_runnable into account (i.e. if the ++# This is AC_RUN_IFELSE but taking $target_runnable into account (i.e. if the + # program can be run, then it is run) + AC_DEFUN([OCAML_RUN_IFELSE], [ + old_cross_compiling="$cross_compiling" +- AS_IF([test "x$host_runnable" = 'xtrue'], [cross_compiling='no']) ++ AS_IF([test "x$target_runnable" = 'xtrue'], [cross_compiling='no']) + AC_RUN_IFELSE([$1],[$2],[$3],[$4]) + cross_compiling="$old_cross_compiling" + ]) +diff --git a/configure b/configure +index e407887556f95b1a0cf36e89b4801af172231845..9ef0edf50277e5cfc17ad978deef969df774805a 100755 +GIT binary patch +delta 1759 +zcmaJ>YfMyE5YBy_b9M`RmjxDt02h|$x=R}fAP~?*TWhM77=odo+htjB+jX(*8mmRc +zvDC<5C!|I(o}2!AGOfhRD;#_+6TTuq5QtIcEQY|AKjN8h2x-aUV1H@lJ`J5gW=P?I1PHb +zxOn(eK=I%ZQAw6kUar`3S-bW;rA+JEAE?Oj2NY+pDTjeZZ_w?5i#)nQbe@bxSmi`$bd;UlJ4xS432#HXTC~Bs7kpyb{awuP7u6^ne+?5T#*idKxvP +zptUCLfv{ycnqENQ@Bp^JDLaaR{>{ij&p6OJO<~ED(2HVtV9rUjii10X +zWPpt>L}=S}bVREY1I)C8V;ZHv@O9Q-a0<2SjWZyMnx>Hyx!gK~N^rPf)o&;|T5sf~ +z2WWq+b;(i~RbeV+Ff_`i%ZoO`-w5fqxT3|t*%R0*B~U}LI@sWdWeX6H7%9#LsidEl!Wub&vz%`b4Y)Fb~=6|F6{oe +z2xk!824)|mTPkt4S!c$u5wDQ66gW2~CBdG0Y@-LOaekhL!|hunlm5CF_oeFJs-nPr +zg1z#5H+E2SH!cn{rXiOK5r&a{OqPc}z%`nJVssUwCI!hI)@a5nViodm9p+-#8_x; +z38@P$9zu$`)h0UEM-G@(#0t?j*lHc_CmZwip|Z@=0u0Iol{W13`5PUX+gjM)+ZPD` +zqMSQCPS5Vg_fY>DoTc`KS(N^ +dog)gob&ACu*@H!BpCic~m*)t*JZGr0{R^cvTsQy# + +delta 1111 +zcmYjPT})h65YA<}Gk5R)+-0L!7Hw{KX<3n75)4pCN_nHEiEC18(_catkWFxRVV4%8 +zNo`_E@Mjw!={)%J&V85y_!PHi+ZtKA}W?Z`$Mpvce~&p#h`sUyrQVz +z=`exxlpns)1wU_+e*_w+#e$HhFTJTcnYClto@z>15Th9%G|_+s2^H!~+p(MoO+~-msb+vJW>tqeoBpMKDyliKS*aAHSdQA*EGR1 +zD+3rB6%Bi$Vie~#!d)fugJ!r8QK)Ax6rCQocfg#3YCGY0iHhDx!iP1Emhl2?+##XG +z^LHTaFcS;VU#gf_7NJemE2HzjLX_L?LQjc$DeZ5a9LIkHOEctH!geZ6hg+b6p122V +z_~+k2LzQRgFYx(LQY52w32X`>2FYWhpH3oriT;3q<1@S%P(B_5Tn@^geU5vp@Nbi_ +z6@4^Vhn4CRYU$bm3{k^92=M21_!g`dIO@hq?r+4*BeFVqx8a+d-HPOh5oWZ^k>1{g +zjXFI)uUFH@{TSgdQy70zhAQZ7k2}P*<9KSVwBxk%rjUB{ve0(_494i(6t1UdKf)Jy +z<_vzKW>m-L&*Do8{-6HdFKF1DB4#pwM=AAV+Bv%!UeaQ`MV2vr_q@n)EFl` +ze7eCH4a&8$XxkQ}UXk9|VzgQ^vufDj#T~}({A#*&^l1h7`Sq`j!vV)Ru_WX~ZW)QV +zdcC{k1W}xF>D*beQ*xqD^hgRSo(_TFrHrV-Yu?FEPxeXl$y3<{m +zftX`ta$$R&cvrQ5FxA(!8gncWH1oaPX}d*aOLpeEZHFcn%8o=$+iTavvdLKTigh!2BulFHiD)hyVZp + +diff --git a/configure.ac b/configure.ac +index 18b0681d26..75429a8b34 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -318,7 +318,7 @@ AS_CASE([$host], + + # Systems that are known not to work, even in bytecode only. + +-AS_CASE([$host], ++AS_CASE([$target], + [i386-*-solaris*], + [AC_MSG_ERROR([Building for 32 bits target is not supported. \ + If your host is 64 bits, you can try with './configure CC="gcc -m64"' \ +@@ -326,7 +326,7 @@ If your host is 64 bits, you can try with './configure CC="gcc -m64"' \ + + # MSVC special case + +-AS_CASE([$host], ++AS_CASE([$target], + [*-pc-windows], + [AS_IF([test -z "$CC"], [CC=cl]) + ccomptype=msvc +@@ -619,10 +619,19 @@ AS_IF([test x"$enable_ocamldoc" = "xno"], + optional_libraries="$optional_libraries ocamldoc/odoc_info" + AC_CONFIG_FILES([ocamldoc/META])]) + ++# Are we building a cross-compiler ++ ++AS_IF( ++ [test x"$host" = x"$target"], ++ [cross_compiler=false], ++ [cross_compiler=true]) ++ + # Initialization of libtool + # Allow the MSVC linker to be found even if ld isn't installed. + # User-specified LD still takes precedence. +-AC_CHECK_TOOLS([LD],[ld link]) ++AS_IF([$cross_compiler], ++ [AC_CHECK_TARGET_TOOLS([LD],[ld link],[false])], ++ [AC_CHECK_TOOLS([LD],[ld link])]) + # libtool will detect a build-to-host C toolchain but when building an OCaml + # cross compiler we need the C toolchain to build the target runtime so we + # temporarily define host* values as macros for target* values so that the +@@ -672,7 +681,7 @@ AS_CASE([$enable_dependency_generation], + [compute_deps=true])], + [compute_deps=false])]) + +-AS_CASE([$host], ++AS_CASE([$target], + # In config/Makefile.mingw*, we had: + # TARGET=i686-w64-mingw32 and x86_64-w64-mingw32 + # TOOLPREF=$(TARGET)- +@@ -684,7 +693,7 @@ AS_CASE([$host], + mkexe_via_cc_extra_cmd=' && $(call MERGEMANIFESTEXE,$(1))' + libext=lib + AR="" +- AS_IF([test "$host_cpu" = "x86_64" ], ++ AS_IF([test "$target_cpu" = "x86_64" ], + [machine="-machine:AMD64 "], + [machine=""]) + mklib="link -lib -nologo $machine /out:\$(1) \$(2)" +@@ -698,7 +707,7 @@ OCAML_CC_VENDOR + + ## In cross-compilation mode, can we run executables produced? + # At the moment, it's required, but the fact is used in C99 function detection +-OCAML_HOST_IS_EXECUTABLE ++OCAML_TARGET_IS_EXECUTABLE + + # Determine how to call the C preprocessor directly. + # Most of the time, calling the C preprocessor through the C compiler is +@@ -739,27 +748,30 @@ AS_CASE([$ocaml_cc_vendor], + ocamlsrcdir=$(unset CDPATH; cd -- "$srcdir" && printf %sX "$PWD") || fail + ocamlsrcdir=${ocamlsrcdir%X} + ++AS_CASE([$host], ++ [*-*-mingw32*|*-pc-windows], ++ [ln='cp -pf' ++ ocamlsrcdir="$(LC_ALL=C.UTF-8 cygpath -w -- "$ocamlsrcdir")"], ++ [ln='ln -sf']) ++ + # Whether ar supports @FILE arguments + + AS_CASE([$lt_cv_ar_at_file], + [no], [ar_supports_response_files=false], + [ar_supports_response_files=true]) + +-# Libraries to build depending on the host ++# Libraries to build depending on the target + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], + [unix_or_win32="win32" +- ln='cp -pf' + ocamltest_libunix="Some false" +- ocamlsrcdir="$(LC_ALL=C.UTF-8 cygpath -w -- "$ocamlsrcdir")" + ocamlyacc_wstr_module="yacc/wstr"], + [unix_or_win32="unix" +- ln='ln -sf' + ocamltest_libunix="Some true" + ocamlyacc_wstr_module=""]) + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-cygwin*|*-*-mingw32*|*-pc-windows], + [exeext=".exe"], + [exeext='']) +@@ -804,7 +816,7 @@ AC_SYS_INTERPRETER + shebangscripts=false + launch_method='exe' + AS_IF([test "x$interpval" = "xyes"], +- [AS_CASE([$host], ++ [AS_CASE([$target], + [*-cygwin], + [# Cygwin supports shebangs, which we use for the compiler itself, but + # partially for legacy, and partially so that executables can be easily +@@ -838,13 +850,6 @@ dnl nefarious single quotes which may appear in any of the strings. + ocaml_bindir='$(echo "$ocaml_bindir" | sed -e "s/'/'\"'\"'/g")' + target_bindir='$(echo "$target_bindir" | sed -e "s/'/'\"'\"'/g")']) + +-# Are we building a cross-compiler +- +-AS_IF( +- [test x"$host" = x"$target"], +- [cross_compiler=false], +- [cross_compiler=true]) +- + # Checks for programs + + ## Check for the C compiler: done by libtool +@@ -890,7 +895,7 @@ AS_CASE([$enable_warn_error,OCAML__DEVELOPMENT_VERSION], + [yes,*|,true], + [cc_warnings="$cc_warnings $warn_error_flag"]) + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], + [AS_CASE([$WINDOWS_UNICODE_MODE], + [ansi], +@@ -952,14 +957,14 @@ AS_CASE([$ocaml_cc_vendor], + [common_cflags="-O"]) + + # Enable SSE2 on x86 mingw to avoid using 80-bit registers. +-AS_CASE([$host], ++AS_CASE([$target], + [i686-*-mingw32*], + [internal_cflags="$internal_cflags -mfpmath=sse -msse2"]) + + # Use 64-bit file offset if possible + # See also AC_SYS_LARGEFILE + # Problem: flags are added to CC rather than CPPFLAGS +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], [], + [common_cppflags="$common_cppflags -D_FILE_OFFSET_BITS=64"]) + +@@ -973,14 +978,14 @@ AS_CASE([$host], + + AS_IF([test x"$enable_shared" = "xno"], + [supports_shared_libraries=false +- AS_CASE([$host], ++ AS_CASE([$target], + [*-pc-windows|*-w64-mingw32*], + [AC_MSG_ERROR([Cannot build native Win32 with --disable-shared])])], + [supports_shared_libraries=true]) + + # Define flexlink chain and flags correctly for the different Windows ports + flexlink_flags='' +-AS_CASE([$host], ++AS_CASE([$target], + [i686-*-cygwin], + [flexdll_chain='cygwin' + flexlink_flags='-merge-manifest -stack 16777216'], +@@ -1070,14 +1075,14 @@ AS_IF([test x"$supports_shared_libraries" != 'xfalse'], [ + ]) + ]) + +-AS_CASE([$have_flexdll_h,$supports_shared_libraries,$host], ++AS_CASE([$have_flexdll_h,$supports_shared_libraries,$target], + [no,true,*-*-cygwin*], + [supports_shared_libraries=false + AC_MSG_WARN([flexdll.h not found: shared library support disabled.])], + [no,*,*-w64-mingw32*|no,*,*-pc-windows], + [AC_MSG_ERROR([flexdll.h is required for native Win32])]) + +-AS_CASE([$flexdll_source_dir,$supports_shared_libraries,$flexlink,$host], ++AS_CASE([$flexdll_source_dir,$supports_shared_libraries,$flexlink,$target], + [,true,,*-*-cygwin*], + [supports_shared_libraries=false + AC_MSG_WARN([flexlink not found: shared library support disabled.])], +@@ -1086,7 +1091,7 @@ AS_CASE([$flexdll_source_dir,$supports_shared_libraries,$flexlink,$host], + + mkexe_cmd_exp="$CC" + +-AS_CASE([$ocaml_cc_vendor,$host], ++AS_CASE([$ocaml_cc_vendor,$target], + [*,x86_64-*-darwin*], + [oc_ldflags='-Wl,-no_compact_unwind'; + AC_DEFINE([HAS_ARCH_CODE32], [1])], +@@ -1103,7 +1108,7 @@ AS_CASE([$ocaml_cc_vendor,$host], + ) + ostype="Cygwin"], + [*,*-*-mingw32*], +- [AS_CASE([$host], ++ [AS_CASE([$target], + [i686-*-*], [oc_dll_ldflags="-static-libgcc"]) + ostype="Win32" + toolchain="mingw" +@@ -1198,7 +1203,7 @@ AC_CHECK_HEADER([sys/select.h], [AC_DEFINE([HAS_SYS_SELECT_H], [1])], [], + + AC_CHECK_HEADER([sys/mman.h], [AC_DEFINE([HAS_SYS_MMAN_H], [1])]) + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-linux*], + [AC_CHECK_HEADER([linux/futex.h], [AC_DEFINE([HAS_LINUX_FUTEX_H])])]) + +@@ -1295,7 +1300,7 @@ AS_IF([! $cc_supports_atomic], + # Full support for thread local storage + # macOS and MinGW-w64 have problems with thread local storage accessed from DLLs + +-AS_CASE([$host], ++AS_CASE([$target], + [*-apple-darwin*|*-mingw32*|*-pc-windows], [], + [AC_DEFINE([HAS_FULL_THREAD_VARIABLES], [1])] + ) +@@ -1311,7 +1316,7 @@ natdynlinkopts="" + + AS_IF([test x"$enable_shared" != "xno"], + [mkdll='' +- AS_CASE([$host], ++ AS_CASE([$target], + [x86_64-apple-darwin*], + [mkdll_flags=\ + '-shared -undefined dynamic_lookup -Wl,-no_compact_unwind -Wl,-w' +@@ -1339,7 +1344,7 @@ AS_IF([test x"$enable_shared" != "xno"], + [[*-*-linux*|*-*-freebsd[3-9]*|*-*-freebsd[1-9][0-9]*\ + |*-*-openbsd*|*-*-netbsd*|*-*-dragonfly*|*-*-gnu*|*-*-haiku*]], + [sharedlib_cflags="-fPIC" +- AS_CASE([$ocaml_cc_vendor,$host], ++ AS_CASE([$ocaml_cc_vendor,$target], + [gcc-*,powerpc-*-linux*], + [mkdll_flags='-shared -mbss-plt'], + [[*,i[3456]86-*]], +@@ -1347,7 +1352,7 @@ AS_IF([test x"$enable_shared" != "xno"], + # See https://github.com/ocaml/ocaml/issues/9800 + [mkdll_flags='-shared -Wl,-z,notext'], + [mkdll_flags='-shared']) +- AS_CASE([$host], ++ AS_CASE([$target], + [[*-*-openbsd7.[3-9]|*-*-openbsd[89].*]], + [mkdll_flags="${mkdll_flags} -Wl,--no-execute-only"]) + oc_ldflags="$oc_ldflags -Wl,-E" +@@ -1367,14 +1372,14 @@ AS_IF([test -z "$mkmaindll"], + # Make sure code sections in OCaml-generated executables are readable + # (required for marshaling of function closures) + +-AS_CASE([$host], ++AS_CASE([$target], + [[*-*-openbsd7.[3-9]|*-*-openbsd[89].*]], + [oc_ldflags="$oc_ldflags -Wl,--no-execute-only" + natdynlinkopts="$natdynlinkopts -Wl,--no-execute-only"]) + + # Disable control flow integrity + +-AS_CASE([$host], ++AS_CASE([$target], + [[*-*-openbsd7.[4-9]|*-*-openbsd[89].*]], + [oc_ldflags="$oc_ldflags -Wl,-z,nobtcfi" + natdynlinkopts="$natdynlinkopts -Wl,-z,nobtcfi"]) +@@ -1385,7 +1390,7 @@ AS_CASE([$host], + natdynlink=false + + AS_IF([test x"$supports_shared_libraries" = 'xtrue'], +- [AS_CASE(["$host"], ++ [AS_CASE(["$target"], + [*-*-cygwin*], [natdynlink=true], + [*-*-mingw32*], [natdynlink=true], + [*-pc-windows], [natdynlink=true], +@@ -1427,7 +1432,7 @@ AS_CASE([$enable_native_toplevel,$natdynlink], + [install_ocamlnat=false]) + + # Try to work around the Skylake/Kaby Lake processor bug. +-AS_CASE(["$ocaml_cc_vendor,$host"], ++AS_CASE(["$ocaml_cc_vendor,$target"], + [*gcc*,x86_64-*|*gcc*,i686-*], + [AX_CHECK_COMPILE_FLAG([-fno-tree-vrp], + [internal_cflags="$internal_cflags -fno-tree-vrp"], [], +@@ -1449,7 +1454,7 @@ system=unknown + # preserving $arch = 'none' <=> $system = 'unknown' + has_native_backend=no + native_ldflags="" +-AS_CASE([$host], ++AS_CASE([$target], + [[i[3456]86-*-linux*]], + [arch=i386; system=linux], + [[i[3456]86-*-freebsd*]], +@@ -1587,9 +1592,11 @@ AS_IF([$natdynlink], + + AC_DEFINE_UNQUOTED([OCAML_OS_TYPE], ["$ostype"]) + +-AC_CHECK_TOOL([DIRECT_LD],[ld]) ++AS_IF([$cross_compiler], ++ [AC_CHECK_TARGET_TOOL([DIRECT_LD],[ld],[false])], ++ [AC_CHECK_TOOL([DIRECT_LD],[ld])]) + AS_IF([test -z "$PARTIALLD"], +- [AS_CASE(["$host,$ocaml_cc_vendor"], ++ [AS_CASE(["$target,$ocaml_cc_vendor"], + [x86_64-*-darwin*,gcc-*], [PACKLD_FLAGS=' -arch x86_64'], + [powerpc64le*-*-linux*,gcc-*], [PACKLD_FLAGS=' -m elf64lppc'], + [powerpc*-*-linux*,gcc-*], +@@ -1624,7 +1631,7 @@ AS_CASE([$arch], + [amd64|arm64|s390x|none], + # ocamlopt generates PIC code or doesn't generate code at all + [], +- [AS_CASE([$host], ++ [AS_CASE([$target], + # expected to match "*-linux-musl" as well as "*-linux-musleabi*" + [*-linux-musl*], + # Alpine and other musl-based Linux distributions +@@ -1742,7 +1749,7 @@ AC_CHECK_FUNC([issetugid], [AC_DEFINE([HAS_ISSETUGID], [1])]) + ## On Unix platforms, we check for the appropriate POSIX feature-test macros. + ## On MacOS clock_gettime's CLOCK_MONOTONIC flag is not actually monotonic. + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-windows], + [has_monotonic_clock=true], + [*-apple-darwin*], [ +@@ -1774,7 +1781,7 @@ AS_CASE([$host], + # clock source is missing. + AS_IF([test "x$enable_instrumented_runtime" != "xno" ], + [ +- AS_CASE([$host], ++ AS_CASE([$target], + [sparc-sun-solaris*], + [instrumented_runtime=false], + [*-*-windows], +@@ -1965,7 +1972,7 @@ AS_IF([$tsan], + + sockets=true + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*], + [cclibs="$cclibs -lws2_32" + AC_SEARCH_LIBS([socket], [ws2_32]) +@@ -1993,7 +2000,7 @@ AS_IF([$sockets], [AC_DEFINE([HAS_SOCKETS], [1])]) + + ## socklen_t + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], + [AC_CHECK_TYPE([socklen_t], [AC_DEFINE([HAS_SOCKLEN_T], [1])], [], + [#include ])], +@@ -2004,7 +2011,7 @@ AC_CHECK_FUNC([inet_aton], [AC_DEFINE([HAS_INET_ATON], [1])]) + + ## Unix domain sockets support on Windows + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], + [AC_CHECK_HEADERS([afunix.h], [AC_DEFINE([HAS_AFUNIX_H], [1])], [], + [#include ])]) +@@ -2013,7 +2020,7 @@ AS_CASE([$host], + + ipv6=true + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], + [AC_CHECK_TYPE( + [struct sockaddr_in6], [], [ipv6=false], [#include ])], +@@ -2047,7 +2054,7 @@ AC_CHECK_FUNC([system], [AC_DEFINE([HAS_SYSTEM], [1])]) + ## Note: this was defined in config/s-nt.h but the autoconf macros do not + # seem to detect it properly on Windows so we hardcode the definition + # of HAS_UTIME on Windows but this will probably need to be clarified +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], [AC_DEFINE([HAS_UTIME], [1])], + [AC_CHECK_HEADER([sys/types.h], + [AC_CHECK_HEADER([utime.h], +@@ -2123,7 +2130,7 @@ AC_CHECK_FUNC([setitimer], + ## gethostname + # Note: detection fails on Windows so hardcoding the result + # (should be debugged later) +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], [AC_DEFINE([HAS_GETHOSTNAME], [1])], + [AC_CHECK_FUNC([gethostname], [AC_DEFINE([HAS_GETHOSTNAME], [1])])]) + +@@ -2147,7 +2154,7 @@ AC_CHECK_FUNC([mktime], [AC_DEFINE([HAS_MKTIME], [1])]) + + ## setsid + +-AS_CASE([$host], ++AS_CASE([$target], + [*-cygwin|*-*-mingw32*|*-pc-windows], [], + [AC_CHECK_FUNC([setsid], [AC_DEFINE([HAS_SETSID], [1])])]) + +@@ -2163,7 +2170,7 @@ AC_CHECK_FUNC([setenv], + ## newlocale() and + # Note: the detection fails on msvc so we hardcode the result + # (should be debugged later) +-AS_CASE([$host], ++AS_CASE([$target], + [*-pc-windows], [AC_DEFINE([HAS_LOCALE_H], [1])], + [AC_CHECK_HEADER([locale.h], + [AC_CHECK_FUNC([newlocale], +@@ -2178,13 +2185,13 @@ AC_CHECK_HEADER([xlocale.h], + ## strtod_l + # Note: not detected on MSVC so hardcoding the result + # (should be debugged later) +-AS_CASE([$host], ++AS_CASE([$target], + [*-pc-windows], [AC_DEFINE([HAS_STRTOD_L], [1])], + [AC_CHECK_FUNC([strtod_l], [AC_DEFINE([HAS_STRTOD_L], [1])])]) + + ## shared library support + AS_IF([$supports_shared_libraries], +- [AS_CASE([$host], ++ [AS_CASE([$target], + [*-*-mingw32*|*-pc-windows|*-*-cygwin*], + [DLLIBS=""], + [AC_CHECK_FUNC([dlopen], +@@ -2210,7 +2217,7 @@ AC_CHECK_HEADER([sys/mman.h], + AC_CHECK_FUNC([pwrite], [AC_DEFINE([HAS_PWRITE], [1])]) + + ## -fdebug-prefix-map support by the C compiler +-AS_CASE([$ocaml_cc_vendor,$host], ++AS_CASE([$ocaml_cc_vendor,$target], + [*,*-*-mingw32*], [cc_has_debug_prefix_map=false], + [*,*-pc-windows], [cc_has_debug_prefix_map=false], + [xlc*,powerpc-ibm-aix*], [cc_has_debug_prefix_map=false], +@@ -2289,7 +2296,9 @@ AC_CHECK_HEADER([spawn.h], + [AC_CHECK_FUNC([posix_spawn], + [AC_CHECK_FUNC([posix_spawnp], [AC_DEFINE([HAS_POSIX_SPAWN], [1])])])]) + +-AC_PATH_TOOL([PKG_CONFIG], [pkg-config], [false]) ++AS_IF([$cross_compiler], ++ [AC_PATH_TARGET_TOOL([PKG_CONFIG], [pkg-config], [false])], ++ [AC_PATH_TOOL([PKG_CONFIG], [pkg-config], [false])]) + + ## ZSTD compression library + +@@ -2320,9 +2329,9 @@ AS_IF([test x"$with_zstd" != "xno"], + # library available, but not have the DLL in PATH. This then causes the build to + # fail as soon as ocamlrun is first executed. This check avoids automatically + # enabling zstd when the resulting executable doesn't actually work. +-AS_CASE([$host], ++AS_CASE([$target], + [*-w64-mingw32*|*-pc-windows], +- [check_zstd_runs=$host_runnable], ++ [check_zstd_runs=$target_runnable], + [check_zstd_runs=false]) + + AS_IF([test x"$zstd_status" = "xok"],[ +@@ -2390,7 +2399,7 @@ AS_CASE([$enable_debug_runtime], + + ## Determine how to link with the POSIX threads library + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*], + [link_gcc_eh='' + AC_CHECK_LIB([gcc_eh], [printf], [link_gcc_eh="-lgcc_eh"]) +@@ -2458,7 +2467,7 @@ AS_CASE([$enable_systhreads,$enable_unix_lib], + as_has_debug_prefix_map=false + asm_cfi_supported=false + AS_IF([$native_compiler], +- [AS_CASE([$host], ++ [AS_CASE([$target], + [*-*-mingw32*|*-pc-windows], [], + [OCAML_AS_HAS_DEBUG_PREFIX_MAP + OCAML_AS_HAS_CFI_DIRECTIVES])]) +@@ -2466,7 +2475,7 @@ AS_IF([$native_compiler], + ## Frame pointers + + AS_IF([test x"$enable_frame_pointers" = "xyes"], +- [AS_CASE([$host], ++ [AS_CASE([$target], + [x86_64-*-linux*|x86_64-*-darwin*], + [AS_CASE([$ocaml_cc_vendor], + [clang-*|gcc-*], +@@ -2647,7 +2656,7 @@ native_cflags="$native_cflags $PTHREAD_CFLAGS $COMPILER_NATIVE_CFLAGS" + bytecode_cppflags="$common_cppflags $COMPILER_BYTECODE_CPPFLAGS" + native_cppflags="$common_cppflags $COMPILER_NATIVE_CPPFLAGS" + +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*], + [cclibs="$cclibs -lole32 -luuid -lversion -lshlwapi -lsynchronization"], + [*-pc-windows], +@@ -2671,15 +2680,14 @@ AS_IF([test x"$prefix" = "xNONE"], + [x86_64-w64-mingw32*], [prefix='C:/ocamlmgw64'], + [i686-pc-windows], [prefix='C:/ocamlms'], + [x86_64-pc-windows], [prefix='C:/ocamlms64'])], +- [AS_IF([test x"$unix_or_win32" = "xwin32" \ +- && test "$host_vendor-$host_os" != "$build_vendor-$build_os" ], +- [AS_CASE([$build], +- [*-pc-cygwin], [prefix="$(LC_ALL=C.UTF-8 cygpath -m "$prefix")"])])]) ++ [AS_CASE([$build,$host], ++ [*-pc-cygwin,*-*-mingw32*|*-pc-cygwin,*-pc-windows], ++ [prefix="$(LC_ALL=C.UTF-8 cygpath -m "$prefix")"])]) + + # Define a few macros that were defined in config/m-nt.h + # but whose value is not guessed properly by configure + # (all this should be understood and fixed) +-AS_CASE([$host], ++AS_CASE([$target], + [*-*-mingw32*], + [AC_DEFINE([HAS_BROKEN_PRINTF], [1]) + AC_DEFINE([HAS_IPV6], [1]) +-- +2.47.2 + diff --git a/patches/5.3.0/0003-Detect-a-_build_-C-toolchain-to-build-sak.patch b/patches/5.3.0/0003-Detect-a-_build_-C-toolchain-to-build-sak.patch new file mode 100644 index 00000000..55aca634 --- /dev/null +++ b/patches/5.3.0/0003-Detect-a-_build_-C-toolchain-to-build-sak.patch @@ -0,0 +1,321 @@ +From bf08fdb19e31cc517539f2c44dab5509c91cf719 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Wed, 21 Feb 2024 18:47:12 +0100 +Subject: [PATCH 03/21] Detect a _build_ C toolchain to build `sak` + +Import `ax_prog_cc_for_build` from the Autoconf Macro Archive to detect +the C toolchain for the build machine when (and only when) we are +generating a cross compiler, namely when code generated for the target +doesn't run on the build machine +Move the configuration of `SAK_*` variables in `configure` to set them +using the build C toolchain to compile and link `sak` when generating a +cross compiler +This assumes that `sak` can be built with the default +automatically-detected flags when building a cross compiler +--- + Makefile | 6 -- + Makefile.build_config.in | 5 + + aclocal.m4 | 1 + + build-aux/ax_prog_cc_for_build.m4 | 155 ++++++++++++++++++++++++++++++ + configure | Bin 668791 -> 704188 bytes + configure.ac | 17 ++++ + 6 files changed, 178 insertions(+), 6 deletions(-) + create mode 100644 build-aux/ax_prog_cc_for_build.m4 + +diff --git a/Makefile b/Makefile +index f7fffdce4d..044012f1d9 100644 +--- a/Makefile ++++ b/Makefile +@@ -1383,12 +1383,6 @@ runtime/caml/jumptbl.h : runtime/caml/instruct.h + sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \ + -e '/^}/q' > $@ + +-# These are provided as a temporary shim to allow cross-compilation systems +-# to supply a host C compiler and different flags and a linking macro. +-SAK_CC ?= $(CC) +-SAK_CFLAGS ?= $(OC_CFLAGS) $(CFLAGS) $(OC_CPPFLAGS) $(CPPFLAGS) +-SAK_LINK ?= $(MKEXE_VIA_CC) +- + $(SAK): runtime/sak.$(O) + $(V_MKEXE)$(call SAK_LINK,$@,$^) + +diff --git a/Makefile.build_config.in b/Makefile.build_config.in +index ae649dceba..dd520bd6e9 100644 +--- a/Makefile.build_config.in ++++ b/Makefile.build_config.in +@@ -99,6 +99,11 @@ OC_DLL_LDFLAGS=@oc_dll_ldflags@ + + MKEXE_VIA_CC=$(CC) @mkexe_via_cc_ldflags@ @mkexe_via_cc_extra_cmd@ + ++# How to build sak ++SAK_CC=@SAK_CC@ ++SAK_CFLAGS=@SAK_CFLAGS@ ++SAK_LINK=@SAK_LINK@ ++ + # Which tool to use to display differences between files + DIFF=@DIFF@ + # Which flags to pass to the diff tool +diff --git a/aclocal.m4 b/aclocal.m4 +index 242a0e6638..b17e11d511 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -30,6 +30,7 @@ m4_include([build-aux/lt~obsolete.m4]) + # Macros from the autoconf macro archive + m4_include([build-aux/ax_check_compile_flag.m4]) + m4_include([build-aux/ax_func_which_gethostbyname_r.m4]) ++m4_include([build-aux/ax_prog_cc_for_build.m4]) + m4_include([build-aux/ax_pthread.m4]) + + # OCaml version +diff --git a/build-aux/ax_prog_cc_for_build.m4 b/build-aux/ax_prog_cc_for_build.m4 +new file mode 100644 +index 0000000000..1db8d73f96 +--- /dev/null ++++ b/build-aux/ax_prog_cc_for_build.m4 +@@ -0,0 +1,155 @@ ++# =========================================================================== ++# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html ++# =========================================================================== ++# ++# SYNOPSIS ++# ++# AX_PROG_CC_FOR_BUILD ++# ++# DESCRIPTION ++# ++# This macro searches for a C compiler that generates native executables, ++# that is a C compiler that surely is not a cross-compiler. This can be ++# useful if you have to generate source code at compile-time like for ++# example GCC does. ++# ++# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything ++# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD). ++# The value of these variables can be overridden by the user by specifying ++# a compiler with an environment variable (like you do for standard CC). ++# ++# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object ++# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if ++# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are ++# substituted in the Makefile. ++# ++# LICENSE ++# ++# Copyright (c) 2008 Paolo Bonzini ++# ++# Copying and distribution of this file, with or without modification, are ++# permitted in any medium without royalty provided the copyright notice ++# and this notice are preserved. This file is offered as-is, without any ++# warranty. ++ ++#serial 21 ++ ++AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) ++AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl ++AC_REQUIRE([AC_PROG_CC])dnl ++AC_REQUIRE([AC_PROG_CPP])dnl ++AC_REQUIRE([AC_CANONICAL_BUILD])dnl ++ ++dnl Use the standard macros, but make them use other variable names ++dnl ++pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl ++pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl ++pushdef([ac_cv_prog_cc_c99], ac_cv_build_prog_cc_c99)dnl ++pushdef([ac_cv_prog_cc_c11], ac_cv_build_prog_cc_c11)dnl ++pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl ++pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl ++pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl ++pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl ++pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl ++pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl ++pushdef([ac_cv_objext], ac_cv_build_objext)dnl ++pushdef([ac_exeext], ac_build_exeext)dnl ++pushdef([ac_objext], ac_build_objext)dnl ++pushdef([CC], CC_FOR_BUILD)dnl ++pushdef([CPP], CPP_FOR_BUILD)dnl ++pushdef([GCC], GCC_FOR_BUILD)dnl ++pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl ++pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl ++pushdef([EXEEXT], BUILD_EXEEXT)dnl ++pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl ++pushdef([OBJEXT], BUILD_OBJEXT)dnl ++pushdef([host], build)dnl ++pushdef([host_alias], build_alias)dnl ++pushdef([host_cpu], build_cpu)dnl ++pushdef([host_vendor], build_vendor)dnl ++pushdef([host_os], build_os)dnl ++pushdef([ac_cv_host], ac_cv_build)dnl ++pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl ++pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl ++pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl ++pushdef([ac_cv_host_os], ac_cv_build_os)dnl ++pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl ++pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl ++pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl ++pushdef([cross_compiling], cross_compiling_build)dnl ++ ++cross_compiling_build=no ++ ++ac_build_tool_prefix= ++AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"], ++ [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"]) ++ ++AC_LANG_PUSH([C]) ++ ++dnl The pushdef([ac_cv_c_compiler_gnu], ...) currently does not cover ++dnl the use of this variable in _AC_LANG_COMPILER_GNU called by ++dnl AC_PROG_CC. Unset this cache variable temporarily as a workaround. ++was_set_c_compiler_gnu=${[ac_cv_c_compiler_gnu]+y} ++AS_IF([test ${was_set_c_compiler_gnu}], ++ [saved_c_compiler_gnu=$[ac_cv_c_compiler_gnu] ++ AS_UNSET([[ac_cv_c_compiler_gnu]])]) ++ ++AC_PROG_CC ++ ++dnl Restore ac_cv_c_compiler_gnu ++AS_IF([test ${was_set_c_compiler_gnu}], ++ [[ac_cv_c_compiler_gnu]=$[saved_c_compiler_gnu]]) ++ ++_AC_COMPILER_EXEEXT ++_AC_COMPILER_OBJEXT ++AC_PROG_CPP ++ ++dnl Restore the old definitions ++dnl ++popdef([cross_compiling])dnl ++popdef([am_cv_prog_cc_c_o])dnl ++popdef([am_cv_CC_dependencies_compiler_type])dnl ++popdef([ac_tool_prefix])dnl ++popdef([ac_cv_host_os])dnl ++popdef([ac_cv_host_vendor])dnl ++popdef([ac_cv_host_cpu])dnl ++popdef([ac_cv_host_alias])dnl ++popdef([ac_cv_host])dnl ++popdef([host_os])dnl ++popdef([host_vendor])dnl ++popdef([host_cpu])dnl ++popdef([host_alias])dnl ++popdef([host])dnl ++popdef([OBJEXT])dnl ++popdef([LDFLAGS])dnl ++popdef([EXEEXT])dnl ++popdef([CPPFLAGS])dnl ++popdef([CFLAGS])dnl ++popdef([GCC])dnl ++popdef([CPP])dnl ++popdef([CC])dnl ++popdef([ac_objext])dnl ++popdef([ac_exeext])dnl ++popdef([ac_cv_objext])dnl ++popdef([ac_cv_exeext])dnl ++popdef([ac_cv_c_compiler_gnu])dnl ++popdef([ac_cv_prog_cc_g])dnl ++popdef([ac_cv_prog_cc_cross])dnl ++popdef([ac_cv_prog_cc_works])dnl ++popdef([ac_cv_prog_cc_c89])dnl ++popdef([ac_cv_prog_gcc])dnl ++popdef([ac_cv_prog_CPP])dnl ++ ++dnl restore global variables ac_ext, ac_cpp, ac_compile, ++dnl ac_link, ac_compiler_gnu (dependant on the current ++dnl language after popping): ++AC_LANG_POP([C]) ++ ++dnl Finally, set Makefile variables ++dnl ++AC_SUBST(BUILD_EXEEXT)dnl ++AC_SUBST(BUILD_OBJEXT)dnl ++AC_SUBST([CFLAGS_FOR_BUILD])dnl ++AC_SUBST([CPPFLAGS_FOR_BUILD])dnl ++AC_SUBST([LDFLAGS_FOR_BUILD])dnl ++]) +diff --git a/configure b/configure +index 9ef0edf50277e5cfc17ad978deef969df774805a..25fce20f5070b041a94ddd51d4899489eab79ac4 100755 +GIT binary patch +delta 6946 +zcmds6eM}t371unt57r+sB?cRU8P;bwFo%s}^IN+_%2Sjffn4s(Zr +zPz$GR8oN~!TO>?cw~6hls+vZYt0-NiB$8>GrXNugSE}T+jVmjS6}KUzsolzQQ+IZE +z_ICEbl?$PN_@tBGn~yi|{pQV^H*f#>f%}zDi_ad}G1lg9YHMiTEj8`jB{e?K(&iU@ +z?d`Lgk{h&<($2sQ9pQ=ob*!-u)?u!oLcocUHhWom4EVy3~!aX=H +z$KrTcbZM<3_NsI|IM6G{MeK>1oHQ^Pi3Gd)WNl1*U{Ds~56Ka{Rlr!&#OEz^xqZH( +zLfXKZH09Lhoj$7RHWj-fOb2Q0Dy6nF1ho!>Hf5-msuH%hQp}{iEe#Z)qC)bc=WVrX +zyXCkXiiab;m}-K3)V63}=%HXZf_tI^x|w9^J;)uqje#PrEhw)(BnU!iAR3EFq39R- +z!+lh?qygiNL +zcP!904QTSUiwHCF_!}sby!|4SlIe@6hBdnXgr0XA8&BHTIRb*|M&$f!C~LLJxB0yy +z=Vi*NV#i*zDye_e@E7vrC3LddkWJ^Ro)kJrk6N_X8W=67#uP{J&ykN;=j5-^DxN>~ +zHj0vO45s9io0Ho7VznAUA~bNR>se#4ms7vZPwKx4n1tU$zqdj_@`h6E{6Z9m+&q2_ +zibJw+6^%}mZXMMd3X$OJ=&7ZAGdX`0GI;S*C5}vuJWl|CG2iDE$=ItP+V!|cPQ40)%nJ^DfOau5{m-yrw`JBWOX*FCaZi|ryO>NV +z%U~UsIX0P~T1SQzhRQ2Qrk?0yaGhcx8aFoR_rXN#166Svhr@fZW#fV1-=%oWo +zt$zNS$3UECgi`9Sqda6qWC78MKSU3{g-%-a{H(&#qx>@I=TX6DAEB&4XO0L(T5qCz +z(#>-+hufL=;m>ZOTHOJkM(~0aZQhoJ#hr%%PXAvH+`_KIrc}6SggV-{29aJhM0ifW=SXn#R_xp^L;uMU145f>ED>~$3P4=8Q{ +zGE+&)mr%t-o_(p}-vGZuENnKELm{avgX`N(kN1wqG2@DE=4E=-1!?x8uE?I8G|x_c +zE2tSaSySQ6Yn)&c;5t8C;edP80}!*4d&Ce1LqX(z$}1{jMXGRBnNiSu)ee@xM4u@Zy$~ +zLxl;`&e`PgzdDMDy#m6lD^dXkj2y3kD&Dv^E5OKDrs=2>6Kyr`qJZ<6SJLB)tgnO| +zURYBlI1McQo%IObye2AVY`m=bi^?+b@iR*X#b}x9C+z~Gv;}uD(wIV}#9hntLi&v3z +zzJz7Jq@y?~31BAnAb||~A)82bu!kGLBXpxKA%{b#v;LL{P1Yw63N|DVDr-!fsE$Us +zr@(X>%WJI7Z^hzpV*-m88m(B=_^en^UdMuA_mU6pW8}YR7iXRUz!O{>Z}OJFTqaKh +zZfWwhK*Hn`O$n3tH_vv8%Bp!f#ZQ_OKwNHyx;w9?(x`i|wRA#jD#o+=HVP(Mc_iEG +z(hDa^lIV3o8lG|lCW@hiY!qR+^2%~ZcQ6lmb0y?3^72ZV2k{0kl5lnJnl?S)`7|3Ub?M6H9Qa2HTZxMID0}l@uWKlr#D8E@BU51FXFRDgIeR@o3#YWI9z(l#&?rH +zeq_sDrtg$q>uM+Y-B3X`&)DiWm@8vi+D^L6JOMGONqKC>b|SUbBCVZPvG@hG3^G|q +z%e`28)s~g}Uu6&!g6bulSfUo4mT?Vje&yw>wlo_b`G0!d)^+E_Q|2g-u5@OQ@lNNv +zV}h23ubu-!YU?KY +aVW%hj_>F8k{X6L2N&jiejcnnItN#OTd!9M~ + +delta 67 +zcmdnaws$v9UCLm@8VwUYuRjiH++g+Bj0Wmue +Oa{w{tc9*4G6_NnX^BSoD + +diff --git a/configure.ac b/configure.ac +index 75429a8b34..f3a219ef9a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -122,6 +122,9 @@ AC_SUBST([CMXS_MAGIC_NUMBER], [CMXS__MAGIC_NUMBER]) + AC_SUBST([CMT_MAGIC_NUMBER], [CMT__MAGIC_NUMBER]) + AC_SUBST([LINEAR_MAGIC_NUMBER], [LINEAR__MAGIC_NUMBER]) + AC_SUBST([CC]) ++AC_SUBST([SAK_CC]) ++AC_SUBST([SAK_CFLAGS]) ++AC_SUBST([SAK_LINK]) + AC_SUBST([DIFF_FLAGS]) + AC_SUBST([CSC]) + AC_SUBST([CSCFLAGS]) +@@ -850,6 +853,20 @@ dnl nefarious single quotes which may appear in any of the strings. + ocaml_bindir='$(echo "$ocaml_bindir" | sed -e "s/'/'\"'\"'/g")' + target_bindir='$(echo "$target_bindir" | sed -e "s/'/'\"'\"'/g")']) + ++# How to build sak ++ ++AS_IF( ++ [test x"$build" = x"$target" -o x"$target_runnable" = xtrue], ++ [SAK_CC='$(CC)' ++ SAK_CFLAGS='$(OC_CFLAGS) $(CFLAGS) $(OC_CPPFLAGS) $(CPPFLAGS)' ++ SAK_LINK='$(MKEXE_VIA_CC)'], ++ [AC_MSG_NOTICE([detecting the C toolchain for build]) ++ AX_PROG_CC_FOR_BUILD ++ SAK_CC="$CC_FOR_BUILD" ++ SAK_CFLAGS="$CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD" ++ # Note that *-pc-windows is not supported for _build_ so we can use '-o' ++ SAK_LINK='$(SAK_CC) $(SAK_CFLAGS) -o $(1) $(2)']) ++ + # Checks for programs + + ## Check for the C compiler: done by libtool +-- +2.47.2 + diff --git a/patches/5.3.0/0004-Check-that-the-OCaml-versions-are-compatible-for-a-c.patch b/patches/5.3.0/0004-Check-that-the-OCaml-versions-are-compatible-for-a-c.patch new file mode 100644 index 00000000..3e3b0be1 --- /dev/null +++ b/patches/5.3.0/0004-Check-that-the-OCaml-versions-are-compatible-for-a-c.patch @@ -0,0 +1,54 @@ +From 81844c1526bf09fc7faa63cb0128364e0de5c54f Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Tue, 16 Jul 2024 19:44:28 +0200 +Subject: [PATCH 04/21] Check that the OCaml versions are compatible for a + cross compiler + +When building a cross compiler using an already built non-cross +compiler, check that they are of the same version as a sanity check, as +the cross compiler will be linked using the OCaml code in the source +tree and the C runtime from the non-cross compiler +--- + configure | Bin 704188 -> 704905 bytes + configure.ac | 11 ++++++++++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 25fce20f5070b041a94ddd51d4899489eab79ac4..328a177641cce86671c394ddde17eae70192f3b1 100755 +GIT binary patch +delta 483 +zcmdn6rkg|gJ5;>`TK=^MYY+t_46Br@}gOA>Q(Qd1QCofC6&5E_#c^AwUwGjmeF +z`cX}tp7@bjwjN|IS=#mV^c0j7?9|Mx6>7N@fFLoaC^a#qG9GSPJk+VSN-7%p$v}4{ +zE9jQxmF8+Hfz^ZDo~l(`qEMk^s%NZcprl|6WUAmaW_n^Qrz3Y|YO#U_SiRXc^4@lX1B^h-1jNih%mT!$K+Fcj>_E%`#GKm=4sb;>0svWN6xRR% + +diff --git a/configure.ac b/configure.ac +index f3a219ef9a..7e3b3a054e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -627,7 +627,16 @@ AS_IF([test x"$enable_ocamldoc" = "xno"], + AS_IF( + [test x"$host" = x"$target"], + [cross_compiler=false], +- [cross_compiler=true]) ++ [# We require a non-cross compiler of the same version ++ AC_MSG_CHECKING(m4_normalize([if the installed OCaml compiler can build the ++ cross compiler])) ++ already_installed_version="$(ocamlc -vnum)" ++ AS_IF([test x"AC_PACKAGE_VERSION" = x"$already_installed_version"], ++ [AC_MSG_RESULT([yes (AC_PACKAGE_VERSION)])], ++ [AC_MSG_RESULT(m4_normalize([no (AC_PACKAGE_VERSION vs ++ $already_installed_version)])) ++ AC_MSG_ERROR([exiting])]) ++ cross_compiler=true]) + + # Initialization of libtool + # Allow the MSVC linker to be found even if ld isn't installed. +-- +2.47.2 + diff --git a/patches/5.3.0/0005-Use-a-TARGET_BINDIR-configure-variable-instead-of-wi.patch b/patches/5.3.0/0005-Use-a-TARGET_BINDIR-configure-variable-instead-of-wi.patch new file mode 100644 index 00000000..425ebcb9 --- /dev/null +++ b/patches/5.3.0/0005-Use-a-TARGET_BINDIR-configure-variable-instead-of-wi.patch @@ -0,0 +1,85 @@ +From f7ce7cf720c530ccf533868b2fc28ba2f75eb699 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 9 Dec 2024 19:23:40 +0100 +Subject: [PATCH 05/21] Use a `TARGET_BINDIR` configure variable instead of + `--with-target-bindir` +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change the way to configure the location of the runtime binaries on the +target system from a `--with-target-bindir=...`, which allows users to +use a meaningless `--without-target-bindir`, to a `TARGET_BINDIR` +variable + +Suggested-by: Sébastien Hinderer +Suggested-by: David Allsopp +--- + configure | Bin 704905 -> 704715 bytes + configure.ac | 13 +++++-------- + 2 files changed, 5 insertions(+), 8 deletions(-) + +diff --git a/configure b/configure +index 328a177641cce86671c394ddde17eae70192f3b1..b9cd0229890350b736c804eaa7cc97a9e8910aef 100755 +GIT binary patch +delta 252 +zcmeBd);`^+y+I*>H^ec>-8CfM$luNV35c12m<5PgftU@5*@2j2`-b(L +z0<7971}Z7oDyUbebCqPI<|$YKjYpB){(1}N$68esF +NP`$DJ;cl)KtNDoz9c{eCeJ=$G&ymPG+S|HaY<_K +z=H7$f*fw83!Srmp%OXah>2KFD@<3HiXI#!GCRCnTk`Z5$Sd^Yx5)UzQ`owLF(w-grr+nOxHy7cq*q1MLN3CLm@8Viq7~ +z1!6WJW(Q)9?Qhp{in31sC(XvL0&#_sf~|sjg*sPBMrxjd6}s8mb+>SStd&D`mAZ;X +rYH~)tf|3eEeEJVVE|u*GMqJxE*q|c&cX3HfzahgWvfX1hS2HUBFztl) + +diff --git a/configure.ac b/configure.ac +index 7e3b3a054e..bb661f9f6a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -519,11 +519,8 @@ AC_ARG_ENABLE([cmm-invariants], + [AS_HELP_STRING([--enable-cmm-invariants], + [enable invariants checks in Cmm])]) + +-AC_ARG_WITH([target-bindir], +- [AS_HELP_STRING([--with-target-bindir], +- [location of the runtime binaries on the target system])], +- [target_bindir=$withval], +- [target_bindir='']) ++AC_ARG_VAR([TARGET_BINDIR], ++ [location of the runtime binaries on the target system]) + + AC_ARG_WITH([target-sh], + [AS_HELP_STRING([--with-target-sh], +@@ -850,7 +847,7 @@ AS_IF([test "x$interpval" = "xyes"], + AC_CONFIG_COMMANDS([shebang], + [printf '%s\n%s\000\n' "$launch_method" "$ocaml_bindir" \ + > stdlib/runtime.info +- printf '%s\n%s\000\n' "$target_launch_method" "$target_bindir" \ ++ printf '%s\n%s\000\n' "$target_launch_method" "$TARGET_BINDIR" \ + > stdlib/target_runtime.info], + dnl These declarations are put in a here-document in configure, so the command + dnl in '$(...)' _is_ evaluated as the content is written to config.status (by +@@ -860,7 +857,7 @@ dnl nefarious single quotes which may appear in any of the strings. + target_launch_method=\ + '$(echo "$target_launch_method" | sed -e "s/'/'\"'\"'/g")' + ocaml_bindir='$(echo "$ocaml_bindir" | sed -e "s/'/'\"'\"'/g")' +- target_bindir='$(echo "$target_bindir" | sed -e "s/'/'\"'\"'/g")']) ++ TARGET_BINDIR='$(echo "$TARGET_BINDIR" | sed -e "s/'/'\"'\"'/g")']) + + # How to build sak + +@@ -2740,7 +2737,7 @@ AC_CONFIG_COMMANDS_PRE([ + eval "exec_prefix=\"$exec_prefix\"" + eval "ocaml_bindir=\"$bindir\"" + eval "ocaml_libdir=\"$libdir\"" +- AS_IF([test x"$target_bindir" = 'x'],[target_bindir="$ocaml_bindir"]) ++ AS_IF([test x"$TARGET_BINDIR" = 'x'],[TARGET_BINDIR="$ocaml_bindir"]) + AS_IF([test x"$target_launch_method" = 'x'], + [target_launch_method="$launch_method"]) + prefix="$saved_prefix" +-- +2.47.2 + diff --git a/patches/5.3.0/0006-Add-a-configurable-library-directory-on-target.patch b/patches/5.3.0/0006-Add-a-configurable-library-directory-on-target.patch new file mode 100644 index 00000000..a67d314d --- /dev/null +++ b/patches/5.3.0/0006-Add-a-configurable-library-directory-on-target.patch @@ -0,0 +1,102 @@ +From 06f5a281e01fc42a8d597eb75ad73fc220da7170 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Wed, 2 Oct 2024 13:24:03 +0200 +Subject: [PATCH 06/21] Add a configurable library directory on target + +Add a `TARGET_LIBDIR` variable to `configure` and assign a Makefile +`TARGET_LIBDIR` variable with it +Use the value of `LIBDIR` by default for this new variable +Use `TARGET_LIBDIR` to define the `OCAML_STDLIB_DIR` macro used by the +runtime + +When building a cross compiler, the OCaml standard library has no reason +to be found at the same paths on the host and on the target. This allows +users to provide a path that is meaningful to look for libraries to link +dynamically on the target. +--- + Makefile | 2 +- + Makefile.config.in | 5 ++++- + configure | Bin 704715 -> 704961 bytes + configure.ac | 8 ++++++++ + 4 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 044012f1d9..1ec0bd20b2 100644 +--- a/Makefile ++++ b/Makefile +@@ -1393,7 +1393,7 @@ C_LITERAL = $(shell $(SAK) encode-C-literal '$(1)') + + runtime/build_config.h: $(ROOTDIR)/Makefile.config $(SAK) + $(V_GEN)echo '/* This file is generated from $(ROOTDIR)/Makefile.config */' > $@ && \ +- echo '#define OCAML_STDLIB_DIR $(call C_LITERAL,$(LIBDIR))' >> $@ && \ ++ echo '#define OCAML_STDLIB_DIR $(call C_LITERAL,$(TARGET_LIBDIR))' >> $@ && \ + echo '#define HOST "$(HOST)"' >> $@ + + ## Runtime libraries and programs +diff --git a/Makefile.config.in b/Makefile.config.in +index e432851cde..522c0f6338 100644 +--- a/Makefile.config.in ++++ b/Makefile.config.in +@@ -46,9 +46,12 @@ BINDIR=@bindir@ + + datarootdir=@datarootdir@ + +-### Where to install the standard library ++### Where to install the standard library on host + LIBDIR=@libdir@ + ++### Where to look for the standard library on target ++TARGET_LIBDIR=@TARGET_LIBDIR@ ++ + ### Where to install the stub code for the standard library + STUBLIBDIR=@libdir@/stublibs + +diff --git a/configure b/configure +index b9cd0229890350b736c804eaa7cc97a9e8910aef..21a2617e3958bd64ddfc1fb914d1c6c9b9fed1dc 100755 +GIT binary patch +delta 252 +zcmX@zsC}?mdqYehZ-`@%yK6|ikEfH1XVB*8K!1KNgwWs1lvr{ylZqzq +zIw9q*qfnBskd&%WTAZ4qkd|M>rGNrbD)VwO^RlfKQc}|rOLIz!LCQ-qQWeS)b4pVc +z^3xQ6CZ%K+ZN75i@TTq4su^94r;Fz^Nw$Al#|XqsK+FupEI`Z(#B4y!zWviWjtj4h +p5iSHeT1mlHp@Iu&aGrt{&{e{bTc-$pFFT>yGIS9i}7@p?Tq5>OV=|3F%u9o12GE_ +cvjQ<25VLPzx}M|0tM(nUIJfVZ#l@)(0Ik*}S^xk5 + +diff --git a/configure.ac b/configure.ac +index bb661f9f6a..9b0331cdee 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -256,6 +256,7 @@ AC_SUBST([build_libraries_manpages]) + AC_SUBST([compute_deps]) + AC_SUBST([ocaml_bindir]) + AC_SUBST([ocaml_libdir]) ++AC_SUBST([TARGET_LIBDIR]) + AC_SUBST([QS]) + AC_SUBST([ar_supports_response_files]) + +@@ -522,6 +523,10 @@ AC_ARG_ENABLE([cmm-invariants], + AC_ARG_VAR([TARGET_BINDIR], + [location of the runtime binaries on the target system]) + ++AC_ARG_VAR([TARGET_LIBDIR], ++ [location of the libraries on the target system, to be used for dynlink; ++ defaults to the value of libdir]) ++ + AC_ARG_WITH([target-sh], + [AS_HELP_STRING([--with-target-sh], + [location of Posix sh on the target system])], +@@ -2693,6 +2698,9 @@ AC_CONFIG_COMMANDS_PRE([cclibs="$cclibs $mathlib $DLLIBS $PTHREAD_LIBS"]) + AS_IF([test x"$libdir" = x'${exec_prefix}/lib'], + [libdir="$libdir"/ocaml]) + ++AS_IF([test x"$TARGET_LIBDIR" = x], ++ [TARGET_LIBDIR="$libdir"]) ++ + AS_IF([test x"$mandir" = x'${datarootdir}/man'], + [mandir='${prefix}/man']) + +-- +2.47.2 + diff --git a/patches/5.3.0/0007-Detect-flexlink-only-on-relevant-targets.patch b/patches/5.3.0/0007-Detect-flexlink-only-on-relevant-targets.patch new file mode 100644 index 00000000..12470776 --- /dev/null +++ b/patches/5.3.0/0007-Detect-flexlink-only-on-relevant-targets.patch @@ -0,0 +1,43 @@ +From eda4278b853186db65dc80acb9e3633ce14c8f9c Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Thu, 3 Oct 2024 11:47:16 +0200 +Subject: [PATCH 07/21] Detect `flexlink` only on relevant targets + +On Unix platforms, make sure it is possible to have a `flexlink` +executable in `PATH` (which is useful for instance when using a cross +compiler to Windows), and still be able to configure and build a +non-cross compiler +--- + configure | Bin 704961 -> 705055 bytes + configure.ac | 4 +++- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 21a2617e3958bd64ddfc1fb914d1c6c9b9fed1dc..8e8f2351c65874ed71a60f10a88584157cb6b08a 100755 +GIT binary patch +delta 75 +zcmX@utUbR)yP<`#g{g(Pg{6gc3!C4?=`PZ2;?paH*?6Ygo@P^=u4cm~yFL3NTOiAH +dp~;Lg)0G~x3AbOo$_B*jK+LiI;#JNMuL0Y&9UK4v + +delta 55 +zcmbQ=qJ6MgyP<`#g{g(Pg{6gc3!C4?=`J4`Ww)=t$QH;l{mv6M<#yX^Y(UHo#2njg +JuW>$l4FF~P7dZd` + +diff --git a/configure.ac b/configure.ac +index 9b0331cdee..ea5fa86609 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1074,7 +1074,9 @@ AS_IF([test x"$supports_shared_libraries" != 'xfalse'], [ + [AC_MSG_RESULT([requested but not supported]) + AC_MSG_ERROR([exiting])])])]) + +- AC_CHECK_PROG([flexlink],[flexlink],[flexlink]) ++ AS_CASE([$target], ++ [*-*-cygwin*|*-w64-mingw32*|*-pc-windows], ++ [AC_CHECK_PROG([flexlink],[flexlink],[flexlink])]) + + AS_IF([test -n "$flexlink" && test -z "$flexdll_source_dir"],[ + OCAML_TEST_FLEXLINK([$flexlink], [$flexdll_chain], +-- +2.47.2 + diff --git a/patches/5.3.0/0008-Add-a-Makefile.cross-with-rules-to-build-a-cross-com.patch b/patches/5.3.0/0008-Add-a-Makefile.cross-with-rules-to-build-a-cross-com.patch new file mode 100644 index 00000000..c16a5ab1 --- /dev/null +++ b/patches/5.3.0/0008-Add-a-Makefile.cross-with-rules-to-build-a-cross-com.patch @@ -0,0 +1,117 @@ +From a7c806941bb8fb5676e11a34f1e2a1e1b481d8c2 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 23 Feb 2024 16:56:07 +0100 +Subject: [PATCH 08/21] Add a Makefile.cross with rules to build a cross + compiler + +Add a new `Makefile.cross` that gets enabled when building a cross +compiler, aka when host is different from target +Define two new (phony) targets: +- crossopt, to build the cross compilers to the native target (and what + is required for such cross compilers to work) +- installcross, to install the cross compilers +--- + Makefile | 5 ++++ + Makefile.cross | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 79 insertions(+) + create mode 100644 Makefile.cross + +diff --git a/Makefile b/Makefile +index 1ec0bd20b2..818d23e4ee 100644 +--- a/Makefile ++++ b/Makefile +@@ -2962,6 +2962,11 @@ endif + + include .depend + ++# Include the cross-compiler recipes only when relevant ++ifneq "$(HOST)" "$(TARGET)" ++include Makefile.cross ++endif ++ + Makefile.config Makefile.build_config: config.status + config.status: + @echo "Please refer to the installation instructions:" +diff --git a/Makefile.cross b/Makefile.cross +new file mode 100644 +index 0000000000..c30d2e2b4f +--- /dev/null ++++ b/Makefile.cross +@@ -0,0 +1,74 @@ ++#************************************************************************** ++#* * ++#* OCaml * ++#* * ++#* Samuel Hym, Tarides * ++#* * ++#* Copyright 2024 Tarides * ++#* * ++#* All rights reserved. This file is distributed under the terms of * ++#* the GNU Lesser General Public License version 2.1, with the * ++#* special exception on linking described in the file LICENSE. * ++#* * ++#************************************************************************** ++ ++# Recipes to build a cross compiler (_not_ cross-compiling the compiler), aka ++# generating code that will run on `target`, assuming that a non-cross OCaml ++# compiler (so targetting our build machine) of the same version is available in ++# $PATH ++ ++# As the cross compiler will be linked with the _build_ version of ++# libcomprmarsh, we cannot rely on the detection of zstd done during `configure` ++# (as it would have detected the _target_ version). So we recover the flags to ++# link with zstd of the non-cross compiler. ++# Note that the shell call is a variable that is used only once, so it doesn't ++# have to be lazier. ++HOST_ZSTD_LIBS=$(shell grep ^ZSTD_LIBS= "$$(ocamlopt -where)/Makefile.config") ++ ++CROSS_OVERRIDES=OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun \ ++ BOOT_OCAMLLEX=ocamllex OCAMLYACC=ocamlyacc ++CROSS_COMPILER_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc CAMLOPT=ocamlopt \ ++ BEST_OCAMLC=ocamlc BEST_OCAMLOPT=ocamlopt BEST_OCAMLLEX=ocamllex ++CROSS_COMPILERLIBS_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc \ ++ CAMLOPT="$(ROOTDIR)/ocamlopt.opt$(EXE) $(STDLIBFLAGS)" ++ ++# The compiler libs that should be rebuilt for target (they are first built for ++# host as part of the .opt compilers) ++CROSSCOMPILERLIBS := $(addprefix compilerlibs/,$(addsuffix .cmxa,\ ++ ocamlcommon ocamlmiddleend ocamlbytecomp ocamloptcomp ocamltoplevel)) ++ ++.PHONY: crossopt ++crossopt: runtime-all ++ $(MAKE) ocamlc $(TOOLS_BYTECODE_TARGETS) expunge$(EXE) \ ++ $(CROSS_COMPILER_OVERRIDES) ++ $(MAKE) library $(CROSS_OVERRIDES) ++ $(MAKE) ocamlyacc $(CROSS_OVERRIDES) ++ $(MAKE) ocamllex $(CROSS_COMPILER_OVERRIDES) ++ $(MAKE) ocaml $(CROSS_COMPILER_OVERRIDES) ++ $(MAKE) dynlink-all $(CROSS_OVERRIDES) ++ $(MAKE) -C otherlibs all $(CROSS_OVERRIDES) ++ $(MAKE) runtimeopt ++ $(MAKE) ocamlc.opt ocamlopt.opt $(TOOLS_NATIVE_TARGETS) \ ++ $(CROSS_COMPILER_OVERRIDES) "$(HOST_ZSTD_LIBS)" ++ $(MAKE) libraryopt $(CROSS_OVERRIDES) ++ $(MAKE) otherlibrariesopt ocamltoolsopt $(CROSS_OVERRIDES) ++ $(MAKE) tools-allopt.opt $(CROSS_COMPILER_OVERRIDES) ++ # We now build the compiler libs again, but for target this time ++ rm -f $(ocamlcommon_NCOBJS) $(ocamlmiddleend_NCOBJS) \ ++ $(ocamlbytecomp_NCOBJS) $(ocamloptcomp_NCOBJS) \ ++ $(ocamltoplevel_NCOBJS) $(CROSSCOMPILERLIBS) ++ $(MAKE) $(CROSSCOMPILERLIBS) $(CROSS_COMPILERLIBS_OVERRIDES) ++ ++INSTALL_OVERRIDES=build_ocamldoc=false WITH_DEBUGGER= OCAMLRUN=ocamlrun ++ ++.PHONY: installcross ++installcross: ++ # Create dummy files to keep `install` happy ++ touch \ ++ $(addprefix toplevel/, \ ++ $(foreach ext,cmi cmt cmti cmx, native/nat__dummy__.$(ext)) \ ++ all__dummy__.cmx topstart.o native/tophooks.cmi) ++ $(LN) `command -v ocamllex` lex/ocamllex.opt$(EXE) ++ $(LN) `command -v ocamlyacc` yacc/ocamlyacc.opt$(EXE) ++ # Real installation ++ $(MAKE) install $(INSTALL_OVERRIDES) +-- +2.47.2 + diff --git a/patches/5.3.0/0009-Enable-bootstrapping-flexdll-in-the-cross-compiler-s.patch b/patches/5.3.0/0009-Enable-bootstrapping-flexdll-in-the-cross-compiler-s.patch new file mode 100644 index 00000000..8e0cb609 --- /dev/null +++ b/patches/5.3.0/0009-Enable-bootstrapping-flexdll-in-the-cross-compiler-s.patch @@ -0,0 +1,99 @@ +From 2db4395bf193b40cde46d87bd7e7fc58d3554763 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Tue, 3 Sep 2024 15:18:23 +0200 +Subject: [PATCH 09/21] Enable bootstrapping flexdll in the cross-compiler + setting + +Add a rule to build flexdll in the cross-compiler setting, namely +building flexdll on Unix, by driving its `Makefile` so that Windows +resources are not built and only the .opt version is really built (and +copied to the byte binary directory nevertheless) +Use the `-o` flag to tell `make` to never try to rebuild `flexlink` (as +it would otherwise, according to the dependencies in the main +`Makefile`) +--- + Makefile.cross | 55 ++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 42 insertions(+), 13 deletions(-) + +diff --git a/Makefile.cross b/Makefile.cross +index c30d2e2b4f..e01792de20 100644 +--- a/Makefile.cross ++++ b/Makefile.cross +@@ -32,32 +32,61 @@ CROSS_COMPILER_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc CAMLOPT=ocamlopt \ + CROSS_COMPILERLIBS_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc \ + CAMLOPT="$(ROOTDIR)/ocamlopt.opt$(EXE) $(STDLIBFLAGS)" + ++ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true" ++# Declare flexlink to be an 'old' file, so that make doesn't try to rebuild it ++# with the build rules in `Makefile`; its build is driven by the `cross-flexdll` ++# recipe provided here instead ++OLDS := -o $(BYTE_BINDIR)/flexlink$(EXE) ++else ++OLDS := ++endif ++ + # The compiler libs that should be rebuilt for target (they are first built for + # host as part of the .opt compilers) + CROSSCOMPILERLIBS := $(addprefix compilerlibs/,$(addsuffix .cmxa,\ + ocamlcommon ocamlmiddleend ocamlbytecomp ocamloptcomp ocamltoplevel)) + + .PHONY: crossopt ++ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true" ++crossopt: cross-flexdll ++ $(MAKE) runtime-all $(OLDS) ++else ++# In that case, $(OLDS) is empty, we can depend directly on runtime-all + crossopt: runtime-all ++endif + $(MAKE) ocamlc $(TOOLS_BYTECODE_TARGETS) expunge$(EXE) \ +- $(CROSS_COMPILER_OVERRIDES) +- $(MAKE) library $(CROSS_OVERRIDES) +- $(MAKE) ocamlyacc $(CROSS_OVERRIDES) +- $(MAKE) ocamllex $(CROSS_COMPILER_OVERRIDES) +- $(MAKE) ocaml $(CROSS_COMPILER_OVERRIDES) +- $(MAKE) dynlink-all $(CROSS_OVERRIDES) +- $(MAKE) -C otherlibs all $(CROSS_OVERRIDES) +- $(MAKE) runtimeopt ++ $(CROSS_COMPILER_OVERRIDES) $(OLDS) ++ $(MAKE) library $(CROSS_OVERRIDES) $(OLDS) ++ $(MAKE) ocamlyacc $(CROSS_OVERRIDES) $(OLDS) ++ $(MAKE) ocamllex $(CROSS_COMPILER_OVERRIDES) $(OLDS) ++ $(MAKE) ocaml $(CROSS_COMPILER_OVERRIDES) $(OLDS) ++ $(MAKE) dynlink-all $(CROSS_OVERRIDES) $(OLDS) ++ $(MAKE) -C otherlibs all $(CROSS_OVERRIDES) $(OLDS) ++ $(MAKE) runtimeopt $(OLDS) + $(MAKE) ocamlc.opt ocamlopt.opt $(TOOLS_NATIVE_TARGETS) \ +- $(CROSS_COMPILER_OVERRIDES) "$(HOST_ZSTD_LIBS)" +- $(MAKE) libraryopt $(CROSS_OVERRIDES) +- $(MAKE) otherlibrariesopt ocamltoolsopt $(CROSS_OVERRIDES) +- $(MAKE) tools-allopt.opt $(CROSS_COMPILER_OVERRIDES) ++ $(CROSS_COMPILER_OVERRIDES) "$(HOST_ZSTD_LIBS)" $(OLDS) ++ $(MAKE) libraryopt $(CROSS_OVERRIDES) $(OLDS) ++ $(MAKE) otherlibrariesopt ocamltoolsopt $(CROSS_OVERRIDES) $(OLDS) ++ $(MAKE) tools-allopt.opt $(CROSS_COMPILER_OVERRIDES) $(OLDS) + # We now build the compiler libs again, but for target this time + rm -f $(ocamlcommon_NCOBJS) $(ocamlmiddleend_NCOBJS) \ + $(ocamlbytecomp_NCOBJS) $(ocamloptcomp_NCOBJS) \ + $(ocamltoplevel_NCOBJS) $(CROSSCOMPILERLIBS) +- $(MAKE) $(CROSSCOMPILERLIBS) $(CROSS_COMPILERLIBS_OVERRIDES) ++ $(MAKE) $(CROSSCOMPILERLIBS) $(CROSS_COMPILERLIBS_OVERRIDES) $(OLDS) ++ ++.PHONY: cross-flexdll ++cross-flexdll: | $(BYTE_BINDIR) $(OPT_BINDIR) ++ rm -f $(FLEXDLL_SOURCE_DIR)/flexlink.exe ++ $(MAKE) -C $(FLEXDLL_SOURCE_DIR) $(FLEXLINK_BUILD_ENV) \ ++ NATDYNLINK=false LINKFLAGS= flexlink.exe support ++ $(LN) $(FLEXDLL_SOURCE_DIR)/flexlink.exe flexlink.opt.exe ++ $(LN) flexlink.opt.exe flexlink.byte.exe ++ cp flexlink.byte.exe $(BYTE_BINDIR)/flexlink ++ cd $(BYTE_BINDIR) && $(LN) flexlink flexlink.exe ++ cp $(addprefix $(FLEXDLL_SOURCE_DIR)/, $(FLEXDLL_OBJECTS)) $(BYTE_BINDIR) ++ cp flexlink.opt.exe $(OPT_BINDIR)/flexlink ++ cd $(OPT_BINDIR) && $(LN) flexlink flexlink.exe ++ cp $(addprefix $(FLEXDLL_SOURCE_DIR)/, $(FLEXDLL_OBJECTS)) $(OPT_BINDIR) + + INSTALL_OVERRIDES=build_ocamldoc=false WITH_DEBUGGER= OCAMLRUN=ocamlrun + +-- +2.47.2 + diff --git a/patches/5.3.0/0010-Fix-static-builds-of-the-compiler.patch b/patches/5.3.0/0010-Fix-static-builds-of-the-compiler.patch new file mode 100644 index 00000000..ba136dfb --- /dev/null +++ b/patches/5.3.0/0010-Fix-static-builds-of-the-compiler.patch @@ -0,0 +1,49 @@ +From 6445eb911ce4ab68cdb6c3186b4652a3538f4cbb Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Sun, 15 Dec 2024 17:34:16 +0000 +Subject: [PATCH 10/21] Fix static builds of the compiler + +ocamlc -custom needs to include and therefore the +build has -I runtime in order to facilitate this. -I runtime breaks +cross-compilation, since it causes the .a files in runtime to be found +by the host ocamlopt instead of its own. + +This workaround defeats that problem by adding + to VPATH as the first +include, which will cause the host compiler's Standard Library directory +(which includes the runtime .a files) to be included first in the search +path. When building the compiler's libraries (which should be using the +target's Standard Library, not the host's), -nostdlib -I stdlib is +already inserted before VPATH by the build system, which means this +mechanism never interferes with the selection of the correct Standard +Library. +--- + Makefile.cross | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/Makefile.cross b/Makefile.cross +index e01792de20..0d2cf8f323 100644 +--- a/Makefile.cross ++++ b/Makefile.cross +@@ -25,6 +25,19 @@ + # have to be lazier. + HOST_ZSTD_LIBS=$(shell grep ^ZSTD_LIBS= "$$(ocamlopt -where)/Makefile.config") + ++# The build system adds various include directories which pertain to the current ++# tree, including -I runtime, which is necessary for -custom executables. ++# ocamltest is always a -custom executable, but some others (ocamldoc; the ++# debugger, etc.) are only -custom in specific circumstances. It is therefore ++# fiddly to change this in the main build system, so we perform a slightly ++# different trick by ensuring that "+" is the first entry in VPATH. This will ++# put the host compiler's standard library (and consequently its runtime ++# objects) well above the .a files found with -I runtime. For now, this seems ++# the least nefarious way of ensuring that the bytecode compiler has the C ++# headers in runtime/caml available without breaking builds with an external ++# ocamlopt. ++VPATH := + $(VPATH) ++ + CROSS_OVERRIDES=OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun \ + BOOT_OCAMLLEX=ocamllex OCAMLYACC=ocamlyacc + CROSS_COMPILER_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc CAMLOPT=ocamlopt \ +-- +2.47.2 + diff --git a/patches/5.3.0/0011-Add-a-dummy-caml_debugger_saved_instruction-when-HAS.patch b/patches/5.3.0/0011-Add-a-dummy-caml_debugger_saved_instruction-when-HAS.patch new file mode 100644 index 00000000..93258c2b --- /dev/null +++ b/patches/5.3.0/0011-Add-a-dummy-caml_debugger_saved_instruction-when-HAS.patch @@ -0,0 +1,39 @@ +From 2787f4b4fa1ba52ea34b1805a7c9e33207d31e66 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Tue, 7 Jan 2025 13:50:21 +0100 +Subject: [PATCH 11/21] Add a dummy `caml_debugger_saved_instruction` when + `HAS_SOCKETS` is false + +The `caml_debugger_saved_instruction` function is called unconditionally +in `runtime/interp.c` to implement the debugger-specific instructions. +This patch provides a dummy implementation for that function, alongside +the other `caml_debugger_*` functions, so that the interpreter can be +built in the uncommon setups with no available socket implementation. +--- + runtime/debugger.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/runtime/debugger.c b/runtime/debugger.c +index 45ba7a6cbf..439d65c4c5 100644 +--- a/runtime/debugger.c ++++ b/runtime/debugger.c +@@ -43,6 +43,16 @@ void caml_debugger_init(void) + { + } + ++opcode_t caml_debugger_saved_instruction(code_t pc) ++{ ++ /* Raise a fatal error in the should-not-happen case where this function ++ * would be called without a socket, so that the execution does not branch ++ * to opcode 0 */ ++ caml_fatal_error("cannot execute debugger instructions" ++ " without a debugger connection socket\n"); ++ return 0; ++} ++ + void caml_debugger(enum event_kind event, value param) + { + } +-- +2.47.2 + diff --git a/patches/5.3.0/0012-Include-asm.h-at-the-beginning-of-assembler-sources.patch b/patches/5.3.0/0012-Include-asm.h-at-the-beginning-of-assembler-sources.patch new file mode 100644 index 00000000..6e8901e4 --- /dev/null +++ b/patches/5.3.0/0012-Include-asm.h-at-the-beginning-of-assembler-sources.patch @@ -0,0 +1,112 @@ +From c27c0945ea345fd7a2044f2629575d015838201a Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Wed, 5 Feb 2025 13:49:03 +0100 +Subject: [PATCH 12/21] Include `asm.h` at the beginning of assembler sources + +--- + runtime/amd64.S | 3 +-- + runtime/arm64.S | 3 +-- + runtime/power.S | 1 + + runtime/riscv.S | 3 +-- + runtime/s390x.S | 3 +-- + 5 files changed, 5 insertions(+), 8 deletions(-) + +diff --git a/runtime/amd64.S b/runtime/amd64.S +index c646f944df..32364d7042 100644 +--- a/runtime/amd64.S ++++ b/runtime/amd64.S +@@ -19,6 +19,7 @@ + /* PIC mode support based on contribution by Paul Stravers (see PR#4795) */ + + #include "caml/m.h" ++#include "caml/asm.h" + + #if defined(SYS_macosx) + +@@ -81,8 +82,6 @@ + #define ENDFUNCTION(name) + #endif + +-#include "../runtime/caml/asm.h" +- + #ifdef WITH_FRAME_POINTERS + #define FRAME_POINTER_SIZE 8 + #else +diff --git a/runtime/arm64.S b/runtime/arm64.S +index b3a475454d..2153558d30 100644 +--- a/runtime/arm64.S ++++ b/runtime/arm64.S +@@ -19,6 +19,7 @@ + /* Must be preprocessed by cpp */ + + #include "caml/m.h" ++#include "caml/asm.h" + + /* Special registers */ + +@@ -152,8 +153,6 @@ G(name): + .size G(name), .-G(name) + #endif + +-#include "../runtime/caml/asm.h" +- + /* Function prologue and epilogue */ + + .macro ENTER_FUNCTION +diff --git a/runtime/power.S b/runtime/power.S +index e05a612f28..e3e4bbe4af 100644 +--- a/runtime/power.S ++++ b/runtime/power.S +@@ -14,6 +14,7 @@ + /**************************************************************************/ + + #include "caml/m.h" ++#include "caml/asm.h" + + .abiversion 2 + +diff --git a/runtime/riscv.S b/runtime/riscv.S +index a3b796bc53..03bb93e020 100644 +--- a/runtime/riscv.S ++++ b/runtime/riscv.S +@@ -17,6 +17,7 @@ + /* Must be preprocessed by cpp */ + + #include "caml/m.h" ++#include "caml/asm.h" + + #define DOMAIN_STATE_PTR s11 + #define TRAP_PTR s1 +@@ -104,8 +105,6 @@ name: + #define END_OBJECT(name) \ + .size name, .-name + +-#include "../runtime/caml/asm.h" +- + /* Function prologue and epilogue */ + + .macro ENTER_FUNCTION +diff --git a/runtime/s390x.S b/runtime/s390x.S +index e67765bca2..917c0592dc 100644 +--- a/runtime/s390x.S ++++ b/runtime/s390x.S +@@ -16,6 +16,7 @@ + /**************************************************************************/ + + #include "caml/m.h" ++#include "caml/asm.h" + + /* Special registers */ + +@@ -130,8 +131,6 @@ caml_hot.code_end: + #define DW_REG_r12 12 + #define DW_REG_r15 15 + +-#include "../runtime/caml/asm.h" +- + /******************************************************************************/ + /* Access to the current domain state block. */ + /******************************************************************************/ +-- +2.47.2 + diff --git a/patches/5.3.0/0013-Detect-the-need-for-the-GNU-note-for-non-executable-.patch b/patches/5.3.0/0013-Detect-the-need-for-the-GNU-note-for-non-executable-.patch new file mode 100644 index 00000000..3947db4f --- /dev/null +++ b/patches/5.3.0/0013-Detect-the-need-for-the-GNU-note-for-non-executable-.patch @@ -0,0 +1,113 @@ +From 2371883be0f6d1e116487e74d43fb1341ea18805 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 13 Jan 2025 12:07:00 +0100 +Subject: [PATCH 13/21] Detect the need for the GNU note for non-executable + stack + +Detect during `configure` whether the C compiler generates a +`.note.GNU-stack` section to mark it explicitly as non-executable +Define a macro in `m.h` and a configure variable so that OCaml can do as +cc does + +Detail: without the explicit `.note.GNU-stack` section, recent versions +of GNU ld show, at least on some targets: +/usr/bin/ld: warning: .... missing .note.GNU-stack section implies executable stack +/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker +--- + aclocal.m4 | 24 ++++++++++++++++++++++++ + configure | Bin 705055 -> 706768 bytes + configure.ac | 3 +++ + runtime/caml/m.h.in | 5 +++++ + 4 files changed, 32 insertions(+) + +diff --git a/aclocal.m4 b/aclocal.m4 +index b17e11d511..9c6feb1034 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -526,6 +526,30 @@ AC_DEFUN([OCAML_CC_SUPPORTS_ATOMIC], [ + OCAML_CC_RESTORE_VARIABLES + ]) + ++# Detects whether the C compiler generates an explicit .note.GNU-stack section ++# to mark the stack as non-executable, so that we can follow suit ++AC_DEFUN([OCAML_WITH_NONEXECSTACK_NOTE], ++ [AC_REQUIRE([AC_PROG_FGREP])dnl ++ AC_CACHE_CHECK([if $CC generates a .note.GNU-stack section], ++ [ocaml_cv_prog_cc_nonexecstack_note], ++ [OCAML_CC_SAVE_VARIABLES ++ ++ # We write the assembly into the .$ac_objext file as AC_COMPILE_IFELSE ++ # assumes an error if such a file doesn't exist after compiling ++ CFLAGS="$CFLAGS -S -o conftest.$ac_objext" ++ ++ ocaml_cv_prog_cc_nonexecstack_note=no ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE], ++ [AS_IF([$FGREP .note.GNU-stack conftest.$ac_objext >/dev/null], ++ [ocaml_cv_prog_cc_nonexecstack_note=yes])]) ++ OCAML_CC_RESTORE_VARIABLES]) ++ ++ AS_IF([test "x$ocaml_cv_prog_cc_nonexecstack_note" = xyes], ++ [with_nonexecstack_note=true ++ AC_DEFINE([WITH_NONEXECSTACK_NOTE], [1])], ++ [with_nonexecstack_note=false]) ++]) ++ + AC_DEFUN([OCAML_CC_SUPPORTS_LABELS_AS_VALUES], [ + AC_CACHE_CHECK([whether $CC supports the labels as values extension], + [ocaml_cv_prog_cc_labels_as_values], +diff --git a/configure b/configure +index 8e8f2351c65874ed71a60f10a88584157cb6b08a..1735c1178d1f8c7c322f108c4f0207e6ff2576a1 100755 +GIT binary patch +delta 669 +zcmbQ=qJ3ea_6CVCvGUB4jQG6#ywr-+UVGy!wu^_c +zPVJn&`39@y^xRZ-c7^oRywsw^lGI{_Ll=dSCS7F +z(NjrGj?YiZO06hSNXyItDN%5Aj(7I=4e<1FjrVkO^$B+6QUC&FknYl4kjwKFQj3c6 +zixe``6pBleGk{(JYfZ^dEzVOfQAn-GEG|(1 +zJY7GAQ&J0TW`1&FZcco1S$siJetLXzGG>_C=H*Xc_?g{vI&&JQp(M~k6*u=F*8ude +zn||;Ylj!6IQ<3S*Ca?=)36b-qtgh1yS~-NK2mE4XnJ${ieq(xbE2Gu)&WY@T0_Y() +z{h=AV`1AunDJgWRR3!yFH8X34TCV9YC$h`)qsdR-=+7a7BYjN&5Y3?|7Va715%1^k +z=NjSa930~4><#3ExK3aHj$Kg!d%ChsOUx-wt<8 + +delta 61 +zcmcaGQG0%i_6CWtX8o{s{V+x#W&&bnAZFRFAI3VRbNXa)HsSVyXRJWX2E^<@%(1=T +I8E3*H0JA6;*#H0l + +diff --git a/configure.ac b/configure.ac +index ea5fa86609..6cf1dbe353 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -177,6 +177,7 @@ AC_SUBST([oc_ldflags]) + AC_SUBST([oc_dll_ldflags]) + AC_SUBST([cclibs]) + AC_SUBST([native_ldflags]) ++AC_SUBST([with_nonexecstack_note]) + AC_SUBST([zstd_libs]) + AC_SUBST([bytecode_cflags]) + AC_SUBST([bytecode_cppflags]) +@@ -672,6 +673,8 @@ popdef([host_cpu])dnl + popdef([host_alias])dnl + popdef([host])dnl + ++OCAML_WITH_NONEXECSTACK_NOTE ++ + AS_CASE([$host], + [sparc-sun-solaris*], + [DEP_CC="false"], +diff --git a/runtime/caml/m.h.in b/runtime/caml/m.h.in +index 3e9ef4b0b9..2fcc9e6e2b 100644 +--- a/runtime/caml/m.h.in ++++ b/runtime/caml/m.h.in +@@ -81,3 +81,8 @@ + #undef SUPPORTS_TREE_VECTORIZE + + #undef USE_MMAP_MAP_STACK ++ ++#undef WITH_NONEXECSTACK_NOTE ++ ++/* Define WITH_NONEXECSTACK_NOTE when an explicit ".note.GNU-stack" section ++ is to be added to indicate the stack should not be executable */ +-- +2.47.2 + diff --git a/patches/5.3.0/0014-Add-a-Config-variable-for-the-need-of-the-GNU-non-ex.patch b/patches/5.3.0/0014-Add-a-Config-variable-for-the-need-of-the-GNU-non-ex.patch new file mode 100644 index 00000000..f5ed98c2 --- /dev/null +++ b/patches/5.3.0/0014-Add-a-Config-variable-for-the-need-of-the-GNU-non-ex.patch @@ -0,0 +1,72 @@ +From caefee1e892042b502e324719640bc7a603b5ca4 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 13 Jan 2025 12:19:19 +0100 +Subject: [PATCH 14/21] Add a `Config` variable for the need of the GNU + non-executable stack note + +Add a `Config.with_nonexecstack_note` variable to indicate whether the +`.note.GNU-stack` section should be present to mark the stack explicitly +as non-executable +--- + utils/config.common.ml.in | 1 + + utils/config.fixed.ml | 1 + + utils/config.generated.ml.in | 1 + + utils/config.mli | 6 ++++++ + 4 files changed, 9 insertions(+) + +diff --git a/utils/config.common.ml.in b/utils/config.common.ml.in +index 3603fe6c60..03a03c9225 100644 +--- a/utils/config.common.ml.in ++++ b/utils/config.common.ml.in +@@ -100,6 +100,7 @@ let configuration_variables () = + p "asm" asm; + p_bool "asm_cfi_supported" asm_cfi_supported; + p_bool "with_frame_pointers" with_frame_pointers; ++ p_bool "with_nonexecstack_note" with_nonexecstack_note; + p "ext_exe" ext_exe; + p "ext_obj" ext_obj; + p "ext_asm" ext_asm; +diff --git a/utils/config.fixed.ml b/utils/config.fixed.ml +index 807b929355..ab9b533d46 100644 +--- a/utils/config.fixed.ml ++++ b/utils/config.fixed.ml +@@ -36,6 +36,7 @@ let bytecomp_c_compiler = "" + let native_c_compiler = c_compiler + let native_c_libraries = "" + let native_ldflags = "" ++let with_nonexecstack_note = false + let native_pack_linker = boot_cannot_call "the linker" + let default_rpath = "" + let mksharedlibrpath = "" +diff --git a/utils/config.generated.ml.in b/utils/config.generated.ml.in +index aa03455409..009e402f93 100644 +--- a/utils/config.generated.ml.in ++++ b/utils/config.generated.ml.in +@@ -45,6 +45,7 @@ let native_c_compiler = + c_compiler ^ " " ^ native_cflags ^ " " ^ native_cppflags + let native_c_libraries = {@QS@|@cclibs@|@QS@} + let native_ldflags = {@QS@|@native_ldflags@|@QS@} ++let with_nonexecstack_note = @with_nonexecstack_note@ + let native_pack_linker = {@QS@|@PACKLD@|@QS@} + let default_rpath = {@QS@|@rpath@|@QS@} + let mksharedlibrpath = {@QS@|@mksharedlibrpath@|@QS@} +diff --git a/utils/config.mli b/utils/config.mli +index 51e31a3729..c08bee00bf 100644 +--- a/utils/config.mli ++++ b/utils/config.mli +@@ -68,6 +68,12 @@ val native_c_libraries: string + val native_ldflags : string + (* Flags to pass to the system linker *) + ++val with_nonexecstack_note : bool ++(** Whether an explicit ".note.GNU-stack" section is to be added to indicate ++ the stack should not be executable ++ ++ @since 5.4 *) ++ + val native_pack_linker: string + (** The linker to use for packaging (ocamlopt -pack) and for partial + links (ocamlopt -output-obj). *) +-- +2.47.2 + diff --git a/patches/5.3.0/0015-Output-the-.note.GNU-stack-section-based-on-configur.patch b/patches/5.3.0/0015-Output-the-.note.GNU-stack-section-based-on-configur.patch new file mode 100644 index 00000000..0e2f0045 --- /dev/null +++ b/patches/5.3.0/0015-Output-the-.note.GNU-stack-section-based-on-configur.patch @@ -0,0 +1,302 @@ +From c16fb4888f0da0e28df22df28e238d4b3048db3c Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 13 Jan 2025 12:25:58 +0100 +Subject: [PATCH 15/21] Output the `.note.GNU-stack` section based on + `configure` + +Uniformly rely on the detection during `configure` of whether the +`.note.GNU-stack` section is generated by the C compiler to decide +whether to output it +Define a macro in `asm.h` and a function in `Emitaux` to output the +section when it should be + +Before that patch, the `.note.GNU-stack` section was: +- on x86_64: + - generated by `emit.mlp` only on Linux and FreeBSD + - present in `amd64.S` only on Linux and FreeBSD +- on ARM: + - generated by `emit.mlp` only on Linux + - present in `arm64.S` except on macOS +- on RISC-V: + - never generated by `emit.mlp` + - always present in `riscv.S` +- on POWER: + - always generated by `emit.mlp` + - always present in `power.S` +- on S/390: + - always generated by `emit.mlp` + - always present in `s390x.S` +--- + asmcomp/amd64/emit.mlp | 2 +- + asmcomp/arm64/emit.mlp | 7 +------ + asmcomp/emitaux.ml | 5 +++++ + asmcomp/emitaux.mli | 3 +++ + asmcomp/power/emit.mlp | 2 +- + asmcomp/riscv/emit.mlp | 3 ++- + asmcomp/s390x/emit.mlp | 3 +-- + runtime/amd64.S | 5 +---- + runtime/arm64.S | 5 +---- + runtime/caml/asm.h | 8 ++++++++ + runtime/power.S | 3 +-- + runtime/riscv.S | 3 +-- + runtime/s390x.S | 3 +-- + testsuite/tools/asmgen_arm.S | 6 ++++-- + testsuite/tools/asmgen_arm64.S | 8 ++++---- + testsuite/tools/asmgen_power.S | 6 ++++-- + testsuite/tools/asmgen_s390x.S | 6 ++++-- + 17 files changed, 43 insertions(+), 35 deletions(-) + +diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp +index 23f5b4525c..d35ac2d710 100644 +--- a/asmcomp/amd64/emit.mlp ++++ b/asmcomp/amd64/emit.mlp +@@ -1083,7 +1083,7 @@ let end_assembly() = + D.size frametable (ConstSub (ConstThis, ConstLabel frametable)) + end; + +- if system = S_linux || system = S_freebsd then ++ if Config.with_nonexecstack_note then + (* Mark stack as non-executable, PR#4564 *) + D.section [".note.GNU-stack"] (Some "") [ "%progbits" ]; + +diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp +index f59a5aed78..ba36dbdd84 100644 +--- a/asmcomp/arm64/emit.mlp ++++ b/asmcomp/arm64/emit.mlp +@@ -1209,9 +1209,4 @@ let end_assembly () = + efa_string = (fun s -> emit_string_directive " .asciz " s) }; + emit_symbol_type emit_symbol lbl "object"; + emit_symbol_size lbl; +- begin match Config.system with +- | "linux" -> +- (* Mark stack as non-executable *) +- ` .section .note.GNU-stack,\"\",%progbits\n` +- | _ -> () +- end ++ emit_nonexecstack_note () +diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml +index 306e249223..c115eacbbe 100644 +--- a/asmcomp/emitaux.ml ++++ b/asmcomp/emitaux.ml +@@ -111,6 +111,11 @@ let emit_float64_split_directive directive x = + let emit_float32_directive directive x = + emit_printf "\t%s\t0x%lx\n" directive x + ++let emit_nonexecstack_note () = ++ if Config.with_nonexecstack_note then begin ++ emit_string "\t.section .note.GNU-stack,\"\",%progbits\n" ++ end ++ + (* Record live pointers at call points *) + + type frame_debuginfo = +diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli +index d174fa92d4..a474c9f902 100644 +--- a/asmcomp/emitaux.mli ++++ b/asmcomp/emitaux.mli +@@ -30,6 +30,9 @@ val emit_float64_directive: string -> int64 -> unit + val emit_float64_split_directive: string -> int64 -> unit + val emit_float32_directive: string -> int32 -> unit + ++val emit_nonexecstack_note : unit -> unit ++(** Emit a [.note.GNU-stack] section when it is supported by the linker *) ++ + val reset : unit -> unit + val reset_debug_info: unit -> unit + val emit_debug_info: Debuginfo.t -> unit +diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp +index f9303ea65d..7d586e5032 100644 +--- a/asmcomp/power/emit.mlp ++++ b/asmcomp/power/emit.mlp +@@ -1170,4 +1170,4 @@ let end_assembly() = + emit_string toc_space; + emit_toctable(); + Hashtbl.clear tocref_entries; +- ` .section .note.GNU-stack,\"\",%progbits\n` ++ emit_nonexecstack_note () +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +index 964dc4db5c..b27833d180 100644 +--- a/asmcomp/riscv/emit.mlp ++++ b/asmcomp/riscv/emit.mlp +@@ -759,4 +759,5 @@ let end_assembly() = + ` .long ({emit_label lbl} - .) + {emit_int32 ofs}\n`); + efa_def_label = (fun l -> `{emit_label l}:\n`); + efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) +- } ++ }; ++ emit_nonexecstack_note () +diff --git a/asmcomp/s390x/emit.mlp b/asmcomp/s390x/emit.mlp +index 9959ff1531..787d590d6d 100644 +--- a/asmcomp/s390x/emit.mlp ++++ b/asmcomp/s390x/emit.mlp +@@ -865,5 +865,4 @@ let end_assembly() = + efa_def_label = (fun l -> `{emit_label l}:\n`); + efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) + }; +- (* Mark stack as non-executable *) +- ` .section .note.GNU-stack,\"\",%progbits\n` ++ emit_nonexecstack_note () +diff --git a/runtime/amd64.S b/runtime/amd64.S +index 32364d7042..3f96122476 100644 +--- a/runtime/amd64.S ++++ b/runtime/amd64.S +@@ -1347,7 +1347,4 @@ G(caml_negf_mask): + G(caml_absf_mask): + .quad 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF + +-#if defined(SYS_linux) || defined(SYS_freebsd) +- /* Mark stack as non-executable, PR#4564 */ +- .section .note.GNU-stack,"",%progbits +-#endif ++ NONEXECSTACK_NOTE +diff --git a/runtime/arm64.S b/runtime/arm64.S +index 2153558d30..2a4e50241a 100644 +--- a/runtime/arm64.S ++++ b/runtime/arm64.S +@@ -1234,7 +1234,4 @@ OBJECT(caml_system.frametable) + .align 3 + END_OBJECT(caml_system.frametable) + +-#if !defined(SYS_macosx) +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits +-#endif ++ NONEXECSTACK_NOTE +diff --git a/runtime/caml/asm.h b/runtime/caml/asm.h +index b3c9b2b230..a889694446 100644 +--- a/runtime/caml/asm.h ++++ b/runtime/caml/asm.h +@@ -45,6 +45,14 @@ + #define CFI_STARTPROC + #endif + ++/* Non-executable stack note */ ++ ++#ifdef WITH_NONEXECSTACK_NOTE ++#define NONEXECSTACK_NOTE .section .note.GNU-stack,"",%progbits ++#else ++#define NONEXECSTACK_NOTE ++#endif ++ + /******************************************************************************/ + /* DWARF */ + /******************************************************************************/ +diff --git a/runtime/power.S b/runtime/power.S +index e3e4bbe4af..5cb0de0493 100644 +--- a/runtime/power.S ++++ b/runtime/power.S +@@ -1212,5 +1212,4 @@ TOCENTRY(caml_array_bound_error_asm) + TOCENTRYLABEL(fiber_exn_handler) + TOCENTRYLABEL(trap_handler) + +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits ++ NONEXECSTACK_NOTE +diff --git a/runtime/riscv.S b/runtime/riscv.S +index 03bb93e020..ac3131dc51 100644 +--- a/runtime/riscv.S ++++ b/runtime/riscv.S +@@ -1257,5 +1257,4 @@ OBJECT(caml_system.frametable) + .align 3 + END_OBJECT(caml_system.frametable) + +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits ++ NONEXECSTACK_NOTE +diff --git a/runtime/s390x.S b/runtime/s390x.S +index 917c0592dc..70a44575fb 100644 +--- a/runtime/s390x.S ++++ b/runtime/s390x.S +@@ -1212,5 +1212,4 @@ caml_system.frametable: + .short 0 /* no roots here */ + .align 8 + +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits ++ NONEXECSTACK_NOTE +diff --git a/testsuite/tools/asmgen_arm.S b/testsuite/tools/asmgen_arm.S +index da6d9ee74f..49d734c513 100644 +--- a/testsuite/tools/asmgen_arm.S ++++ b/testsuite/tools/asmgen_arm.S +@@ -13,6 +13,9 @@ + /* */ + /**************************************************************************/ + ++#include "caml/m.h" ++#include "caml/asm.h" ++ + .text + + .global call_gen_code +@@ -38,5 +41,4 @@ caml_c_call: + @ function to call is in r10 + bx r10 + +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits ++ NONEXECSTACK_NOTE +diff --git a/testsuite/tools/asmgen_arm64.S b/testsuite/tools/asmgen_arm64.S +index 6a06f8d7e2..d43144cf59 100644 +--- a/testsuite/tools/asmgen_arm64.S ++++ b/testsuite/tools/asmgen_arm64.S +@@ -13,6 +13,9 @@ + /* */ + /**************************************************************************/ + ++#include "caml/m.h" ++#include "caml/asm.h" ++ + #if defined(SYS_macosx) + #define G(sym) _##sym + #else +@@ -60,7 +63,4 @@ G(call_gen_code): + G(caml_c_call): + br x15 + +-#if !defined(SYS_macosx) +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits +-#endif ++ NONEXECSTACK_NOTE +diff --git a/testsuite/tools/asmgen_power.S b/testsuite/tools/asmgen_power.S +index b332348417..754afefa6b 100644 +--- a/testsuite/tools/asmgen_power.S ++++ b/testsuite/tools/asmgen_power.S +@@ -10,6 +10,9 @@ + /* */ + /*********************************************************************/ + ++#include "caml/m.h" ++#include "caml/asm.h" ++ + #define RESERVED_STACK 32 + #define LR_SAVE_AREA 16 + +@@ -131,5 +134,4 @@ FUNCTION(caml_c_call) + mr 12, 28 + bctr + +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits ++ NONEXECSTACK_NOTE +diff --git a/testsuite/tools/asmgen_s390x.S b/testsuite/tools/asmgen_s390x.S +index 99eeca2704..14c014c76e 100644 +--- a/testsuite/tools/asmgen_s390x.S ++++ b/testsuite/tools/asmgen_s390x.S +@@ -1,3 +1,6 @@ ++#include "caml/m.h" ++#include "caml/asm.h" ++ + #define ALIGN 8 + + #define CALL_GEN_CODE call_gen_code +@@ -63,5 +66,4 @@ CAML_ABSF_MASK: + + .comm young_limit, 8 + +-/* Mark stack as non-executable */ +- .section .note.GNU-stack,"",%progbits ++ NONEXECSTACK_NOTE +-- +2.47.2 + diff --git a/patches/5.3.0/0016-Detect-support-for-.size-and-.type-assembler-directi.patch b/patches/5.3.0/0016-Detect-support-for-.size-and-.type-assembler-directi.patch new file mode 100644 index 00000000..80cf1d64 --- /dev/null +++ b/patches/5.3.0/0016-Detect-support-for-.size-and-.type-assembler-directi.patch @@ -0,0 +1,143 @@ +From d3827762c1226cb09b0b9947b8e148dd2e5f3cf4 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 31 Jan 2025 18:25:06 +0100 +Subject: [PATCH 16/21] Detect support for `.size` and `.type` assembler + directives + +Detect during `configure` whether the C compiler generates `.size` and +`.type` assembler directives +Set the result to true if and only if both directives are generated for +functions and the `.type` directive is generated for objects (directives +equivalent to `.size` could be used for a simple `int`); display a +warning if some of the three combinations appear but not all three +Define a macro in `m.h` and a configure variable so that OCaml can do as +cc does +--- + aclocal.m4 | 48 ++++++++++++++++++++++++++++++++++++++++++++ + configure | Bin 706768 -> 709722 bytes + configure.ac | 2 ++ + runtime/caml/m.h.in | 5 +++++ + 4 files changed, 55 insertions(+) + +diff --git a/aclocal.m4 b/aclocal.m4 +index 9c6feb1034..daf2f0ce5e 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -550,6 +550,54 @@ AC_DEFUN([OCAML_WITH_NONEXECSTACK_NOTE], + [with_nonexecstack_note=false]) + ]) + ++AC_DEFUN([OCAML_ASM_SIZE_TYPE_DIRECTIVES], ++ [AC_REQUIRE([AC_PROG_GREP])dnl ++ AC_CACHE_CHECK([if $CC generates .size and .type asm directives], ++ [ocaml_cv_prog_cc_asm_size_type_directives], ++ [OCAML_CC_SAVE_VARIABLES ++ ++ # We write the assembly into the .$ac_objext file as AC_COMPILE_IFELSE ++ # assumes an error if such a file doesn't exist after compiling ++ CFLAGS="$CFLAGS -S -o conftest.$ac_objext" ++ ++ ocaml_cv_prog_cc_asm_size_type_directives=no ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ ++int feat_detect_obj; ++int feat_detect_func(void) { ++ return 42; ++} ++ ]])], ++ [asm_type_obj_directive=no ++ asm_type_func_directive=no ++ asm_size_func_directive=no ++ # We do not look for a .size directive for the object as it is not ++ # generated in that simple case for instance by the compiler ++ # powerpc64le-linux-gnu-gcc 14.2 which emits instead an .lcomm directive ++ AS_IF([$GREP '\.type.*feat_detect_obj' conftest.$ac_objext >/dev/null], ++ [asm_type_obj_directive=yes]) ++ AS_IF([$GREP '\.type.*feat_detect_func' conftest.$ac_objext >/dev/null], ++ [asm_type_func_directive=yes]) ++ AS_IF([$GREP '\.size.*feat_detect_func' conftest.$ac_objext >/dev/null], ++ [asm_size_func_directive=yes]) ++ AS_CASE([m4_join([,],[$asm_type_obj_directive],[$asm_type_func_directive], ++ [$asm_size_func_directive])], ++ [yes,yes,yes], ++ [ocaml_cv_prog_cc_asm_size_type_directives=yes], ++ [no,no,no], ++ [ocaml_cv_prog_cc_asm_size_type_directives=no], ++ [ocaml_cv_prog_cc_asm_size_type_directives=unconclusive])]) ++ OCAML_CC_RESTORE_VARIABLES]) ++ ++ AS_CASE([$ocaml_cv_prog_cc_asm_size_type_directives], ++ [yes], ++ [asm_size_type_directives=true ++ AC_DEFINE([ASM_SIZE_TYPE_DIRECTIVES], [1])], ++ [no], ++ [asm_size_type_directives=false], ++ [AC_MSG_WARN([found inconsistent results for .size and .type directives]) ++ asm_size_type_directives=false]) ++]) ++ + AC_DEFUN([OCAML_CC_SUPPORTS_LABELS_AS_VALUES], [ + AC_CACHE_CHECK([whether $CC supports the labels as values extension], + [ocaml_cv_prog_cc_labels_as_values], +diff --git a/configure b/configure +index 1735c1178d1f8c7c322f108c4f0207e6ff2576a1..d7921b85866b3adb0de8a9469b5a3d0966c1516b 100755 +GIT binary patch +delta 1614 +zcmbW1&rcIU6vtC^3*C!p1Oesn0w|OpO(YFOn;MNaSPupZ(P#|YWp~;RZf7>TTM&ix +zU+#`tziTiUb&Hhp`TnfICZzVFTZSRDQIdUWGw +z^0ZB#5XD(BiK0`BXbxQ>&-Rj~y`*nAB!a8H+w1eIKD0Kp6KE$(^Q+PyD&BvVZuNy- +zZ%~;IVHW|aor4NSZ2k84iK}0v;33C^zgL7_wFi69TWJ!GEw*0xBBi&Pz@Sh3+Lk_? +zYjrTjxG2&<;u>WRq>1V%I&m;3g)b~d<;KNyo@v8Noa!NXDg#)=$y*E}6H$3h7TfQn +zZjrjw)>puwJb92&lL&7@7x(AJ;_bV*RtLPSS{)dGdjxb2j5}a({s_|C0u{>I>V-;G +zyk#d#00Y6C@M542P}}v}k7WQdgb_=1hz^v2lT{tCY0fkVXsS&-0%f+NGL68(3Ld}> +zo-?UItSZ9f%fvFZ$%sM54a!pa$Kx56AJ1qST#SS#U^z>*ERY;^FaU%RRmTp1uz{pn +z^~pYureSb88J~fnhhB?>M;hufB#HrFmw3J-bxv2ctk-&l*m9a43FvBkfOxY?Y!JUC +z(ydf|j19;_wfX*q^yD6_-d>l_SZ%!?QQm0MD{e6dhEV_vyD)|y*FtdFlZ0z(&QP=^ +z#k6=v(KMwRVEwDMW9S6YXqm+LnD;+6Wfoh%N*Ot}dkhQ2nP%i|95l$0iLGj4dohqK +zb$*l1`_43v{^gw?JtFm83fAOr$gUr*T$qf)nv9~9)jzT@2j#6K)I1Dg3(f*VowJDt +zab@oQOkBB +Date: Fri, 31 Jan 2025 18:33:42 +0100 +Subject: [PATCH 17/21] Add a `Config` variable for the `.size` and `.type` + assembler directives + +Add a `Config.asm_size_type_directives` variable to indicate whether the +`.size` and `.type` assembler directives can be used in assembler code +--- + utils/config.common.ml.in | 1 + + utils/config.fixed.ml | 1 + + utils/config.generated.ml.in | 1 + + utils/config.mli | 5 +++++ + 4 files changed, 8 insertions(+) + +diff --git a/utils/config.common.ml.in b/utils/config.common.ml.in +index 03a03c9225..8b62216b7d 100644 +--- a/utils/config.common.ml.in ++++ b/utils/config.common.ml.in +@@ -99,6 +99,7 @@ let configuration_variables () = + p "system" system; + p "asm" asm; + p_bool "asm_cfi_supported" asm_cfi_supported; ++ p_bool "asm_size_type_directives" asm_size_type_directives; + p_bool "with_frame_pointers" with_frame_pointers; + p_bool "with_nonexecstack_note" with_nonexecstack_note; + p "ext_exe" ext_exe; +diff --git a/utils/config.fixed.ml b/utils/config.fixed.ml +index ab9b533d46..10c7fcd349 100644 +--- a/utils/config.fixed.ml ++++ b/utils/config.fixed.ml +@@ -60,6 +60,7 @@ let model = "default" + let system = "unknown" + let asm = boot_cannot_call "the assembler" + let asm_cfi_supported = false ++let asm_size_type_directives = false + let with_frame_pointers = false + let reserved_header_bits = 0 + let ext_exe = ".ex_The boot compiler should not be using Config.ext_exe" +diff --git a/utils/config.generated.ml.in b/utils/config.generated.ml.in +index 009e402f93..10bd9f9576 100644 +--- a/utils/config.generated.ml.in ++++ b/utils/config.generated.ml.in +@@ -74,6 +74,7 @@ let system = {@QS@|@system@|@QS@} + + let asm = {@QS@|@AS@|@QS@} + let asm_cfi_supported = @asm_cfi_supported@ ++let asm_size_type_directives = @asm_size_type_directives@ + let with_frame_pointers = @frame_pointers@ + let reserved_header_bits = @reserved_header_bits@ + +diff --git a/utils/config.mli b/utils/config.mli +index c08bee00bf..a3a7268f11 100644 +--- a/utils/config.mli ++++ b/utils/config.mli +@@ -176,6 +176,11 @@ val asm: string + val asm_cfi_supported: bool + (** Whether assembler understands CFI directives *) + ++val asm_size_type_directives: bool ++(** Whether the [.size] and [.type] assembler directives can be used ++ ++ @since 5.4 *) ++ + val with_frame_pointers : bool + (** Whether assembler should maintain frame pointers *) + +-- +2.47.2 + diff --git a/patches/5.3.0/0018-Output-the-.size-and-.type-directives-based-on-confi.patch b/patches/5.3.0/0018-Output-the-.size-and-.type-directives-based-on-confi.patch new file mode 100644 index 00000000..02996341 --- /dev/null +++ b/patches/5.3.0/0018-Output-the-.size-and-.type-directives-based-on-confi.patch @@ -0,0 +1,481 @@ +From 0eac47067f78c99373d6df727fcf3c115d2da141 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 31 Jan 2025 19:13:28 +0100 +Subject: [PATCH 18/21] Output the `.size` and `.type` directives based on + `configure` result + +Uniformly rely on the detection during `configure` of whether the +`.size` and `.type` directives are generated by the C compiler to decide +whether to output them +Define two macros in `asm.h` and two functions in `Emitaux` to output +those directives to factorize them; to do so, `Emitaux.emit_symbol` +knows the special macOS case + +Before that patch, the `.size` and `.type` directives were: +- on x86_64: + - generated by `emit.mlp` only on Linux and GNU OSes; `.size` was + generated for frametables only for a definite list of OSes, `.type` + was never generated for frametables + - present in `amd64.S` only on Linux and GNU OSes; the `.type` + directives was present for functions on all but macOS, Cygwin, + MinGW, MSVC +- on ARM: + - generated by `emit.mlp` except on macOS + - present in `arm64.S` except on macOS +- on RISC-V: + - always generated by `emit.mlp`; `.size` was not generated for + frametables + - always present in `riscv.S` +- on POWER: + - always generated by `emit.mlp`; `.size` was not generated for + frametables + - always present in `power.S` +- on S/390: + - always generated by `emit.mlp` for `.type`, never generated for + `.size` + - always present in `s390x.S` for `.type`, never present for `.size` +--- + asmcomp/amd64/emit.mlp | 7 +++---- + asmcomp/arm64/emit.mlp | 32 ++++++++++---------------------- + asmcomp/emitaux.ml | 21 +++++++++++++++++++++ + asmcomp/emitaux.mli | 10 ++++++++++ + asmcomp/power/emit.mlp | 7 ++++--- + asmcomp/riscv/emit.mlp | 7 ++++--- + asmcomp/s390x/emit.mlp | 6 ++++-- + runtime/amd64.S | 8 ++------ + runtime/arm64.S | 8 ++++---- + runtime/caml/asm.h | 12 ++++++++++++ + runtime/power.S | 4 ++-- + runtime/riscv.S | 8 ++++---- + runtime/s390x.S | 5 +++-- + 13 files changed, 83 insertions(+), 52 deletions(-) + +diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp +index d35ac2d710..25e2a16b1c 100644 +--- a/asmcomp/amd64/emit.mlp ++++ b/asmcomp/amd64/emit.mlp +@@ -941,14 +941,12 @@ let fundecl fundecl = + end; + end; + cfi_endproc (); +- begin match system with +- | S_gnu | S_linux -> ++ if Config.asm_size_type_directives then begin + D.type_ (emit_symbol fundecl.fun_name) "@function"; + D.size (emit_symbol fundecl.fun_name) + (ConstSub ( + ConstThis, + ConstLabel (emit_symbol fundecl.fun_name))) +- | _ -> () + end + + (* Emission of data *) +@@ -1078,8 +1076,9 @@ let end_assembly() = + efa_string = (fun s -> D.bytes (s ^ "\000")) + }; + +- if system = S_linux || system = S_freebsd || system = S_netbsd || system = S_openbsd then begin ++ if Config.asm_size_type_directives then begin + let frametable = emit_symbol (Compilenv.make_symbol (Some "frametable")) in ++ D.type_ frametable "@object"; + D.size frametable (ConstSub (ConstThis, ConstLabel frametable)) + end; + +diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp +index ba36dbdd84..d653fbdada 100644 +--- a/asmcomp/arm64/emit.mlp ++++ b/asmcomp/arm64/emit.mlp +@@ -45,23 +45,11 @@ let label_prefix = + let emit_label lbl = + emit_string label_prefix; emit_int lbl + +-(* Symbols *) +- +-let emit_symbol s = +- if macosx then emit_string "_"; +- Emitaux.emit_symbol s +- + (* Object types *) + +-let emit_symbol_type emit_lbl_or_sym lbl_or_sym ty = +- if not macosx then begin +- ` .type {emit_lbl_or_sym lbl_or_sym}, %{emit_string ty}\n` +- end +- +- +-let emit_symbol_size sym = +- if not macosx then begin +- ` .size {emit_symbol sym}, .-{emit_symbol sym}\n` ++let emit_label_type lbl ty = ++ if Config.asm_size_type_directives then begin ++ ` .type {emit_label lbl}, {emit_string ty}\n` + end + + (* Output a pseudo-register *) +@@ -1068,7 +1056,7 @@ let fundecl fundecl = + emit_named_text_section fundecl.fun_name; + ` .align 3\n`; + ` .globl {emit_symbol fundecl.fun_name}\n`; +- emit_symbol_type emit_symbol fundecl.fun_name "function"; ++ emit_type_directive fundecl.fun_name "%function"; + (* Dynamic stack checking *) + let stack_threshold_size = Config.stack_threshold * 8 in (* bytes *) + let max_frame_size = frame_size env + fundecl.fun_extra_stack_used in +@@ -1119,8 +1107,8 @@ let fundecl fundecl = + assert (List.length env.bound_error_sites = num_check_bound); + + cfi_endproc(); +- emit_symbol_type emit_symbol fundecl.fun_name "function"; +- emit_symbol_size fundecl.fun_name; ++ emit_type_directive fundecl.fun_name "%function"; ++ emit_size_directive fundecl.fun_name; + emit_literals env + + (* Emission of data *) +@@ -1193,10 +1181,10 @@ let end_assembly () = + `{emit_symbol lbl}:\n`; + emit_frames + { efa_code_label = (fun lbl -> +- emit_symbol_type emit_label lbl "function"; ++ emit_label_type lbl "%function"; + ` .quad {emit_label lbl}\n`); + efa_data_label = (fun lbl -> +- emit_symbol_type emit_label lbl "object"; ++ emit_label_type lbl "%object"; + ` .quad {emit_label lbl}\n`); + efa_8 = (fun n -> ` .byte {emit_int n}\n`); + efa_16 = (fun n -> ` .short {emit_int n}\n`); +@@ -1207,6 +1195,6 @@ let end_assembly () = + ` .long {emit_label lbl} - . + {emit_int32 ofs}\n`); + efa_def_label = (fun lbl -> `{emit_label lbl}:\n`); + efa_string = (fun s -> emit_string_directive " .asciz " s) }; +- emit_symbol_type emit_symbol lbl "object"; +- emit_symbol_size lbl; ++ emit_type_directive lbl "%object"; ++ emit_size_directive lbl; + emit_nonexecstack_note () +diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml +index c115eacbbe..98274742e8 100644 +--- a/asmcomp/emitaux.ml ++++ b/asmcomp/emitaux.ml +@@ -35,7 +35,10 @@ let emit_printf fmt = + + let emit_int32 n = emit_printf "0x%lx" n + ++let macosx = Config.system = "macosx" ++ + let emit_symbol s = ++ if macosx then output_char !output_channel '_'; + for i = 0 to String.length s - 1 do + let c = s.[i] in + match c with +@@ -111,6 +114,24 @@ let emit_float64_split_directive directive x = + let emit_float32_directive directive x = + emit_printf "\t%s\t0x%lx\n" directive x + ++let emit_size_directive symbol = ++ if Config.asm_size_type_directives then begin ++ emit_string "\t.size\t"; ++ emit_symbol symbol; ++ emit_string ", . - "; ++ emit_symbol symbol; ++ emit_char '\n' ++ end ++ ++let emit_type_directive symbol ty = ++ if Config.asm_size_type_directives then begin ++ emit_string "\t.type\t"; ++ emit_symbol symbol; ++ emit_string ", "; ++ emit_string ty; ++ emit_char '\n' ++ end ++ + let emit_nonexecstack_note () = + if Config.with_nonexecstack_note then begin + emit_string "\t.section .note.GNU-stack,\"\",%progbits\n" +diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli +index a474c9f902..37f1b18fd4 100644 +--- a/asmcomp/emitaux.mli ++++ b/asmcomp/emitaux.mli +@@ -30,6 +30,16 @@ val emit_float64_directive: string -> int64 -> unit + val emit_float64_split_directive: string -> int64 -> unit + val emit_float32_directive: string -> int32 -> unit + ++val emit_size_directive: string -> unit ++(** [emit_size_directive symbol] ++ Emit a [.size] assembler directive for the given [symbol] when it is ++ supported by the assembler *) ++ ++val emit_type_directive: string -> string -> unit ++(** [emit_type_directive symbol typ] ++ Emit a [.type] assembler directive that [symbol] has type [typ] when it is ++ supported by the assembler *) ++ + val emit_nonexecstack_note : unit -> unit + (** Emit a [.note.GNU-stack] section when it is supported by the linker *) + +diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp +index 7d586e5032..f91c87d121 100644 +--- a/asmcomp/power/emit.mlp ++++ b/asmcomp/power/emit.mlp +@@ -1018,7 +1018,7 @@ let fundecl fundecl = + end; + (* Function entry point *) + ` .globl {emit_symbol fundecl.fun_name}\n`; +- ` .type {emit_symbol fundecl.fun_name}, @function\n`; ++ emit_type_directive fundecl.fun_name "@function"; + `{emit_symbol fundecl.fun_name}:\n`; + `0: addis 2, 12, (.TOC. - 0b)@ha\n`; + ` addi 2, 2, (.TOC. - 0b)@l\n`; +@@ -1054,7 +1054,7 @@ let fundecl fundecl = + (* Emit the glue code to handle bound errors *) + emit_call_bound_errors env; + cfi_endproc(); +- ` .size {emit_symbol fundecl.fun_name}, . - {emit_symbol fundecl.fun_name}\n`; ++ emit_size_directive fundecl.fun_name; + (* Emit the numeric literals *) + if env.float_literals <> [] then begin + emit_string rodata_space; +@@ -1082,7 +1082,7 @@ let fundecl fundecl = + + let declare_global_data s = + ` .globl {emit_symbol s}\n`; +- ` .type {emit_symbol s}, @object\n` ++ emit_type_directive s "@object" + + let emit_item = function + Cglobal_symbol s -> +@@ -1166,6 +1166,7 @@ let end_assembly() = + efa_def_label = (fun l -> `{emit_label l}:\n`); + efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) + }; ++ emit_size_directive lbl; + (* Emit the TOC entries *) + emit_string toc_space; + emit_toctable(); +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +index b27833d180..b612a61218 100644 +--- a/asmcomp/riscv/emit.mlp ++++ b/asmcomp/riscv/emit.mlp +@@ -619,7 +619,7 @@ let rec emit_all env = function + let fundecl fundecl = + let env = mk_env fundecl in + ` .globl {emit_symbol fundecl.fun_name}\n`; +- ` .type {emit_symbol fundecl.fun_name}, @function\n`; ++ emit_type_directive fundecl.fun_name "@function"; + emit_named_text_section fundecl.fun_name; + ` .align 2\n`; + `{emit_symbol fundecl.fun_name}:\n`; +@@ -666,7 +666,7 @@ let fundecl fundecl = + end; + + cfi_endproc(); +- ` .size {emit_symbol fundecl.fun_name}, .-{emit_symbol fundecl.fun_name}\n`; ++ emit_size_directive fundecl.fun_name; + (* Emit the float literals *) + if env.float_literals <> [] then begin + ` {emit_string rodata_space}\n`; +@@ -682,7 +682,7 @@ let fundecl fundecl = + + let declare_global_data s = + ` .globl {emit_symbol s}\n`; +- ` .type {emit_symbol s}, @object\n` ++ emit_type_directive s "@object" + + let emit_item = function + | Cglobal_symbol s -> +@@ -760,4 +760,5 @@ let end_assembly() = + efa_def_label = (fun l -> `{emit_label l}:\n`); + efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) + }; ++ emit_size_directive lbl; + emit_nonexecstack_note () +diff --git a/asmcomp/s390x/emit.mlp b/asmcomp/s390x/emit.mlp +index 787d590d6d..d38dd55754 100644 +--- a/asmcomp/s390x/emit.mlp ++++ b/asmcomp/s390x/emit.mlp +@@ -718,7 +718,7 @@ let fundecl fundecl = + let env = mk_env fundecl in + ` .globl {emit_symbol fundecl.fun_name}\n`; + emit_debug_info fundecl.fun_dbg; +- ` .type {emit_symbol fundecl.fun_name}, @function\n`; ++ emit_type_directive fundecl.fun_name "@function"; + emit_named_text_section fundecl.fun_name; + ` .align 8\n`; + `{emit_symbol fundecl.fun_name}:\n`; +@@ -763,6 +763,7 @@ let fundecl fundecl = + end; + + cfi_endproc (); ++ emit_size_directive fundecl.fun_name; + (* Emit the numeric literals *) + if env.float_literals <> [] || env.int_literals <> [] then begin + emit_string rodata_space; +@@ -782,7 +783,7 @@ let fundecl fundecl = + + let declare_global_data s = + ` .globl {emit_symbol s}\n`; +- ` .type {emit_symbol s}, @object\n` ++ emit_type_directive s "@object" + + let emit_item = function + Cglobal_symbol s -> +@@ -865,4 +866,5 @@ let end_assembly() = + efa_def_label = (fun l -> `{emit_label l}:\n`); + efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) + }; ++ emit_size_directive lbl; + emit_nonexecstack_note () +diff --git a/runtime/amd64.S b/runtime/amd64.S +index 3f96122476..80f8ffff3e 100644 +--- a/runtime/amd64.S ++++ b/runtime/amd64.S +@@ -69,18 +69,14 @@ + #define FUNCTION(name) \ + TEXT_SECTION(name); \ + .globl name; \ +- .type name,@function; \ ++ TYPE_DIRECTIVE(name,@function); \ + .align FUNCTION_ALIGN; \ + name: + + #endif + +-#if defined(SYS_linux) || defined(SYS_gnu) + #define ENDFUNCTION(name) \ +- .size name, . - name +-#else +-#define ENDFUNCTION(name) +-#endif ++ SIZE_DIRECTIVE(name) + + #ifdef WITH_FRAME_POINTERS + #define FRAME_POINTER_SIZE 8 +diff --git a/runtime/arm64.S b/runtime/arm64.S +index 2a4e50241a..de4f8fb57d 100644 +--- a/runtime/arm64.S ++++ b/runtime/arm64.S +@@ -138,19 +138,19 @@ G(\name): + TEXT_SECTION(name); \ + .align 2; \ + .globl G(name); \ +- .type G(name), %function; \ ++ TYPE_DIRECTIVE(G(name),%function) \ + G(name): + #define END_FUNCTION(name) \ +- .size G(name), .-G(name) ++ SIZE_DIRECTIVE(G(name)) + + #define OBJECT(name) \ + .data; \ + .align 3; \ + .globl G(name); \ +- .type G(name), %object; \ ++ TYPE_DIRECTIVE(G(name),%object) \ + G(name): + #define END_OBJECT(name) \ +- .size G(name), .-G(name) ++ SIZE_DIRECTIVE(G(name)) + #endif + + /* Function prologue and epilogue */ +diff --git a/runtime/caml/asm.h b/runtime/caml/asm.h +index a889694446..77372ea11e 100644 +--- a/runtime/caml/asm.h ++++ b/runtime/caml/asm.h +@@ -45,6 +45,18 @@ + #define CFI_STARTPROC + #endif + ++/* .size and .type directives, with explicit end-of-directive semi-colons */ ++ ++#ifdef ASM_SIZE_TYPE_DIRECTIVES ++#define SIZE_DIRECTIVE(name) \ ++ .size name, . - name; ++#define TYPE_DIRECTIVE(name,ty) \ ++ .type name, ty; ++#else ++#define SIZE_DIRECTIVE(name) ++#define TYPE_DIRECTIVE(name,ty) ++#endif ++ + /* Non-executable stack note */ + + #ifdef WITH_NONEXECSTACK_NOTE +diff --git a/runtime/power.S b/runtime/power.S +index 5cb0de0493..47c711ca3a 100644 +--- a/runtime/power.S ++++ b/runtime/power.S +@@ -89,7 +89,7 @@ caml_hot.code_end: + .macro FUNCTION name + TEXT_SECTION \name + .globl \name +- .type \name, @function ++ TYPE_DIRECTIVE(\name,@function) + \name: + 0: addis 2, 12, .TOC.- 0b@ha + addi 2, 2, .TOC.- 0b@l +@@ -97,7 +97,7 @@ caml_hot.code_end: + .endm + + .macro ENDFUNCTION name +- .size \name, . - \name ++ SIZE_DIRECTIVE(\name) + .endm + + /* Function prologue and epilogue */ +diff --git a/runtime/riscv.S b/runtime/riscv.S +index ac3131dc51..4a300578e3 100644 +--- a/runtime/riscv.S ++++ b/runtime/riscv.S +@@ -80,13 +80,13 @@ caml_hot.code_end: + TEXT_SECTION(name); \ + .align 2; \ + .globl name; \ +- .type name, @function; \ ++ TYPE_DIRECTIVE(name,@function) \ + name:; \ + CFI_STARTPROC + + #define END_FUNCTION(name) \ + CFI_ENDPROC; \ +- .size name, .-name ++ SIZE_DIRECTIVE(name) + + #if defined(__PIC__) + .option pic +@@ -100,10 +100,10 @@ name:; \ + .data; \ + .align 3; \ + .globl name; \ +- .type name, @object; \ ++ TYPE_DIRECTIVE(name,@object) \ + name: + #define END_OBJECT(name) \ +- .size name, .-name ++ SIZE_DIRECTIVE(name) + + /* Function prologue and epilogue */ + +diff --git a/runtime/s390x.S b/runtime/s390x.S +index 70a44575fb..740d2a5496 100644 +--- a/runtime/s390x.S ++++ b/runtime/s390x.S +@@ -60,10 +60,11 @@ caml_hot.code_end: + #define FUNCTION(name) \ + TEXT_SECTION(name); \ + .globl name; \ +- .type name,@function; \ ++ TYPE_DIRECTIVE(name,@function) \ + name: + +-#define ENDFUNCTION(name) ++#define ENDFUNCTION(name) \ ++ SIZE_DIRECTIVE(name) + + /* Stack space to be reserved by the caller of a C function */ + #define RESERVED_STACK 160 +-- +2.47.2 + diff --git a/patches/5.3.0/0019-Accept-native-freestanding-targets-at-configure-time.patch b/patches/5.3.0/0019-Accept-native-freestanding-targets-at-configure-time.patch new file mode 100644 index 00000000..8e99a3dc --- /dev/null +++ b/patches/5.3.0/0019-Accept-native-freestanding-targets-at-configure-time.patch @@ -0,0 +1,68 @@ +From ec3c09ba2a8e70d51413ffae650fcc101fdf96be Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 26 Feb 2024 19:35:26 +0100 +Subject: [PATCH 19/21] Accept native freestanding targets at configure time + +Accept `*-none` and `*-elf*` triplets for all the architectures with a +native backend to describe the corresponding freestanding target; `none` +and `elf*` are the most commonly-used last components in triplets for +freestanding targets +Set `system` to `none` and `os_type` to `None` in such cases +--- + configure | Bin 709722 -> 710423 bytes + configure.ac | 18 ++++++++++++++++-- + 2 files changed, 16 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index d7921b85866b3adb0de8a9469b5a3d0966c1516b..e4efe90505bfeba237bce9057e33f6924fd4ed28 100755 +GIT binary patch +delta 444 +zcmcb$LVNl;?S>Y{7N!>F7M2#)7Pc+yr`a`hv~;y}^YZgjYqY@3)SNUeO$9411t7>T +zE~zX?wN>&1N>3N;WtZ80hn;=<>gng#uydIv7A0qxnZPtB7Ud#w;Bp|-YG86e&h&p9 +z*-eZ=)+tz9D=2FKttrSaPc14)HZ#ddg*ydJ45X27BfHvk&lT*l`q*`2>II1)>l8Aw +zRw%A4E=kR`MKPi%vpBg7;dlfWuDNhCyR15jo?>H5g9^Bna2{L--%55#R2>x-X7LD1 +i;5?`f6IPJ%T+Y{7N!>F7M2#)7Pc+yr`f01++-Kn&d0&NWA${!A`ao{4OiK?+H<$D +Q12G2>b8gSw# +Date: Mon, 26 Feb 2024 11:51:11 +0100 +Subject: [PATCH 20/21] Allow `ocaml` in a triplet target to build freestanding + cross compilers + +Allow `ocaml` to be used as the last component of the target triplet in +case we are using a custom toolchain for a freestanding target. The +target triplet is then temporarily rewritten to "-none" to compute +the canonical target. + +This allows to use a `*-*-ocaml-` prefixes (ie `x86_64-solo5-ocaml-`) to +create cross-compiler toolchains dedicated to specific freestanding +targets +--- + configure | Bin 710423 -> 710909 bytes + configure.ac | 13 +++++++++++++ + 2 files changed, 13 insertions(+) + +diff --git a/configure b/configure +index e4efe90505bfeba237bce9057e33f6924fd4ed28..c11e7ad19c318385e30455286cbc53d285786ef7 100755 +GIT binary patch +delta 532 +zcmZ8du}(rU6wOl*eIu*O^+AGy&%wpSh>45F(a27&_m-gr7_vmafoklN(gN?t-On;G*x8f{f +YY%#VO1xAsv!zeL!8GDQ3EH2;t0=9m!@c;k- + +delta 64 +zcmeynQG5D2?S?IkA>GsWv@@D-_wQw_W@&#jkr9ZQfS4JGL3~yqW&>h&Am#vK&h2j| +IatXQv0N^JcY5)KL + +diff --git a/configure.ac b/configure.ac +index 04d31b4962..6d0d1be9c0 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -299,7 +299,20 @@ AC_CONFIG_COMMANDS_PRE(OCAML_QUOTED_STRING_ID) + + AC_CANONICAL_BUILD + AC_CANONICAL_HOST ++# Allow "ocaml" to be used as the last component of the target triplet in case ++# we are using a custom toolchain for a freestanding target. To do so, the ++# target triplet is temporarily rewritten to "-none" to compute the ++# canonical target ++save_target_alias="$target_alias" ++AS_CASE([$target_alias], ++ [*-*-ocaml], ++ [ac_save_IFS=$IFS ++ IFS='-' ++ set x $target_alias ++ target_alias="$2-none" ++ IFS=$ac_save_IFS]) + AC_CANONICAL_TARGET ++target_alias="$save_target_alias" + + # Override cross_compiling and ac_tool_prefix variables since the C toolchain is + # used to generate target code when building a cross compiler +-- +2.47.2 + diff --git a/patches/5.3.0/0021-Set-Max_domains_-def-max-to-1.patch b/patches/5.3.0/0021-Set-Max_domains_-def-max-to-1.patch new file mode 100644 index 00000000..47051faa --- /dev/null +++ b/patches/5.3.0/0021-Set-Max_domains_-def-max-to-1.patch @@ -0,0 +1,44 @@ +From d5e79fe4ecb1782cc53d3f3639e7a7511f58d522 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 12 Apr 2024 19:21:52 +0200 +Subject: [PATCH 21/21] Set `Max_domains_{def,max}` to 1 + +Solo5 is single-core with no scheduler, so avoid the useless memory +waste + +Note that since PR#13272 the maximum number of domains can set using a +parameter in `OCAMLRUNPARAM` so a patchless implementation could be to +add to `nolibc`: +- a `secure_getenv` returning `"d=1"` for the `OCAMLRUNPARAM` value, +- a `sscanf`; it could be hard-coded version just for that use case + (namely recover the `1`) +but this would still be rather brittle +--- + runtime/caml/domain.h | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/runtime/caml/domain.h b/runtime/caml/domain.h +index 7d3337e4c7..9964f035f1 100644 +--- a/runtime/caml/domain.h ++++ b/runtime/caml/domain.h +@@ -24,15 +24,11 @@ + #include "mlvalues.h" + #include "domain_state.h" + +-#ifdef ARCH_SIXTYFOUR +-#define Max_domains_def 128 +-#else +-#define Max_domains_def 16 +-#endif ++#define Max_domains_def 1 + + /* Upper limit for the number of domains. Chosen to be arbitrarily large. Used + * for sanity checking [max_domains] value in OCAMLRUNPARAM. */ +-#define Max_domains_max 4096 ++#define Max_domains_max 1 + + /* is the minor heap full or an external interrupt has been triggered */ + Caml_inline int caml_check_gc_interrupt(caml_domain_state * dom_st) +-- +2.47.2 + From 961083fec6acb94fdb516542266968314b1453af Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 10:45:08 +0100 Subject: [PATCH 05/15] =?UTF-8?q?Use=20OCaml=E2=80=99s=20`crossopt`=20and?= =?UTF-8?q?=20`installcross`=20rules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since PR 13526, the OCaml compiler comes with specific rules to build and install a cross compiler so rely on them rather than `ocaml-solo5`-specific workarounds Use opam’s ability to install both what is registered in a .install file and run the `install` commands to combine OCaml’s install rule with a `.install` file for other files (`nolibc` and `openlibm` libraries, `ocamlfind` files and the toolchain) --- Makefile | 25 +++++------ gen_dot_install.sh | 16 +------ gen_ocaml_install.sh | 82 ---------------------------------- ocaml-solo5-cross-aarch64.opam | 3 ++ ocaml-solo5.opam | 3 ++ 5 files changed, 18 insertions(+), 111 deletions(-) delete mode 100755 gen_ocaml_install.sh diff --git a/Makefile b/Makefile index 38064ff4..8170d8af 100644 --- a/Makefile +++ b/Makefile @@ -121,18 +121,10 @@ ocaml/Makefile.config: $(LIBS) $(TOOLCHAIN_FOR_BUILD) | ocaml OCAML_IS_BUILT := _build/ocaml_is_built $(OCAML_IS_BUILT): ocaml/Makefile.config | _build - PATH="$$PWD/$(TOOLDIR_FOR_BUILD):$$PATH" $(MAKE) -C ocaml cross.opt - cd ocaml && ocamlrun tools/stripdebug ocamlc ocamlc.tmp - cd ocaml && ocamlrun tools/stripdebug ocamlopt ocamlopt.tmp + PATH="$$PWD/$(TOOLDIR_FOR_BUILD):$$PATH" \ + $(MAKE) -C ocaml crossopt OLDS="-o yacc/ocamlyacc -o lex/ocamllex" touch $@ -DOT_INSTALL_PREFIX_FOR_OCAML := _build/ocaml.install -DOT_INSTALL_CHUNKS_FOR_OCAML := $(addprefix $(DOT_INSTALL_PREFIX_FOR_OCAML),\ - .lib .libexec) -$(DOT_INSTALL_CHUNKS_FOR_OCAML): | ocaml/Makefile.config - MAKE="$(MAKE)" ./gen_ocaml_install.sh \ - $(DOT_INSTALL_PREFIX_FOR_OCAML) ocaml $(MAKECONF_SYSROOT) - # CONFIGURATION FILES _build/solo5.conf: gen_solo5_conf.sh $(OCAML_IS_BUILT) PREFIX="$(MAKECONF_PREFIX)" SYSROOT="$(MAKECONF_SYSROOT)" ./gen_solo5_conf.sh > $@ @@ -144,14 +136,19 @@ _build/empty-META: | _build PACKAGES := $(basename $(wildcard *.opam)) INSTALL_FILES := $(foreach pkg,$(PACKAGES),$(pkg).install) -$(INSTALL_FILES): $(TOOLCHAIN_FINAL) $(DOT_INSTALL_CHUNKS_FOR_OCAML) - ./gen_dot_install.sh $(DOT_INSTALL_PREFIX_FOR_OCAML) $(TOOLCHAIN_FINAL)\ - > $@ +$(INSTALL_FILES): $(TOOLCHAIN_FINAL) + ./gen_dot_install.sh $(TOOLCHAIN_FINAL) > $@ # COMMANDS +.PHONY: install-ocaml +install-ocaml: + ln -sf "$$(command -v ocamllex)" ocaml/lex/ocamllex + ln -sf "$$(command -v ocamlyacc)" ocaml/yacc/ocamlyacc + $(MAKE) -C ocaml installcross + PACKAGE := ocaml-solo5 .PHONY: install -install: $(PACKAGE).install +install: $(PACKAGE).install install-ocaml opam-installer --prefix=$(MAKECONF_PREFIX) $< .PHONY: clean diff --git a/gen_dot_install.sh b/gen_dot_install.sh index ea228e29..50346e2d 100755 --- a/gen_dot_install.sh +++ b/gen_dot_install.sh @@ -1,14 +1,5 @@ #!/bin/sh -if [ ! -e "$1.lib" ] || [ ! -e "$1.libexec" ]; then - echo "Usage: $0 " - echo "The *.install.lib and *.install.libexec for OCaml must be available." - exit 1 -fi - -prefix_for_ocaml_chunks="$1" -shift - install_file() { # install_file [dest] if [ -z "$2" ]; then @@ -42,12 +33,7 @@ main() { install_file _build/solo5.conf findlib.conf.d/solo5.conf printf ']\n' - printf '%s: [\n' libexec - cat "$prefix_for_ocaml_chunks".libexec - printf ']\n' - printf '%s: [\n' lib - cat "$prefix_for_ocaml_chunks".lib walk_tree nolibc/include include install_file nolibc/libnolibc.a lib/libnolibc.a walk_tree openlibm/include include @@ -60,5 +46,5 @@ main() { printf ']\n' } -# The only arguments left are the toolchain tools +# The only arguments are the toolchain tools main "$@" diff --git a/gen_ocaml_install.sh b/gen_ocaml_install.sh deleted file mode 100755 index dd12d624..00000000 --- a/gen_ocaml_install.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env bash - -main() { - PREFIXINSTALLFILE="$1" - OCAMLDIR="$2" - PREFIX="$3" - - if [ ! -d "$OCAMLDIR" ] || [ -z "$PREFIX" ]; then - echo "Usage: $0 " - exit 1 - fi - - OCAMLDIR="$(realpath "$OCAMLDIR")" - INSTALLDIR="$(mktemp -d "$OCAMLDIR/tmp.XXXXXX")" - ME="$(realpath "$0")" - ln -s "$ME" "$INSTALLDIR/fake_install" - ln -s "$ME" "$INSTALLDIR/rm" - ln -s "$ME" "$INSTALLDIR/ln" - ln -s "$ME" "$INSTALLDIR/fake_ocamlrun" - - export PATH="$INSTALLDIR:$PATH" - export GEN_OCAML_INSTALL_BASEDIR="$OCAMLDIR" - export GEN_OCAML_INSTALL_INSTALLDIR="$INSTALLDIR" - export GEN_OCAML_INSTALL_PREFIX="$PREFIX" - ${MAKE:-make} -C "$OCAMLDIR" \ - DESTDIR="$INSTALLDIR" \ - INSTALL_PROG="fake_install libexec" \ - INSTALL_DATA="fake_install lib" \ - OCAMLRUN=fake_ocamlrun \ - install - - mv "$INSTALLDIR/install.lib" "$PREFIXINSTALLFILE.lib" - mv "$INSTALLDIR/install.libexec" "$PREFIXINSTALLFILE.libexec" -} - -install() { - # This argument massaging is bash-only, I think making it more portable would - # be more verbose - destdir="${!#}" # the last argument - section="$1" - set -- "${@:2:$(($# - 2))}" # all but the first and last arguments - todrop="$GEN_OCAML_INSTALL_INSTALLDIR$GEN_OCAML_INSTALL_PREFIX/" - destsubdir="${destdir:${#todrop}}" - todrop="$GEN_OCAML_INSTALL_BASEDIR/" - srcsubdir="${PWD:${#todrop}}" - # if not empty, had a trailing `/` - srcsubdir="${srcsubdir:+$srcsubdir/}" - if [ ! -d "$destdir" ]; then - # we are installing one binary under a different name - if [ ! "$#" = 1 ]; then - echo Unexpected install command line! - exit 1 - fi - f="${1#./}" - printf ' "?ocaml/%s%s" { "%s" }\n' "$srcsubdir" "$f" "$destsubdir" >> \ - "$GEN_OCAML_INSTALL_INSTALLDIR/install.$section" - else - for f in "$@"; do - printf ' "?ocaml/%s%s" { "%s" }\n' "$srcsubdir" "${f#./}" \ - "$destsubdir/$(basename "$f")" >> \ - "$GEN_OCAML_INSTALL_INSTALLDIR/install.$section" - done - fi -} - -case "$0" in - *fake_install) - install "$@" - ;; - *rm) - echo "Dummy rm $*" - ;; - *ln) - echo "Dummy ln $*" - ;; - *fake_ocamlrun) - echo "Dummy ocamlrun $*" - ;; - *) - main "$@" - ;; -esac diff --git a/ocaml-solo5-cross-aarch64.opam b/ocaml-solo5-cross-aarch64.opam index bcbe637d..a164da15 100644 --- a/ocaml-solo5-cross-aarch64.opam +++ b/ocaml-solo5-cross-aarch64.opam @@ -17,6 +17,9 @@ build: [ [make "-j%{jobs}%"] [make "%{name}%.install"] ] +install: [ + [make "install-ocaml"] +] depopts: [ "ocaml-option-no-flat-float-array" "ocaml-option-flambda" diff --git a/ocaml-solo5.opam b/ocaml-solo5.opam index c2fa60d1..bd2aa181 100644 --- a/ocaml-solo5.opam +++ b/ocaml-solo5.opam @@ -17,6 +17,9 @@ build: [ [make "-j%{jobs}%"] [make "%{name}%.install"] ] +install: [ + [make "install-ocaml"] +] depopts: [ "ocaml-option-no-flat-float-array" "ocaml-option-flambda" From 00b5fc487ea14c12c18e39cf9cf66fb9264e6ba6 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 11:05:26 +0100 Subject: [PATCH 06/15] Add stubs for `qsort` and `longjmp` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those functions are necessary only to compile the bytecode part of the OCaml compiler so they won’t be called --- nolibc/stubs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nolibc/stubs.c b/nolibc/stubs.c index bf189e32..54942217 100644 --- a/nolibc/stubs.c +++ b/nolibc/stubs.c @@ -65,6 +65,7 @@ STUB_WARN_ONCE(int, fclose, 1); STUB_WARN_ONCE(char *, getenv, NULL); STUB_WARN_ONCE(char *, secure_getenv, NULL); STUB_ABORT(system); +STUB_ABORT(qsort); /* unistd.h */ STUB_WARN_ONCE(int, chdir, -1); @@ -150,3 +151,5 @@ STUB_ABORT(pthread_detach); STUB_IGNORE(int, sigfillset, 0); STUB_ABORT(sigwait); STUB_ABORT(usleep); + +STUB_ABORT(longjmp); From d911f738ce171314a86db52fc5d4f32c653852b1 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 11:06:35 +0100 Subject: [PATCH 07/15] =?UTF-8?q?Add=20OCaml=E2=80=99s=20directory=20to=20?= =?UTF-8?q?the=20toolchain-configuration=20`path`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow the `ocamlfind` configuration for the standard OCaml compiler by adding the compiler’s directory at the beginning of the configuration `path` variable, so that OCaml-provided `META` files can be found by `ocamlfind` This makes it possible to find the OCaml-provided libraries, such as `compiler-libs` --- gen_solo5_conf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen_solo5_conf.sh b/gen_solo5_conf.sh index b5d214ee..82c8d6f4 100755 --- a/gen_solo5_conf.sh +++ b/gen_solo5_conf.sh @@ -43,7 +43,7 @@ checkopt() { # mirage tool takes care of this detail, using opam monorepo. cat << EOF -path(solo5) = "$SYSROOT/lib/:$PREFIX/lib" +path(solo5) = "$SYSROOT/lib/ocaml:$SYSROOT/lib:$PREFIX/lib" destdir(solo5) = "$PREFIX/lib" stdlib(solo5) = "$SYSROOT/lib/ocaml" ocamlopt(solo5) = "$SYSROOT/bin/ocamlopt$(checkopt ocamlopt)" From 02b71e7e39ffd96132588b7f9cb2a38c5767f4b9 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 11:04:33 +0100 Subject: [PATCH 08/15] opam: Update dependency to OCaml 5.3.0 --- ocaml-solo5-cross-aarch64.opam | 2 +- ocaml-solo5.opam | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ocaml-solo5-cross-aarch64.opam b/ocaml-solo5-cross-aarch64.opam index a164da15..bbf86cc6 100644 --- a/ocaml-solo5-cross-aarch64.opam +++ b/ocaml-solo5-cross-aarch64.opam @@ -32,7 +32,7 @@ depends: [ "conf-pkg-config" {build} # to detect how to link with zstd "ocamlfind" {build} # needed by dune context (for tests) "ocaml-src" {build} - "ocaml" {= "5.2.1"} + "ocaml" {= "5.3.0"} "solo5" {>= "0.9.0"} "solo5-cross-aarch64" {>= "0.9.0" } ] diff --git a/ocaml-solo5.opam b/ocaml-solo5.opam index bd2aa181..92625fb8 100644 --- a/ocaml-solo5.opam +++ b/ocaml-solo5.opam @@ -32,7 +32,7 @@ depends: [ "conf-pkg-config" {build} # to detect how to link with zstd "ocamlfind" {build} # needed by dune context (for tests) "ocaml-src" {build} - "ocaml" {= "5.2.1"} + "ocaml" {= "5.3.0"} "solo5" {>= "0.9.0"} ] conflicts: [ From d4178e872c2088dd9b591ecabe722a5deda27b0f Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 11:04:54 +0100 Subject: [PATCH 09/15] CI: Update OCaml version to 5.3.0 --- .cirrus.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 344f6cff..777de43a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -6,7 +6,7 @@ freebsd_task: OPAMYES: 1 env: matrix: - - OCAML_VERSION: 5.2.1 + - OCAML_VERSION: 5.3.0 pkg_install_script: pkg install -y ocaml-opam gmp gmake pkgconf bash opam_ocaml_cache: folder: $HOME/.opam diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93aa7c8f..92933851 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ jobs: test: strategy: matrix: - ocaml-compiler: [5.2.1] + ocaml-compiler: [5.3.0] name: OCaml ${{ matrix.ocaml-compiler }} runs-on: ubuntu-latest steps: From 2812bb6e72e932f9d37796c218cdf0f9feed6f05 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Tue, 25 Feb 2025 17:42:48 +0100 Subject: [PATCH 10/15] CI: Show the configuration of the Solo5 toolchain --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 92933851..72e8ada3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,12 @@ jobs: !ocaml-solo5-cross-aarch64.opam - name: Install ocaml-solo5 and dune run: opam install ocaml-solo5 conf-libseccomp dune + - name: Show the toolchain configuration + run: | + set -x + opam exec -- ocamlfind -toolchain solo5 opt -config + opam exec -- ocamlfind -toolchain solo5 printconf + opam exec -- ocamlfind -toolchain solo5 list - name: Compile examples with hvt run: MODE=hvt opam exec -- dune build --root example - name: Compile examples with spt From db23516cb4b1e59bab1843478ebee4d62324a337 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 13:47:32 +0100 Subject: [PATCH 11/15] README: Update the supported OCaml version to 5.3.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ea5fa73..2efb127b 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ application manifest and a startup file to initialize the libc. ## Supported compiler versions -Tested against OCaml 5.2.1. Other versions would require specific patches (see +Tested against OCaml 5.3.0. Other versions would require specific patches (see the `patches` directory). ## Porting to a different (uni)kernel base layer From f0a9c7a565f7b38719197c4babcd1f029a329893 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 23 Jan 2025 10:13:39 +0100 Subject: [PATCH 12/15] Remove patches for 5.2.1 --- ...sues-with-preprocessor-directives-13.patch | 49 --- ...and-use-CC-.-_FOR_BUILD-to-build-sak.patch | 311 ------------------ ...ad-of-host-to-detect-the-C-toolchain.patch | 112 ------- ...ad-of-host-when-relevant-in-configur.patch | 83 ----- ...he-strip-command-detected-by-libtool.patch | 42 --- ...-Strip-tmpheader.exe-also-on-Windows.patch | 32 -- ...-target-OS-to-configure-freestanding.patch | 65 ---- .../5.2.1/0008-Define-OS-type-to-None.patch | 38 --- ...-targets-to-supported-configurations.patch | 40 --- ...onfigured-and-the-installed-OCaml-ar.patch | 46 --- ...the-target-pkg-config-to-detect-zstd.patch | 44 --- ...le.cross-for-recipes-to-build-a-cros.patch | 122 ------- patches/5.2.1/0013-Set-Max_domains-to-1.patch | 35 -- ...n-executable-on-freestanding-targets.patch | 53 --- 14 files changed, 1072 deletions(-) delete mode 100644 patches/5.2.1/0001-Fix-two-small-issues-with-preprocessor-directives-13.patch delete mode 100644 patches/5.2.1/0002-Detect-and-use-CC-.-_FOR_BUILD-to-build-sak.patch delete mode 100644 patches/5.2.1/0003-Use-target-instead-of-host-to-detect-the-C-toolchain.patch delete mode 100644 patches/5.2.1/0004-Use-target-instead-of-host-when-relevant-in-configur.patch delete mode 100644 patches/5.2.1/0005-Use-the-strip-command-detected-by-libtool.patch delete mode 100644 patches/5.2.1/0006-Strip-tmpheader.exe-also-on-Windows.patch delete mode 100644 patches/5.2.1/0007-Allow-ocaml-as-a-target-OS-to-configure-freestanding.patch delete mode 100644 patches/5.2.1/0008-Define-OS-type-to-None.patch delete mode 100644 patches/5.2.1/0009-Add-freestanding-targets-to-supported-configurations.patch delete mode 100644 patches/5.2.1/0010-Check-that-the-configured-and-the-installed-OCaml-ar.patch delete mode 100644 patches/5.2.1/0011-Use-the-target-pkg-config-to-detect-zstd.patch delete mode 100644 patches/5.2.1/0012-WIP-Add-a-Makefile.cross-for-recipes-to-build-a-cros.patch delete mode 100644 patches/5.2.1/0013-Set-Max_domains-to-1.patch delete mode 100644 patches/5.2.1/0014-Set-stack-as-non-executable-on-freestanding-targets.patch diff --git a/patches/5.2.1/0001-Fix-two-small-issues-with-preprocessor-directives-13.patch b/patches/5.2.1/0001-Fix-two-small-issues-with-preprocessor-directives-13.patch deleted file mode 100644 index 6895757f..00000000 --- a/patches/5.2.1/0001-Fix-two-small-issues-with-preprocessor-directives-13.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 189d0adbdcbc480fe3c9c79abf4b3f1df584e0c1 Mon Sep 17 00:00:00 2001 -From: shym -Date: Thu, 4 Jul 2024 18:01:17 +0200 -Subject: [PATCH 01/14] Fix two small issues with preprocessor directives - (#13281) - -* Add missing `defined` in preprocessor test - -When `HAS_CLOCK_GETTIME_NSEC_NP` is not defined, -`#elif HAS_CLOCK_GETTIME_NSEC_NP` triggers a warning - -* Include `caml/config.h` before `HAS_GETTIMEOFDAY` is tested - -Also remove a duplicate `errno.h` ---- - runtime/unix.c | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/runtime/unix.c b/runtime/unix.c -index b5fd4de17b..c0677e09ac 100644 ---- a/runtime/unix.c -+++ b/runtime/unix.c -@@ -27,13 +27,12 @@ - #include - #include - #include -+#include "caml/config.h" - #ifdef HAS_GETTIMEOFDAY - #include - #endif - #include - #include --#include --#include "caml/config.h" - #if defined(SUPPORT_DYNAMIC_LINKING) && !defined(BUILDING_LIBCAMLRUNS) - #define WITH_DYNAMIC_LINKING - #ifdef __CYGWIN__ -@@ -47,7 +46,7 @@ - #endif - #ifdef HAS_POSIX_MONOTONIC_CLOCK - #include --#elif HAS_CLOCK_GETTIME_NSEC_NP -+#elif defined(HAS_CLOCK_GETTIME_NSEC_NP) - #include - #endif - #ifdef HAS_DIRENT --- -2.45.2 - diff --git a/patches/5.2.1/0002-Detect-and-use-CC-.-_FOR_BUILD-to-build-sak.patch b/patches/5.2.1/0002-Detect-and-use-CC-.-_FOR_BUILD-to-build-sak.patch deleted file mode 100644 index 91ede646..00000000 --- a/patches/5.2.1/0002-Detect-and-use-CC-.-_FOR_BUILD-to-build-sak.patch +++ /dev/null @@ -1,311 +0,0 @@ -From acd2f9c4ae0ee5dd550796b547e781794eb9b58c Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Wed, 21 Feb 2024 18:47:12 +0100 -Subject: [PATCH 02/14] Detect and use {CC,...}_FOR_BUILD to build sak - ---- - Makefile | 9 +- - Makefile.config.in | 4 + - aclocal.m4 | 1 + - build-aux/ax_prog_cc_for_build.m4 | 155 ++++++++++++++++++++++++++++++ - configure | Bin 647326 -> 682393 bytes - configure.ac | 10 +- - 6 files changed, 172 insertions(+), 7 deletions(-) - create mode 100644 build-aux/ax_prog_cc_for_build.m4 - -diff --git a/Makefile b/Makefile -index 71d41cd2d6..df191af79c 100644 ---- a/Makefile -+++ b/Makefile -@@ -1284,11 +1284,10 @@ runtime/caml/jumptbl.h : runtime/caml/instruct.h - sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \ - -e '/^}/q' > $@ - --# These are provided as a temporary shim to allow cross-compilation systems --# to supply a host C compiler and different flags and a linking macro. --SAK_CC ?= $(CC) --SAK_CFLAGS ?= $(OC_CFLAGS) $(CFLAGS) $(OC_CPPFLAGS) $(CPPFLAGS) --SAK_LINK ?= $(MKEXE_VIA_CC) -+SAK_CC ?= $(CC_FOR_BUILD) -+SAK_CFLAGS ?=\ -+ $(OC_CFLAGS) $(CFLAGS_FOR_BUILD) $(OC_CPPFLAGS) $(CPPFLAGS_FOR_BUILD) -+SAK_LINK ?= $(SAK_CC) $(SAK_CFLAGS) $(OC_EXE_LDFLAGS) $(OUTPUTEXE)$(1) $(2) - - $(SAK): runtime/sak.$(O) - $(V_MKEXE)$(call SAK_LINK,$@,$^) -diff --git a/Makefile.config.in b/Makefile.config.in -index 559738f6ed..4243bebad9 100644 ---- a/Makefile.config.in -+++ b/Makefile.config.in -@@ -65,11 +65,13 @@ LIBTOOL = $(TOP_BUILDDIR)/libtool - ### Which C compiler to use - TOOLPREF=@ac_tool_prefix@ - CC=@CC@ -+CC_FOR_BUILD=@CC_FOR_BUILD@ - - CC_HAS_DEBUG_PREFIX_MAP=@cc_has_debug_prefix_map@ - AS_HAS_DEBUG_PREFIX_MAP=@as_has_debug_prefix_map@ - - LDFLAGS?=@LDFLAGS@ -+LDFLAGS_FOR_BUILD=@LDFLAGS_FOR_BUILD@ - - ### How to invoke the C preprocessor through the C compiler - CPP=@CPP@ -@@ -160,7 +162,9 @@ UNIX_OR_WIN32=@unix_or_win32@ - INSTALL_SOURCE_ARTIFACTS=@install_source_artifacts@ - - CFLAGS=@CFLAGS@ -+CFLAGS_FOR_BUILD=@CFLAGS_FOR_BUILD@ - CPPFLAGS=@CPPFLAGS@ -+CPPFLAGS_FOR_BUILD=@CPPFLAGS_FOR_BUILD@ - OCAMLC_CFLAGS=@ocamlc_cflags@ - - OCAMLC_CPPFLAGS=@ocamlc_cppflags@ -diff --git a/aclocal.m4 b/aclocal.m4 -index cb73385dda..d2e58a45f6 100644 ---- a/aclocal.m4 -+++ b/aclocal.m4 -@@ -30,6 +30,7 @@ m4_include([build-aux/ax_check_compile_flag.m4]) - - # Macros from the autoconf macro archive - m4_include([build-aux/ax_func_which_gethostbyname_r.m4]) -+m4_include([build-aux/ax_prog_cc_for_build.m4]) - m4_include([build-aux/ax_pthread.m4]) - - # OCaml version -diff --git a/build-aux/ax_prog_cc_for_build.m4 b/build-aux/ax_prog_cc_for_build.m4 -new file mode 100644 -index 0000000000..1db8d73f96 ---- /dev/null -+++ b/build-aux/ax_prog_cc_for_build.m4 -@@ -0,0 +1,155 @@ -+# =========================================================================== -+# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html -+# =========================================================================== -+# -+# SYNOPSIS -+# -+# AX_PROG_CC_FOR_BUILD -+# -+# DESCRIPTION -+# -+# This macro searches for a C compiler that generates native executables, -+# that is a C compiler that surely is not a cross-compiler. This can be -+# useful if you have to generate source code at compile-time like for -+# example GCC does. -+# -+# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything -+# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD). -+# The value of these variables can be overridden by the user by specifying -+# a compiler with an environment variable (like you do for standard CC). -+# -+# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object -+# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if -+# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are -+# substituted in the Makefile. -+# -+# LICENSE -+# -+# Copyright (c) 2008 Paolo Bonzini -+# -+# Copying and distribution of this file, with or without modification, are -+# permitted in any medium without royalty provided the copyright notice -+# and this notice are preserved. This file is offered as-is, without any -+# warranty. -+ -+#serial 21 -+ -+AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) -+AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl -+AC_REQUIRE([AC_PROG_CC])dnl -+AC_REQUIRE([AC_PROG_CPP])dnl -+AC_REQUIRE([AC_CANONICAL_BUILD])dnl -+ -+dnl Use the standard macros, but make them use other variable names -+dnl -+pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl -+pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl -+pushdef([ac_cv_prog_cc_c99], ac_cv_build_prog_cc_c99)dnl -+pushdef([ac_cv_prog_cc_c11], ac_cv_build_prog_cc_c11)dnl -+pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl -+pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl -+pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl -+pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl -+pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl -+pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl -+pushdef([ac_cv_objext], ac_cv_build_objext)dnl -+pushdef([ac_exeext], ac_build_exeext)dnl -+pushdef([ac_objext], ac_build_objext)dnl -+pushdef([CC], CC_FOR_BUILD)dnl -+pushdef([CPP], CPP_FOR_BUILD)dnl -+pushdef([GCC], GCC_FOR_BUILD)dnl -+pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl -+pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl -+pushdef([EXEEXT], BUILD_EXEEXT)dnl -+pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl -+pushdef([OBJEXT], BUILD_OBJEXT)dnl -+pushdef([host], build)dnl -+pushdef([host_alias], build_alias)dnl -+pushdef([host_cpu], build_cpu)dnl -+pushdef([host_vendor], build_vendor)dnl -+pushdef([host_os], build_os)dnl -+pushdef([ac_cv_host], ac_cv_build)dnl -+pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl -+pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl -+pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl -+pushdef([ac_cv_host_os], ac_cv_build_os)dnl -+pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl -+pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl -+pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl -+pushdef([cross_compiling], cross_compiling_build)dnl -+ -+cross_compiling_build=no -+ -+ac_build_tool_prefix= -+AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"], -+ [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"]) -+ -+AC_LANG_PUSH([C]) -+ -+dnl The pushdef([ac_cv_c_compiler_gnu], ...) currently does not cover -+dnl the use of this variable in _AC_LANG_COMPILER_GNU called by -+dnl AC_PROG_CC. Unset this cache variable temporarily as a workaround. -+was_set_c_compiler_gnu=${[ac_cv_c_compiler_gnu]+y} -+AS_IF([test ${was_set_c_compiler_gnu}], -+ [saved_c_compiler_gnu=$[ac_cv_c_compiler_gnu] -+ AS_UNSET([[ac_cv_c_compiler_gnu]])]) -+ -+AC_PROG_CC -+ -+dnl Restore ac_cv_c_compiler_gnu -+AS_IF([test ${was_set_c_compiler_gnu}], -+ [[ac_cv_c_compiler_gnu]=$[saved_c_compiler_gnu]]) -+ -+_AC_COMPILER_EXEEXT -+_AC_COMPILER_OBJEXT -+AC_PROG_CPP -+ -+dnl Restore the old definitions -+dnl -+popdef([cross_compiling])dnl -+popdef([am_cv_prog_cc_c_o])dnl -+popdef([am_cv_CC_dependencies_compiler_type])dnl -+popdef([ac_tool_prefix])dnl -+popdef([ac_cv_host_os])dnl -+popdef([ac_cv_host_vendor])dnl -+popdef([ac_cv_host_cpu])dnl -+popdef([ac_cv_host_alias])dnl -+popdef([ac_cv_host])dnl -+popdef([host_os])dnl -+popdef([host_vendor])dnl -+popdef([host_cpu])dnl -+popdef([host_alias])dnl -+popdef([host])dnl -+popdef([OBJEXT])dnl -+popdef([LDFLAGS])dnl -+popdef([EXEEXT])dnl -+popdef([CPPFLAGS])dnl -+popdef([CFLAGS])dnl -+popdef([GCC])dnl -+popdef([CPP])dnl -+popdef([CC])dnl -+popdef([ac_objext])dnl -+popdef([ac_exeext])dnl -+popdef([ac_cv_objext])dnl -+popdef([ac_cv_exeext])dnl -+popdef([ac_cv_c_compiler_gnu])dnl -+popdef([ac_cv_prog_cc_g])dnl -+popdef([ac_cv_prog_cc_cross])dnl -+popdef([ac_cv_prog_cc_works])dnl -+popdef([ac_cv_prog_cc_c89])dnl -+popdef([ac_cv_prog_gcc])dnl -+popdef([ac_cv_prog_CPP])dnl -+ -+dnl restore global variables ac_ext, ac_cpp, ac_compile, -+dnl ac_link, ac_compiler_gnu (dependant on the current -+dnl language after popping): -+AC_LANG_POP([C]) -+ -+dnl Finally, set Makefile variables -+dnl -+AC_SUBST(BUILD_EXEEXT)dnl -+AC_SUBST(BUILD_OBJEXT)dnl -+AC_SUBST([CFLAGS_FOR_BUILD])dnl -+AC_SUBST([CPPFLAGS_FOR_BUILD])dnl -+AC_SUBST([LDFLAGS_FOR_BUILD])dnl -+]) -diff --git a/configure b/configure -index 49d5bff6495b2f38d91d97ec777a4212e3c23677..9f16ca87352a88b5e995631c15fd8914f6b2ebfc 100755 -GIT binary patch -delta 6754 -zcmds5eN0r@70*4x8{mn2L`L~qc=H?>6lV~20WBRBXVBG91-ET%WBL}xfn~)RWQLV3 -zK{Ph8G;Lv*T~2gUm$peawcBQClTMp#7frfd~-*CgKtYi-PWh1EjxEfo4>TJ!N+?W -z8xy+B9SWzkbMyB4-CyKYqJDS1OwiektY*LDk4RoG(`6)%4(vEKu!GPa=x?EaQgmPk -zCq?@O`mwwor=!&CUFGDJ0n>(*L8ULokf4OZqV;M_3A)QXS|_Y>;&smIz@rCKDhu}p -zA_0G-J=i8ho(TwEArcC8_@8NR4+^cJE&+dkm=p|WZnXCQcfOYH_Kv-xu%V>7wvXp| -ze^)3Rmi(dpo$Vb|w4@Asf+3!#uqlKjuOoGK1zOvCJbZhr5DA1Mf-5M94pkOUw-XdT -zM=?>R_^Euu9F5N<@_~-T=~8n?dvjPc30Xjf%Ip#`R0Vl0`hg0LM1yh48mNi|D5mT& -z3NAmLVLHC~WDMJsh&p=bXY13E4L3g**el`eq@~y@8*s0HbCZ_r -zR8OtY9i$7WB-Hjjn(%T8y!i21B52L#+u%d#9QnLPpEyTO@%l;Q_umC?8f!TC!Utf> -zWqUj#V_DI;H_4Ytj%mC%W+X^1kkMLQzDG76|8w+ih1!h%DR!vJEz`x}l@{>w4Bb3V -za#*^5oP_Z7QA>Wc&eY%&Yh{lSR4=H>6?&NMH~6q=ng}?3kxZFkz|0#Yh3%wB-ssD*=nipMRUe0kFG9Cw1hao4yR_!c2`GQcu=@lR>02cTt?kscg#)x@ -zU{(Q{=X~*nNn&Hc{Lv&4b(>s{mnX?Sjo$h$`7z7-pl$M}eL5DMPaef5m#3FT6!YjXS+>N5zVze)Ev!8CrD0uj%x_WG#nV6j;C!8ib?i(unx_xlH^~OgT=(51ubXiUofuV%kt{}1NX -z6lFtIeqK#M%(f~DB_%Yd?G-w^@J2Zq!0&B<^l0%1q~C)7oPZkq$M2HT@Z4`xQ}OQw -zbY#2$-Xf|kzdS~q_`^cDyHdY|p63JM*t@=!)dzo41O;xLvF!OiIoFWGYe~&2XjEm& -zE^xL8yxIC3nk)GOosqEM!n&%Id>pi=EV0cu+=gck5fOU@7${To10`Ja`=vHHO_LK; -z(^4MM)h1%|U*Y7)AZN`mO~RRV)@+=ygLSFCoJSOKw3OIJZgAD;{u)<1vOPH$Px+Fw -z@VE%&Su7_N&Zpwsb*^6F#HW9gY}Xt@XeHF>cn%N!t8_jJ>m2Z6x^Y{0<|AtkcJ8xs -zcIw4 -z_y$Y&mB2<5U5Ha9@R$b7of3FbYkHhexJ2JRKRkBZhoesLvGbcMVVlOkrW8DJ6m9s1 -z3$nD4@07v@cG9P=I7aW6!fRPZg#8s2IN^r3GtJ$YwV$xi53Gg)CWJO5I1N5QiwG1c -zIJO#G+HNkdh9P!0`^$`wP}%^=wX!%Qt~K*OGPDMcvGN#5B-cWaoOUe;Ns${~)3*Ay -z8z!{o%jHn2THKrE_pbJP<#Dw$*BaFxU29aE(uMfR+PEd;R>akQx?&!+sU>9Kx0?u$ -zmnxup0RWCyE(E}bl?wv!mB-@%eD-)8fD2D(0Bly%Q0iCw>(;CFA)!xpF9}Hv>k5tL -zP*@emWqTEDeB=r=o7KBxti#X(O)Pr4hZ>Ahamn{M)LM*5lKj5mk!{JHIFbSB__vvq -z>geu|$+WdtU05wL(dR~f=#)1wmSU>cvB3hG$Hl=ka79Ngu#MQ+xw5wmhUDpL=|LHb -zewqZkEx9aTtTds@^{2o(^}<9?q`)1E)~0J5)!t9cN{9N?xCG2BfFku?9ZZL6wNNOj -z+t&+=D(!KowcF@;I#hy|kVoe-VOW#>i}!BsA$VmO=hNJ#a(!ii*36A*j^L^nOS(pS -z#>QA6$y~emm{}-w19A-89*ndKc(N$Ty@Xi+<(l78rlY|Zt(oOgIrgpCbd76yPu7q0nJy5)&Kwi - -delta 62 -zcmbPvS##b&^$i_<&20YdZ2pWu%ml>DK+Lk8&7U=4`}CCy*!ib_XJZp-XX|GJVs;?r -L*v{6^Ir$a -Date: Thu, 22 Feb 2024 13:37:28 +0100 -Subject: [PATCH 03/14] Use `target` instead of `host` to detect the C - toolchain - -When building a cross-compiler, the runtime will run on the target, not -the host so: -- set `cross_compiling` by comparing `build` to `target` (rather than to - `host`), as this variable will be used later -- use `target` to set up the tool prefix, -- as the libtool configuration will configure a `build` to `host` - toolchain, temporarily assign `host*` values to `target*` values ---- - configure | Bin 682393 -> 682949 bytes - configure.ac | 18 ++++++++++++++++++ - 2 files changed, 18 insertions(+) - -diff --git a/configure b/configure -index 9f16ca87352a88b5e995631c15fd8914f6b2ebfc..f81f4ca213b710395b61b64d1380318d4d80867d 100755 -GIT binary patch -delta 1998 -zcmZ`(drVbz9N+yt?u9D~^12Qaj&QXR!UV#QN5pXGe6e(h`QUQ6_W&nu=Unc&0<{Wr -zD<>GO8vK+s2i9!ONBq(FHF{hNafq|VoH5JU!?YZcjAl&@>UX)nUodan?QEa>`F_s# -z{XIu7rw)#$?*GVC)z(thsCd1qOOc#j-7p+Z{W*{7R<&A5)?AY8bog}L?eKV&8nsz! -zl)b84?N$uQP&KC_`RWv@L<%UJb+W2Ss$or$_8E$caZ;_KDPGyfRI;~L@kvgd1!<~N -zG^u)@>UPb9kerEusLU3Ks(7txjpS1dpVXXepHY#uX0tt(X$v*os<;hBvde};(>>O= -zdymC~8kGz+TUI=jXQ4e9(jmK5*+{q6sB}-8>Ch7ioYsxGab`&J;7ijZcm~ph0aI~I -z5R;zYOxrmuo&>9j|1VP}X|$OmN!hr`N;5`Hp1Ap?(RA&&X)65x1(f-^xhyQ0)1w(= -zxdl8gomu7I0!t;ZJwKOzJrW(hzrdtQTD3?x@xW)&S1G|1oF}<2d&V -z0MXK5amo3CP0_59hg(n2Y;C8)fgU;wM8tvmlQcC0q52Vq>Rs&=oWH^-Tei -z`Kx(_XiAjJlFp9jyr&%H3jX8{)RMsY^aj)_T=pC2JFx&qUPN8uP;w5SB5^=Xub~m4 -z+4KhLS|s8Yp(#LbcB9|LJ!^jSSl{QUUPNX8RSQ>tdmiL-^Wu2knhm89Y%(qoTQV@9d>Y>^JvXM;@S`#FF%xv6}}Qi^R#~c?*uD -zJ1qDuQ4?c-;Zewy#rQ5y3tm<(;iJEM4=x*@sTt_(vb-*3Sw#J&~(LDy}@uZwgq -zmfARQznZR9_EoeIZ=!5!znGe4&ZHKV1x};-!_~d#i~n4@+jl$nbAEl! -z`JVF~ycmiPhdMsdUfdzOcWRvl`E@a~sXAur^)DGsQM1Wt4bGW_g2rMa*xFLRab2v% -z4C+mF(TzrtZWxwYK7Udx$q?Tswdvw&C6w7xo@n?(OBeV4qXlH-TW$Lchgw={pY8z3 -zM_N9^_k$hxW)@pmM$)|1Y*!jd$$GZb@9>kmx3UNBLz}7iY7Z+#o3zm0VVi9iG5#*A -z6uEI`h=%vrEa{E2t4OgdMFL2AtCxN3aYp^}5X&LMPd{SkIN5z8*#btAw~y^|k<^o9 -zfF3(}aFJp6Ma-+wv*gezc2Al!Z@1V!XQyP~UzV?l -z!W!Lsq!!#N2Rd8{i_x`uhTO9NW+}T91#rMa>X(;7HkBhRsj#~Y -zQsiJMjHtQ}Jp+L$3}2{%7*Jk$u^M`(@Zt^7H3giz1y(q~`4V4+r~}NC6FXr46fi7c -zkxztwb@{}lYDkyc_rgI{N#TBoXHX>r -ziHP^IxiXZG3FRX%6yWI;758v4M#$W?1n+1RLs(><6$O{kC$9Blnrth<{uyNRSUDD| -z3fn8NeI`YaJ`>y2?CoyG@6;VNwqZg|rhgkQQBxgx1HV?<@Y|S}_P?o$d$1)ysrve{ -zi&6X0ck$(Ip -zu1*Wu8&SO_YCRZ@lZ#@Vc&Achtpe)Lez!{FqCDmY6Nw>3mT0 -zQM8z8Y*?3T#)7(7*~w>$M;f_LxH9?Y#Ohoo|5*_@mc`wZS8zU?o9U!p9_A0LZEw%z -z5p^x{r}^CDCH0>re4Hl3CnrjIK2v0hp5UugdGRNCvD%d@PxA_LS-6}ZR>~VI_-)li -zOA1JQjvtuZk`oc$rxsOqmh+Xf$?@_le2C`FFORhIoM|f8_?x^nPZhpZ1FzgRz{}A7 -u&lW!p@=K}(wVRsnJ~JiB)J%E(6z`yWe|`NKZk-hCq*})%*Pn5(>G=<2b2Q8V - -diff --git a/configure.ac b/configure.ac -index 2e3a11f60c..0862b381ff 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -288,6 +288,14 @@ AC_CANONICAL_BUILD - AC_CANONICAL_HOST - AC_CANONICAL_TARGET - -+# Override cross_compiling and ac_tool_prefix variables since the C toolchain is -+# used to generate target code when building a cross compiler -+AS_IF([test x"$build" = x"$target"], -+ [cross_compiling=no], -+ [cross_compiling=yes]) -+AS_IF([test -n "$target_alias"], -+ [ac_tool_prefix=$target_alias-]) -+ - # Ensure that AC_CONFIG_LINKS will either create symlinks which are compatible - # with native Windows (i.e. NTFS symlinks, not WSL or Cygwin-emulated ones) or - # use its fallback mechanisms. Native Windows versions of ocamlc/ocamlopt cannot -@@ -594,12 +602,22 @@ AC_CHECK_TOOLS([LD],[ld link]) - # Also, it has been observed that, on some platforms (e.g. msvc) LT_INIT - # alters the CFLAGS variable, so we save its value before calling the macro - # and restore it after the call -+pushdef([host], target)dnl -+pushdef([host_alias], target_alias)dnl -+pushdef([host_cpu], target_cpu)dnl -+pushdef([host_vendor], target_vendor)dnl -+pushdef([host_os], target_os)dnl - old_host_os=$host_os - AS_IF([test x"$host_os" = "xwindows"],[host_os=mingw]) - saved_CFLAGS="$CFLAGS" - LT_INIT - CFLAGS="$saved_CFLAGS" - host_os=$old_host_os -+popdef([host_os])dnl -+popdef([host_vendor])dnl -+popdef([host_cpu])dnl -+popdef([host_alias])dnl -+popdef([host])dnl - - AS_CASE([$host], - [sparc-sun-solaris*], --- -2.45.2 - diff --git a/patches/5.2.1/0004-Use-target-instead-of-host-when-relevant-in-configur.patch b/patches/5.2.1/0004-Use-target-instead-of-host-when-relevant-in-configur.patch deleted file mode 100644 index 4ab437d1..00000000 --- a/patches/5.2.1/0004-Use-target-instead-of-host-when-relevant-in-configur.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 7acd97746d8c41a191d5de96b03c915a52bdc142 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Wed, 21 Feb 2024 19:05:44 +0100 -Subject: [PATCH 04/14] Use `target` instead of `host` when relevant in - configuration - ---- - configure | Bin 682949 -> 682314 bytes - configure.ac | 10 +++++----- - 2 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/configure b/configure -index f81f4ca213b710395b61b64d1380318d4d80867d..b393e6e2871a942e0171f1a52b70f75ef74f780a 100755 -GIT binary patch -delta 382 -zcmX?lUGvl>&4w+Esyn8O?`5>&ElDg&Pc4a0%*jkF)}0=(m(dngX#2w*j4@28V$(0M -zFi)HQa5v-Y=?MmGT+?stVdP~=$?_$tCeVF19K@F4I5U -zVH4S|wwG}+i@bsYNDL;+rJ#_SQ=AHlQVFkN& -zd+d3(9Zb`AtYPEdu5^hlt_dpK9K!A)Jbhvrvm8H)pK?;B8!l!t#SnCS!Z>65{|xr~ -zjHsTQ{82+<`h?qz72E5w*?AbJD}82^n9fto&NY2~4m&5t;^V@#oqI3i7MAJ%DwqU?d|Z?iY!xc3 -z6-qKv^SBg%VETPAHnr*ftC>otpS{Z3$pg{^)82mXAR`bn0WmWWvj8#c_In4}?0BaC -zv|{Jou6>Se9n1^xsX_NBR0pbmyQbR|u*QYK - -diff --git a/configure.ac b/configure.ac -index 0862b381ff..26de5bed24 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -597,7 +597,7 @@ AS_IF([test x"$enable_ocamldoc" = "xno"], - # Initialization of libtool - # Allow the MSVC linker to be found even if ld isn't installed. - # User-specified LD still takes precedence. --AC_CHECK_TOOLS([LD],[ld link]) -+AC_CHECK_TARGET_TOOLS([LD],[ld link]) - # libtool expects host_os=mingw for native Windows - # Also, it has been observed that, on some platforms (e.g. msvc) LT_INIT - # alters the CFLAGS variable, so we save its value before calling the macro -@@ -1027,7 +1027,7 @@ AS_CASE([$flexdll_source_dir,$supports_shared_libraries,$flexlink,$host], - - mkexe_cmd_exp="$CC" - --AS_CASE([$ocaml_cc_vendor,$host], -+AS_CASE([$ocaml_cc_vendor,$target], - [*,x86_64-*-darwin*], - [oc_ldflags='-Wl,-no_compact_unwind'; - AC_DEFINE([HAS_ARCH_CODE32], [1])], -@@ -1045,7 +1045,7 @@ AS_CASE([$ocaml_cc_vendor,$host], - ) - ostype="Cygwin"], - [*,*-*-mingw32*], -- [AS_CASE([$host], -+ [AS_CASE([$target], - [i686-*-*], [oc_dll_ldflags="-static-libgcc"]) - ostype="Win32" - toolchain="mingw" -@@ -1342,7 +1342,7 @@ system=unknown - # preserving $arch = 'none' <=> $system = 'unknown' - has_native_backend=no - native_ldflags="" --AS_CASE([$host], -+AS_CASE([$target], - [[i[3456]86-*-linux*]], - [arch=i386; system=linux], - [[i[3456]86-*-freebsd*]], -@@ -1479,7 +1479,7 @@ AS_IF([$natdynlink], - - AC_DEFINE_UNQUOTED([OCAML_OS_TYPE], ["$ostype"]) - --AC_CHECK_TOOL([DIRECT_LD],[ld]) -+AC_CHECK_TARGET_TOOL([DIRECT_LD],[ld]) - AS_IF([test -z "$PARTIALLD"], - [AS_CASE(["$host,$ocaml_cc_vendor"], - [x86_64-*-darwin*,gcc-*], [PACKLD_FLAGS=' -arch x86_64'], --- -2.45.2 - diff --git a/patches/5.2.1/0005-Use-the-strip-command-detected-by-libtool.patch b/patches/5.2.1/0005-Use-the-strip-command-detected-by-libtool.patch deleted file mode 100644 index a0e2cc9f..00000000 --- a/patches/5.2.1/0005-Use-the-strip-command-detected-by-libtool.patch +++ /dev/null @@ -1,42 +0,0 @@ -From a67f2491770af3937b9cf5c548855dff678d99b5 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Fri, 5 Jul 2024 12:42:36 +0200 -Subject: [PATCH 05/14] Use the `strip` command detected by libtool - -Instead of using `strip` unconditionally to build `tmpheader.exe`, use -the `strip` command detected by `libtool` during configure so that it is -replaced with `:` when the command is absent and it becomes easy to -override it if need be ---- - Makefile.config.in | 1 + - stdlib/Makefile | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/Makefile.config.in b/Makefile.config.in -index 4243bebad9..b91634efb6 100644 ---- a/Makefile.config.in -+++ b/Makefile.config.in -@@ -185,6 +185,7 @@ OCAMLOPT_CFLAGS=@ocamlc_cflags@ - OCAMLOPT_CPPFLAGS=@ocamlc_cppflags@ - NATIVECCLIBS=@cclibs@ - SYSTHREAD_SUPPORT=@systhread_support@ -+STRIP=@STRIP@ - PACKLD=@PACKLD@$(EMPTY) - CCOMPTYPE=@ccomptype@ - TOOLCHAIN=@toolchain@ -diff --git a/stdlib/Makefile b/stdlib/Makefile -index 50f825a1b3..b6286920f2 100644 ---- a/stdlib/Makefile -+++ b/stdlib/Makefile -@@ -98,7 +98,7 @@ tmpheader.exe: $(HEADERPROGRAM).$(O) - $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^) - # FIXME This is wrong - mingw could invoke strip; MSVC equivalent? - ifneq "$(UNIX_OR_WIN32)" "win32" -- strip $@ -+ $(STRIP) $@ - endif - - stdlib.cma: $(OBJS) --- -2.45.2 - diff --git a/patches/5.2.1/0006-Strip-tmpheader.exe-also-on-Windows.patch b/patches/5.2.1/0006-Strip-tmpheader.exe-also-on-Windows.patch deleted file mode 100644 index 5b6d5950..00000000 --- a/patches/5.2.1/0006-Strip-tmpheader.exe-also-on-Windows.patch +++ /dev/null @@ -1,32 +0,0 @@ -From aefbbb813cdc27252153d2cf043900681c8689d8 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Fri, 5 Jul 2024 12:58:58 +0200 -Subject: [PATCH 06/14] Strip tmpheader.exe also on Windows - -GNU strip can be called safely on binaries generated by cl as well as by -MinGW GCC (even if it doesn't produce a smaller executable for -cl-generated binaries) so invoke strip also on Windows so that MinGW -binaries are properly stripped -Tested with GNU strip 2.42 ---- - stdlib/Makefile | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/stdlib/Makefile b/stdlib/Makefile -index b6286920f2..a7f2e60a7a 100644 ---- a/stdlib/Makefile -+++ b/stdlib/Makefile -@@ -96,10 +96,7 @@ endif - .INTERMEDIATE: tmpheader.exe - tmpheader.exe: $(HEADERPROGRAM).$(O) - $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^) --# FIXME This is wrong - mingw could invoke strip; MSVC equivalent? --ifneq "$(UNIX_OR_WIN32)" "win32" - $(STRIP) $@ --endif - - stdlib.cma: $(OBJS) - $(V_LINKC)$(CAMLC) -a -o $@ $^ --- -2.45.2 - diff --git a/patches/5.2.1/0007-Allow-ocaml-as-a-target-OS-to-configure-freestanding.patch b/patches/5.2.1/0007-Allow-ocaml-as-a-target-OS-to-configure-freestanding.patch deleted file mode 100644 index 0af801e5..00000000 --- a/patches/5.2.1/0007-Allow-ocaml-as-a-target-OS-to-configure-freestanding.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 627cf134087f67001306b9480a51f6c5ea082758 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Mon, 26 Feb 2024 11:51:11 +0100 -Subject: [PATCH 07/14] Allow `ocaml` as a target OS to configure freestanding - cross-compilers - -Allow the use of *-*-ocaml or *-*-*-ocaml target triplets to stand for -freestanding cross-compilers by temporarily rewriting the target OS to -`none` when generating the canonical target - -This allows to use *-*-ocaml and *-*-*-ocaml prefixes for cross-compiler -specific toolchains, so that all the specific tools (for instance -aarch64-solo5-ocaml-gcc, etc.) are automatically discovered ---- - configure | Bin 682314 -> 682823 bytes - configure.ac | 17 +++++++++++++++++ - 2 files changed, 17 insertions(+) - -diff --git a/configure b/configure -index b393e6e2871a942e0171f1a52b70f75ef74f780a..498bc2042686e7fc202a6ecdfaa1ca6d2c780efc 100755 -GIT binary patch -delta 551 -zcmb7Au}T9$5G64hyAYqSwV3K0acut*y?#&dEm?A?al#Tc8Uibbka`3PGf -zpCDMKu(PuF8=Rb?7e!E(x6Hg5-n^N|dGPQQ4DU;Kqd^T0mC`*BI>uB9Kno5{LJrPa -z(9s4uhR8b1E@YNKtkbSkWZ=9Hj?%6+Xr$_cp`MYBJG>gWODae>4IMa;o{|61aQCv0LGEUD~e8z -zTTP$8oLnUJu%5@31`e*51@l62Dx261{k<^X;#0yeh(n|C<>7x0jx1mLPY!+`Kb@Rb -sH>dMqd4KjYD&17JzPbN#R&m=Nml$Qn3ZueUWvnr(jP+T2yz%<{2ER13{Qv*} - -delta 60 -zcmX?pP4mg9ZU -F7XS(}7}x*+ - -diff --git a/configure.ac b/configure.ac -index 26de5bed24..6f02258356 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -286,7 +286,24 @@ AC_CONFIG_COMMANDS_PRE(OCAML_QUOTED_STRING_ID) - - AC_CANONICAL_BUILD - AC_CANONICAL_HOST -+# Allow "ocaml" as target OS for freestanding compiler by temporarily rewriting -+# the target OS to "none" to generate the canonical target -+real_target_alias="$target_alias" -+AS_CASE([$target_alias], -+ [*-*-*-ocaml], -+ [ac_save_IFS=$IFS -+ IFS='-' -+ set x $target_alias -+ target_alias="$2-$3-none" -+ IFS=$ac_save_IFS], -+ [*-*-ocaml], -+ [ac_save_IFS=$IFS -+ IFS='-' -+ set x $target_alias -+ target_alias="$2-none" -+ IFS=$ac_save_IFS]) - AC_CANONICAL_TARGET -+target_alias="$real_target_alias" - - # Override cross_compiling and ac_tool_prefix variables since the C toolchain is - # used to generate target code when building a cross compiler --- -2.45.2 - diff --git a/patches/5.2.1/0008-Define-OS-type-to-None.patch b/patches/5.2.1/0008-Define-OS-type-to-None.patch deleted file mode 100644 index 089f6897..00000000 --- a/patches/5.2.1/0008-Define-OS-type-to-None.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 8056ab2f13faa7a484dc1d985208a6066cebfc89 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Mon, 26 Feb 2024 12:06:45 +0100 -Subject: [PATCH 08/14] Define OS type to None - ---- - configure | Bin 682823 -> 682873 bytes - configure.ac | 4 +++- - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/configure b/configure -index 498bc2042686e7fc202a6ecdfaa1ca6d2c780efc..0eebc7063ceea9c5c392b02e68dce28144556545 100755 -GIT binary patch -delta 89 -zcmX?pP4nk9&4w1n7N!>F7M2#)Eo{-()pfLVwRH3H^HOWHz|7Q~G))C7E(IXSFD|Jp -lNVQe+1IkWsRN)k!zQC8At3CHR8xXStF~|1Y>zubH0{~+sAF2QV - -delta 44 -ycmex)P4oCQ&4w1n7N!>F7M2#)Eo{-(r@y(&F3>*rIvWtP12M<;xz{=GOa=hQ!xZiS - -diff --git a/configure.ac b/configure.ac -index 6f02258356..5523a1013c 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1090,7 +1090,9 @@ AS_CASE([$ocaml_cc_vendor,$target], - [oc_ldflags='-brtl -bexpfull' - AC_DEFINE([HAS_ARCH_CODE32], [1])], - [gcc-*,powerpc-*-linux*], -- [oc_ldflags="-mbss-plt"]) -+ [oc_ldflags="-mbss-plt"], -+ [*,*-*-none|*,*-*-elf], -+ [ostype="None"]) - - ## Program to use to install files - AC_PROG_INSTALL --- -2.45.2 - diff --git a/patches/5.2.1/0009-Add-freestanding-targets-to-supported-configurations.patch b/patches/5.2.1/0009-Add-freestanding-targets-to-supported-configurations.patch deleted file mode 100644 index 8c24fcb1..00000000 --- a/patches/5.2.1/0009-Add-freestanding-targets-to-supported-configurations.patch +++ /dev/null @@ -1,40 +0,0 @@ -From cbcf96dca5420b9a2665b0064c5ba2b37b7ecaa6 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Mon, 26 Feb 2024 19:35:26 +0100 -Subject: [PATCH 09/14] Add freestanding targets to supported configurations - ---- - configure | Bin 682873 -> 683028 bytes - configure.ac | 6 +++++- - 2 files changed, 5 insertions(+), 1 deletion(-) - -diff --git a/configure b/configure -index 0eebc7063ceea9c5c392b02e68dce28144556545..d95fd568597e59d6f9e92aacadc9f50840dcee16 100755 -GIT binary patch -delta 99 -zcmex)O>@c(&4w1n7N!>F7M2#)7Pc+yfyvYRBiK2opN(bbWXa3VOPzi;f!$ad#8R-f -sR#4X9Qcy@tEK1HWGtt%31uNK_$ZiZ)+8&t94#XTl%(*=F7M2#)7Pc+yfyvW13UCOw|4(KIVh$kY-2OkAOOyiuw<;1a - -diff --git a/configure.ac b/configure.ac -index 5523a1013c..3b2de0b053 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1458,7 +1458,11 @@ AS_CASE([$target], - [x86_64-*-cygwin*], - [has_native_backend=yes; arch=amd64; system=cygwin], - [riscv64-*-linux*], -- [has_native_backend=yes; arch=riscv; model=riscv64; system=linux] -+ [has_native_backend=yes; arch=riscv; model=riscv64; system=linux], -+ [x86_64-*-none], -+ [has_native_backend=yes; arch=amd64; system=none], -+ [aarch64-*-none], -+ [has_native_backend=yes; arch=arm64; system=none] - ) - - AS_CASE([$arch], --- -2.45.2 - diff --git a/patches/5.2.1/0010-Check-that-the-configured-and-the-installed-OCaml-ar.patch b/patches/5.2.1/0010-Check-that-the-configured-and-the-installed-OCaml-ar.patch deleted file mode 100644 index 87b0c450..00000000 --- a/patches/5.2.1/0010-Check-that-the-configured-and-the-installed-OCaml-ar.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 156caacd6b9b4d3d83adf02ffd0c68f11a0ff5a7 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Tue, 19 Mar 2024 19:14:29 +0100 -Subject: [PATCH 10/14] Check that the configured and the installed OCaml are - compatible - ---- - configure | Bin 683028 -> 683595 bytes - configure.ac | 7 +++++++ - 2 files changed, 7 insertions(+) - -diff --git a/configure b/configure -index d95fd568597e59d6f9e92aacadc9f50840dcee16..58c25a0c685bf6860c63c9c394d191f9281bd1b3 100755 -GIT binary patch -delta 436 -zcmbPoL-X_<&4w1n7N!>F7M2#)Eo{FyO_deGQx%F*3rjPLQWX*v^78X^lZ*0;i*=Lp -za|<$aQi~Mw(-cZFQWc65b5j+{Qj3Z+^Yf-}+{1384HAV4z!YWX6_+ID9)8%)`*8P*$vF7M2#)Eo{Fyr$_j)>$S)8umLeU5OV-A=k|CWt~ZGQuvrin - -diff --git a/configure.ac b/configure.ac -index 3b2de0b053..c5b2a3f217 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -825,6 +825,13 @@ AS_IF( - CPPFLAGS_FOR_BUILD='$(CPPFLAGS)' - LDFLAGS_FOR_BUILD='$(LDFLAGS)'], - [cross_compiler=true -+ # We require a non-cross-compiler of the same version -+ AC_MSG_CHECKING([the version of the installed OCaml compiler]) -+ already_installed_version=`ocamlc -vnum` -+ AS_IF([test x"AC_PACKAGE_VERSION" = x"$already_installed_version"], -+ [AC_MSG_RESULT([compatible (AC_PACKAGE_VERSION)])], -+ [AC_MSG_ERROR(m4_normalize([incompatible (AC_PACKAGE_VERSION vs -+ $already_installed_version)]))]) - AC_MSG_NOTICE([detecting the C toolchain for build]) - AX_PROG_CC_FOR_BUILD]) - --- -2.45.2 - diff --git a/patches/5.2.1/0011-Use-the-target-pkg-config-to-detect-zstd.patch b/patches/5.2.1/0011-Use-the-target-pkg-config-to-detect-zstd.patch deleted file mode 100644 index f4d0a0e5..00000000 --- a/patches/5.2.1/0011-Use-the-target-pkg-config-to-detect-zstd.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 40f00c44630bae376edf63dc5f76150b3a8065af Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Wed, 20 Mar 2024 17:41:26 +0100 -Subject: [PATCH 11/14] Use the target pkg-config to detect zstd - -Make sure that we don't detect zstd on build when we are building a -cross-compiler, as the native zstd has no reason to be compatible with -the cross toolchain ---- - configure | Bin 683595 -> 683354 bytes - configure.ac | 2 +- - 2 files changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure b/configure -index 58c25a0c685bf6860c63c9c394d191f9281bd1b3..e364c57560a234055311de9b09ff0f399fd0f44a 100755 -GIT binary patch -delta 151 -zcmV;I0BHZq+$q}HDS(6lgaU*Egam{Iga(8MvRQ2tN&UVRC0>bYEd? -zX<>6Mx88CHV+59$0ST8ba0d&QSa%2*m(sogDwlJ22ppG`a0ef^tak{b1DEr^2oaZv -zcnA~)A|NIvAeVu72pb4JB4%N1b7dm8OnV4E0hi=`2q6SzY;$FouzUy_hXsBJw*`I) -FM({SFH0=NY - -delta 171 -zcmcb0OY`&{&4w1n7N!>F7M2#)7Pc1lEgUvQ)4#lA3T7_IPM_Ylo5Ongft!qiVBUq@ -z9J8lOlyUHFk1yuf&OAL}1(W!6t#S^D>6zsm^3z4WFv@OUUe2+YdHSzX4({zst2qo9 -zr~BKp@ktbv#0Pl0$2g?s_5lEp)jm4_ - -diff --git a/configure.ac b/configure.ac -index c5b2a3f217..14d0356368 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -2261,7 +2261,7 @@ AC_CHECK_HEADER([spawn.h], - [AC_CHECK_FUNC([posix_spawn], - [AC_CHECK_FUNC([posix_spawnp], [AC_DEFINE([HAS_POSIX_SPAWN])])])]) - --AC_PATH_TOOL([PKG_CONFIG], [pkg-config], [false]) -+AC_PATH_TARGET_TOOL([PKG_CONFIG], [pkg-config], [false]) - - ## ZSTD compression library - --- -2.45.2 - diff --git a/patches/5.2.1/0012-WIP-Add-a-Makefile.cross-for-recipes-to-build-a-cros.patch b/patches/5.2.1/0012-WIP-Add-a-Makefile.cross-for-recipes-to-build-a-cros.patch deleted file mode 100644 index 44c04581..00000000 --- a/patches/5.2.1/0012-WIP-Add-a-Makefile.cross-for-recipes-to-build-a-cros.patch +++ /dev/null @@ -1,122 +0,0 @@ -From 4ab2e100f97da1a4251137dfaf473af705f0274f Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Fri, 23 Feb 2024 16:56:07 +0100 -Subject: [PATCH 12/14] WIP Add a Makefile.cross for recipes to build a - cross-compiler - -Define cross.opt and cross-install targets - -FIXME: Problems of inconsistencies between compilation options (only -about zstd?) between the native toolchain and the cross toolchain may -break the build? ---- - Makefile | 2 ++ - Makefile.cross | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 85 insertions(+) - create mode 100644 Makefile.cross - -diff --git a/Makefile b/Makefile -index df191af79c..cb6b3f4484 100644 ---- a/Makefile -+++ b/Makefile -@@ -2732,6 +2732,8 @@ endif - - include .depend - -+include Makefile.cross -+ - Makefile.config Makefile.build_config: config.status - config.status: - @echo "Please refer to the installation instructions:" -diff --git a/Makefile.cross b/Makefile.cross -new file mode 100644 -index 0000000000..b993783d2f ---- /dev/null -+++ b/Makefile.cross -@@ -0,0 +1,83 @@ -+#************************************************************************** -+#* * -+#* OCaml * -+#* * -+#* Samuel Hym, Tarides * -+#* * -+#* Copyright 2024 Tarides * -+#* * -+#* All rights reserved. This file is distributed under the terms of * -+#* the GNU Lesser General Public License version 2.1, with the * -+#* special exception on linking described in the file LICENSE. * -+#* * -+#************************************************************************** -+ -+# Recipes to build a cross-compiler (_not_ cross-compiling the compiler), aka -+# generating code that will run on `target`, assuming that a non-cross OCaml -+# compiler (so targetting our build machine) of the same version is available in -+# $PATH -+ -+# We assume no zstd for the cross-compiler (ie no requirement on zstd for the -+# target) -+# Still the cross-compiler will run on host, not target. And as a consequence of -+# the rules linking it, the cross-compilers will be linked with the _build_ -+# version of libcomprmarsh, so we still must discover the flags to link with -+# libzstd if it was set up in the non-cross compiler, so we rely on the -+# pkg-config command to get the linking flags for zstd -+PKG_CONFIG := pkg-config -+# This is used only once, so it doesn't have to be much lazier -+NATIVE_ZSTD_LIBS=ZSTD_LIBS="$(shell $(PKG_CONFIG) --libs libzstd)" -+# As the libcomprmarsh built by the C cross compiler will not be linked in, we -+# can build an empty one -+NO_ZSTD=libcomprmarsh_OBJECTS= -+ -+CROSS_OVERRIDES=OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun \ -+ BOOT_OCAMLLEX=ocamllex OCAMLYACC=ocamlyacc -+CROSS_COMPILER_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc CAMLOPT=ocamlopt \ -+ BEST_OCAMLC=ocamlc BEST_OCAMLOPT=ocamlopt BEST_OCAMLLEX=ocamllex -+ -+INSTALL_OVERRIDES=build_ocamldoc=false WITH_DEBUGGER= -+ -+# Freestanding target custom options -+ifeq "$(SYSTEM)" "none" -+RUNTIME_BUILD_OVERRIDES=runtime_PROGRAMS= -+INSTALL_OVERRIDES += runtime_PROGRAMS=`which ocamlrun` \ -+ runtime_BYTECODE_STATIC_LIBRARIES=runtime/ld.conf -+else -+RUNTIME_BUILD_OVERRIDES= -+endif -+ -+cross.opt: -+ $(MAKE) runtime-all $(NO_ZSTD) $(RUNTIME_BUILD_OVERRIDES) -+ $(MAKE) ocamlc ocamlopt $(TOOLS_BYTECODE_TARGETS) expunge \ -+ $(CROSS_COMPILER_OVERRIDES) -+ $(MAKE) library $(CROSS_OVERRIDES) -+ifneq "$(SYSTEM)" "none" -+ $(MAKE) ocamlyacc $(CROSS_OVERRIDES) -+ $(MAKE) ocamllex $(CROSS_COMPILER_OVERRIDES) -+endif -+ $(MAKE) ocaml $(CROSS_COMPILER_OVERRIDES) -+ $(MAKE) -C otherlibs all $(CROSS_OVERRIDES) -+ # Opt -+ $(MAKE) runtimeopt $(NO_ZSTD) -+ $(MAKE) ocamlc.opt ocamlopt.opt $(TOOLS_NATIVE_TARGETS) \ -+ $(NO_ZSTD) $(CROSS_COMPILER_OVERRIDES) $(NATIVE_ZSTD_LIBS) -+ $(MAKE) libraryopt $(NO_ZSTD) $(CROSS_OVERRIDES) -+ $(MAKE) otherlibrariesopt ocamltoolsopt $(NO_ZSTD) $(CROSS_OVERRIDES) -+ $(MAKE) tools-allopt.opt $(NO_ZSTD) $(CROSS_COMPILER_OVERRIDES) -+ -+.PHONY: cross-install -+cross-install: -+ # dummy files -+ touch \ -+ $(addprefix toplevel/, \ -+ $(foreach ext,cmi cmt cmti cmx, native/nat__dummy__.$(ext)) \ -+ all__dummy__.cmx topstart.o native/tophooks.cmi) -+ $(LN) `which ocamlyacc` yacc/ocamlyacc.opt$(EXE) -+ $(LN) `which ocamllex` lex/ocamllex.opt$(EXE) -+ifeq "$(SYSTEM)" "none" -+ $(LN) `which ocamlyacc` yacc/ocamlyacc$(EXE) -+ $(LN) `which ocamllex` lex/ocamllex$(EXE) -+endif -+ # Real installation -+ $(MAKE) install $(INSTALL_OVERRIDES) OCAMLRUN=ocamlrun --- -2.45.2 - diff --git a/patches/5.2.1/0013-Set-Max_domains-to-1.patch b/patches/5.2.1/0013-Set-Max_domains-to-1.patch deleted file mode 100644 index 2eb55151..00000000 --- a/patches/5.2.1/0013-Set-Max_domains-to-1.patch +++ /dev/null @@ -1,35 +0,0 @@ -From bde7866513c8deeddd9165d05502162229abd13a Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Fri, 12 Apr 2024 19:21:52 +0200 -Subject: [PATCH 13/14] Set Max_domains to 1 - -Solo5 is single-core with no scheduler, so avoid the useless memory -waste - -Note that since PR#13272 the maximum number of domains can set using a -parameter in OCAMLRUNPARAM so `getenv` might be a better place to set -this limit in the future ---- - runtime/caml/domain.h | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/runtime/caml/domain.h b/runtime/caml/domain.h -index 4b9be80b41..986486478c 100644 ---- a/runtime/caml/domain.h -+++ b/runtime/caml/domain.h -@@ -31,11 +31,7 @@ extern "C" { - - /* The runtime currently has a hard limit on the number of domains. - This hard limit may go away in the future. */ --#ifdef ARCH_SIXTYFOUR --#define Max_domains 128 --#else --#define Max_domains 16 --#endif -+#define Max_domains 1 - - /* is the minor heap full or an external interrupt has been triggered */ - Caml_inline int caml_check_gc_interrupt(caml_domain_state * dom_st) --- -2.45.2 - diff --git a/patches/5.2.1/0014-Set-stack-as-non-executable-on-freestanding-targets.patch b/patches/5.2.1/0014-Set-stack-as-non-executable-on-freestanding-targets.patch deleted file mode 100644 index d0e29b0f..00000000 --- a/patches/5.2.1/0014-Set-stack-as-non-executable-on-freestanding-targets.patch +++ /dev/null @@ -1,53 +0,0 @@ -From d6d0345ba0d079ffc17c397ae1773e50ecc470b1 Mon Sep 17 00:00:00 2001 -From: Samuel Hym -Date: Mon, 29 Apr 2024 18:21:24 +0200 -Subject: [PATCH 14/14] Set stack as non-executable on freestanding targets - ---- - asmcomp/amd64/emit.mlp | 2 +- - asmcomp/arm64/emit.mlp | 2 +- - runtime/amd64.S | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp -index 619ce9c3c5..19f896c1ac 100644 ---- a/asmcomp/amd64/emit.mlp -+++ b/asmcomp/amd64/emit.mlp -@@ -1079,7 +1079,7 @@ let end_assembly() = - D.size frametable (ConstSub (ConstThis, ConstLabel frametable)) - end; - -- if system = S_linux then -+ if system = S_linux || system = S_unknown then - (* Mark stack as non-executable, PR#4564 *) - D.section [".note.GNU-stack"] (Some "") [ "%progbits" ]; - -diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp -index 1816f8c345..41769e4f93 100644 ---- a/asmcomp/arm64/emit.mlp -+++ b/asmcomp/arm64/emit.mlp -@@ -1217,7 +1217,7 @@ let end_assembly () = - emit_symbol_type emit_symbol lbl "object"; - emit_symbol_size lbl; - begin match Config.system with -- | "linux" -> -+ | "linux" | "none" -> - (* Mark stack as non-executable *) - ` .section .note.GNU-stack,\"\",%progbits\n` - | _ -> () -diff --git a/runtime/amd64.S b/runtime/amd64.S -index 49c712b167..be0856a72b 100644 ---- a/runtime/amd64.S -+++ b/runtime/amd64.S -@@ -1386,7 +1386,7 @@ G(caml_negf_mask): - G(caml_absf_mask): - .quad 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF - --#if defined(SYS_linux) -+#if defined(SYS_linux) || defined(SYS_none) - /* Mark stack as non-executable, PR#4564 */ - .section .note.GNU-stack,"",%progbits - #endif --- -2.45.2 - From c65dc8b8102e88314f70ea40df45f05814917045 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 6 Mar 2025 17:33:49 +0100 Subject: [PATCH 13/15] Bump the `solo5` dependency to 0.9.1 --- ocaml-solo5-cross-aarch64.opam | 4 ++-- ocaml-solo5.opam | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ocaml-solo5-cross-aarch64.opam b/ocaml-solo5-cross-aarch64.opam index bbf86cc6..e3529999 100644 --- a/ocaml-solo5-cross-aarch64.opam +++ b/ocaml-solo5-cross-aarch64.opam @@ -33,8 +33,8 @@ depends: [ "ocamlfind" {build} # needed by dune context (for tests) "ocaml-src" {build} "ocaml" {= "5.3.0"} - "solo5" {>= "0.9.0"} - "solo5-cross-aarch64" {>= "0.9.0" } + "solo5" {>= "0.9.1"} + "solo5-cross-aarch64" {>= "0.9.1" } ] conflicts: [ "ocaml-solo5" diff --git a/ocaml-solo5.opam b/ocaml-solo5.opam index 92625fb8..ae662c27 100644 --- a/ocaml-solo5.opam +++ b/ocaml-solo5.opam @@ -33,7 +33,7 @@ depends: [ "ocamlfind" {build} # needed by dune context (for tests) "ocaml-src" {build} "ocaml" {= "5.3.0"} - "solo5" {>= "0.9.0"} + "solo5" {>= "0.9.1"} ] conflicts: [ "sexplib" {= "v0.9.0"} From 15b119a5debb874c726503b83b3f1df21cef46cd Mon Sep 17 00:00:00 2001 From: Pierre Alain Date: Fri, 7 Mar 2025 07:52:51 +0100 Subject: [PATCH 14/15] update CHANGES.md, release version not set yet --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 6416c90a..7c78ecd3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## XXX + +* Support for Ocaml 5.3.0 (@shym #148) +* Update the FreeBSD version for CI (@shym #149) + ## v1.0.1 (2024-12-17) * allow findlib/dune use libraries available from OPAM (@dinosaure #144) From 6b1fc97a8ae733ba17dd7a317014358792b7da44 Mon Sep 17 00:00:00 2001 From: Pierre Alain Date: Fri, 7 Mar 2025 12:55:57 +0100 Subject: [PATCH 15/15] remove cirrus CI cache --- .cirrus.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 777de43a..c306ac97 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,15 +8,8 @@ freebsd_task: matrix: - OCAML_VERSION: 5.3.0 pkg_install_script: pkg install -y ocaml-opam gmp gmake pkgconf bash - opam_ocaml_cache: - folder: $HOME/.opam - reupload_on_changes: false # since there is a fingerprint script - fingerprint_script: - - echo $CIRRUS_OS - - echo $OCAML_VERSION - populate_script: - - opam init -a --comp=$OCAML_VERSION setup_script: + - opam init -a --comp=$OCAML_VERSION - opam update - opam install dune - opam pin add -n -t .