Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ocaml-windows.5.1.1 #304

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
package: ${{ fromJson(needs.build_details.outputs.packages) }}
# ocaml compiler 4.14.1 does not have an option to build in 32 bit mode anymore.
arch: [x64]
ocaml_version: [4.14.1]
ocaml_version: [4.14.1, 5.1.1]
container:
image: ocamlcross/windows-${{ matrix.arch }}-base:${{ matrix.ocaml_version }}
options: --user root
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
matrix:
package: ${{ fromJson(needs.collect_revdeps.outputs.revdeps) }}
arch: [x64]
ocaml_version: [4.14.1]
ocaml_version: [4.14.1, 5.1.1]
container:
image: ocamlcross/windows-${{ matrix.arch }}-base:${{ matrix.ocaml_version }}
options: --user root
Expand Down
12 changes: 12 additions & 0 deletions packages/ocaml-windows/ocaml-windows.5.1.1/files/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh -e

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

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

for bin in 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.5.1.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.5.1.1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
opam-version: "2.0"
maintainer: "whitequark@whitequark.org"
install: [
["./install.sh" "%{prefix}%" "%{conf-gcc-windows:host}%"]
]
remove: [
["./remove.sh" "%{prefix}%" "%{conf-gcc-windows:host}%"]
]
depends: [
"ocaml"
"conf-gcc-windows"
"ocaml-windows64" {= version}
]
synopsis: "A meta-package depending on any OCaml cross-compiler"
extra-files: [
["remove.sh" "md5=b97c542567963902a748467b7edf90d8"]
["install.sh" "md5=767ed38d97e0f3293a2f9ecdfd676fae"]
]
35 changes: 35 additions & 0 deletions packages/ocaml-windows64/ocaml-windows64.5.1.1/files/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -e

HOST=$1
OPAM_PREFIX="$2"
FLEXDLL_DIR="$3"

OPTS=""

if [ `opam var conf-flambda-windows:installed` = "true" ]; then
OPTS="--enable-flambda"
fi

export PATH=${FLEXDLL_DIR}:$PATH

./configure --host="${HOST}" --prefix="${OPAM_PREFIX}/windows-sysroot" --enable-systhreads ${OPTS}

make runtime/sak.exe DEP_CC="${HOST}-gcc -MM" SAK_CC=cc SAK_CFLAGS= SAK_LINK='cc -o $(1) $(2)'

make ocamlopt ocamlc OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun CAMLC="`which ocamlc`"
make ocamlmklib OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun CAMLC="`which ocamlc`"
make boot/ocamlruns.exe
make runtime-all
make -C stdlib OCAMLRUN=ocamlrun COMPILER="${PWD}/boot/ocamlc"
make ocamlyacc OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun
make ocamllex OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun OCAMLYACC=ocamlyacc CAMLC="`which ocamlc`"
make coldstart OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun
make runtime/libasmrun.a

make library otherlibs opt ocamlnat ocaml ocamldoc ocamldebugger \
OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun \
OPTCOMPILER="${PWD}/ocamlopt.exe" \
MKLIB="ocamlrun \"${PWD}/tools/ocamlmklib.exe\"" \
OCAMLYACC=ocamlyacc
31 changes: 31 additions & 0 deletions packages/ocaml-windows64/ocaml-windows64.5.1.1/files/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

set -e

PREFIX="$1"
FLEXDLL_PATH="$2"

cd tools && ln -s stripdebug.exe stripdebug && cd ..
make install installopt RUNTIMED=false INSTRUMENTED_RUNTIME=false OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun

cp -rf compilerlibs/*.cmxa compilerlibs/*.a "${PREFIX}/windows-sysroot/lib/ocaml/compiler-libs"

for bin in ocaml ocamlc ocamlopt ocamlcp ocamlmklib ocamlmktop ocamldoc ocamldep; do
cat >"${PREFIX}/windows-sysroot/bin/${bin}" <<END
#!/bin/sh
export PATH=${FLEXDLL_PATH}:\$PATH
${PREFIX}/bin/ocamlrun "${PREFIX}/windows-sysroot/bin/${bin}.exe" "\$@"
END
chmod +x "${PREFIX}/windows-sysroot/bin/${bin}"
done

# Copy META files from ocamlfind
for pkg in bigarray bytes compiler-libs dynlink findlib graphics stdlib str threads unix; do
if [ -f "${PREFIX}/lib/${pkg}/META" ]; then
mkdir -p "${PREFIX}/windows-sysroot/lib/${pkg}"
cp -r "${PREFIX}/lib/${pkg}/META" "${PREFIX}/windows-sysroot/lib/${pkg}/META"
fi
done

mkdir -p "${PREFIX}/lib/findlib.conf.d"
cp windows.conf "${PREFIX}/lib/findlib.conf.d"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--- ocaml-5.1.1/configure.orig 2024-02-25 18:21:29.787786010 +0000
+++ ocaml-5.1.1/configure 2024-02-25 18:21:31.795786011 +0000
@@ -13947,6 +13947,14 @@



+ flexlink_where_cmd_prefix=''
+ case $build in #(
+ *-w64-mingw32*|*-pc-windows) :
+ flexlink_where_cmd_prefix="cmd /c" ;; #(
+ *) :
+ ;;
+esac
+
if test -n "$flexlink" && test -z "$flexdir"
then :

@@ -14024,7 +14032,7 @@

case $host in #(
*-w64-mingw32*|*-pc-windows) :
- flexlink_where="$(cmd /c "$flexlink" -where 2>/dev/null)"
+ flexlink_where="$($flexlink_where_cmd_prefix "$flexlink" -where 2>/dev/null)"
if test -z "$flexlink_where"
then :
as_fn_error $? "$flexlink is not executable from a native Win32 process" "$LINENO" 5
@@ -18358,9 +18366,17 @@

## Determine how to link with the POSIX threads library

+extra_mingw_pthread_lib=''
+case $build in #(
+ *-*-mingw32*) :
+ extra_mingw_pthread_lib="-lgcc_eh" ;; #(
+ *) :
+ ;;
+esac
+
case $host in #(
*-*-mingw32*) :
- PTHREAD_LIBS="-l:libpthread.a -lgcc_eh" ;; #(
+ PTHREAD_LIBS="-l:libpthread.a $extra_mingw_pthread_lib" ;; #(
*-pc-windows) :
PTHREAD_LIBS="-l:libpthread.lib" ;; #(
*) :
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/middle_end/closure/closure.ml b/middle_end/closure/closure.ml
index b4095b7237..62d67b17d7 100644
--- a/middle_end/closure/closure.ml
+++ b/middle_end/closure/closure.ml
@@ -1080,9 +1080,9 @@ let rec close ({ backend; fenv; cenv ; mutable_vars } as env) lam =
| Word_size -> make_const_int (8*B.size_int)
| Int_size -> make_const_int (8*B.size_int - 1)
| Max_wosize -> make_const_int ((1 lsl ((8*B.size_int) - 10)) - 1 )
- | Ostype_unix -> make_const_bool (Sys.os_type = "Unix")
- | Ostype_win32 -> make_const_bool (Sys.os_type = "Win32")
- | Ostype_cygwin -> make_const_bool (Sys.os_type = "Cygwin")
+ | Ostype_unix -> make_const_bool false
+ | Ostype_win32 -> make_const_bool true
+ | Ostype_cygwin -> make_const_bool false
| Backend_type ->
make_const_int 0 (* tag 0 is the same as Native here *)
in
diff --git a/utils/config.common.ml b/utils/config.common.ml
index d4850ffd50..182046f38b 100644
--- a/utils/config.common.ml
+++ b/utils/config.common.ml
@@ -64,11 +64,7 @@ let lazy_tag = 246
let max_young_wosize = 256
let stack_threshold = 32 (* see runtime/caml/config.h *)
let stack_safety_margin = 6
-let default_executable_name =
- match Sys.os_type with
- "Unix" -> "a.out"
- | "Win32" | "Cygwin" -> "camlprog.exe"
- | _ -> "camlprog"
+let default_executable_name = "camlprog.exe"
type configuration_value =
| String of string
| Int of int
@@ -107,7 +103,7 @@ let configuration_variables () =
p "ext_asm" ext_asm;
p "ext_lib" ext_lib;
p "ext_dll" ext_dll;
- p "os_type" Sys.os_type;
+ p "os_type" "Win32";
p "default_executable_name" default_executable_name;
p_bool "systhread_supported" systhread_supported;
p "host" host;
diff --git a/utils/config.generated.ml.in b/utils/config.generated.ml.in
index 83d99afaa3..60708e888e 100644
--- a/utils/config.generated.ml.in
+++ b/utils/config.generated.ml.in
@@ -96,7 +96,7 @@ let asm_cfi_supported = @asm_cfi_supported@
let with_frame_pointers = @frame_pointers@
let reserved_header_bits = @reserved_header_bits@

-let ext_exe = {@QS@|@exeext@|@QS@}
+let ext_exe = ".exe"
let ext_obj = "." ^ {@QS@|@OBJEXT@|@QS@}
let ext_asm = "." ^ {@QS@|@S@|@QS@}
let ext_lib = "." ^ {@QS@|@libext@|@QS@}
10 changes: 10 additions & 0 deletions packages/ocaml-windows64/ocaml-windows64.5.1.1/files/remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh -e

PREFIX="$1"

for bin in ocaml ocamlc ocamlcp ocamldebug ocamldep ocamldoc ocamllex ocamlmklib ocamlmktop ocamlobjinfo ocamlopt ocamloptp ocamlprof ocamlrun ocamlyacc; do
rm -f "${PREFIX}/windows-sysroot/bin/${bin}"
done

rm -rf "${PREFIX}/windows-sysroot/lib/ocaml"
rm -rf "${PREFIX}/lib/findlib.conf.d/windows.conf"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
path(windows) = "%{prefix}%/windows-sysroot/lib"
destdir(windows) = "%{prefix}%/windows-sysroot/lib"
stdlib(windows) = "%{prefix}%/windows-sysroot/lib/ocaml"
ocamlc(windows) = "%{prefix}%/windows-sysroot/bin/ocamlc"
ocamlopt(windows) = "%{prefix}%/windows-sysroot/bin/ocamlopt"
ocamlmklib(windows) = "%{prefix}%/windows-sysroot/bin/ocamlmklib"
ocamlmktop(windows) = "%{prefix}%/bin/ocamlmktop"
ocamldoc(windows) = "%{prefix}%/bin/ocamldoc"
ocamldep(windows) = "%{prefix}%/bin/ocamldep"
40 changes: 40 additions & 0 deletions packages/ocaml-windows64/ocaml-windows64.5.1.1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
opam-version: "2.0"
maintainer: "whitequark@whitequark.org"
patches: [
"patches/ostype-fix.patch"
"patches/configure.patch"
]
substs: [
"windows.conf"
]
build: [
["/bin/sh" "./build.sh" "%{conf-gcc-windows64:host}%" "%{prefix}%" "%{flexdll-windows:lib}%"]
]
install: [
["/bin/sh" "./install.sh" "%{prefix}%" "%{flexdll-windows:lib}%"]
]
depends: [
"ocaml" {= version}
"ocamlfind" {>= "1.5.4"}
"conf-gcc-windows64"
"flexdll-windows" {>= "0.42"}
]
depopts: [
"conf-flambda-windows"
]
available: arch = "x86_64" | (arch = "arm64" & os = "macos")
conflicts: [
"ocaml-windows32"
]
synopsis: "OCaml cross-compiler for 64-bit x86 Windows targets"
extra-files: [
["windows.conf.in" "md5=69f2a64db241a28e172eb316ddd9cef1"]
["build.sh" "md5=93e8e83fed757be1e6c59b65873b5c93"]
["install.sh" "md5=771227318703c168f819281d3c051b29"]
["patches/ostype-fix.patch" "md5=57404edca01e9a353f28d3b3c0139f55"]
["patches/configure.patch" "md5=668bfb4f3fccd959daa553f70b28e803"]
]
url {
src: "https://github.com/ocaml/ocaml/archive/5.1.1.tar.gz"
checksum: "md5=ac4a19e57d1ed6c2efc70d1a9b97c567"
}
Loading