diff --git a/INSTALL b/INSTALL index 24e3c8d25b..85c8e4cef1 100644 --- a/INSTALL +++ b/INSTALL @@ -49,6 +49,12 @@ if 'CFLAGS' is specified it must enable optimization. For example: $ ../glibc-VERSION/configure CC="gcc -m32" CFLAGS="-O3" + To test the GNU C Library with a different C compiler or a different +C++ compiler, 'TEST_CC=COMPILER' and 'TEST_CXX=COMPILER' arguments can +be passed to 'configure'. For example: + + $ ../glibc-VERSION/configure TEST_CC="gcc-6.4.1" TEST_CXX="g++-6.4.1" + The following list describes all of the available options for 'configure': diff --git a/Makefile.in b/Makefile.in index 3fe9e73645..ee9270491e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,17 @@ srcdir = @srcdir@ +TEST_CC = @TEST_CC@ +TEST_CXX = @TEST_CXX@ +test-cc-option-wimplicit-fallthrough = @libc_cv_test_cc_wimplicit_fallthrough@ +test-config-cflags-mprefer-vector-width = @libc_cv_test_cc_mprefer_vector_width@ +test-config-cflags-signaling-nans = @libc_cv_test_cc_signaling_nans@ +test-config-cflags-wno-ignored-attributes = @libc_cv_test_wno_ignored_attributes@ +test-enable-cet = @test_enable_cet@ +test-have-mamx-tile = @libc_cv_test_x86_have_amx_tile@ +test-have-mtls-descriptor = @libc_cv_test_mtls_descriptor@ +test-have-static-pie = @libc_cv_test_static_pie@ +test-supported-fortify = @libc_cv_test_supported_fortify_source@ + # Uncomment the line below if you want to do parallel build. # PARALLELMFLAGS = -j 4 @@ -8,6 +20,20 @@ srcdir = @srcdir@ all .DEFAULT: $(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@ +check xcheck: + $(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) \ + CC="$(TEST_CC)" CXX="$(TEST_CXX)" \ + cc-option-wimplicit-fallthrough="$(test-cc-option-wimplicit-fallthrough)" \ + config-cflags-mprefer-vector-width="$(test-config-cflags-mprefer-vector-width)" \ + config-cflags-signaling-nans="$(test-config-cflags-signaling-nans)" \ + config-cflags-wno-ignored-attributes="$(test-config-cflags-wno-ignored-attributes)" \ + enable-cet="$(test-enable-cet)" \ + have-mamx-tile="$(test-have-mamx-tile)" \ + have-mtls-descriptor="$(test-have-mtls-descriptor)" \ + have-static-pie="$(test-have-static-pie)" \ + supported-fortify="$(test-supported-fortify)" \ + objdir=`pwd` $@ + install: LC_ALL=C; export LC_ALL; \ $(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@ diff --git a/aclocal.m4 b/aclocal.m4 index d8c613faf7..88ed3a6b71 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -315,3 +315,86 @@ case "$prefix" in fi ;; esac]) + +dnl Run a test with TEST_CC. +dnl LIBC_CHECK_TEST_CC([commands]) +AC_DEFUN([LIBC_CHECK_TEST_CC], +[ +saved_CC="$CC" +CC="$TEST_CC" +[$1] +CC="$saved_CC" +]) + +dnl Test a CC and TEST_CC compiler option or options with an empty input +dnl file. +dnl LIBC_TRY_CC_AND_TEST_CC_OPTION([message], [options], +dnl [CC-cache-id], [CC-action-if-true], [CC-action-if-false] +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_CC_AND_TEST_CC_OPTION], +[ +AC_CACHE_CHECK([$1], $3, + [LIBC_TRY_CC_OPTION([$2], [$4], [$5])]) +if test "$TEST_CC" = "$CC"; then + $6=$[$3] +else + LIBC_CHECK_TEST_CC( + AC_CACHE_CHECK([$1 in testing], $6, + [LIBC_TRY_CC_OPTION([$2], [$7], [$8])]) + ) +fi +]) + +dnl Test a CC and TEST_CC compiler option or options with an input file. +dnl LIBC_TRY_CC_AND_TEST_CC_COMMAND([message], [code], [options], +dnl [CC-cache-id], [CC-action-if-true], [CC-action-if-false] +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_CC_AND_TEST_CC_COMMAND], +[ +cat > conftest.c <&AS_MESSAGE_LOG_FD]) + then + [$5] + else + [$6] + fi +]) +if test "$TEST_CC" = "$CC"; then + $7=$[$4] +else + LIBC_CHECK_TEST_CC( + AC_CACHE_CHECK([$1 in testing], $7, [dnl + if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $3 conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD]) + then + [$8] + else + [$9] + fi]) + ) +fi +rm -f conftest*]) + +dnl Test if CC and TEST_CC can link with an input file. +dnl LIBC_TRY_CC_AND_TEST_LINK([message], [code], +dnl [CC-cache-id], [CC-action-if-true], [CC-action-if-false] +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_CC_AND_TEST_LINK], +[ +AC_CACHE_CHECK([$1], $3, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [$2])], + [$4], [$5]) +]) +if test "$TEST_CC" = "$CC"; then + $6=$[$3] +else + LIBC_CHECK_TEST_CC( + AC_CACHE_CHECK([$1 in testing], $6, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [$2])], + [$7], [$8]) + ]) + ) +fi +]) diff --git a/configure b/configure index e99c0d23af..fbfe849474 100755 --- a/configure +++ b/configure @@ -620,6 +620,9 @@ DEFINES static_nss profile libc_cv_multidir +libc_cv_test_x86_have_amx_tile +test_enable_cet +libc_cv_test_cc_mprefer_vector_width shared static ldd_rewrite_script @@ -641,15 +644,21 @@ fortify_source no_fortify_source libc_cv_fortify_source enable_fortify_source +libc_cv_test_supported_fortify_source have_selinux have_libcap have_libaudit LIBGD +libc_cv_test_cc_wimplicit_fallthrough libc_cv_cc_loop_to_function +libc_cv_test_cc_signaling_nans libc_cv_cc_submachine libc_cv_cc_nofma +libc_cv_test_wno_ignored_attributes +libc_cv_test_mtls_descriptor libc_cv_has_glob_dat libc_cv_fpie +libc_cv_test_static_pie libc_cv_z_execstack ASFLAGS_config libc_cv_cc_with_libunwind @@ -704,12 +713,14 @@ man_pages_version rtld_early_cflags extra_nonshared_cflags sysheaders +TEST_CXX ac_ct_CXX CXXFLAGS CXX CPP cross_compiling BUILD_CC +TEST_CC OBJEXT ac_ct_CC CPPFLAGS @@ -819,10 +830,12 @@ CFLAGS LDFLAGS LIBS CPPFLAGS +TEST_CC CPP CXX CXXFLAGS -CCC' +CCC +TEST_CXX' ac_subdirs_all='' # Initialize some variables set by options. @@ -1523,9 +1536,11 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory + TEST_CC C compiler for testing CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags + TEST_CXX C++ compiler for testing Use these variables to override the choices made by 'configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -3806,6 +3821,10 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + +if test -z "$TEST_CC"; then + TEST_CC="$CC" +fi if test $host != $build; then for ac_prog in gcc cc do @@ -4280,6 +4299,14 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + +if test -z "$TEST_CXX"; then + saved_CXX= + TEST_CXX="$CXX" +else + saved_CXX="$CXX" + CXX="$TEST_CXX" +fi # It's useless to us if it can't link programs (e.g. missing -lstdc++). { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX can link programs" >&5 @@ -4357,6 +4384,9 @@ if test $libc_cv_cxx_link_ok != yes then : CXX= fi +if test -n "$saved_CXX"; then + CXX="$saved_CXX" +fi if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then as_fn_error $? "you must configure in a separate build directory" "$LINENO" 5 @@ -7103,6 +7133,7 @@ printf "%s\n" "$libc_linker_feature" >&6; } config_vars="$config_vars have-no-dynamic-linker = $libc_cv_no_dynamic_linker" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5 printf %s "checking for -static-pie... " >&6; } if test ${libc_cv_static_pie+y} @@ -7120,15 +7151,49 @@ then : else case e in #( e) libc_cv_static_pie=no ;; esac -fi - ;; +fi ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_static_pie" >&5 printf "%s\n" "$libc_cv_static_pie" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_static_pie=$libc_cv_static_pie +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie in testing" >&5 +printf %s "checking for -static-pie in testing... " >&6; } +if test ${libc_cv_test_static_pie+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} -static-pie -xc /dev/null -S -o /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + libc_cv_test_static_pie=yes +else case e in #( + e) libc_cv_test_static_pie=no + ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_static_pie" >&5 +printf "%s\n" "$libc_cv_test_static_pie" >&6; } + +CC="$saved_CC" + +fi + config_vars="$config_vars have-static-pie = $libc_cv_static_pie" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -fpie" >&5 printf %s "checking for -fpie... " >&6; } if test ${libc_cv_fpie+y} @@ -7190,70 +7255,144 @@ fi printf "%s\n" "$libc_cv_has_glob_dat" >&6; } +conftest_code=" +__thread int i; +void foo (void) +{ + i = 10; +} +" + +cat > conftest.c <&5 printf %s "checking for tls descriptor support... " >&6; } if test ${libc_cv_mtls_descriptor+y} then : printf %s "(cached) " >&6 else case e in #( - e) cat > conftest.c <&5 (eval $ac_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } -then - libc_cv_mtls_descriptor=$mtls_descriptor -else - libc_cv_mtls_descriptor=no -fi -rm -f conftest* ;; + then + libc_cv_mtls_descriptor=$mtls_descriptor + else + libc_cv_mtls_descriptor=no + fi + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mtls_descriptor" >&5 printf "%s\n" "$libc_cv_mtls_descriptor" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_mtls_descriptor=$libc_cv_mtls_descriptor +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tls descriptor support in testing" >&5 +printf %s "checking for tls descriptor support in testing... " >&6; } +if test ${libc_cv_test_mtls_descriptor+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=$mtls_descriptor -nostdlib -nostartfiles -shared conftest.c -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_test_mtls_descriptor=$mtls_descriptor + else + libc_cv_test_mtls_descriptor=no + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_mtls_descriptor" >&5 +printf "%s\n" "$libc_cv_test_mtls_descriptor" >&6; } + +CC="$saved_CC" + +fi +rm -f conftest* config_vars="$config_vars have-mtls-descriptor = $libc_cv_mtls_descriptor" + +conftest_code=" +void __foo (void) +{ +} +extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo"))); +extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo"))); +" + +cat > conftest.c <&5 printf %s "checking if -Wno-ignored-attributes is required for aliases... " >&6; } if test ${libc_cv_wno_ignored_attributes+y} then : printf %s "(cached) " >&6 else case e in #( - e) cat > conftest.c <&5 (eval $ac_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } -then - libc_cv_wno_ignored_attributes="-Wno-ignored-attributes" -fi -rm -f conftest* ;; + then + libc_cv_wno_ignored_attributes="-Wno-ignored-attributes" + else + libc_cv_wno_ignored_attributes= + fi + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_wno_ignored_attributes" >&5 printf "%s\n" "$libc_cv_wno_ignored_attributes" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_wno_ignored_attributes=$libc_cv_wno_ignored_attributes +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -Wno-ignored-attributes is required for aliases in testing" >&5 +printf %s "checking if -Wno-ignored-attributes is required for aliases in testing... " >&6; } +if test ${libc_cv_test_wno_ignored_attributes+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c -Werror -Wno-ignored-attributes conftest.c -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_test_wno_ignored_attributes="-Wno-ignored-attributes" + else + libc_cv_test_wno_ignored_attributes= + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_wno_ignored_attributes" >&5 +printf "%s\n" "$libc_cv_test_wno_ignored_attributes" >&6; } + +CC="$saved_CC" + +fi +rm -f conftest* config_vars="$config_vars config-cflags-wno-ignored-attributes = $libc_cv_wno_ignored_attributes" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether cc puts quotes around section names" >&5 printf %s "checking whether cc puts quotes around section names... " >&6; } if test ${libc_cv_have_section_quotes+y} @@ -7405,6 +7544,7 @@ printf "%s\n" "$libc_cv_cc_submachine" >&6; } fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compiler option that -fsignaling-nans" >&5 printf %s "checking for compiler option that -fsignaling-nans... " >&6; } if test ${libc_cv_cc_signaling_nans+y} @@ -7422,15 +7562,48 @@ then : else case e in #( e) libc_cv_cc_signaling_nans= ;; esac -fi - ;; +fi ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_signaling_nans" >&5 printf "%s\n" "$libc_cv_cc_signaling_nans" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_cc_signaling_nans=$libc_cv_cc_signaling_nans +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compiler option that -fsignaling-nans in testing" >&5 +printf %s "checking for compiler option that -fsignaling-nans in testing... " >&6; } +if test ${libc_cv_test_cc_signaling_nans+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} -Werror -fsignaling-nans -xc /dev/null -S -o /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + libc_cv_test_cc_signaling_nans=-fsignaling-nans +else case e in #( + e) libc_cv_test_cc_signaling_nans= ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_signaling_nans" >&5 +printf "%s\n" "$libc_cv_test_cc_signaling_nans" >&6; } + +CC="$saved_CC" + +fi + config_vars="$config_vars config-cflags-signaling-nans = $libc_cv_cc_signaling_nans" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC accepts -fno-tree-loop-distribute-patterns with \ __attribute__ ((__optimize__))" >&5 printf %s "checking if $CC accepts -fno-tree-loop-distribute-patterns with \ @@ -7465,6 +7638,7 @@ if test $libc_cv_cc_loop_to_function = yes; then fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wimplicit-fallthrough" >&5 printf %s "checking for -Wimplicit-fallthrough... " >&6; } if test ${libc_cv_cc_wimplicit_fallthrough+y} @@ -7480,17 +7654,50 @@ else case e in #( then : libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough else case e in #( - e) libc_cv_cc_wimplicit_fallthrough= ;; + e) libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough ;; esac -fi - ;; +fi ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_wimplicit_fallthrough" >&5 printf "%s\n" "$libc_cv_cc_wimplicit_fallthrough" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_cc_wimplicit_fallthrough=$libc_cv_cc_wimplicit_fallthrough +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wimplicit-fallthrough in testing" >&5 +printf %s "checking for -Wimplicit-fallthrough in testing... " >&6; } +if test ${libc_cv_test_cc_wimplicit_fallthrough+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} -Werror -Wimplicit-fallthrough -xc /dev/null -S -o /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + libc_cv_test_cc_wimplicit_fallthrough=-Wimplicit-fallthrough +else case e in #( + e) libc_cv_test_cc_wimplicit_fallthrough= ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_wimplicit_fallthrough" >&5 +printf "%s\n" "$libc_cv_test_cc_wimplicit_fallthrough" >&6; } + +CC="$saved_CC" + +fi + config_vars="$config_vars cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5 printf %s "checking for libgd... " >&6; } if test "$with_gd" != "no"; then @@ -7721,6 +7928,7 @@ fi no_fortify_source="-U_FORTIFY_SOURCE" fortify_source="${no_fortify_source}" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for maximum supported _FORTIFY_SOURCE level" >&5 printf %s "checking for maximum supported _FORTIFY_SOURCE level... " >&6; } if test ${libc_cv_supported_fortify_source+y} @@ -7728,7 +7936,7 @@ then : printf %s "(cached) " >&6 else case e in #( e) - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -7753,6 +7961,50 @@ esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_supported_fortify_source" >&5 printf "%s\n" "$libc_cv_supported_fortify_source" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_supported_fortify_source=$libc_cv_supported_fortify_source +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for maximum supported _FORTIFY_SOURCE level in testing" >&5 +printf %s "checking for maximum supported _FORTIFY_SOURCE level in testing... " >&6; } +if test ${libc_cv_test_supported_fortify_source+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +__builtin_dynamic_object_size("", 0) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + libc_cv_test_supported_fortify_source=3 +else case e in #( + e) libc_cv_test_supported_fortify_source=2 ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_supported_fortify_source" >&5 +printf "%s\n" "$libc_cv_test_supported_fortify_source" >&6; } + +CC="$saved_CC" + +fi + + case $enable_fortify_source in #( yes) : @@ -8244,6 +8496,11 @@ fi config_vars="$config_vars enable-static-pie = $libc_cv_static_pie" +# Support configure.ac under sysdeps. + + + + # Set the `multidir' variable by grabbing the variable from the compiler. # We do it once and save the result in a generated makefile. libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory` diff --git a/configure.ac b/configure.ac index 06a9c3f252..1b0e07dfab 100644 --- a/configure.ac +++ b/configure.ac @@ -46,6 +46,11 @@ AC_CONFIG_SUBDIRS() AC_CANONICAL_HOST AC_PROG_CC +AC_ARG_VAR([TEST_CC], + [C compiler for testing]) +if test -z "$TEST_CC"; then + TEST_CC="$CC" +fi if test $host != $build; then AC_CHECK_PROGS(BUILD_CC, gcc cc) fi @@ -70,6 +75,15 @@ AC_ARG_ENABLE([static-c++-link-check], # We need the C++ compiler only for testing. AC_PROG_CXX +AC_ARG_VAR([TEST_CXX], + [C++ compiler for testing]) +if test -z "$TEST_CXX"; then + saved_CXX= + TEST_CXX="$CXX" +else + saved_CXX="$CXX" + CXX="$TEST_CXX" +fi # It's useless to us if it can't link programs (e.g. missing -lstdc++). AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl AC_LANG_PUSH([C++]) @@ -97,6 +111,9 @@ main() fi AC_LANG_POP([C++])]) AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=]) +if test -n "$saved_CXX"; then + CXX="$saved_CXX" +fi if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then AC_MSG_ERROR([you must configure in a separate build directory]) @@ -1278,12 +1295,14 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker], [libc_cv_no_dynamic_linker=no]) LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker]) -AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl -LIBC_TRY_CC_OPTION([-static-pie], - [libc_cv_static_pie=yes], - [libc_cv_static_pie=no]) -]) +LIBC_TRY_CC_AND_TEST_CC_OPTION(for -static-pie, [-static-pie], + libc_cv_static_pie, + [libc_cv_static_pie=yes], [libc_cv_static_pie=no], + libc_cv_test_static_pie, + [libc_cv_test_static_pie=yes], [libc_cv_test_static_pie=no] +) LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie]) +AC_SUBST(libc_cv_test_static_pie) AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no]) @@ -1314,46 +1333,48 @@ fi rm -f conftest*]) AC_SUBST(libc_cv_has_glob_dat) -AC_CACHE_CHECK([for tls descriptor support], libc_cv_mtls_descriptor, -[dnl -cat > conftest.c < conftest.c <&5 -printf %s "checking -mprefer-vector-width=128... " >&6; } + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -mprefer-vector-width=128" >&5 +printf %s "checking for -mprefer-vector-width=128... " >&6; } if test ${libc_cv_cc_mprefer_vector_width+y} then : printf %s "(cached) " >&6 @@ -18,12 +19,44 @@ then : else case e in #( e) libc_cv_cc_mprefer_vector_width=no ;; esac -fi - ;; +fi ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_mprefer_vector_width" >&5 printf "%s\n" "$libc_cv_cc_mprefer_vector_width" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_cc_mprefer_vector_width=$libc_cv_cc_mprefer_vector_width +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -mprefer-vector-width=128 in testing" >&5 +printf %s "checking for -mprefer-vector-width=128 in testing... " >&6; } +if test ${libc_cv_test_cc_mprefer_vector_width+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} -mprefer-vector-width=128 -xc /dev/null -S -o /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + libc_cv_test_cc_mprefer_vector_width=yes +else case e in #( + e) libc_cv_test_cc_mprefer_vector_width=no ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_mprefer_vector_width" >&5 +printf "%s\n" "$libc_cv_test_cc_mprefer_vector_width" >&6; } + +CC="$saved_CC" + +fi + config_vars="$config_vars config-cflags-mprefer-vector-width = $libc_cv_cc_mprefer_vector_width" @@ -66,34 +99,73 @@ if test x"$build_mathvec" = xnotset; then build_mathvec=yes fi +test_enable_cet=$enable_cet if test $enable_cet != no; then # Check if CET can be enabled. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CET can be enabled" >&5 + conftest_code=" +#if !defined __CET__ || __CET__ != 3 +# error CET is not available. +#endif +" + +cat > conftest.c <&5 printf %s "checking whether CET can be enabled... " >&6; } if test ${libc_cv_x86_cet_available+y} then : printf %s "(cached) " >&6 else case e in #( - e) cat > conftest.c <&5 (eval $ac_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - libc_cv_x86_cet_available=yes - else - libc_cv_x86_cet_available=no - fi - rm -rf conftest* ;; + test $ac_status = 0; }; } + then + libc_cv_x86_cet_available=yes + else + libc_cv_x86_cet_available=no + fi + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_x86_cet_available" >&5 printf "%s\n" "$libc_cv_x86_cet_available" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_x86_cet_available=$libc_cv_x86_cet_available +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CET can be enabled in testing" >&5 +printf %s "checking whether CET can be enabled in testing... " >&6; } +if test ${libc_cv_test_x86_cet_available+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c -fcf-protection -include cet.h conftest.c -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_test_x86_cet_available=yes + else + libc_cv_test_x86_cet_available=no + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_x86_cet_available" >&5 +printf "%s\n" "$libc_cv_test_x86_cet_available" >&6; } + +CC="$saved_CC" + +fi +rm -f conftest* + test_enable_cet=$libc_cv_test_x86_cet_available if test $libc_cv_x86_cet_available != yes; then as_fn_error $? "$CC doesn't support CET" "$LINENO" 5 fi @@ -139,31 +211,75 @@ config_vars="$config_vars enable-cet = $enable_cet" # Check if -mamx-tile works properly. +check_x86_have_amx_tile () +{ + eval $1=no + if grep -q __builtin_ia32_ldtilecfg conftest; then + eval $1=yes + fi +} + +conftest_code=" +#include +" + +cat > conftest.c <&5 printf %s "checking whether -mamx-tile works properly... " >&6; } if test ${libc_cv_x86_have_amx_tile+y} then : printf %s "(cached) " >&6 else case e in #( - e) cat > conftest.c < -EOF - libc_cv_x86_have_amx_tile=no - if { ac_try='${CC-cc} -E $CFLAGS -mamx-tile conftest.c > conftest.i' + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -E -mamx-tile conftest.c -o conftest 1>&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 (eval $ac_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - if grep -q __builtin_ia32_ldtilecfg conftest.i; then - libc_cv_x86_have_amx_tile=yes - fi - fi - rm -rf conftest* ;; + test $ac_status = 0; }; } + then + check_x86_have_amx_tile libc_cv_x86_have_amx_tile + else + libc_cv_x86_have_amx_tile=no + fi + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_x86_have_amx_tile" >&5 printf "%s\n" "$libc_cv_x86_have_amx_tile" >&6; } +if test "$TEST_CC" = "$CC"; then + libc_cv_test_x86_have_amx_tile=$libc_cv_x86_have_amx_tile +else + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -mamx-tile works properly in testing" >&5 +printf %s "checking whether -mamx-tile works properly in testing... " >&6; } +if test ${libc_cv_test_x86_have_amx_tile+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -E -mamx-tile conftest.c -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + check_x86_have_amx_tile libc_cv_test_x86_have_amx_tile + else + libc_cv_test_x86_have_amx_tile=no + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_x86_have_amx_tile" >&5 +printf "%s\n" "$libc_cv_test_x86_have_amx_tile" >&6; } + +CC="$saved_CC" + +fi +rm -f conftest* config_vars="$config_vars have-mamx-tile = $libc_cv_x86_have_amx_tile" diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac index c7b68544a2..fcf457d03b 100644 --- a/sysdeps/x86_64/configure.ac +++ b/sysdeps/x86_64/configure.ac @@ -2,11 +2,14 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. # Local configure fragment for sysdeps/x86_64. dnl Check if -mprefer-vector-width=128 works. -AC_CACHE_CHECK(-mprefer-vector-width=128, libc_cv_cc_mprefer_vector_width, [dnl -LIBC_TRY_CC_OPTION([-mprefer-vector-width=128], - [libc_cv_cc_mprefer_vector_width=yes], - [libc_cv_cc_mprefer_vector_width=no]) -]) +LIBC_TRY_CC_AND_TEST_CC_OPTION([for -mprefer-vector-width=128], + [-mprefer-vector-width=128], + libc_cv_cc_mprefer_vector_width, + [libc_cv_cc_mprefer_vector_width=yes], + [libc_cv_cc_mprefer_vector_width=no], + libc_cv_test_cc_mprefer_vector_width, + [libc_cv_test_cc_mprefer_vector_width=yes], + [libc_cv_test_cc_mprefer_vector_width=no]) LIBC_CONFIG_VAR([config-cflags-mprefer-vector-width], [$libc_cv_cc_mprefer_vector_width]) @@ -18,21 +21,24 @@ if test x"$build_mathvec" = xnotset; then build_mathvec=yes fi +test_enable_cet=$enable_cet if test $enable_cet != no; then # Check if CET can be enabled. - AC_CACHE_CHECK(whether CET can be enabled, - libc_cv_x86_cet_available, [dnl -cat > conftest.c < conftest.c <