From b082fd17f080c7fb7e13f2bbb57edb06cd1e81c8 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Mon, 29 Aug 2022 10:34:52 +0100 Subject: [PATCH 1/3] Create symlinks on Windows when available Previously Windows unconditionally uses `cp`, doubling the size required for the OCaml binaries. `configure` now determines if `ln` creates native symlinks and only uses `cp` if that fails. Users of the compiler are simply required to enable Developer Mode (or build OCaml using an elevated shell). --- Changes | 4 ++++ aclocal.m4 | 15 +++++++++++++++ configure | 23 ++++++++++++++++++++++- configure.ac | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index d59143429747..631047b00c87 100644 --- a/Changes +++ b/Changes @@ -233,6 +233,10 @@ Working version team. (Nathan Rebours, review by Florian Angeletti) +- #13494: Use native symlinks on Windows for the OCaml installation, reducing + disk usage considerably. + (David Allsopp, review by Nicolás Ojeda Bär and Gabriel Scherer) + * #13526: Simplify the build of cross compilers This replaces the configure `--with-target-bindir` option by an equivalent `TARGET_BINDIR` variable diff --git a/aclocal.m4 b/aclocal.m4 index bff5f671f237..dbd7c662d758 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -545,3 +545,18 @@ AC_DEFUN([OCAML_CC_SUPPORTS_LABELS_AS_VALUES], [ [Define if the C compiler supports the labels as values extension.]) fi ]) + +AC_DEFUN([OCAML_CHECK_LN_ON_WINDOWS], [ + AC_MSG_CHECKING([for a workable solution for ln -sf]) + ln -sf configure conftestLink + AS_IF([test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)"], + [rm -f conftestLink + CYGWIN=winsymlinks:native ln -sf configure conftestLink + AS_IF([test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)"], + [ln='cp -pf'], + [ln='CYGWIN=winsymlinks:native ln -sf'] + )], + [ln='ln -sf'] + ) + AC_MSG_RESULT([$ln]) +]) diff --git a/configure b/configure index ead6b90e26a3..25b503f5d12e 100755 --- a/configure +++ b/configure @@ -14728,7 +14728,28 @@ ocamlsrcdir=${ocamlsrcdir%X} case $host in #( *-*-mingw32*|*-pc-windows) : - ln='cp -pf' + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a workable solution for ln -sf" >&5 +printf %s "checking for a workable solution for ln -sf... " >&6; } + ln -sf configure conftestLink + if test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)" +then : + rm -f conftestLink + CYGWIN=winsymlinks:native ln -sf configure conftestLink + if test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)" +then : + ln='cp -pf' +else $as_nop + ln='CYGWIN=winsymlinks:native ln -sf' + +fi +else $as_nop + ln='ln -sf' + +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ln" >&5 +printf "%s\n" "$ln" >&6; } + ocamlsrcdir="$(LC_ALL=C.UTF-8 cygpath -w -- "$ocamlsrcdir")" ;; #( *) : ln='ln -sf' ;; diff --git a/configure.ac b/configure.ac index 8e3754f37553..2fcdf29bbe50 100644 --- a/configure.ac +++ b/configure.ac @@ -768,7 +768,7 @@ ocamlsrcdir=${ocamlsrcdir%X} AS_CASE([$host], [*-*-mingw32*|*-pc-windows], - [ln='cp -pf' + [OCAML_CHECK_LN_ON_WINDOWS ocamlsrcdir="$(LC_ALL=C.UTF-8 cygpath -w -- "$ocamlsrcdir")"], [ln='ln -sf']) From e0467cc670b51d29942556a028313b6d260344da Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 17 May 2023 13:57:57 +0100 Subject: [PATCH 2/3] Set MSYS and CYGWIN permanently Slightly easier detection, and a somewhat hardened implementation. --- Makefile.common | 9 +++++++++ aclocal.m4 | 14 +++++--------- configure | 15 +++------------ 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Makefile.common b/Makefile.common index 253356d68fbb..d3c36cc9caac 100644 --- a/Makefile.common +++ b/Makefile.common @@ -467,3 +467,12 @@ endef # INSTALL_STRIPPED_BYTE_PROG # boot/ as part of coldstart. See read_runtime_launch_info in # bytecomp/bytelink.ml for further details. HEADER_NAME = runtime-launch-info + +ifeq "$(UNIX_OR_WIN32)" "win32" +# Ensure that no command can create Cygwin symbolic links by ensuring that +# symlink(2) will fail if native NTFS symlinks aren't available. +export CYGWIN := $(strip \ + $(filter-out winsymlinks winsymlinks:%, $(CYGWIN)) winsymlinks:nativestrict) +export MSYS := $(strip \ + $(filter-out winsymlinks winsymlinks:%, $(MSYS)) winsymlinks:nativestrict) +endif diff --git a/aclocal.m4 b/aclocal.m4 index dbd7c662d758..7aadcaee8d2d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -548,15 +548,11 @@ AC_DEFUN([OCAML_CC_SUPPORTS_LABELS_AS_VALUES], [ AC_DEFUN([OCAML_CHECK_LN_ON_WINDOWS], [ AC_MSG_CHECKING([for a workable solution for ln -sf]) - ln -sf configure conftestLink - AS_IF([test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)"], - [rm -f conftestLink - CYGWIN=winsymlinks:native ln -sf configure conftestLink - AS_IF([test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)"], - [ln='cp -pf'], - [ln='CYGWIN=winsymlinks:native ln -sf'] - )], - [ln='ln -sf'] + AS_IF([m4_normalize(MSYS=winsymlinks:nativestrict + CYGWIN=winsymlinks:nativestrict + ln -sf configure conftestLink 2>/dev/null)], + [ln='ln -sf'], + [ln='cp -pf'] ) AC_MSG_RESULT([$ln]) ]) diff --git a/configure b/configure index 25b503f5d12e..b9bc2ae55c95 100755 --- a/configure +++ b/configure @@ -14731,20 +14731,11 @@ case $host in #( { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a workable solution for ln -sf" >&5 printf %s "checking for a workable solution for ln -sf... " >&6; } - ln -sf configure conftestLink - if test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)" + if MSYS=winsymlinks:nativestrict CYGWIN=winsymlinks:nativestrict ln -sf configure conftestLink 2>/dev/null then : - rm -f conftestLink - CYGWIN=winsymlinks:native ln -sf configure conftestLink - if test -z "$(cmd /c dir conftestLink 2>/dev/null | grep -F SYMLINK)" -then : - ln='cp -pf' -else $as_nop - ln='CYGWIN=winsymlinks:native ln -sf' - -fi -else $as_nop ln='ln -sf' +else $as_nop + ln='cp -pf' fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ln" >&5 From e24eacc40c5c955e57bf59707a60e2cb64dc124f Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sun, 29 Sep 2024 00:25:05 +0100 Subject: [PATCH 3/3] Test installations on the MSVC workflow --- .gitattributes | 1 + .github/workflows/build-msvc.yml | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 93e6e3d03221..ed07cd7f617d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -59,6 +59,7 @@ META.in typo.missing-header # Github templates and scripts lack headers, have long lines /.github/** typo.missing-header typo.long-line=may typo.very-long-line=may /.github/workflows/build-cross.yml typo.non-ascii +/.github/workflows/build-msvc.yml typo.utf8 /.mailmap typo.long-line typo.missing-header typo.non-ascii /CONTRIBUTING.md typo.non-ascii=may diff --git a/.github/workflows/build-msvc.yml b/.github/workflows/build-msvc.yml index ecc762f8762b..808d3da4d1d7 100644 --- a/.github/workflows/build-msvc.yml +++ b/.github/workflows/build-msvc.yml @@ -95,10 +95,12 @@ jobs: CC: ${{ matrix.cc }} run: >- eval $(tools/msvs-promote-path) ; - if ! ./configure --cache-file=config.cache --host=$HOST CC=$CC ; then + if ! ./configure --cache-file=config.cache --host=$HOST CC=$CC + --prefix "$PROGRAMFILES/Бактріан🐫"; then rm -rf config.cache ; failed=0 ; - ./configure --cache-file=config.cache --host=$HOST CC=$CC \ + ./configure --cache-file=config.cache --host=$HOST CC=$CC + --prefix "$PROGRAMFILES/Бактріан🐫" || failed=$?; if ((failed)) ; then cat config.log ; exit $failed ; fi ; fi ; @@ -136,3 +138,7 @@ jobs: run: >- eval $(tools/msvs-promote-path) ; make -j tests ; + + - name: Install the compiler + shell: bash + run: make install