diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-12-06 04:44:05 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-12-11 18:31:00 +0800 |
commit | b79f25753346a577c9ba0a3dca69bd9d9d72a020 (patch) | |
tree | b126cf018240a668e5bb8b742029fd9632745c15 | |
parent | 4d9a4c02f9327338bb8dc890d26fbbeef956ba1b (diff) | |
download | glibc-b79f25753346a577c9ba0a3dca69bd9d9d72a020.zip glibc-b79f25753346a577c9ba0a3dca69bd9d9d72a020.tar.gz glibc-b79f25753346a577c9ba0a3dca69bd9d9d72a020.tar.bz2 |
Add TEST_CC and TEST_CXX support
Support testing glibc build with a different C compiler or a different
C++ compiler with
$ ../glibc-VERSION/configure TEST_CC="gcc-6.4.1" TEST_CXX="g++-6.4.1"
1. Add LIBC_TRY_CC_AND_TEST_CC_OPTION, LIBC_TRY_CC_AND_TEST_CC_COMMAND
and LIBC_TRY_CC_AND_TEST_LINK to test both CC and TEST_CC.
2. Add check and xcheck targets to Makefile.in and override build compiler
options with ones from TEST_CC and TEST_CXX.
Tested on Fedora 41/x86-64:
1. Building with GCC 14.2.1 and testing with GCC 6.4.1 and GCC 11.2.1.
2. Building with GCC 15 and testing with GCC 6.4.1.
Support for GCC versions older than GCC 6.2 may need to change the test
sources. Other targets may need to update configure.ac under sysdeps and
modify Makefile.in to override target build compiler options.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
-rw-r--r-- | INSTALL | 6 | ||||
-rw-r--r-- | Makefile.in | 26 | ||||
-rw-r--r-- | aclocal.m4 | 83 | ||||
-rwxr-xr-x | configure | 329 | ||||
-rw-r--r-- | configure.ac | 125 | ||||
-rw-r--r-- | manual/install.texi | 9 | ||||
-rwxr-xr-x | sysdeps/x86_64/configure | 172 | ||||
-rw-r--r-- | sysdeps/x86_64/configure.ac | 68 |
8 files changed, 682 insertions, 136 deletions
@@ -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 3fe9e73..ee92704 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` $@ @@ -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 <<EOF +$2 +EOF +AC_CACHE_CHECK([$1], $4, [dnl + if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $3 conftest.c -o conftest 1>&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 +]) @@ -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<library> CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> + 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; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tls descriptor support" >&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 <<EOF +conftest_code=" __thread int i; void foo (void) { i = 10; } +" + +cat > conftest.c <<EOF +$conftest_code EOF -if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=$mtls_descriptor -nostdlib -nostartfiles - -shared conftest.c -o conftest 1>&5' +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tls descriptor support" >&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) 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_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; } -config_vars="$config_vars -have-mtls-descriptor = $libc_cv_mtls_descriptor" +if test "$TEST_CC" = "$CC"; then + libc_cv_test_mtls_descriptor=$libc_cv_mtls_descriptor +else -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -Wno-ignored-attributes is required for aliases" >&5 -printf %s "checking if -Wno-ignored-attributes is required for aliases... " >&6; } -if test ${libc_cv_wno_ignored_attributes+y} +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) cat > conftest.c <<EOF + 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 <<EOF +$conftest_code EOF -libc_cv_wno_ignored_attributes="" -if ! { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c' +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -Wno-ignored-attributes is required for aliases" >&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) 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_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 06a9c3f..1b0e07d 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 <<EOF +conftest_code=" __thread int i; void foo (void) { i = 10; } -EOF -if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=$mtls_descriptor -nostdlib -nostartfiles - -shared conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD]) -then - libc_cv_mtls_descriptor=$mtls_descriptor -else - libc_cv_mtls_descriptor=no -fi -rm -f conftest*]) +" +LIBC_TRY_CC_AND_TEST_CC_COMMAND([for tls descriptor support], + [$conftest_code], + [-fPIC -mtls-dialect=$mtls_descriptor -nostdlib -nostartfiles -shared], + libc_cv_mtls_descriptor, + [libc_cv_mtls_descriptor=$mtls_descriptor], + [libc_cv_mtls_descriptor=no], + libc_cv_test_mtls_descriptor, + [libc_cv_test_mtls_descriptor=$mtls_descriptor], + [libc_cv_test_mtls_descriptor=no]) LIBC_CONFIG_VAR([have-mtls-descriptor], [$libc_cv_mtls_descriptor]) +AC_SUBST(libc_cv_test_mtls_descriptor) dnl clang emits an warning for a double alias redirection, to warn the dnl original symbol is sed even when weak definition overrides it. dnl It is a usual pattern for weak_alias, where multiple alias point to dnl same symbol. -AC_CACHE_CHECK([if -Wno-ignored-attributes is required for aliases], - libc_cv_wno_ignored_attributes, [dnl -cat > conftest.c <<EOF +conftest_code=" void __foo (void) { } extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo"))); extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo"))); -EOF -libc_cv_wno_ignored_attributes="" -if ! AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c]) -then - libc_cv_wno_ignored_attributes="-Wno-ignored-attributes" -fi -rm -f conftest*]) +" +LIBC_TRY_CC_AND_TEST_CC_COMMAND([if -Wno-ignored-attributes is required for aliases], + [$conftest_code], + [-c -Werror -Wno-ignored-attributes], + libc_cv_wno_ignored_attributes, + [libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"], + [libc_cv_wno_ignored_attributes=], + libc_cv_test_wno_ignored_attributes, + [libc_cv_test_wno_ignored_attributes="-Wno-ignored-attributes"], + [libc_cv_test_wno_ignored_attributes=]) LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes], [$libc_cv_wno_ignored_attributes]) +AC_SUBST(libc_cv_test_wno_ignored_attributes) AC_CACHE_CHECK(whether cc puts quotes around section names, libc_cv_have_section_quotes, @@ -1440,14 +1461,17 @@ fi AC_SUBST(libc_cv_cc_submachine) dnl Determine if compiler supports -fsignaling-nans -AC_CACHE_CHECK([for compiler option that -fsignaling-nans], - libc_cv_cc_signaling_nans, [dnl -LIBC_TRY_CC_OPTION([-Werror -fsignaling-nans], - [libc_cv_cc_signaling_nans=-fsignaling-nans], - [libc_cv_cc_signaling_nans=]) -]) +LIBC_TRY_CC_AND_TEST_CC_OPTION([for compiler option that -fsignaling-nans], + [-Werror -fsignaling-nans], + libc_cv_cc_signaling_nans, + [libc_cv_cc_signaling_nans=-fsignaling-nans], + [libc_cv_cc_signaling_nans=], + libc_cv_test_cc_signaling_nans, + [libc_cv_test_cc_signaling_nans=-fsignaling-nans], + [libc_cv_test_cc_signaling_nans=]) LIBC_CONFIG_VAR([config-cflags-signaling-nans], [$libc_cv_cc_signaling_nans]) +AC_SUBST(libc_cv_test_cc_signaling_nans) AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \ __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl @@ -1467,14 +1491,17 @@ if test $libc_cv_cc_loop_to_function = yes; then fi AC_SUBST(libc_cv_cc_loop_to_function) -AC_CACHE_CHECK([for -Wimplicit-fallthrough], - libc_cv_cc_wimplicit_fallthrough, [dnl -LIBC_TRY_CC_OPTION([-Werror -Wimplicit-fallthrough], - [libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough], - [libc_cv_cc_wimplicit_fallthrough=]) -]) +LIBC_TRY_CC_AND_TEST_CC_OPTION([for -Wimplicit-fallthrough], + [-Werror -Wimplicit-fallthrough], + libc_cv_cc_wimplicit_fallthrough, + [libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough], + [libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough], + libc_cv_test_cc_wimplicit_fallthrough, + [libc_cv_test_cc_wimplicit_fallthrough=-Wimplicit-fallthrough], + [libc_cv_test_cc_wimplicit_fallthrough=]) LIBC_CONFIG_VAR([cc-option-wimplicit-fallthrough], [$libc_cv_cc_wimplicit_fallthrough]) +AC_SUBST(libc_cv_test_cc_wimplicit_fallthrough) dnl Check whether we have the gd library available. AC_MSG_CHECKING(for libgd) @@ -1538,12 +1565,15 @@ dnl support it no_fortify_source="-U_FORTIFY_SOURCE" fortify_source="${no_fortify_source}" -AC_CACHE_CHECK([for maximum supported _FORTIFY_SOURCE level], - [libc_cv_supported_fortify_source], [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_dynamic_object_size("", 0)])], - [libc_cv_supported_fortify_source=3], - [libc_cv_supported_fortify_source=2]) -]) +LIBC_TRY_CC_AND_TEST_LINK([for maximum supported _FORTIFY_SOURCE level], + [__builtin_dynamic_object_size("", 0)], + libc_cv_supported_fortify_source, + [libc_cv_supported_fortify_source=3], + [libc_cv_supported_fortify_source=2], + libc_cv_test_supported_fortify_source, + [libc_cv_test_supported_fortify_source=3], + [libc_cv_test_supported_fortify_source=2]) +AC_SUBST(libc_cv_test_supported_fortify_source) AS_CASE([$enable_fortify_source], [yes], [libc_cv_fortify_source=yes enable_fortify_source=$libc_cv_supported_fortify_source], @@ -1835,6 +1865,11 @@ if test "$libc_cv_static_pie" = "yes"; then fi LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie]) +# Support configure.ac under sysdeps. +AC_SUBST(libc_cv_test_cc_mprefer_vector_width) +AC_SUBST(test_enable_cet) +AC_SUBST(libc_cv_test_x86_have_amx_tile) + # 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/manual/install.texi b/manual/install.texi index 3e68a3d..61745b8 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -75,6 +75,15 @@ and @theglibc{} cannot be compiled without optimization, so if $ ../glibc-@var{version}/configure CC="gcc -m32" CFLAGS="-O3" @end smallexample +To test @theglibc{} with a different C compiler or a different C++ +compiler, @samp{TEST_CC=@var{compiler}} and +@samp{TEST_CXX=@var{compiler}} arguments can be passed to +@code{configure}. For example: + +@smallexample +$ ../glibc-@var{version}/configure TEST_CC="gcc-6.4.1" TEST_CXX="g++-6.4.1" +@end smallexample + The following list describes all of the available options for @code{configure}: diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure index 231e6ff..5846b67 100755 --- a/sysdeps/x86_64/configure +++ b/sysdeps/x86_64/configure @@ -1,8 +1,9 @@ # This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/x86_64. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking -mprefer-vector-width=128" >&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 <<EOF +$conftest_code +EOF +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CET can be enabled" >&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 <<EOF -#if !defined __CET__ || __CET__ != 3 -# error CET isn't available. -#endif -EOF - if { ac_try='${CC-cc} -c $CFLAGS -fcf-protection -include cet.h conftest.c 1>&5' + 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_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 <x86intrin.h> +" + +cat > conftest.c <<EOF +$conftest_code +EOF { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -mamx-tile works properly" >&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 -#include <x86intrin.h> -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 c7b6854..fcf457d 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 <<EOF + conftest_code=" #if !defined __CET__ || __CET__ != 3 -# error CET isn't available. +# error CET is not available. #endif -EOF - if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS -fcf-protection -include cet.h conftest.c 1>&AS_MESSAGE_LOG_FD); then - libc_cv_x86_cet_available=yes - else - libc_cv_x86_cet_available=no - fi - rm -rf conftest*]) +" + LIBC_TRY_CC_AND_TEST_CC_COMMAND([whether CET can be enabled], + [$conftest_code], + [-c -fcf-protection -include cet.h], + libc_cv_x86_cet_available, + [libc_cv_x86_cet_available=yes], + [libc_cv_x86_cet_available=no], + libc_cv_test_x86_cet_available, + [libc_cv_test_x86_cet_available=yes], + [libc_cv_test_x86_cet_available=no]) + test_enable_cet=$libc_cv_test_x86_cet_available if test $libc_cv_x86_cet_available != yes; then AC_MSG_ERROR([$CC doesn't support CET]) fi @@ -62,18 +68,26 @@ fi LIBC_CONFIG_VAR([enable-cet], [$enable_cet]) # Check if -mamx-tile works properly. -AC_CACHE_CHECK(whether -mamx-tile works properly, - libc_cv_x86_have_amx_tile, [dnl -cat > conftest.c <<EOF +check_x86_have_amx_tile () +{ + eval $1=no + if grep -q __builtin_ia32_ldtilecfg conftest; then + eval $1=yes + fi +} + +conftest_code=" #include <x86intrin.h> -EOF - libc_cv_x86_have_amx_tile=no - if AC_TRY_COMMAND(${CC-cc} -E $CFLAGS -mamx-tile conftest.c > conftest.i); then - if grep -q __builtin_ia32_ldtilecfg conftest.i; then - libc_cv_x86_have_amx_tile=yes - fi - fi - rm -rf conftest*]) +" +LIBC_TRY_CC_AND_TEST_CC_COMMAND([whether -mamx-tile works properly], + [$conftest_code], + [-E -mamx-tile], + libc_cv_x86_have_amx_tile, + [check_x86_have_amx_tile libc_cv_x86_have_amx_tile], + [libc_cv_x86_have_amx_tile=no], + libc_cv_test_x86_have_amx_tile, + [check_x86_have_amx_tile libc_cv_test_x86_have_amx_tile], + [libc_cv_test_x86_have_amx_tile=no]) LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_x86_have_amx_tile]) # Check if -mapxf is enabled. |