Skip to content
Open
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
12 changes: 10 additions & 2 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ AC_DEFUN([OCAML_CC_VENDOR], [
msvc _MSC_VER
#elif defined(__INTEL_COMPILER)
icc __INTEL_COMPILER
#elif defined(__MINGW32__)
#include <_mingw_mac.h>
mingw32 __MINGW64_VERSION_MAJOR __MINGW64_VERSION_MINOR
# if defined(__clang_major__) && defined(__clang_minor__)
clang __clang_major__ __clang_minor__
# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
gcc __GNUC__ __GNUC_MINOR__
# endif
#elif defined(__clang_major__) && defined(__clang_minor__)
clang __clang_major__ __clang_minor__
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
Expand All @@ -62,8 +70,8 @@ unknown
#endif]
)],
[AC_CACHE_VAL([ocaml_cv_cc_vendor],
[ocaml_cv_cc_vendor=`grep ['^[a-z]'] conftest.i | tr -s ' ' '-' \
| tr -d '\r'`])],
[ocaml_cv_cc_vendor=`sed -e '/^#/d' conftest.i | tr -s '[:space:]' '-' \
| sed -e 's/^-//' -e 's/-$//'`])],
[AC_MSG_FAILURE([unexpected preprocessor failure])])
AC_MSG_RESULT([$ocaml_cv_cc_vendor])
])
Expand Down
74 changes: 34 additions & 40 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 38 additions & 49 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -788,56 +788,45 @@ AS_CASE([$enable_warn_error,OCAML__DEVELOPMENT_VERSION],
# Concerning optimization level, -O3 is somewhat risky, so take -O2.
# Concerning language version, recent enough versions of GCC and Clang
# default to gnu11 (C11 + GNU extensions) or gnu17, which is fine.

# Note: the vendor macro can not recognize MinGW because it calls the
# C preprocessor directly so no compiler specific macro like __MING32__
# is defined. We thus catch MinGW first by looking at host and examine
# the vendor only as a fall-back. We could put tis part of the logic
# in the macro itself, too
AS_CASE([$host],
[*-*-mingw32*],
[AS_CASE([$ocaml_cv_cc_vendor],
[gcc-[[01234]]-*],
[AC_MSG_ERROR(m4_normalize([This version of MinGW-w64 GCC is too old.
Please use GCC version 5 or above.]))],
[gcc-*],
[internal_cflags="-Wno-unused $cc_warnings \
-fexcess-precision=standard"
# TODO: see whether the code can be fixed to avoid -Wno-unused
common_cflags="-O2 -fno-strict-aliasing -fwrapv -mms-bitfields"
internal_cppflags='-D__USE_MINGW_ANSI_STDIO=0 -DUNICODE -D_UNICODE'
internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE="
internal_cppflags="${internal_cppflags}\$(WINDOWS_UNICODE)"],
[AC_MSG_ERROR([Unsupported C compiler for a MinGW-w64 build])])],
[AS_CASE([$ocaml_cv_cc_vendor],
[clang-*],
[common_cflags="-O2 -fno-strict-aliasing -fwrapv";
internal_cflags="$cc_warnings -fno-common"],
[gcc-[[0123]]-*|gcc-4-[[0-8]]],
# No C11 support
[AC_MSG_ERROR(m4_normalize([This version of GCC is too old.
Please use GCC version 4.9 or above.]), 69)],
[gcc-*],
[common_cflags="-O2 -fno-strict-aliasing -fwrapv";
internal_cflags="$cc_warnings -fno-common -fexcess-precision=standard \
AS_CASE([$ocaml_cv_cc_vendor],
[clang-*],
[common_cflags="-O2 -fno-strict-aliasing -fwrapv";
internal_cflags="$cc_warnings -fno-common"],
[*gcc-[[0123]]-*|*gcc-4-[[0-8]]],
# No C11 support
[AC_MSG_ERROR(m4_normalize([This version of GCC is too old.
Please use GCC version 4.9 or above.]), 69)],
[gcc-*],
[common_cflags="-O2 -fno-strict-aliasing -fwrapv";
internal_cflags="$cc_warnings -fno-common -fexcess-precision=standard \
-Wvla"],
[msvc-*],
[common_cflags="-nologo -O2 -Gy- -MD $cc_warnings"
common_cppflags="-D_CRT_SECURE_NO_DEPRECATE"
internal_cppflags='-DUNICODE -D_UNICODE'
OCAML_CL_HAS_VOLATILE_METADATA
AS_IF([test "x$cl_has_volatile_metadata" = "xtrue"],
[internal_cflags='-d2VolatileMetadata-'])
internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE="
internal_cppflags="${internal_cppflags}\$(WINDOWS_UNICODE)"],
[xlc-*],
[common_cflags="-O5 -qtune=balanced -qnoipa -qinline";
internal_cflags="$cc_warnings"],
[sunc-*], # Optimization should be >= O4 to inline functions
# and prevent unresolved externals
[common_cflags="-O4 -xc99=all -D_XPG6 $CFLAGS";
internal_cflags="$cc_warnings"],
[common_cflags="-O"])])
[mingw32-*-*-gcc-*|mingw32-*-*-clang-*],
[internal_cflags="-Wno-unused $cc_warnings \
-fexcess-precision=standard"
# TODO: see whether the code can be fixed to avoid -Wno-unused
common_cflags="-O2 -fno-strict-aliasing -fwrapv -mms-bitfields"
internal_cppflags='-D__USE_MINGW_ANSI_STDIO=0 -DUNICODE -D_UNICODE'
internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE="
internal_cppflags="${internal_cppflags}\$(WINDOWS_UNICODE)"],
[mingw32-*],
[AC_MSG_ERROR([Unsupported C compiler for a MinGW-w64 build])],
[msvc-*],
[common_cflags="-nologo -O2 -Gy- -MD $cc_warnings"
common_cppflags="-D_CRT_SECURE_NO_DEPRECATE"
internal_cppflags='-DUNICODE -D_UNICODE'
OCAML_CL_HAS_VOLATILE_METADATA
AS_IF([test "x$cl_has_volatile_metadata" = "xtrue"],
[internal_cflags='-d2VolatileMetadata-'])
internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE="
internal_cppflags="${internal_cppflags}\$(WINDOWS_UNICODE)"],
[xlc-*],
[common_cflags="-O5 -qtune=balanced -qnoipa -qinline";
internal_cflags="$cc_warnings"],
[sunc-*], # Optimization should be >= O4 to inline functions
# and prevent unresolved externals
[common_cflags="-O4 -xc99=all -D_XPG6 $CFLAGS";
internal_cflags="$cc_warnings"],
[common_cflags="-O"])

# Enable SSE2 on x86 mingw to avoid using 80-bit registers.
AS_CASE([$host],
Expand Down
5 changes: 5 additions & 0 deletions runtime/caml/fail.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ struct longjmp_buffer {
struct longjmp_buffer {
intptr_t buf[5];
};
#if defined(__clang__)
#define sigsetjmp(buf,save) __builtin_setjmp((void **)(buf))
#define siglongjmp(buf,val) __builtin_longjmp((void **)(buf),val)
#else
#define sigsetjmp(buf,save) __builtin_setjmp(buf)
#define siglongjmp(buf,val) __builtin_longjmp(buf,val)
#endif
#else
struct longjmp_buffer {
jmp_buf buf;
Expand Down
3 changes: 2 additions & 1 deletion runtime/runtime_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,11 @@ void caml_runtime_events_destroy(void) {
static void runtime_events_create_from_stw_single(void) {
/* Don't initialise runtime_events twice */
if (!atomic_load_acquire(&runtime_events_enabled)) {
int ret, ring_headers_length, ring_data_length;
int ring_headers_length, ring_data_length;
#ifdef _WIN32
DWORD pid = GetCurrentProcessId();
#else
int ret;
int ring_fd;
long int pid = getpid();
#endif
Expand Down
3 changes: 1 addition & 2 deletions runtime/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static void expand_argument(wchar_t * arg)

static void expand_pattern(wchar_t * pat)
{
wchar_t * prefix, * p, * name;
wchar_t * prefix, * name;
intptr_t handle;
struct _wfinddata_t ffblk;
size_t i;
Expand Down Expand Up @@ -1094,7 +1094,6 @@ CAMLexport clock_t caml_win32_clock(void)
{
FILETIME _creation, _exit;
CAML_ULONGLONG_FILETIME stime, utime;
ULARGE_INTEGER tmp;
ULONGLONG clocks_per_sec;

if (!(GetProcessTimes(GetCurrentProcess(), &_creation, &_exit,
Expand Down