Skip to content

Commit

Permalink
Fix compilation of ocaml 4.14.0 for regular mingw targets, add 4.14.1… (
Browse files Browse the repository at this point in the history
  • Loading branch information
toots authored Feb 12, 2023
1 parent e653ee0 commit 78b60a8
Show file tree
Hide file tree
Showing 47 changed files with 1,858 additions and 881 deletions.
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ opam-cross-windows

This repository contains an up-to-date Windows toolchain featuring OCaml 4.07.0, 4.08.0, 4.12.0 and 4.14.0, as well as some commonly used packages.

The supported build systems are 32-bit and 64-bit x86 Linux. The supported target systems are 32-bit and 64-bit x86 Windows.
The supported build systems are 32-bit and 64-bit x86 Linux and arm64 macos. The supported target systems are 32-bit and 64-bit x86 Windows.

If you need support for other platforms or versions, please [open an issue](https://github.com/ocaml-cross/opam-cross-windows/issues).

Prerequisites
-------------

On 64-bit Linux build systems, 32-bit libraries must be installed. On Debian derivatives they are provided in the `gcc-multilib` package.

A C cross-compiler targeting the appropriate Windows platform must be installed. On Debian derivatives they are provided in the `gcc-mingw-w64-i686` (for 32-bit x86 Windows targets) or `gcc-mingw-w64-x86-64` (for 64-bit x86 Windows targets) packages. Alternatively, the [MXE environment](http://mxe.cc) can be used.

Installation
Expand All @@ -21,14 +19,9 @@ Add this repository to OPAM:

opam repository add windows https://github.com/ocaml-cross/opam-cross-windows.git

On 64-bit build systems, switch to 32-bit compiler when compiling for 32-bit targets:

opam switch 4.14.0 --package=ocaml-option-32bit
eval `opam config env`

Otherwise, use a regular compiler; its version must match the version of the cross-compiler:
The version of the regular compiler installed in your current `opam` switch must match the version of the cross-compiler:

opam switch 4.14.0
opam switch 4.14.1
eval `opam config env`

If desired, request the compiler to be built with [flambda][] optimizers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ maintainer: "[email protected]"
conflicts: [
"ocaml-windows32"
]
depends: ["ocaml"]
depends: ["ocaml" {<= "4.12.0"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bin: [
"flexlink"
]
libexec: [
"flexlink.exe"
]
lib: [
"flexdll.h"
"?flexdll_mingw.o"
"?flexdll_initer_mingw.o"
"?flexdll_mingw64.o"
"?flexdll_initer_mingw64.o"
]
5 changes: 5 additions & 0 deletions packages/flexdll-windows/flexdll-windows.0.42/files/flexlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

DIRNAME=`dirname $0`

${DIRNAME}/../lib/flexdll-windows/flexlink.exe "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/reloc.ml b/reloc.ml
index 827413f..523dc72 100644
--- a/reloc.ml
+++ b/reloc.ml
@@ -1279,7 +1279,7 @@ let setup_toolchain () =
flush stdout
end;
default_libs :=
- ["-lmingw32"; "-lgcc"; "-lgcc_eh"; "-lmoldname"; "-lmingwex"; "-lmsvcrt";
+ ["-lmingw32"; "-lgcc"; "-lmoldname"; "-lmingwex"; "-lmsvcrt";
"-luser32"; "-lkernel32"; "-ladvapi32"; "-lshell32" ];
if !exe_mode = `EXE then default_libs := "crt2.o" :: !default_libs
else default_libs := "dllcrt2.o" :: !default_libs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let version = "%{version}%"
let mingw_prefix = "%{conf-gcc-windows32:prefix}%"
let mingw64_prefix = "%{conf-gcc-windows64:prefix}%"
74 changes: 74 additions & 0 deletions packages/flexdll-windows/flexdll-windows.0.42/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
opam-version: "2.0"
maintainer: "[email protected]"
substs: [
"version.ml"
]
patches: [
"patches/no-gcc_eh.patch"
]
build: [
["touch" "Compat.ml"]
["sh" "-c" "cat Compat402.ml >> Compat.ml"] {ocaml:compiler < "4.02.0"}
["sh" "-c" "cat Compat403.ml >> Compat.ml"] {ocaml:compiler < "4.03.0"}
["sh" "-c" "cat Compat405.ml >> Compat.ml"] {ocaml:compiler < "4.05.0"}
["sh" "-c" "cat Compat406.ml >> Compat.ml"] {ocaml:compiler < "4.06.0"}
[
"%{conf-gcc-windows32:prefix}%gcc"
"-c"
"-DMINGW"
"flexdll.c"
"-o"
"flexdll_mingw.o"
] {conf-gcc-windows32:installed}
[
"%{conf-gcc-windows32:prefix}%gcc"
"-c"
"-DMINGW"
"flexdll_initer.c"
"-o"
"flexdll_initer_mingw.o"
] {conf-gcc-windows32:installed}
[
"%{conf-gcc-windows64:prefix}%gcc"
"-c"
"-DMINGW"
"flexdll.c"
"-o"
"flexdll_mingw64.o"
] {conf-gcc-windows64:installed}
[
"%{conf-gcc-windows64:prefix}%gcc"
"-c"
"-DMINGW"
"flexdll_initer.c"
"-o"
"flexdll_initer_mingw64.o"
] {conf-gcc-windows64:installed}
[
"ocamlopt"
"version.ml"
"Compat.ml"
"coff.ml"
"cmdline.ml"
"create_dll.ml"
"reloc.ml"
"-g"
"-w"
"-165"
"-o"
"flexlink.exe"
]
]
depends: ["ocaml" "conf-gcc-windows32" | "conf-gcc-windows64"]
synopsis:
"FlexDLL is a Windows dynamic linker extension allowing DLLs to depend on each other"
extra-files: [
["flexlink" "md5=e4522fc7b43c35e45278158caf45159d"]
["version.ml.in" "md5=f1bb53b9442eeda71d4963c02bf9fa84"]
["flexdll-windows.install" "md5=1b80c115bb264f51debdd24c5b25b306"]
["patches/no-gcc_eh.patch" "md5=65bdd2a32d0777a9d8b315df91632166"]
]
url {
src: "https://github.com/alainfrisch/flexdll/archive/0.42.tar.gz"
checksum: "9464ae7a7e566ba7c96336cf2f34cc73"
}
8 changes: 6 additions & 2 deletions packages/ocaml-windows/ocaml-windows.4.14.0/files/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
PREFIX="$1"
HOST="$2"

for bin in ocamlc ocamlopt ocamlcp ocamlmklib ocamlmktop ocamldoc ocamldep; do
ln -s "${PREFIX}/windows-sysroot/bin/${bin}" "${PREFIX}/bin/${HOST}-${bin}"
for bin in ocamlc ocamlopt ocamlmklib; do
ln -s "${PREFIX}/windows-sysroot/bin/${bin}.exe" "${PREFIX}/bin/${HOST}-${bin}"
done

for bin in ocamlmktop ocamldoc ocamldep; do
ln -s "${PREFIX}/bin/${bin}" "${PREFIX}/bin/${HOST}-${bin}"
done
2 changes: 1 addition & 1 deletion packages/ocaml-windows/ocaml-windows.4.14.0/opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ depends: [
synopsis: "A meta-package depending on any OCaml cross-compiler"
extra-files: [
["remove.sh" "md5=b97c542567963902a748467b7edf90d8"]
["install.sh" "md5=e4136c0c84d4794a3709aa5e7db6f970"]
["install.sh" "md5=8becbd7f7f90364a36d39ea5d1f940bd"]
]
13 changes: 13 additions & 0 deletions packages/ocaml-windows/ocaml-windows.4.14.1/files/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh -e

PREFIX="$1"
HOST="$2"

for bin in ocamlc ocamlopt ocamlmklib; do
ln -s "${PREFIX}/windows-sysroot/bin/${bin}.exe" "${PREFIX}/bin/${HOST}-${bin}"
ln -s "${PREFIX}/windows-sysroot/bin/${bin}.exe" "${PREFIX}/windows-sysroot/bin/${bin}"
done

for bin in ocamlcp ocamlmktop ocamldoc ocamldep; do
ln -s "${PREFIX}/bin/${bin}" "${PREFIX}/bin/${HOST}-${bin}"
done
8 changes: 8 additions & 0 deletions packages/ocaml-windows/ocaml-windows.4.14.1/files/remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh -e

PREFIX="$1"
HOST="$2"

for bin in ocamlc ocamlopt ocamlcp ocamlmklib ocamlmktop ocamldoc ocamldep; do
rm -f "${PREFIX}/bin/${HOST}-${bin}"
done
18 changes: 18 additions & 0 deletions packages/ocaml-windows/ocaml-windows.4.14.1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
opam-version: "2.0"
maintainer: "[email protected]"
install: [
["./install.sh" "%{prefix}%" "%{conf-gcc-windows:host}%"]
]
remove: [
["./remove.sh" "%{prefix}%" "%{conf-gcc-windows:host}%"]
]
depends: [
"ocaml"
"conf-gcc-windows"
"ocaml-windows32" {= "4.14.1"} | "ocaml-windows64" {= "4.14.1"}
]
synopsis: "A meta-package depending on any OCaml cross-compiler"
extra-files: [
["remove.sh" "md5=b97c542567963902a748467b7edf90d8"]
["install.sh" "md5=037f9267dee33f7b29380504b94bff98"]
]
1 change: 0 additions & 1 deletion packages/ocaml-windows32/ocaml-windows32.4.12.0/opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ depends: [
]
depopts: [
"conf-flambda-windows"
"conf-spacetime-windows"
]
conflicts: [
"ocaml-windows64"
Expand Down
Loading

0 comments on commit 78b60a8

Please sign in to comment.