From patchwork Fri Dec 6 12:16:07 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: 102534 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 7F5D03858D28 for ; Fri, 6 Dec 2024 12:17:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F5D03858D28 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=bor6t8KM X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by sourceware.org (Postfix) with ESMTPS id 8BEF03858D28 for ; Fri, 6 Dec 2024 12:16:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BEF03858D28 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 8BEF03858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733487404; cv=none; b=Z8a+Ydpg1ail86OzjBuEjxm0OQnuRZjBtS8DCesL2wgayQyu7bbMvxIwQAyyv0njMxGRM20kjahPapdRyrsEnFIOySvTzLN/6ZndmElpnvYYjAU2rOqY02BZJCEH3dqYzd2w6Ca4Zv4Jp38y0S6x1ZqSyIRf2WnUpsnBu505pYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733487404; c=relaxed/simple; bh=d/oQW0Asi8TSgZdd0fOW7nf1boj4tT5eCoqUAO7D6FI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=jcxewL+8hmVpolifYoYKIB4Fni+cH+uHmEx0HqupIdm/+rhEGl9duwQ7kFKoQhY+k171xHqLvdrEqcTKI1V6b4hOtChHGbjPwKOffGtgIv9w70Y2StP3GZfERGzepVukN37kjytzg+9QAXa+bmHSnNeekAVqWNA5ddYZV3koR1U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BEF03858D28 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-6ef0cee54daso18948907b3.3 for ; Fri, 06 Dec 2024 04:16:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733487403; x=1734092203; darn=sourceware.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=ZVGe92hb9e7eAZIcqPSA86HLCeq7LB/DolH/CZ/87E8=; b=bor6t8KMYe1qJdJPH2xyrQuIz43oTKBII9GV5mt0LU2GR/LqCHOuvDGYxqpPWZr8my Qh0F8IxsNM2+FSh4xSCHnuuZ19ibtVdAYyDnvz/2xM7/AvXhXeEjdT+dNWKLDo718FyK HtFua+G84AMXTNSRjQwPhVaQHCKKlx0QmYS/dVpWmfcEUC5O3fZCpXw5P23qNx7dzZDZ g0OJx65zDKA6vBRheVMnShhju47kFfp8Spg14o24xNdijdkvaPCbLjHyQgLelSUTOzrB Fj/ItwnKaSUDSsRLXYJW0nCOgdvBxNlO+52w/puonC0drtlqqA5oVl6UkZLY/UQJavrx gMlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733487403; x=1734092203; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZVGe92hb9e7eAZIcqPSA86HLCeq7LB/DolH/CZ/87E8=; b=kPA3aSYN3ZKBzWii9qI0Vj+Bl5ZttiKcIrB+UxDXfLId6YkzoQ++yBkUGZxZCZSOgA 3rWOAfAAp+6P3SFH4WdM3Lta7TEFznBUr2zrwqUZw77yLNPMY2wGN3qBiJOz7n+7sXvY ncpHLLqz/AINDexuaelGZmRDU605g4ALGftnewv0lSot+7m6UY/BODukKLDkkiJkkB4h 5Exo+xWFas+ZPMHSiprponTk60RB8txxewYgdr6BrChdxAcfwpplNLTs8HtYEQFklN5M Cd3JWNqDtUdSXrMDDuFD5KD8cXaj9NjMmQpwhdk9kAssh+joiNW9Lxfe9+NgBHa0o8oU t2eQ== X-Gm-Message-State: AOJu0Yyf/QQFfv3sirOYeXEdX92eOlRZAYb0f98PBV07nA/oTsxCnF1k +fu8pzubaiGFJTAOWlifCsRjGhoSV6jzN6bcqW7yqeDcGjOKVWBrzWZZf0ogMBRh2sSgb5z0C1K 7axCKOhVyLdAKGhZV7tCrCjeqgVGb6ogC0hZ096LIsIQ= X-Gm-Gg: ASbGnct0aQwPFqhS/so33raqRZjs4hS6jQGQy0T9WhA1so7A22QKKMmsPJRNW1+lRci Dd5r+JbzMZrV0PRUsrcpcVRV7QXchHlQ= X-Google-Smtp-Source: AGHT+IF1SgFOLEpzzOR56+kRZay/Q+qKR438PA5S2z7EsoCbT8rixlb6jTajMOfrfbwyRxD3PEDr1lPPhikBWOtLEoQ= X-Received: by 2002:a05:690c:450c:b0:6ef:4ed2:7df5 with SMTP id 00721157ae682-6efe3bce9afmr35938837b3.9.1733487403559; Fri, 06 Dec 2024 04:16:43 -0800 (PST) MIME-Version: 1.0 From: "H.J. Lu" Date: Fri, 6 Dec 2024 20:16:07 +0800 Message-ID: Subject: [PATCH v3] Add TEST_CC and TEST_CXX support To: GNU C Library , Sam James X-Spam-Status: No, score=-3017.2 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 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="gi++-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, building with GCC 14.2.1 and testing with GCC 11.2.1. It doesn't work with older GCC yet. From 2dd73000078325516d46198d10c60676589e113a Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 6 Dec 2024 04:44:05 +0800 Subject: [PATCH v3] 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="gi++-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, building with GCC 14.2.1 and testing with GCC 11.2.1. Signed-off-by: H.J. Lu --- INSTALL | 6 ++ Makefile.in | 20 ++++ configure | 243 +++++++++++++++++++++++++++++++++++++++++++- configure.ac | 124 +++++++++++++++++++++- manual/install.texi | 9 ++ 5 files changed, 397 insertions(+), 5 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..57f69635e7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,14 @@ srcdir = @srcdir@ +TEST_CC = @TEST_CC@ +TEST_CXX = @TEST_CXX@ +test-have-static-pie = @libc_cv_test_static_pie@ +test-have-mtls-descriptor = @libc_cv_test_mtls_descriptor@ +test-config-cflags-wno-ignored-attributes = @libc_cv_test_wno_ignored_attributes@ +test-config-cflags-signaling-nans = @libc_cv_test_cc_signaling_nans@ +test-cc-option-wimplicit-fallthrough = @libc_cv_test_cc_wimplicit_fallthrough@ +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 +17,17 @@ 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)" \ + have-static-pie=$(test-have-static-pie) \ + have-mtls-descriptor=$(test-have-mtls-descriptor) \ + config-cflags-wno-ignored-attributes=$(test-config-cflags-wno-ignored-attributes) \ + config-cflags-signaling-nans=$(test-config-cflags-signaling-nans) \ + cc-option-wimplicit-fallthrough=$(test-cc-option-wimplicit-fallthrough) \ + 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 9bcf62dca5..2a7932b2d7 100755 --- a/configure +++ b/configure @@ -641,16 +641,22 @@ 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_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 @@ -705,12 +711,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 @@ -820,10 +828,12 @@ CFLAGS LDFLAGS LIBS CPPFLAGS +TEST_CC CPP CXX CXXFLAGS -CCC' +CCC +TEST_CXX' ac_subdirs_all='' # Initialize some variables set by options. @@ -1524,9 +1534,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. @@ -3807,6 +3819,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 @@ -4281,6 +4297,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 @@ -4358,6 +4382,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 @@ -7129,6 +7156,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; } @@ -7225,9 +7283,48 @@ 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 + 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 <&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 + + { 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 ${libc_cv_test_wno_ignored_attributes+y} then : printf %s "(cached) " >&6 else case e in #( @@ -7251,10 +7348,46 @@ fi rm -f conftest* ;; 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; } +{ 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; } 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_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_test_wno_ignored_attributes="-Wno-ignored-attributes" + fi + rm -f conftest* ;; +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; } + 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; } @@ -7432,6 +7565,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 @@ -7492,6 +7656,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; } @@ -7755,6 +7950,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) : diff --git a/configure.ac b/configure.ac index 895bd5267d..3886b64c5c 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]) @@ -1334,12 +1364,39 @@ rm -f conftest*]) AC_SUBST(libc_cv_mtls_descriptor) 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 + libc_cv_test_wno_ignored_attributes, [dnl cat > conftest.c < conftest.c <