summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes3
-rw-r--r--Makefile25
-rw-r--r--Makefile.common4
-rw-r--r--Makefile.config.in11
-rwxr-xr-xconfigure41
-rw-r--r--configure.ac43
-rw-r--r--ocamltest/ocaml_actions.ml3
-rw-r--r--runtime/unix.c11
-rw-r--r--testsuite/Makefile27
-rw-r--r--tools/Makefile5
-rw-r--r--tools/ci/appveyor/appveyor_build.cmd1
-rw-r--r--utils/config.mlp6
12 files changed, 100 insertions, 80 deletions
diff --git a/Changes b/Changes
index 81ec25ea59..e7b342bc32 100644
--- a/Changes
+++ b/Changes
@@ -362,7 +362,8 @@ Working version
of the runtime is built, and shared artefacts are no longer built twice. The
flexdll target no longer has to be separately built, but is folded into the
default make target. flexlink.opt is now built automatically with opt.opt. If
- the flexdll code is present, any flexlink in PATH is ignored.
+ the flexdll code is present, any flexlink in PATH is ignored. The Cygwin port
+ now also supports bootstrapping FlexDLL.
(David Allsopp, review by Sébastien Hinderer)
- #10156: configure script: fix sockets feature detection.
diff --git a/Makefile b/Makefile
index da3be2254f..4709cf475e 100644
--- a/Makefile
+++ b/Makefile
@@ -90,13 +90,11 @@ endif
BOOT_FLEXLINK_CMD=
-ifeq "$(UNIX_OR_WIN32)" "win32"
FLEXDLL_SUBMODULE_PRESENT := $(wildcard flexdll/Makefile)
ifneq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
BOOT_FLEXLINK_CMD = \
FLEXLINK_CMD="../boot/ocamlruns$(EXE) ../boot/flexlink.byte$(EXE)"
-endif # ifneq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
-endif # ifeq "$(UNIX_OR_WIN32)" "win32"
+endif
expunge := expunge$(EXE)
@@ -254,11 +252,9 @@ opt.opt: checknative
$(MAKE) otherlibrariesopt
$(MAKE) ocamllex.opt ocamltoolsopt ocamltoolsopt.opt $(OCAMLDOC_OPT) \
$(OCAMLTEST_OPT)
-ifeq "$(UNIX_OR_WIN32)" "win32"
ifneq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
$(MAKE) flexlink.opt$(EXE)
endif
-endif
ifeq "$(WITH_OCAMLDOC)-$(STDLIB_MANPAGES)" "ocamldoc-true"
$(MAKE) manpages
endif
@@ -432,9 +428,8 @@ endif
if test -n "$(WITH_DEBUGGER)"; then \
$(MAKE) -C debugger install; \
fi
-ifeq "$(UNIX_OR_WIN32)" "win32"
ifneq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
-ifneq "$(filter-out mingw,$(TOOLCHAIN))" ""
+ifeq "$(TOOLCHAIN)" "msvc"
$(INSTALL_DATA) flexdll/default$(filter-out _i386,_$(ARCH)).manifest \
"$(INSTALL_BINDIR)/"
endif
@@ -443,9 +438,8 @@ endif
ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
$(INSTALL_PROG) \
boot/flexlink.byte$(EXE) "$(INSTALL_BINDIR)/flexlink.byte$(EXE)"
-endif
-endif
-endif
+endif # ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
+endif # ifneq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
$(INSTALL_DATA) Makefile.config "$(INSTALL_LIBDIR)"
ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
if test -f ocamlopt$(EXE); then $(MAKE) installopt; else \
@@ -537,13 +531,11 @@ installoptopt:
$(LN) ocamlc.opt$(EXE) ocamlc$(EXE); \
$(LN) ocamlopt.opt$(EXE) ocamlopt$(EXE); \
$(LN) ocamllex.opt$(EXE) ocamllex$(EXE)
-ifeq "$(UNIX_OR_WIN32)" "win32"
ifneq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
$(INSTALL_PROG) flexlink.opt$(EXE) "$(INSTALL_BINDIR)"
cd "$(INSTALL_BINDIR)"; \
$(LN) flexlink.opt$(EXE) flexlink$(EXE)
endif
-endif
$(INSTALL_DATA) \
utils/*.cmx parsing/*.cmx typing/*.cmx bytecomp/*.cmx \
file_formats/*.cmx \
@@ -959,13 +951,12 @@ endif
# Check that the stack limit is reasonable (Unix-only)
.PHONY: checkstack
ifeq "$(UNIX_OR_WIN32)" "unix"
-checkstack := tools/checkstack
-checkstack: $(checkstack)$(EXE)
+checkstack: tools/checkstack$(EXE)
$<
-.INTERMEDIATE: $(checkstack)$(EXE) $(checkstack).$(O)
-$(checkstack)$(EXE): $(checkstack).$(O)
- $(MKEXE) $(OUTPUTEXE)$@ $<
+.INTERMEDIATE: tools/checkstack$(EXE) tools/checkstack.$(O)
+tools/checkstack$(EXE): tools/checkstack.$(O)
+ $(MAKE) -C tools $(BOOT_FLEXLINK_CMD) checkstack$(EXE)
else
checkstack:
@
diff --git a/Makefile.common b/Makefile.common
index d0495e100b..4836437931 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -34,11 +34,7 @@ INSTALL_LIBDIR := $(DESTDIR)$(LIBDIR)
INSTALL_STUBLIBDIR := $(DESTDIR)$(STUBLIBDIR)
INSTALL_MANDIR := $(DESTDIR)$(MANDIR)
-ifeq "$(UNIX_OR_WIN32)" "win32"
FLEXDLL_SUBMODULE_PRESENT := $(wildcard $(ROOTDIR)/flexdll/Makefile)
-else
-FLEXDLL_SUBMODULE_PRESENT =
-endif
# Variables used to represent the OCaml runtime system
# Most of the time, boot/ocamlrun and runtime/ocamlrun are the same.
diff --git a/Makefile.config.in b/Makefile.config.in
index adcb8a09d0..c7bcf0c2a9 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -204,6 +204,7 @@ NATIVECCLIBS=@nativecclibs@
SYSTHREAD_SUPPORT=@systhread_support@
PACKLD=@PACKLD@
IFLEXDIR=@iflexdir@
+FLEXDLL_CHAIN=@flexdll_chain@
EXTRALIBS=@extralibs@
CCOMPTYPE=@ccomptype@
TOOLCHAIN=@toolchain@
@@ -270,19 +271,17 @@ ifeq "$(UNIX_OR_WIN32)" "win32"
FIND=/usr/bin/find
SORT=/usr/bin/sort
SET_LD_PATH=PATH="$(PATH):$(LD_PATH)"
- FLEXLINK_CMD=flexlink
- FLEXDLL_CHAIN=@flexdll_chain@
- # FLEXLINK_FLAGS must be safe to insert in an OCaml string
- FLEXLINK_FLAGS=@flexlink_flags@
- FLEXLINK=$(FLEXLINK_CMD) $(FLEXLINK_FLAGS)
else # ifeq "$(UNIX_OR_WIN32)" "win32"
# On Unix, make sure FLEXLINK is defined but empty
- FLEXLINK =
SORT=sort
CYGPATH=echo
SET_LD_PATH=CAML_LD_LIBRARY_PATH="$(LD_PATH)"
endif # ifeq "$(UNIX_OR_WIN32)" "win32"
+FLEXLINK_FLAGS=@flexlink_flags@
+FLEXLINK_CMD=flexlink
+FLEXLINK=$(FLEXLINK_CMD) $(FLEXLINK_FLAGS)
+
# Deprecated variables
## Variables renamed in OCaml 4.13
diff --git a/configure b/configure
index b6651efe0c..2eca31e94b 100755
--- a/configure
+++ b/configure
@@ -12799,31 +12799,36 @@ case $CC,$host in #(
*,*-*-cygwin*) :
case $target in #(
i686-*) :
- flavor=cygwin ;; #(
+ flexdll_chain=cygwin ;; #(
x86_64-*) :
- flavor=cygwin64 ;; #(
+ flexdll_chain=cygwin64 ;; #(
*) :
as_fn_error $? "unknown cygwin variant" "$LINENO" 5 ;;
esac
common_cppflags="$common_cppflags -U_WIN32"
if $with_sharedlibs; then :
- flexlink="flexlink -chain $flavor -merge-manifest -stack 16777216"
- flexdir="$(flexlink -where | tr -d '\r')"
- if test -z "$flexdir"; then :
+ if test -e 'flexdll/Makefile'; then :
+ flexdir='$(ROOTDIR)/flexdll'
+else
+ flexlink="flexlink -chain $flexdll_chain -merge-manifest \
+-stack 16777216"
+ flexdir="$($flexlink -where | tr -d '\r')"
+ if test -z "$flexdir"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: flexlink not found: native shared libraries won't be available.
- " >&5
+ " >&5
$as_echo "$as_me: WARNING: flexlink not found: native shared libraries won't be available.
- " >&2;}
- with_sharedlibs=false
-else
- iflexdir="-I\"$flexdir\""
- mkexe="$flexlink -exe"
- mkexedebugflag="-link -g"
+ " >&2;}
+ with_sharedlibs=false
fi
fi
- if ! $with_sharedlibs; then :
+fi
+ if $with_sharedlibs; then :
+ iflexdir="-I\"$flexdir\""
+ mkexe='$(FLEXLINK) -exe $(if $(OC_LDFLAGS),-link "$(OC_LDFLAGS)")'
+ mkexedebugflag="-link -g"
+else
mkexe="$mkexe -Wl,--stack,16777216"
oc_ldflags="-Wl,--stack,16777216"
@@ -13695,8 +13700,8 @@ fi
mkmaindll='$(FLEXLINK) -maindll'
shared_libraries_supported=$with_sharedlibs ;; #(
*-*-cygwin*) :
- mksharedlib="$flexlink"
- mkmaindll="$flexlink -maindll"
+ mksharedlib='$(FLEXLINK)'
+ mkmaindll='$(FLEXLINK) -maindll'
shared_libraries_supported=true ;; #(
powerpc-ibm-aix*) :
case $ocaml_cv_cc_vendor in #(
@@ -17255,6 +17260,12 @@ esac
# Define flexlink chain and flags correctly for the different Windows ports
case $host in #(
+ i686-*-cygwin) :
+ flexdll_chain='cygwin'
+ flexlink_flags="-chain $flexdll_chain -merge-manifest -stack 16777216" ;; #(
+ x86_64-*-cygwin) :
+ flexdll_chain='cygwin64'
+ flexlink_flags="-chain $flexdll_chain -merge-manifest -stack 16777216" ;; #(
i686-w64-mingw32) :
flexdll_chain='mingw'
flexlink_flags="-chain $flexdll_chain -stack 16777216" ;; #(
diff --git a/configure.ac b/configure.ac
index 2b43f70f55..cfd6719266 100644
--- a/configure.ac
+++ b/configure.ac
@@ -685,24 +685,27 @@ AS_CASE([$CC,$host],
[*,*-*-haiku*], [mathlib=""],
[*,*-*-cygwin*],
[AS_CASE([$target],
- [i686-*], [flavor=cygwin],
- [x86_64-*], [flavor=cygwin64],
+ [i686-*], [flexdll_chain=cygwin],
+ [x86_64-*], [flexdll_chain=cygwin64],
[AC_MSG_ERROR([unknown cygwin variant])])
common_cppflags="$common_cppflags -U_WIN32"
AS_IF([$with_sharedlibs],
- [flexlink="flexlink -chain $flavor -merge-manifest -stack 16777216"
- flexdir="$(flexlink -where | tr -d '\r')"
- AS_IF([test -z "$flexdir"],
- [AC_MSG_WARN(
- [flexlink not found: native shared libraries won't be available.]
- )
- with_sharedlibs=false],
- [iflexdir="-I\"$flexdir\""
- mkexe="$flexlink -exe"
- mkexedebugflag="-link -g"]
- )]
- )
- AS_IF([! $with_sharedlibs],
+ [AS_IF([test -e 'flexdll/Makefile'],
+ [flexdir='$(ROOTDIR)/flexdll'],
+ [flexlink="flexlink -chain $flexdll_chain -merge-manifest \
+-stack 16777216"
+ flexdir="$($flexlink -where | tr -d '\r')"
+ AS_IF([test -z "$flexdir"],
+ [AC_MSG_WARN(
+ [flexlink not found: native shared libraries won't be available.]
+ )
+ with_sharedlibs=false]
+ )]
+ )])
+ AS_IF([$with_sharedlibs],
+ [iflexdir="-I\"$flexdir\""
+ mkexe='$(FLEXLINK) -exe $(if $(OC_LDFLAGS),-link "$(OC_LDFLAGS)")'
+ mkexedebugflag="-link -g"],
[mkexe="$mkexe -Wl,--stack,16777216"
oc_ldflags="-Wl,--stack,16777216"]
)
@@ -867,8 +870,8 @@ AS_IF([test x"$enable_shared" != "xno"],
mkmaindll='$(FLEXLINK) -maindll'
shared_libraries_supported=$with_sharedlibs],
[*-*-cygwin*],
- [mksharedlib="$flexlink"
- mkmaindll="$flexlink -maindll"
+ [mksharedlib='$(FLEXLINK)'
+ mkmaindll='$(FLEXLINK) -maindll'
shared_libraries_supported=true],
[powerpc-ibm-aix*],
[AS_CASE([$ocaml_cv_cc_vendor],
@@ -1873,6 +1876,12 @@ AS_CASE([$host],
# Define flexlink chain and flags correctly for the different Windows ports
AS_CASE([$host],
+ [i686-*-cygwin],
+ [flexdll_chain='cygwin'
+ flexlink_flags="-chain $flexdll_chain -merge-manifest -stack 16777216"],
+ [x86_64-*-cygwin],
+ [flexdll_chain='cygwin64'
+ flexlink_flags="-chain $flexdll_chain -merge-manifest -stack 16777216"],
[i686-w64-mingw32],
[flexdll_chain='mingw'
flexlink_flags="-chain $flexdll_chain -stack 16777216"],
diff --git a/ocamltest/ocaml_actions.ml b/ocamltest/ocaml_actions.ml
index 56936d7ad5..428ba6152f 100644
--- a/ocamltest/ocaml_actions.ml
+++ b/ocamltest/ocaml_actions.ml
@@ -1086,7 +1086,8 @@ let config_variables _log env =
Ocaml_variables.nativecc_libs, Ocamltest_config.nativecc_libs;
Ocaml_variables.mkdll,
Sys.getenv_with_default_value "MKDLL" Ocamltest_config.mkdll;
- Ocaml_variables.mkexe, Ocamltest_config.mkexe;
+ Ocaml_variables.mkexe,
+ Sys.getenv_with_default_value "MKEXE" Ocamltest_config.mkexe;
Ocaml_variables.c_preprocessor, Ocamltest_config.c_preprocessor;
Ocaml_variables.cc, Ocamltest_config.cc;
Ocaml_variables.csc, Ocamltest_config.csc;
diff --git a/runtime/unix.c b/runtime/unix.c
index a33717738b..21715a761e 100644
--- a/runtime/unix.c
+++ b/runtime/unix.c
@@ -30,7 +30,8 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include "caml/config.h"
-#ifdef SUPPORT_DYNAMIC_LINKING
+#if defined(SUPPORT_DYNAMIC_LINKING) && !defined(BUILDING_LIBCAMLRUNS)
+#define WITH_DYNAMIC_LINKING
#ifdef __CYGWIN__
#include "flexdll.h"
#else
@@ -225,7 +226,7 @@ caml_stat_string caml_search_dll_in_path(struct ext_table * path,
return res;
}
-#ifdef SUPPORT_DYNAMIC_LINKING
+#ifdef WITH_DYNAMIC_LINKING
#ifdef __CYGWIN__
/* Use flexdll */
@@ -256,7 +257,7 @@ char * caml_dlerror(void)
return flexdll_dlerror();
}
-#else
+#else /* ! __CYGWIN__ */
/* Use normal dlopen */
#ifndef RTLD_GLOBAL
@@ -296,7 +297,7 @@ char * caml_dlerror(void)
return (char*) dlerror();
}
-#endif
+#endif /* __CYGWIN__ */
#else
void * caml_dlopen(char * libname, int for_execution, int global)
@@ -323,7 +324,7 @@ char * caml_dlerror(void)
return "dynamic loading not supported on this platform";
}
-#endif
+#endif /* WITH_DYNAMIC_LINKING */
/* Add to [contents] the (short) names of the files contained in
the directory named [dirname]. No entries are added for [.] and [..].
diff --git a/testsuite/Makefile b/testsuite/Makefile
index 95ca6a0b88..e33bd58ecd 100644
--- a/testsuite/Makefile
+++ b/testsuite/Makefile
@@ -42,17 +42,18 @@ ifeq "$(UNIX_OR_WIN32)" "unix"
else # Non-cygwin Unix
find := find
endif
- FLEXLINK_ENV =
else # Windows
find := /usr/bin/find
- FLEXDLL_SUBMODULE_PRESENT := $(wildcard ../flexdll/Makefile)
- ifeq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
- FLEXLINK_ENV =
- else
- FLEXLINK_ENV = \
- OCAML_FLEXLINK="$(ROOTDIR_HOST)/boot/ocamlrun$(EXE) \
- $(ROOTDIR_HOST)/boot/flexlink.byte$(EXE)"
- endif
+endif
+
+ifneq "$(FLEXDLL_SUBMODULE_PRESENT)" ""
+ # The testsuite needs an absolute path to the runtime, so override the
+ # definition in Makefile.common
+ FLEXLINK_ENV = \
+ OCAML_FLEXLINK="$(ROOTDIR_HOST)/boot/ocamlrun$(EXE) \
+ $(ROOTDIR_HOST)/boot/flexlink.byte$(EXE)"
+else
+ FLEXLINK_ENV =
endif
ifeq "$(ocamltest_program)" ""
@@ -62,12 +63,16 @@ else
ocamltest := MKDLL="$(MKDLL)" SORT=$(SORT) MAKE=$(MAKE) $(ocamltest_program)
else
FLEXLINK_DLL_LDFLAGS=$(if $(OC_DLL_LDFLAGS), -link "$(OC_DLL_LDFLAGS)")
+ FLEXLINK_EXE_LDFLAGS=$(if $(OC_LDFLAGS), -link "$(OC_LDFLAGS)")
MKDLL=$(ROOTDIR_HOST)/boot/ocamlrun$(EXE) \
$(ROOTDIR_HOST)/boot/flexlink.byte$(EXE) \
$(FLEXLINK_FLAGS) $(FLEXLINK_DLL_LDFLAGS)
+ MKEXE=$(ROOTDIR_HOST)/boot/ocamlrun$(EXE) \
+ $(ROOTDIR_HOST)/boot/flexlink.byte$(EXE) \
+ $(FLEXLINK_FLAGS) -exe $(FLEXLINK_EXE_LDFLAGS)
- ocamltest := $(FLEXLINK_ENV) MKDLL="$(MKDLL)" SORT=$(SORT) MAKE=$(MAKE) \
- $(ocamltest_program)
+ ocamltest := $(FLEXLINK_ENV) MKEXE="$(MKEXE)" MKDLL="$(MKDLL)" \
+ SORT=$(SORT) MAKE=$(MAKE)$(ocamltest_program)
endif
endif
diff --git a/tools/Makefile b/tools/Makefile
index c7c62be91e..62eaaee782 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -314,6 +314,11 @@ caml_tex_files := \
$(ROOTDIR)/otherlibs/$(UNIXLIB)/unix.cma \
caml_tex.ml
+# checkstack tool
+
+checkstack$(EXE): checkstack.$(O)
+ $(MKEXE) $(OUTPUTEXE)$@ $<
+
#Scan latex files, and run ocaml code examples
caml_tex := caml-tex$(EXE)
diff --git a/tools/ci/appveyor/appveyor_build.cmd b/tools/ci/appveyor/appveyor_build.cmd
index f3dbd0c7e9..83e2295e78 100644
--- a/tools/ci/appveyor/appveyor_build.cmd
+++ b/tools/ci/appveyor/appveyor_build.cmd
@@ -122,6 +122,7 @@ if "%PORT%" equ "cygwin64" (
set CYGWIN_PACKAGES=%CYGWIN_PACKAGES% gcc-core flexdll
set CYGWIN_COMMANDS=%CYGWIN_COMMANDS% x86_64-pc-cygwin-gcc flexlink
)
+if "%PORT:~0,6%%BOOTSTRAP_FLEXDLL%" equ "cygwinfalse" set CYGWIN_PACKAGES=%CYGWIN_PACKAGES% flexdll
set CYGWIN_INSTALL_PACKAGES=
set CYGWIN_UPGRADE_REQUIRED=%FORCE_CYGWIN_UPGRADE%
diff --git a/utils/config.mlp b/utils/config.mlp
index 6da46df231..37b4d89259 100644
--- a/utils/config.mlp
+++ b/utils/config.mlp
@@ -58,16 +58,17 @@ let ranlib = "%%RANLIBCMD%%"
let default_rpath = "%%RPATH%%"
let mksharedlibrpath = "%%MKSHAREDLIBRPATH%%"
let ar = "%%ARCMD%%"
+let supports_shared_libraries = %%SUPPORTS_SHARED_LIBRARIES%%
let mkdll, mkexe, mkmaindll =
(* @@DRA Cygwin - but only if shared libraries are enabled, which we
should be able to detect? *)
- if Sys.os_type = "Win32" then
+ if Sys.win32 || Sys.cygwin && supports_shared_libraries then
try
let flexlink =
let flexlink = Sys.getenv "OCAML_FLEXLINK" in
let f i =
let c = flexlink.[i] in
- if c = '/' then '\\' else c in
+ if c = '/' && Sys.win32 then '\\' else c in
(String.init (String.length flexlink) f) ^ " %%FLEXLINK_FLAGS%%" in
flexlink ^ "%%FLEXLINK_DLL_LDFLAGS%%",
flexlink ^ " -exe%%FLEXLINK_LDFLAGS%%",
@@ -83,7 +84,6 @@ let with_cmm_invariants = %%WITH_CMM_INVARIANTS%%
let safe_string = %%FORCE_SAFE_STRING%%
let default_safe_string = %%DEFAULT_SAFE_STRING%%
let windows_unicode = %%WINDOWS_UNICODE%% != 0
-let supports_shared_libraries = %%SUPPORTS_SHARED_LIBRARIES%%
let flat_float_array = %%FLAT_FLOAT_ARRAY%%