From patchwork Fri Dec 6 07:15:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 102510 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 6E7E73858C51 for ; Fri, 6 Dec 2024 07:17:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E7E73858C51 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=KAety3R2 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by sourceware.org (Postfix) with ESMTPS id 99E5F3858C50 for ; Fri, 6 Dec 2024 07:16:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99E5F3858C50 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 99E5F3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733469365; cv=none; b=LcLmM1uBt/9oGEGCvtp4Jp7czAxsITORrmN2WnHlxzKv9Ey/bFwXgpibeeI2LbIlrSieYBRbf3/CVvAoupUyI5gq2skuDBHEvMW8tfwE6BdeprX8Htz6J3RIPAqKmckGGXgYL4ZXkkiUQKk6LVMNvl0PsOL7gFh4FvivA+0XzpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733469365; c=relaxed/simple; bh=zx3nZEZuSNUijB2nj4iTTcH3vGosNgDh9DsChn0QX30=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=VvbRJtfddETrL8z9aaVtlQhPwiKM8l9wjewtR4uhn+rkOT53mSwlvGoWubBcqKxKdw92fpLVrv2MqC0ndFoXzaCXNYTNt0k7jlfaNndTkz85hjnmfVNalg/OJrYph4wcKExssBfYcGzNdQOwYxRyGg+RmY1KpyCV9fyEoyjgtwQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-6ef6a67834fso15029267b3.2 for ; Thu, 05 Dec 2024 23:16:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733469349; x=1734074149; darn=sourceware.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=NNvO9KGscMVv3HwJmMcMp6eACsHsWVO46+dbsrUwk2U=; b=KAety3R2dsVSJ2K9maDARDQDAGSfC1xNaqfrQwhj1rOuVfQzAHxXrvvUTXEr0qzl1f AmuVrE2sS7jvR/rHUV1lfU2AudJfm6H3MeIjd5QtFnUIzSlPX44XQjLMAO2E/shT4PpP EpG7+47rqYvC+JYvYXSXXYfKGwKiMxTG4bZpAOqwfmwqXp6SULArZ5b2VvrI7HiSblxR jSyUlEPyagT5lH3OKzGcXNJuQYLV25XjiZ8vQM0GJmjudkVG+DYLA8vsEPdMJAWE6UJV RmeC75vODHn5DQ58GKZvqVNcXiw+rXgMnnE24XebxInRY8r3154ENQStOM6oT++LCMgR Ribw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733469349; x=1734074149; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NNvO9KGscMVv3HwJmMcMp6eACsHsWVO46+dbsrUwk2U=; b=qel993o8K2nV8TcZRTjUk0aKKxOtv8aZcoOho4JO/YjAD9HgRGaVflv3AiabUWH/qi oJXaOJ/PYa4wYryLnZkOytAaCOcs47zPis45u8zbnmFky8qoKwh6ItWABqNVDEPBVpHH IkX6BNU/Y40LDd9HuUGWVLoG7o+f6mikPpURF2ThFubne8u0RX33BdpGaXqOVZZPO/ab FWRfJ8B9Sta2ERIAykEX8WtIj2LCEXwvqsH0d8ejmj76mfRjYQMe2UlufCUd39hpZp+8 y+12wigd9kbnfFP9YQvaF/8EzTnp2zxP9y9oSjMUPG294EJO1Soms9RAr/qZP9/qQxM+ r5BQ== X-Gm-Message-State: AOJu0YxwqcVfP6v5+uhUcMA84aSqKBNfeiis+c1ghtFtFr0ejFzUzty3 rvcvVRLX08majbN1VqXXb0mI48Dbu9iYWW8yzJZBrjX+a2k36yZel54fDS+/HAa8yBGXL1oplMq EHCusgYFU/9FjaPAKv6e8Z+6howbTgrg17EiRmVUK X-Gm-Gg: ASbGncueDDtfAHHdco/GLeu39PiFGLmA11HJtomHfojQzh+C5m9llX4v/u1gD1PxVpQ ynRG52jhSF4Z9Sb7CX7iR+hc0d9zz7kU= X-Google-Smtp-Source: AGHT+IG6wvMcnxuDboYs3HumF2YO5mKca3LG/Pr7fOXA1gGtzXdOZCAFOh6LSYDE89GP1KpL5lrCu6Fei6Qnqrgezek= X-Received: by 2002:a05:690c:6081:b0:6ef:4ed2:7dda with SMTP id 00721157ae682-6efe3ac65afmr31181437b3.0.1733469349521; Thu, 05 Dec 2024 23:15:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "H.J. Lu" Date: Fri, 6 Dec 2024 15:15:13 +0800 Message-ID: Subject: [PATCH v2] Add TEST_CC and TEST_CXX support To: GNU C Library X-Spam-Status: No, score=-3017.3 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 On Fri, Dec 6, 2024 at 7:35 AM H.J. Lu wrote: > > 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. > Here is the v2 patch. Tested with GCC 14.2.1 build and GCC 11.2.1 test on x86-64. I got FAIL: math/test-float64x-fpclassify FAIL: math/test-float64x-isinf FAIL: math/test-float64x-isnan FAIL: math/test-ldouble-fpclassify FAIL: math/test-ldouble-isinf FAIL: math/test-ldouble-isnan More changes in configure.ac under sysdeps are needed to support older GCCs. From cfe2ac169f156915f894cbc2a2204832e4128247 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 6 Dec 2024 04:44:05 +0800 Subject: [PATCH v2] 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. Signed-off-by: H.J. Lu --- INSTALL | 6 ++ Makefile.in | 20 ++++ configure | 237 +++++++++++++++++++++++++++++++++++++++++++- configure.ac | 122 +++++++++++++++++++++++ manual/install.texi | 9 ++ 5 files changed, 393 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 24e3c8d25b..d35e2cb5f5 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="gi++-6.4.1" + The following list describes all of the available options for 'configure': diff --git a/Makefile.in b/Makefile.in index 3fe9e73645..4a839d5001 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,14 @@ srcdir = @srcdir@ +TEST_CC = @TEST_CC@ +TEST_CXX = @TEST_CXX@ +have-test-static-pie = @libc_cv_have_test_static_pie@ +have-mtls-descriptor = @libc_cv_test_mtls_descriptor@ +config-test-cflags-wno-ignored-attributes = @libc_cv_test_wno_ignored_attributes@ +config-test-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=$(have-test-static-pie) \ + have-mtls-descriptor=$(have-mtls-descriptor) \ + config-cflags-wno-ignored-attributes=$(config-test-cflags-wno-ignored-attributes) \ + config-cflags-signaling-nans=$(config-test-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..bae52c70c6 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_have_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_have_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_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_have_test_static_pie=yes +else case e in #( + e) libc_cv_have_test_static_pie=no ;; +esac +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; } + CC="$saved_CC" +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -fpie" >&5 printf %s "checking for -fpie... " >&6; } @@ -7225,6 +7283,45 @@ 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} @@ -7255,6 +7352,42 @@ fi 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_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_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_cc_signaling_nans" >&5 +printf "%s\n" "$libc_cv_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..1ffb7b6a73 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_have_test_static_pie=$libc_cv_static_pie +else + saved_CC="$CC" + CC="$TEST_CC" + AC_CACHE_CHECK(for -static-pie in testing, libc_cv_static_pie, [dnl + LIBC_TRY_CC_OPTION([-static-pie], + [libc_cv_have_test_static_pie=yes], + [libc_cv_have_test_static_pie=no]) + ]) + CC="$saved_CC" +fi +AC_SUBST(libc_cv_have_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,6 +1364,33 @@ 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 @@ -1355,6 +1412,29 @@ fi rm -f conftest*]) LIBC_CONFIG_VAR([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" + AC_CACHE_CHECK([if -Wno-ignored-attributes is required for aliases in testing], + libc_cv_wno_ignored_attributes, [dnl + cat > conftest.c <