The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

configure: rework and cache C11 atomics CFLAGS detection

+60 -195
+31 -18
aclocal.m4
··· 495 495 done 496 496 ]) 497 497 498 - AC_DEFUN([OCAML_CC_SUPPORTS_ATOMIC], [ 499 - OCAML_CC_SAVE_VARIABLES 500 - 501 - opts="" 502 - AS_IF([test -n "$1"],[CFLAGS="$CFLAGS $1"; opts="$1"]) 503 - AS_IF([test -n "$2"],[LIBS="$LIBS $2"; opts="${opts:+$opts }$2"]) 504 - AC_MSG_CHECKING(m4_normalize([if $CC supports _Atomic types with 505 - ${opts:-no additional options}])) 506 - 507 - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 498 + # OCAML_CC_C11_ATOMIC_CFLAGS([LIBS]) 499 + AC_DEFUN([OCAML_CC_C11_ATOMIC_CFLAGS], [ 500 + AC_MSG_CHECKING([for options needed to enable C11 atomic support]) 501 + AC_CACHE_VAL([ocaml_cv_prog_cc_c11_atomic_cflags], 502 + [ocaml_cv_prog_cc_c11_atomic_cflags=no 503 + for ocaml_arg in dnl 504 + ''dnl 505 + '-experimental:c11atomics'dnl 506 + '-std:c11'dnl remove with Autoconf 2.73 as cl will default to C11 507 + '-std:c11 -experimental:c11atomics'dnl same 508 + ; do 509 + OCAML_CC_SAVE_VARIABLES 510 + CFLAGS="$CFLAGS $ocaml_arg" 511 + AS_IF([test -n "$1"], [LIBS="$LIBS $1"]) 512 + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 508 513 #include <stdint.h> 509 514 #include <stdatomic.h> 510 - ]],[[ 515 + ]],[[ 511 516 _Atomic int64_t n; 512 517 int m; 513 518 int * _Atomic p = &m; ··· 515 520 * atomic_exchange(&p, 0) = 45; 516 521 if (atomic_load_explicit(&n, memory_order_acquire)) 517 522 return 1; 518 - ]])], 519 - [cc_supports_atomic=true 520 - AC_MSG_RESULT([yes])], 521 - [cc_supports_atomic=false 522 - AC_MSG_RESULT([no])]) 523 - 524 - OCAML_CC_RESTORE_VARIABLES 523 + ]])], 524 + [AS_IF([test x"$ocaml_arg" = x], 525 + [ocaml_cv_prog_cc_c11_atomic_cflags=''], 526 + [ocaml_cv_prog_cc_c11_atomic_cflags="$ocaml_arg"]) 527 + OCAML_CC_RESTORE_VARIABLES 528 + break]) 529 + OCAML_CC_RESTORE_VARIABLES 530 + done]) 531 + AS_IF([test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = xno], 532 + [AC_MSG_FAILURE(m4_normalize( 533 + [C11 atomic support is required, use another C compiler]))], 534 + [AS_IF([test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = x], 535 + [AC_MSG_RESULT([none needed])], 536 + [AC_MSG_RESULT([$ocaml_cv_prog_cc_c11_atomic_cflags]) 537 + common_cflags="$common_cflags $ocaml_cv_prog_cc_c11_atomic_cflags"])]) 525 538 ]) 526 539 527 540 # Detects whether the C compiler generates an explicit .note.GNU-stack section
+28 -165
configure
··· 18473 18473 # Support for C11 atomic types 18474 18474 18475 18475 18476 - 18477 - saved_CC="$CC" 18478 - saved_CFLAGS="$CFLAGS" 18479 - saved_CPPFLAGS="$CPPFLAGS" 18480 - saved_LIBS="$LIBS" 18481 - saved_ac_ext="$ac_ext" 18482 - saved_ac_compile="$ac_compile" 18483 - # Move the content of confdefs.h to another file so it does not 18484 - # get included 18485 - mv confdefs.h confdefs.h.bak 18486 - touch confdefs.h 18487 - 18488 - 18489 - opts="" 18490 - if test -n "" 18476 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for options needed to enable C11 atomic support" >&5 18477 + printf %s "checking for options needed to enable C11 atomic support... " >&6; } 18478 + if test ${ocaml_cv_prog_cc_c11_atomic_cflags+y} 18491 18479 then : 18492 - CFLAGS="$CFLAGS "; opts="" 18493 - fi 18494 - if test -n "$cclibs" 18495 - then : 18496 - LIBS="$LIBS $cclibs"; opts="${opts:+$opts }$cclibs" 18497 - fi 18498 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports _Atomic types with ${opts:-no additional options}" >&5 18499 - printf %s "checking if $CC supports _Atomic types with ${opts:-no additional options}... " >&6; } 18500 - 18501 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 18502 - /* end confdefs.h. */ 18503 - 18504 - #include <stdint.h> 18505 - #include <stdatomic.h> 18506 - 18507 - int 18508 - main (void) 18509 - { 18510 - 18511 - _Atomic int64_t n; 18512 - int m; 18513 - int * _Atomic p = &m; 18514 - atomic_store_explicit(&n, 123, memory_order_release); 18515 - * atomic_exchange(&p, 0) = 45; 18516 - if (atomic_load_explicit(&n, memory_order_acquire)) 18517 - return 1; 18518 - 18519 - ; 18520 - return 0; 18521 - } 18522 - _ACEOF 18523 - if ac_fn_c_try_link "$LINENO" 18524 - then : 18525 - cc_supports_atomic=true 18526 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 18527 - printf "%s\n" "yes" >&6; } 18480 + printf %s "(cached) " >&6 18528 18481 else $as_nop 18529 - cc_supports_atomic=false 18530 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 18531 - printf "%s\n" "no" >&6; } 18532 - fi 18533 - rm -f core conftest.err conftest.$ac_objext conftest.beam \ 18534 - conftest$ac_exeext conftest.$ac_ext 18535 - 18536 - 18537 - # Restore the content of confdefs.h 18538 - mv confdefs.h.bak confdefs.h 18539 - ac_compile="$saved_ac_compile" 18540 - ac_ext="$saved_ac_ext" 18541 - CPPFLAGS="$saved_CPPFLAGS" 18542 - CFLAGS="$saved_CFLAGS" 18543 - CC="$saved_CC" 18544 - LIBS="$saved_LIBS" 18545 - 18546 - 18547 - case $cc_supports_atomic,$ocaml_cc_vendor in #( 18548 - false,msvc-*) : 18549 - 18482 + ocaml_cv_prog_cc_c11_atomic_cflags=no 18483 + for ocaml_arg in '' '-experimental:c11atomics' '-std:c11' '-std:c11 -experimental:c11atomics' ; do 18550 18484 18551 18485 saved_CC="$CC" 18552 18486 saved_CFLAGS="$CFLAGS" ··· 18559 18493 mv confdefs.h confdefs.h.bak 18560 18494 touch confdefs.h 18561 18495 18562 - 18563 - opts="" 18564 - if test -n "-std:c11" 18565 - then : 18566 - CFLAGS="$CFLAGS -std:c11"; opts="-std:c11" 18567 - fi 18568 - if test -n "" 18496 + CFLAGS="$CFLAGS $ocaml_arg" 18497 + if test -n "$cclibs" 18569 18498 then : 18570 - LIBS="$LIBS "; opts="${opts:+$opts }" 18499 + LIBS="$LIBS $cclibs" 18571 18500 fi 18572 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports _Atomic types with ${opts:-no additional options}" >&5 18573 - printf %s "checking if $CC supports _Atomic types with ${opts:-no additional options}... " >&6; } 18574 - 18575 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 18501 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 18576 18502 /* end confdefs.h. */ 18577 18503 18578 18504 #include <stdint.h> ··· 18596 18522 _ACEOF 18597 18523 if ac_fn_c_try_link "$LINENO" 18598 18524 then : 18599 - cc_supports_atomic=true 18600 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 18601 - printf "%s\n" "yes" >&6; } 18525 + if test x"$ocaml_arg" = x 18526 + then : 18527 + ocaml_cv_prog_cc_c11_atomic_cflags='' 18602 18528 else $as_nop 18603 - cc_supports_atomic=false 18604 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 18605 - printf "%s\n" "no" >&6; } 18529 + ocaml_cv_prog_cc_c11_atomic_cflags="$ocaml_arg" 18606 18530 fi 18607 - rm -f core conftest.err conftest.$ac_objext conftest.beam \ 18608 - conftest$ac_exeext conftest.$ac_ext 18609 - 18610 18531 18611 18532 # Restore the content of confdefs.h 18612 18533 mv confdefs.h.bak confdefs.h ··· 18617 18538 CC="$saved_CC" 18618 18539 LIBS="$saved_LIBS" 18619 18540 18620 - 18621 - if $cc_supports_atomic 18622 - then : 18623 - common_cflags="$common_cflags -std:c11" 18624 - else $as_nop 18625 - 18626 - 18627 - saved_CC="$CC" 18628 - saved_CFLAGS="$CFLAGS" 18629 - saved_CPPFLAGS="$CPPFLAGS" 18630 - saved_LIBS="$LIBS" 18631 - saved_ac_ext="$ac_ext" 18632 - saved_ac_compile="$ac_compile" 18633 - # Move the content of confdefs.h to another file so it does not 18634 - # get included 18635 - mv confdefs.h confdefs.h.bak 18636 - touch confdefs.h 18637 - 18638 - 18639 - opts="" 18640 - if test -n "-std:c11 -experimental:c11atomics" 18641 - then : 18642 - CFLAGS="$CFLAGS -std:c11 -experimental:c11atomics"; opts="-std:c11 -experimental:c11atomics" 18643 - fi 18644 - if test -n "" 18645 - then : 18646 - LIBS="$LIBS "; opts="${opts:+$opts }" 18647 - fi 18648 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports _Atomic types with ${opts:-no additional options}" >&5 18649 - printf %s "checking if $CC supports _Atomic types with ${opts:-no additional options}... " >&6; } 18650 - 18651 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 18652 - /* end confdefs.h. */ 18653 - 18654 - #include <stdint.h> 18655 - #include <stdatomic.h> 18656 - 18657 - int 18658 - main (void) 18659 - { 18660 - 18661 - _Atomic int64_t n; 18662 - int m; 18663 - int * _Atomic p = &m; 18664 - atomic_store_explicit(&n, 123, memory_order_release); 18665 - * atomic_exchange(&p, 0) = 45; 18666 - if (atomic_load_explicit(&n, memory_order_acquire)) 18667 - return 1; 18668 - 18669 - ; 18670 - return 0; 18671 - } 18672 - _ACEOF 18673 - if ac_fn_c_try_link "$LINENO" 18674 - then : 18675 - cc_supports_atomic=true 18676 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 18677 - printf "%s\n" "yes" >&6; } 18678 - else $as_nop 18679 - cc_supports_atomic=false 18680 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 18681 - printf "%s\n" "no" >&6; } 18541 + break 18682 18542 fi 18683 18543 rm -f core conftest.err conftest.$ac_objext conftest.beam \ 18684 18544 conftest$ac_exeext conftest.$ac_ext 18685 - 18686 18545 18687 18546 # Restore the content of confdefs.h 18688 18547 mv confdefs.h.bak confdefs.h ··· 18693 18552 CC="$saved_CC" 18694 18553 LIBS="$saved_LIBS" 18695 18554 18696 - 18697 - if $cc_supports_atomic 18698 - then : 18699 - common_cflags="$common_cflags -std:c11 -experimental:c11atomics" 18555 + done 18700 18556 fi 18701 18557 18702 - fi ;; #( 18703 - *) : 18704 - ;; 18705 - esac 18706 - if ! $cc_supports_atomic 18558 + if test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = xno 18707 18559 then : 18708 18560 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 18709 18561 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} 18710 18562 as_fn_error $? "C11 atomic support is required, use another C compiler 18711 18563 See \`config.log' for more details" "$LINENO" 5; } 18564 + else $as_nop 18565 + if test "x$ocaml_cv_prog_cc_c11_atomic_cflags" = x 18566 + then : 18567 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 18568 + printf "%s\n" "none needed" >&6; } 18569 + else $as_nop 18570 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ocaml_cv_prog_cc_c11_atomic_cflags" >&5 18571 + printf "%s\n" "$ocaml_cv_prog_cc_c11_atomic_cflags" >&6; } 18572 + common_cflags="$common_cflags $ocaml_cv_prog_cc_c11_atomic_cflags" 18712 18573 fi 18574 + fi 18575 + 18713 18576 18714 18577 # Full support for thread local storage 18715 18578 # macOS and MinGW-w64 have problems with thread local storage accessed from DLLs
+1 -12
configure.ac
··· 1461 1461 1462 1462 # Support for C11 atomic types 1463 1463 1464 - OCAML_CC_SUPPORTS_ATOMIC([], [$cclibs]) 1465 - AS_CASE([$cc_supports_atomic,$ocaml_cc_vendor], 1466 - [false,msvc-*], 1467 - [OCAML_CC_SUPPORTS_ATOMIC([-std:c11]) 1468 - AS_IF([$cc_supports_atomic], 1469 - [common_cflags="$common_cflags -std:c11"], 1470 - [OCAML_CC_SUPPORTS_ATOMIC([-std:c11 -experimental:c11atomics]) 1471 - AS_IF([$cc_supports_atomic], 1472 - [common_cflags="$common_cflags -std:c11 -experimental:c11atomics"]) 1473 - ])]) 1474 - AS_IF([! $cc_supports_atomic], 1475 - [AC_MSG_FAILURE([C11 atomic support is required, use another C compiler])]) 1464 + OCAML_CC_C11_ATOMIC_CFLAGS([$cclibs]) 1476 1465 1477 1466 # Full support for thread local storage 1478 1467 # macOS and MinGW-w64 have problems with thread local storage accessed from DLLs