···495495 done
496496])
497497498498-AC_DEFUN([OCAML_CC_SUPPORTS_ATOMIC], [
499499- OCAML_CC_SAVE_VARIABLES
500500-501501- opts=""
502502- AS_IF([test -n "$1"],[CFLAGS="$CFLAGS $1"; opts="$1"])
503503- AS_IF([test -n "$2"],[LIBS="$LIBS $2"; opts="${opts:+$opts }$2"])
504504- AC_MSG_CHECKING(m4_normalize([if $CC supports _Atomic types with
505505- ${opts:-no additional options}]))
506506-507507- AC_LINK_IFELSE([AC_LANG_PROGRAM([[
498498+# OCAML_CC_C11_ATOMIC_CFLAGS([LIBS])
499499+AC_DEFUN([OCAML_CC_C11_ATOMIC_CFLAGS], [
500500+ AC_MSG_CHECKING([for options needed to enable C11 atomic support])
501501+ AC_CACHE_VAL([ocaml_cv_prog_cc_c11_atomic_cflags],
502502+ [ocaml_cv_prog_cc_c11_atomic_cflags=no
503503+ for ocaml_arg in dnl
504504+ ''dnl
505505+ '-experimental:c11atomics'dnl
506506+ '-std:c11'dnl remove with Autoconf 2.73 as cl will default to C11
507507+ '-std:c11 -experimental:c11atomics'dnl same
508508+ ; do
509509+ OCAML_CC_SAVE_VARIABLES
510510+ CFLAGS="$CFLAGS $ocaml_arg"
511511+ AS_IF([test -n "$1"], [LIBS="$LIBS $1"])
512512+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
508513#include <stdint.h>
509514#include <stdatomic.h>
510510- ]],[[
515515+ ]],[[
511516 _Atomic int64_t n;
512517 int m;
513518 int * _Atomic p = &m;
···515520 * atomic_exchange(&p, 0) = 45;
516521 if (atomic_load_explicit(&n, memory_order_acquire))
517522 return 1;
518518- ]])],
519519- [cc_supports_atomic=true
520520- AC_MSG_RESULT([yes])],
521521- [cc_supports_atomic=false
522522- AC_MSG_RESULT([no])])
523523-524524- OCAML_CC_RESTORE_VARIABLES
523523+ ]])],
524524+ [AS_IF([test x"$ocaml_arg" = x],
525525+ [ocaml_cv_prog_cc_c11_atomic_cflags=''],
526526+ [ocaml_cv_prog_cc_c11_atomic_cflags="$ocaml_arg"])
527527+ OCAML_CC_RESTORE_VARIABLES
528528+ break])
529529+ OCAML_CC_RESTORE_VARIABLES
530530+ done])
531531+ AS_IF([test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = xno],
532532+ [AC_MSG_FAILURE(m4_normalize(
533533+ [C11 atomic support is required, use another C compiler]))],
534534+ [AS_IF([test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = x],
535535+ [AC_MSG_RESULT([none needed])],
536536+ [AC_MSG_RESULT([$ocaml_cv_prog_cc_c11_atomic_cflags])
537537+ common_cflags="$common_cflags $ocaml_cv_prog_cc_c11_atomic_cflags"])])
525538])
526539527540# Detects whether the C compiler generates an explicit .note.GNU-stack section
+28-165
configure
···1847318473# Support for C11 atomic types
184741847418475184751847618476-1847718477- saved_CC="$CC"
1847818478- saved_CFLAGS="$CFLAGS"
1847918479- saved_CPPFLAGS="$CPPFLAGS"
1848018480- saved_LIBS="$LIBS"
1848118481- saved_ac_ext="$ac_ext"
1848218482- saved_ac_compile="$ac_compile"
1848318483- # Move the content of confdefs.h to another file so it does not
1848418484- # get included
1848518485- mv confdefs.h confdefs.h.bak
1848618486- touch confdefs.h
1848718487-1848818488-1848918489- opts=""
1849018490- if test -n ""
1847618476+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for options needed to enable C11 atomic support" >&5
1847718477+printf %s "checking for options needed to enable C11 atomic support... " >&6; }
1847818478+ if test ${ocaml_cv_prog_cc_c11_atomic_cflags+y}
1849118479then :
1849218492- CFLAGS="$CFLAGS "; opts=""
1849318493-fi
1849418494- if test -n "$cclibs"
1849518495-then :
1849618496- LIBS="$LIBS $cclibs"; opts="${opts:+$opts }$cclibs"
1849718497-fi
1849818498- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports _Atomic types with ${opts:-no additional options}" >&5
1849918499-printf %s "checking if $CC supports _Atomic types with ${opts:-no additional options}... " >&6; }
1850018500-1850118501- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1850218502-/* end confdefs.h. */
1850318503-1850418504-#include <stdint.h>
1850518505-#include <stdatomic.h>
1850618506-1850718507-int
1850818508-main (void)
1850918509-{
1851018510-1851118511- _Atomic int64_t n;
1851218512- int m;
1851318513- int * _Atomic p = &m;
1851418514- atomic_store_explicit(&n, 123, memory_order_release);
1851518515- * atomic_exchange(&p, 0) = 45;
1851618516- if (atomic_load_explicit(&n, memory_order_acquire))
1851718517- return 1;
1851818518-1851918519- ;
1852018520- return 0;
1852118521-}
1852218522-_ACEOF
1852318523-if ac_fn_c_try_link "$LINENO"
1852418524-then :
1852518525- cc_supports_atomic=true
1852618526- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1852718527-printf "%s\n" "yes" >&6; }
1848018480+ printf %s "(cached) " >&6
1852818481else $as_nop
1852918529- cc_supports_atomic=false
1853018530- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
1853118531-printf "%s\n" "no" >&6; }
1853218532-fi
1853318533-rm -f core conftest.err conftest.$ac_objext conftest.beam \
1853418534- conftest$ac_exeext conftest.$ac_ext
1853518535-1853618536-1853718537- # Restore the content of confdefs.h
1853818538- mv confdefs.h.bak confdefs.h
1853918539- ac_compile="$saved_ac_compile"
1854018540- ac_ext="$saved_ac_ext"
1854118541- CPPFLAGS="$saved_CPPFLAGS"
1854218542- CFLAGS="$saved_CFLAGS"
1854318543- CC="$saved_CC"
1854418544- LIBS="$saved_LIBS"
1854518545-1854618546-1854718547-case $cc_supports_atomic,$ocaml_cc_vendor in #(
1854818548- false,msvc-*) :
1854918549-1848218482+ ocaml_cv_prog_cc_c11_atomic_cflags=no
1848318483+ for ocaml_arg in '' '-experimental:c11atomics' '-std:c11' '-std:c11 -experimental:c11atomics' ; do
18550184841855118485 saved_CC="$CC"
1855218486 saved_CFLAGS="$CFLAGS"
···1855918493 mv confdefs.h confdefs.h.bak
1856018494 touch confdefs.h
18561184951856218562-1856318563- opts=""
1856418564- if test -n "-std:c11"
1856518565-then :
1856618566- CFLAGS="$CFLAGS -std:c11"; opts="-std:c11"
1856718567-fi
1856818568- if test -n ""
1849618496+ CFLAGS="$CFLAGS $ocaml_arg"
1849718497+ if test -n "$cclibs"
1856918498then :
1857018570- LIBS="$LIBS "; opts="${opts:+$opts }"
1849918499+ LIBS="$LIBS $cclibs"
1857118500fi
1857218572- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports _Atomic types with ${opts:-no additional options}" >&5
1857318573-printf %s "checking if $CC supports _Atomic types with ${opts:-no additional options}... " >&6; }
1857418574-1857518575- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1850118501+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1857618502/* end confdefs.h. */
18577185031857818504#include <stdint.h>
···1859618522_ACEOF
1859718523if ac_fn_c_try_link "$LINENO"
1859818524then :
1859918599- cc_supports_atomic=true
1860018600- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1860118601-printf "%s\n" "yes" >&6; }
1852518525+ if test x"$ocaml_arg" = x
1852618526+then :
1852718527+ ocaml_cv_prog_cc_c11_atomic_cflags=''
1860218528else $as_nop
1860318603- cc_supports_atomic=false
1860418604- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
1860518605-printf "%s\n" "no" >&6; }
1852918529+ ocaml_cv_prog_cc_c11_atomic_cflags="$ocaml_arg"
1860618530fi
1860718607-rm -f core conftest.err conftest.$ac_objext conftest.beam \
1860818608- conftest$ac_exeext conftest.$ac_ext
1860918609-18610185311861118532 # Restore the content of confdefs.h
1861218533 mv confdefs.h.bak confdefs.h
···1861718538 CC="$saved_CC"
1861818539 LIBS="$saved_LIBS"
18619185401862018620-1862118621- if $cc_supports_atomic
1862218622-then :
1862318623- common_cflags="$common_cflags -std:c11"
1862418624-else $as_nop
1862518625-1862618626-1862718627- saved_CC="$CC"
1862818628- saved_CFLAGS="$CFLAGS"
1862918629- saved_CPPFLAGS="$CPPFLAGS"
1863018630- saved_LIBS="$LIBS"
1863118631- saved_ac_ext="$ac_ext"
1863218632- saved_ac_compile="$ac_compile"
1863318633- # Move the content of confdefs.h to another file so it does not
1863418634- # get included
1863518635- mv confdefs.h confdefs.h.bak
1863618636- touch confdefs.h
1863718637-1863818638-1863918639- opts=""
1864018640- if test -n "-std:c11 -experimental:c11atomics"
1864118641-then :
1864218642- CFLAGS="$CFLAGS -std:c11 -experimental:c11atomics"; opts="-std:c11 -experimental:c11atomics"
1864318643-fi
1864418644- if test -n ""
1864518645-then :
1864618646- LIBS="$LIBS "; opts="${opts:+$opts }"
1864718647-fi
1864818648- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports _Atomic types with ${opts:-no additional options}" >&5
1864918649-printf %s "checking if $CC supports _Atomic types with ${opts:-no additional options}... " >&6; }
1865018650-1865118651- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1865218652-/* end confdefs.h. */
1865318653-1865418654-#include <stdint.h>
1865518655-#include <stdatomic.h>
1865618656-1865718657-int
1865818658-main (void)
1865918659-{
1866018660-1866118661- _Atomic int64_t n;
1866218662- int m;
1866318663- int * _Atomic p = &m;
1866418664- atomic_store_explicit(&n, 123, memory_order_release);
1866518665- * atomic_exchange(&p, 0) = 45;
1866618666- if (atomic_load_explicit(&n, memory_order_acquire))
1866718667- return 1;
1866818668-1866918669- ;
1867018670- return 0;
1867118671-}
1867218672-_ACEOF
1867318673-if ac_fn_c_try_link "$LINENO"
1867418674-then :
1867518675- cc_supports_atomic=true
1867618676- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1867718677-printf "%s\n" "yes" >&6; }
1867818678-else $as_nop
1867918679- cc_supports_atomic=false
1868018680- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
1868118681-printf "%s\n" "no" >&6; }
1854118541+ break
1868218542fi
1868318543rm -f core conftest.err conftest.$ac_objext conftest.beam \
1868418544 conftest$ac_exeext conftest.$ac_ext
1868518685-18686185451868718546 # Restore the content of confdefs.h
1868818547 mv confdefs.h.bak confdefs.h
···1869318552 CC="$saved_CC"
1869418553 LIBS="$saved_LIBS"
18695185541869618696-1869718697- if $cc_supports_atomic
1869818698-then :
1869918699- common_cflags="$common_cflags -std:c11 -experimental:c11atomics"
1855518555+ done
1870018556fi
18701185571870218702-fi ;; #(
1870318703- *) :
1870418704- ;;
1870518705-esac
1870618706-if ! $cc_supports_atomic
1855818558+ if test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = xno
1870718559then :
1870818560 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
1870918561printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
1871018562as_fn_error $? "C11 atomic support is required, use another C compiler
1871118563See \`config.log' for more details" "$LINENO" 5; }
1856418564+else $as_nop
1856518565+ if test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = x
1856618566+then :
1856718567+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
1856818568+printf "%s\n" "none needed" >&6; }
1856918569+else $as_nop
1857018570+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ocaml_cv_prog_cc_c11_atomic_cflags" >&5
1857118571+printf "%s\n" "$ocaml_cv_prog_cc_c11_atomic_cflags" >&6; }
1857218572+ common_cflags="$common_cflags $ocaml_cv_prog_cc_c11_atomic_cflags"
1871218573fi
1857418574+fi
1857518575+18713185761871418577# Full support for thread local storage
1871518578# macOS and MinGW-w64 have problems with thread local storage accessed from DLLs
+1-12
configure.ac
···1461146114621462# Support for C11 atomic types
1463146314641464-OCAML_CC_SUPPORTS_ATOMIC([], [$cclibs])
14651465-AS_CASE([$cc_supports_atomic,$ocaml_cc_vendor],
14661466- [false,msvc-*],
14671467- [OCAML_CC_SUPPORTS_ATOMIC([-std:c11])
14681468- AS_IF([$cc_supports_atomic],
14691469- [common_cflags="$common_cflags -std:c11"],
14701470- [OCAML_CC_SUPPORTS_ATOMIC([-std:c11 -experimental:c11atomics])
14711471- AS_IF([$cc_supports_atomic],
14721472- [common_cflags="$common_cflags -std:c11 -experimental:c11atomics"])
14731473-])])
14741474-AS_IF([! $cc_supports_atomic],
14751475- [AC_MSG_FAILURE([C11 atomic support is required, use another C compiler])])
14641464+OCAML_CC_C11_ATOMIC_CFLAGS([$cclibs])
1476146514771466# Full support for thread local storage
14781467# macOS and MinGW-w64 have problems with thread local storage accessed from DLLs