From patchwork Fri Dec 6 21:54:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 102607 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7DE073858414 for ; Fri, 6 Dec 2024 21:56:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DE073858414 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=SrETJyaZ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by sourceware.org (Postfix) with ESMTPS id 78656385840E for ; Fri, 6 Dec 2024 21:55:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78656385840E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 78656385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733522135; cv=none; b=RhEpbAQzn7wYyLO74+syK36f0ZJYZCt8bdpZS2iMQFNWZprCSC7MhqBYuYbG6hAXe6ndyy2PgrUxK8im8ge7+JP99TG8mHWe6OUvvIeI3h2ILpYv3YM4+jWOQMrVUkjQTlMO51R9OhE/OfmV4ILmSDSatw6LgcvvD4VFPJJ8FGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733522135; c=relaxed/simple; bh=uq8fnz6p4HCXaRGqxldHGEqr5jCx62+mZvNGS6S1W7s=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=mMp8ShpMH1qXbr/riA2BNFskcznCzR+MGZpOpZldrxNZLvhqdo4DNtEifJGNee/YeR97i82Ec8AV/BjZ5Y6LIYBS+2buElk3cuzBy8aIpVuGfrlCWNhnb0KdeFCAATJr+StaGQmz/H9oBiEnRSTZy9NdlYgdH/Pd5wge1eKBBm8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78656385840E Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-6efa5bf5202so27172327b3.3 for ; Fri, 06 Dec 2024 13:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733522135; x=1734126935; darn=sourceware.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=DiENYi1GxCo9TOAD4eG+OfLuaVLuDMeP3SO+OdlUI+w=; b=SrETJyaZ6vAG4Wjx/dVpoZQHe6nE+AdWsGO67ZojRgm0g8oLrpFX1SLIspk9KNyE5K TDGg3fZ0KmgcU61t1oLt8X9hFKnbAGIMsP2ps3o69BM7K7E+TFC0NLDMsydqNe0kZTZx YsH+Md+UAYfqVk3Bwb24Iyrln6Iz2rxyOvEdUYuGqXVDTq95e2GULQtIQkX4IarIx3t0 H8RufrhgeHWvSD+3rm9Lr2cITRecwb1M7ey3723wscVRzaDvN5lX6Z18hlRo7HDlV+lF K4PK39A1Xy/fz32IwUTToYymDH5+8Vb0nGN94uG+DfDrVobvAAxWF6fn17nd9CIm+T3w C/lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733522135; x=1734126935; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DiENYi1GxCo9TOAD4eG+OfLuaVLuDMeP3SO+OdlUI+w=; b=aynAaKOrkA/eIu4TRdSyHFKJgollmkXPBhyIdIEvthctHikgCBfz04UvtmkSvmxtg3 LKjiKxlfHmBdTwPiQQInWzcCUrU9Y+j/g9VIIkoUFuly80wUBY04cC3ZOcMK5wgXanpp TpVk9BdF0mq0tAnMaVM1TEpBHuY2FZvdu06wRH19FDWfoeBtXOnyZ/5ur6K9dhgnXjKU di3o0ykgwCJEmMwf81Dz5iDynS/hT8QQ8+WFbRf1QQ3epTib3aSyDTqrbX6JVJSxDHCt MEBANkexe71ifH2Aak8r5ctEmL0KxJgFPdWT1O/qIxQGwy9nVoCBwDbTmy/j0TPFT4nw vx8w== X-Gm-Message-State: AOJu0YyK61VXH4xnvNigLPdyfAS6DVzeBqnZS3f1Y8mDQdC00osAIZ3A fh91aVP+YKW+nI/2oPs4NibnO6NC5NUdFx81Xkltlu4FEvzU02Q7cXoH8Rzwz2Fls9v95lSuyhe I1djW/5TEQtH4tnDYmDttQrdKcAfM1mNmkweiXJA2TZo= X-Gm-Gg: ASbGncsvVh18oeJJawlHtrM7qtRwaEAA/Q/ZgitUw48k4FBmHiJi95q7QnkLH2SmidJ cpqOXUd6FGNcPULzv9cB+oMIGuw8jQeM= X-Google-Smtp-Source: AGHT+IGSQXFfrrqI1p6o3htlApklJgn3pKJKIJFcwYEsll63Uuj8odSemc8pG44n3tAaXuri0dibgJwEGLpkix3hYdk= X-Received: by 2002:a05:690c:380b:b0:6ef:5688:f966 with SMTP id 00721157ae682-6efe3c861e3mr55005377b3.37.1733522134574; Fri, 06 Dec 2024 13:55:34 -0800 (PST) MIME-Version: 1.0 From: "H.J. Lu" Date: Sat, 7 Dec 2024 05:54:58 +0800 Message-ID: Subject: [PATCH v5] Add TEST_CC and TEST_CXX support To: GNU C Library , Sam James X-Spam-Status: No, score=-3017.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Changes in v5: 1. Fix a typo. 2. Update sysdeps/x86_64/configure.ac for GCC 6 --- 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. Also check compiler options with TEST_CC and TEST_CXX. 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. From 247d061d723a8c04c8bc6af1bd0ed7c6ddd445ca Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 6 Dec 2024 04:44:05 +0800 Subject: [PATCH v5] 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. Also check compiler options with TEST_CC and TEST_CXX. 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 --- INSTALL | 6 + Makefile.in | 26 ++++ configure | 253 ++++++++++++++++++++++++++++++++++-- configure.ac | 138 ++++++++++++++++++-- manual/install.texi | 9 ++ sysdeps/x86_64/configure | 122 +++++++++++++---- sysdeps/x86_64/configure.ac | 81 +++++++++--- 7 files changed, 567 insertions(+), 68 deletions(-) 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/configure b/configure index e99c0d23af..6eca24ae27 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 @@ -7128,6 +7158,37 @@ fi printf "%s\n" "$libc_cv_static_pie" >&6; } config_vars="$config_vars have-static-pie = $libc_cv_static_pie" +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 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -fpie" >&5 printf %s "checking for -fpie... " >&6; } @@ -7223,36 +7284,99 @@ printf "%s\n" "$libc_cv_mtls_descriptor" >&6; } config_vars="$config_vars have-mtls-descriptor = $libc_cv_mtls_descriptor" -{ 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} +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) cat > conftest.c < 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_test_mtls_descriptor=$mtls_descriptor + else + libc_cv_test_mtls_descriptor=no + fi + rm -f conftest* ;; +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 + + +wno_ignored_attributes_check () +{ + 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 + eval $1="-Wno-ignored-attributes" + fi + rm -f conftest* +} + +{ 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) wno_ignored_attributes_check libc_cv_wno_ignored_attributes ;; 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; } config_vars="$config_vars config-cflags-wno-ignored-attributes = $libc_cv_wno_ignored_attributes" +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) wno_ignored_attributes_check libc_cv_test_wno_ignored_attributes ;; +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 + { 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; } @@ -7430,6 +7554,37 @@ fi printf "%s\n" "$libc_cv_cc_signaling_nans" >&6; } config_vars="$config_vars config-cflags-signaling-nans = $libc_cv_cc_signaling_nans" +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 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC accepts -fno-tree-loop-distribute-patterns with \ __attribute__ ((__optimize__))" >&5 @@ -7490,6 +7645,37 @@ fi printf "%s\n" "$libc_cv_cc_wimplicit_fallthrough" >&6; } config_vars="$config_vars cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough" +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 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5 printf %s "checking for libgd... " >&6; } @@ -7753,6 +7939,46 @@ 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 +8470,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..e6260f7160 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]) @@ -1284,6 +1301,19 @@ LIBC_TRY_CC_OPTION([-static-pie], [libc_cv_static_pie=no]) ]) LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie]) +if test "$TEST_CC" = "$CC"; then + libc_cv_test_static_pie=$libc_cv_static_pie +else + saved_CC="$CC" + CC="$TEST_CC" + AC_CACHE_CHECK(for -static-pie in testing, libc_cv_test_static_pie, [dnl + LIBC_TRY_CC_OPTION([-static-pie], + [libc_cv_test_static_pie=yes], + [libc_cv_test_static_pie=no]) + ]) + CC="$saved_CC" +fi +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]) @@ -1333,27 +1363,70 @@ fi rm -f conftest*]) LIBC_CONFIG_VAR([have-mtls-descriptor], [$libc_cv_mtls_descriptor]) +if test "$TEST_CC" = "$CC"; then + libc_cv_test_mtls_descriptor=$libc_cv_mtls_descriptor +else + saved_CC="$CC" + CC="$TEST_CC" + AC_CACHE_CHECK([for tls descriptor support in testing], + libc_cv_test_mtls_descriptor, + [dnl + cat > conftest.c <&AS_MESSAGE_LOG_FD]) + then + libc_cv_test_mtls_descriptor=$mtls_descriptor + else + libc_cv_test_mtls_descriptor=no + fi + rm -f conftest*]) + CC="$saved_CC" +fi +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 < conftest.c <&6; } config_vars="$config_vars config-cflags-mprefer-vector-width = $libc_cv_cc_mprefer_vector_width" +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 -mprefer-vector-width=128 in testing" >&5 +printf %s "checking -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 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker that supports -z mark-plt" >&5 printf %s "checking for linker that supports -z mark-plt... " >&6; } @@ -66,30 +96,36 @@ 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 -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 < 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* ;; + eval $1=yes + else + eval $1=no + fi + rm -rf conftest* + } + + # Check if CET can be enabled. + { 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) check_config_clags_cf_protection libc_cv_x86_cet_available ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_x86_cet_available" >&5 @@ -97,6 +133,14 @@ printf "%s\n" "$libc_cv_x86_cet_available" >&6; } if test $libc_cv_x86_cet_available != yes; then as_fn_error $? "$CC doesn't support CET" "$LINENO" 5 fi + if test "$TEST_CC" = "$CC"; then + test_enable_cet=$libc_cv_x86_cet_available + else + saved_CC="$CC" + CC="$TEST_CC" + check_config_clags_cf_protection test_enable_cet + CC="$saved_CC" + fi fi if test $enable_cet != no; then # Check if assembler supports CET. @@ -139,33 +183,55 @@ config_vars="$config_vars enable-cet = $enable_cet" # Check if -mamx-tile works properly. -{ 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 < conftest.c < EOF - libc_cv_x86_have_amx_tile=no - if { ac_try='${CC-cc} -E $CFLAGS -mamx-tile conftest.c > conftest.i' + eval $1=no + if { ac_try='${CC-cc} -E $CFLAGS -mamx-tile conftest.c > conftest.i' { { 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* ;; + if grep -q __builtin_ia32_ldtilecfg conftest.i; then + eval $1=yes + fi + fi + rm -rf conftest* +} + +{ 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) check_x86_have_amx_tile libc_cv_x86_have_amx_tile ;; 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; } config_vars="$config_vars have-mamx-tile = $libc_cv_x86_have_amx_tile" +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) check_x86_have_amx_tile libc_cv_test_x86_have_amx_tile ;; +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; } +fi # Check if -mapxf is enabled. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -mapxf is enabled" >&5 diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac index c7b68544a2..ffd0292485 100644 --- a/sysdeps/x86_64/configure.ac +++ b/sysdeps/x86_64/configure.ac @@ -9,6 +9,19 @@ LIBC_TRY_CC_OPTION([-mprefer-vector-width=128], ]) LIBC_CONFIG_VAR([config-cflags-mprefer-vector-width], [$libc_cv_cc_mprefer_vector_width]) +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" + AC_CACHE_CHECK(-mprefer-vector-width=128 in testing, + libc_cv_test_cc_mprefer_vector_width, [dnl + LIBC_TRY_CC_OPTION([-mprefer-vector-width=128], + [libc_cv_test_cc_mprefer_vector_width=yes], + [libc_cv_test_cc_mprefer_vector_width=no]) + ]) + CC="$saved_CC" +fi LIBC_LINKER_FEATURE([-z mark-plt], [-Wl,-z,mark-plt], [libc_cv_z_mark_plt=yes], [libc_cv_z_mark_plt=no]) @@ -18,24 +31,38 @@ 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 <&AS_MESSAGE_LOG_FD); then - libc_cv_x86_cet_available=yes - else - libc_cv_x86_cet_available=no - fi - rm -rf conftest*]) + if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS -fcf-protection -include cet.h conftest.c 1>&AS_MESSAGE_LOG_FD); then + eval $1=yes + else + eval $1=no + fi + rm -rf conftest* + } + + # Check if CET can be enabled. + AC_CACHE_CHECK(whether CET can be enabled, + libc_cv_x86_cet_available, [dnl + check_config_clags_cf_protection libc_cv_x86_cet_available]) if test $libc_cv_x86_cet_available != yes; then AC_MSG_ERROR([$CC doesn't support CET]) fi + if test "$TEST_CC" = "$CC"; then + test_enable_cet=$libc_cv_x86_cet_available + else + saved_CC="$CC" + CC="$TEST_CC" + check_config_clags_cf_protection test_enable_cet + CC="$saved_CC" + fi fi if test $enable_cet != no; then # Check if assembler supports CET. @@ -62,19 +89,33 @@ 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 < conftest.c < 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*]) + eval $1=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 + eval $1=yes + fi + fi + rm -rf conftest* +} + +AC_CACHE_CHECK(whether -mamx-tile works properly, + libc_cv_x86_have_amx_tile, [dnl + check_x86_have_amx_tile libc_cv_x86_have_amx_tile]) LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_x86_have_amx_tile]) +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" + AC_CACHE_CHECK(whether -mamx-tile works properly in testing, + libc_cv_test_x86_have_amx_tile, [dnl + check_x86_have_amx_tile libc_cv_test_x86_have_amx_tile]) +fi # Check if -mapxf is enabled. AC_CACHE_CHECK(whether -mapxf is enabled, -- 2.47.1