summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2013-12-03 14:43:02 +0000
committerDamien Doligez <damien.doligez-inria.fr>2013-12-03 14:43:02 +0000
commitaa58e559586b17ee402372d0b02a05b9be914467 (patch)
tree47570c41d4242d627498d4545c8850dc4c872ea8
parent0f6873a183ea29afba8053d4c18d7c5bdf896488 (diff)
downloadocaml-aa58e559586b17ee402372d0b02a05b9be914467.tar.gz
port to cygwin-64
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14337 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Makefile3
-rw-r--r--asmcomp/amd64/emit.mlp13
-rw-r--r--asmcomp/amd64/proc.ml2
-rw-r--r--asmrun/amd64.S16
-rw-r--r--byterun/io.c3
-rwxr-xr-xconfigure5
6 files changed, 26 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index d8df5798a2..012695cf24 100644
--- a/Makefile
+++ b/Makefile
@@ -786,7 +786,8 @@ partialclean::
# Check that the stack limit is reasonable.
checkstack:
- @if $(BYTECC) -o tools/checkstack tools/checkstack.c; \
+ @if $(BYTECC) $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) \
+ -o tools/checkstack tools/checkstack.c; \
then tools/checkstack; \
else :; \
fi
diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp
index 674ed2adb2..76b642c286 100644
--- a/asmcomp/amd64/emit.mlp
+++ b/asmcomp/amd64/emit.mlp
@@ -22,6 +22,7 @@ open Emitaux
let macosx = (Config.system = "macosx")
let mingw64 = (Config.system = "mingw64")
+let cygwin = (Config.system = "cygwin")
let fp = Config.with_frame_pointers
@@ -61,17 +62,17 @@ let emit_symbol s =
Emitaux.emit_symbol '$' s
let emit_call s =
- if !Clflags.dlcode && not macosx && not mingw64
+ if !Clflags.dlcode && not macosx && not mingw64 && not cygwin
then `call {emit_symbol s}@PLT`
else `call {emit_symbol s}`
let emit_jump s =
- if !Clflags.dlcode && not macosx && not mingw64
+ if !Clflags.dlcode && not macosx && not mingw64 && not cygwin
then `jmp {emit_symbol s}@PLT`
else `jmp {emit_symbol s}`
let load_symbol_addr s =
- if !Clflags.dlcode && not mingw64
+ if !Clflags.dlcode && not mingw64 && not cygwin
then `movq {emit_symbol s}@GOTPCREL(%rip)`
else if !pic_code
then `leaq {emit_symbol s}(%rip)`
@@ -636,7 +637,7 @@ let emit_instr fallthrough i =
` jmp *{emit_reg tmp1}\n`;
if macosx then
` .const\n`
- else if mingw64 then
+ else if mingw64 || cygwin then
` .section .rdata,\"dr\"\n`
else
` .section .rodata\n`;
@@ -790,7 +791,7 @@ let begin_assembly() =
(* from amd64.S; could emit these constants on demand *)
if macosx then
` .literal16\n`
- else if mingw64 then
+ else if mingw64 || cygwin then
` .section .rdata,\"dr\"\n`
else
` .section .rodata.cst8,\"a\",@progbits\n`;
@@ -813,7 +814,7 @@ let end_assembly() =
if !float_constants <> [] then begin
if macosx then
` .literal8\n`
- else if mingw64 then
+ else if mingw64 || cygwin then
` .section .rdata,\"dr\"\n`
else
` .section .rodata.cst8,\"a\",@progbits\n`;
diff --git a/asmcomp/amd64/proc.ml b/asmcomp/amd64/proc.ml
index ddec43db79..b6e0fa94ab 100644
--- a/asmcomp/amd64/proc.ml
+++ b/asmcomp/amd64/proc.ml
@@ -24,7 +24,7 @@ let fp = Config.with_frame_pointers
let win64 =
match Config.system with
- | "win64" | "mingw64" -> true
+ | "win64" | "mingw64" | "cygwin" -> true
| _ -> false
(* Which asm conventions to use *)
diff --git a/asmrun/amd64.S b/asmrun/amd64.S
index 1b54c4ff39..d2e007529d 100644
--- a/asmrun/amd64.S
+++ b/asmrun/amd64.S
@@ -32,7 +32,7 @@
.align FUNCTION_ALIGN; \
name:
-#elif defined(SYS_mingw64)
+#elif defined(SYS_mingw64) || defined(SYS_cygwin)
#define LBL(x) .L##x
#define G(r) r
@@ -90,7 +90,7 @@
#endif
-#if defined(__PIC__) && !defined(SYS_mingw64)
+#if defined(__PIC__) && !defined(SYS_mingw64) && !defined(SYS_cygwin)
/* Position-independent operations on global variables. */
@@ -179,7 +179,7 @@
/* Save and restore all callee-save registers on stack.
Keep the stack 16-aligned. */
-#if defined(SYS_mingw64)
+#if defined(SYS_mingw64) || defined(SYS_cygwin)
/* Win64 API: callee-save regs are rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15 */
@@ -249,7 +249,7 @@
#endif
-#ifdef SYS_mingw64
+#if defined(SYS_mingw64) || defined (SYS_cygwin)
/* Calls from OCaml to C must reserve 32 bytes of extra stack space */
# define PREPARE_FOR_C_CALL subq $32, %rsp; CFI_ADJUST(32)
# define CLEANUP_AFTER_C_CALL addq $32, %rsp; CFI_ADJUST(-32)
@@ -271,7 +271,7 @@ FUNCTION(G(caml_call_gc))
CFI_STARTPROC
RECORD_STACK_FRAME(0)
LBL(caml_call_gc):
-#ifndef SYS_mingw64
+#if !defined(SYS_mingw64) && !defined(SYS_cygwin)
/* Touch the stack to trigger a recoverable segfault
if insufficient space remains */
subq $32768, %rsp
@@ -448,7 +448,7 @@ LBL(caml_c_call):
STORE_VAR(%r12, caml_last_return_address)
STORE_VAR(%rsp, caml_bottom_of_stack)
subq $8, %rsp; CFI_ADJUST(8) /* equivalent to pushq %r12 */
-#ifndef SYS_mingw64
+#if !defined(SYS_mingw64) && !defined(SYS_cygwin)
/* Touch the stack to trigger a recoverable segfault
if insufficient space remains */
subq $32768, %rsp
@@ -517,7 +517,7 @@ CFI_ENDPROC
/* Registers holding arguments of C functions. */
-#ifdef SYS_mingw64
+#if defined(SYS_mingw64) || defined(SYS_cygwin)
#define C_ARG_1 %rcx
#define C_ARG_2 %rdx
#define C_ARG_3 %r8
@@ -674,7 +674,7 @@ G(caml_system__frametable):
#if defined(SYS_macosx)
.literal16
-#elif defined(SYS_mingw64)
+#elif defined(SYS_mingw64) || defined(SYS_cygwin)
.section .rdata,"dr"
#else
.section .rodata.cst8,"a",@progbits
diff --git a/byterun/io.c b/byterun/io.c
index 676cb5b2bf..c1566b72c9 100644
--- a/byterun/io.c
+++ b/byterun/io.c
@@ -22,6 +22,9 @@
#ifdef HAS_UNISTD
#include <unistd.h>
#endif
+#ifdef __CYGWIN__
+#include </usr/include/io.h>
+#endif
#include "alloc.h"
#include "custom.h"
#include "fail.h"
diff --git a/configure b/configure
index de8b3c3249..7fdfb0a0ce 100755
--- a/configure
+++ b/configure
@@ -381,6 +381,10 @@ case "$bytecc,$target" in
mkexedebugflag="-link -g"
fi
fi
+ if test $with_sharedlibs = no; then
+ mkexe="$mkexe -Wl,--stack,16777216"
+ bytecclinkopts="-Wl,--stack,16777216"
+ fi
exe=".exe"
ostype="Cygwin";;
*gcc*,*-*-mingw*)
@@ -858,6 +862,7 @@ case "$target" in
x86_64-*-darwin*) arch=amd64; system=macosx;;
x86_64-*-mingw*) arch=amd64; system=mingw;;
aarch64-*-linux*) arch=arm64; system=linux;;
+ x86_64-*-cygwin*) arch=amd64; system=cygwin;;
esac
# Some platforms exist both in 32-bit and 64-bit variants, not distinguished