diff options
-rw-r--r-- | aclocal.m4 | 8 | ||||
-rwxr-xr-x | configure | 111 | ||||
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | runtime/caml/m.h.in | 2 | ||||
-rw-r--r-- | runtime/caml/misc.h | 9 |
5 files changed, 93 insertions, 53 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index ff12869a29..5ac1b7293e 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -86,6 +86,14 @@ AC_DEFUN([OCAML_CC_HAS_FNO_TREE_VRP], [ CFLAGS="$saved_CFLAGS" ]) +AC_DEFUN([OCAML_CC_SUPPORTS_ALIGNED], [ + AC_MSG_CHECKING([whether the C compiler supports __attribute__((aligned(n)))]) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([typedef struct {__attribute__((aligned(8))) int t;} t;])], + [AC_DEFINE([SUPPORTS_ALIGNED_ATTRIBUTE]) + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])])]) + AC_DEFUN([OCAML_CC_HAS_DEBUG_PREFIX_MAP], [ AC_MSG_CHECKING([whether the C compiler supports -fdebug-prefix-map]) saved_CFLAGS="$CFLAGS" @@ -12291,6 +12291,48 @@ fi ;; esac +## Find vendor of the C compiler + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking C compiler vendor" >&5 +$as_echo_n "checking C compiler vendor... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if defined(_MSC_VER) +msvc _MSC_VER +#elif defined(__INTEL_COMPILER) +icc __INTEL_COMPILER +#elif defined(__clang_major__) && defined(__clang_minor__) +clang __clang_major__ __clang_minor__ +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +gcc __GNUC__ __GNUC_MINOR__ +#elif defined(__xlc__) && defined(__xlC__) +xlc __xlC__ __xlC_ver__ +#else +unknown +#endif + +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + if ${ocaml_cv_cc_vendor+:} false; then : + $as_echo_n "(cached) " >&6 +else + ocaml_cv_cc_vendor=`grep '^[a-z]' conftest.i | tr -s ' ' '-'` +fi + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "unexpected preprocessor failure +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.err conftest.i conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ocaml_cv_cc_vendor" >&5 +$as_echo "$ocaml_cv_cc_vendor" >&6; } + + # Determine how to call the C preprocessor directly. # Most of the time, calling the C preprocessor through the C compiler is # desirable and even important. @@ -12302,8 +12344,11 @@ esac # We thus figure out how to invoke the C preprocessor directly but # let the CPP variable untouched, except for the MSVC port where we set it # manually to make sure the backward compatibility is preserved -case $host in #( - *-pc-windows) : +case $ocaml_cv_cc_vendor in #( + xlc-*) : + CPP="$CC -E -qnoppline" ;; #( + # suppress incompatible XLC line directives + msvc-*) : CPP="$CC -nologo -EP" ;; #( *) : ;; @@ -12407,48 +12452,6 @@ fi ## Check for C99 support: done by libtool ## AC_PROG_CC_C99 -## Find vendor of the C compiler - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking C compiler vendor" >&5 -$as_echo_n "checking C compiler vendor... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#if defined(_MSC_VER) -msvc _MSC_VER -#elif defined(__INTEL_COMPILER) -icc __INTEL_COMPILER -#elif defined(__clang_major__) && defined(__clang_minor__) -clang __clang_major__ __clang_minor__ -#elif defined(__GNUC__) && defined(__GNUC_MINOR__) -gcc __GNUC__ __GNUC_MINOR__ -#elif defined(__xlc__) && defined(__xlC__) -xlc __xlC__ __xlC_ver__ -#else -unknown -#endif - -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - if ${ocaml_cv_cc_vendor+:} false; then : - $as_echo_n "(cached) " >&6 -else - ocaml_cv_cc_vendor=`grep '^[a-z]' conftest.i | tr -s ' ' '-'` -fi - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "unexpected preprocessor failure -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.err conftest.i conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ocaml_cv_cc_vendor" >&5 -$as_echo "$ocaml_cv_cc_vendor" >&6; } - - ## Determine which flags to use for the C compiler case $ocaml_cv_cc_vendor in #( @@ -12456,7 +12459,7 @@ case $ocaml_cv_cc_vendor in #( outputobj='-o $(EMPTY)'; gcc_warnings="-qflag=i:i" ;; #( # all warnings enabled msvc-*) : - outputobj=-Fo; CPP="cl -nologo -EP"; gcc_warnings="" ;; #( + outputobj=-Fo; gcc_warnings="" ;; #( *) : outputobj='-o $(EMPTY)'; case 4.10.0+dev2-2019-10-18 in #( *+dev*) : @@ -13542,6 +13545,24 @@ fi ;; #( ;; esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler supports __attribute__((aligned(n)))" >&5 +$as_echo_n "checking whether the C compiler supports __attribute__((aligned(n)))... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +typedef struct {__attribute__((aligned(8))) int t;} t; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + $as_echo "#define SUPPORTS_ALIGNED_ATTRIBUTE 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # Configure the native-code compiler arch=none diff --git a/configure.ac b/configure.ac index b5d44c0476..c4953bd4d3 100644 --- a/configure.ac +++ b/configure.ac @@ -436,6 +436,9 @@ AS_CASE([$host], mklib="rm -f \$(1) && ${AR} rc \$(1) \$(2) && ${RANLIB} \$(1)" ]) +## Find vendor of the C compiler +OCAML_CC_VENDOR + # Determine how to call the C preprocessor directly. # Most of the time, calling the C preprocessor through the C compiler is # desirable and even important. @@ -447,8 +450,10 @@ AS_CASE([$host], # We thus figure out how to invoke the C preprocessor directly but # let the CPP variable untouched, except for the MSVC port where we set it # manually to make sure the backward compatibility is preserved -AS_CASE([$host], - [*-pc-windows], +AS_CASE([$ocaml_cv_cc_vendor], + [xlc-*], + [CPP="$CC -E -qnoppline"], # suppress incompatible XLC line directives + [msvc-*], [CPP="$CC -nologo -EP"]) # Libraries to build depending on the host @@ -513,16 +518,13 @@ AS_IF( ## Check for C99 support: done by libtool ## AC_PROG_CC_C99 -## Find vendor of the C compiler -OCAML_CC_VENDOR - ## Determine which flags to use for the C compiler AS_CASE([$ocaml_cv_cc_vendor], [xlc-*], [outputobj='-o $(EMPTY)'; gcc_warnings="-qflag=i:i"], # all warnings enabled [msvc-*], - [outputobj=-Fo; CPP="cl -nologo -EP"; gcc_warnings=""], + [outputobj=-Fo; gcc_warnings=""], [outputobj='-o $(EMPTY)'; AS_CASE([AC_PACKAGE_VERSION], [*+dev*], [gcc_warnings="-Wall -Werror"], @@ -843,6 +845,8 @@ AS_CASE(["$CC,$host"], AS_IF([$cc_has_fno_tree_vrp], [internal_cflags="$internal_cflags -fno-tree-vrp"])]) +OCAML_CC_SUPPORTS_ALIGNED + # Configure the native-code compiler arch=none diff --git a/runtime/caml/m.h.in b/runtime/caml/m.h.in index 1a1575db9b..4299643aa0 100644 --- a/runtime/caml/m.h.in +++ b/runtime/caml/m.h.in @@ -104,3 +104,5 @@ #undef FLAT_FLOAT_ARRAY #undef FUNCTION_SECTIONS + +#undef SUPPORTS_ALIGNED_ATTRIBUTE diff --git a/runtime/caml/misc.h b/runtime/caml/misc.h index 91457a303c..9c9ca28cc2 100644 --- a/runtime/caml/misc.h +++ b/runtime/caml/misc.h @@ -95,8 +95,13 @@ CAMLdeprecated_typedef(addr, char *); #define CAMLweakdef #endif -/* Alignment */ -#ifdef __GNUC__ +/* Alignment is necessary for domain_state.h, since the code generated */ +/* by ocamlopt makes direct references into the domain state structure,*/ +/* which is stored in a register on many platforms. For this to work, */ +/* we need to be able to compute the exact offset of each member. */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define CAMLalign(n) _Alignas(n) +#elif defined(SUPPORTS_ALIGNED_ATTRIBUTE) #define CAMLalign(n) __attribute__((aligned(n))) #elif _MSC_VER >= 1500 #define CAMLalign(n) __declspec(align(n)) |