From patchwork Fri Dec 6 12:23:00 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: 102536 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 0D6363858C78 for ; Fri, 6 Dec 2024 12:25:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D6363858C78 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=Bz8aasUZ 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 86AC53858D29 for ; Fri, 6 Dec 2024 12:23:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86AC53858D29 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 86AC53858D29 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=1733487817; cv=none; b=W32QUbaC4t/MsK/yaYcaTxRg8f0y1a1JqBo9VdqdkxE+j4FjEcG2YILeoF/3jaoumkjJMoxV+Mb07kincK2BLqA6YQy+wgIh89fxucg1b5qEhe3qa2rYHvo4KrhD11iAR6aakSwH32i+zejwPpsN2l4YaOwbDYfvrveNVYwrkyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733487817; c=relaxed/simple; bh=WF7P6vAYLNiq/Hqg2PeH0TBE6riU2JVZ0zuSEnWlfjY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=H3KP1PUSrE0+ZDeHZaC0ZyjfciTr8QcLpXRfl3gD0dMbZo6kj8M+OBPp4sCao6zygsumfYzK5S+3xDfjYFFfompEt6Dy3rK6jq+iaywpjyX03zm3deU+6WpOfR275lQx+2pGg5XViSGJ6Xq2I/bc1G83JwwlJT89TbDVcLZXBTM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86AC53858D29 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-6ef7640e484so19714777b3.3 for ; Fri, 06 Dec 2024 04:23:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733487817; x=1734092617; darn=sourceware.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=kV9Q8AplLR54rpnmL86qPqWcrMhw/ws9iN4I48sWE2k=; b=Bz8aasUZmxXdEmtwRqYdc/FothQC8q28cQAtEzJiE0L6T7ss8gT88DLeAJyKRzZBDs tyIylX3b266qW87USOYXFkkaippMRC5sDNMz4jXYnO8QwICX0H8eyHtZlFH8H3SSg+V1 qB5VlhLYCzlZPeIaKWitNoaxiIs4WJNsm1269SpHdUT4KX56hq8X3TrzI0jnl6oWYXhd 7M4nSO7Lk7Hz0Bn+3BXpzxuSC3dX2JuCdOnNM6ney0ngWZqjTT48D0x9vVQVvs73mJrz KfvjUytUFDmWTcZGTturocLG/1pyDXeo49w8lTOJexgmqi1PLuOwnp3sFI+0WObgSQPq nQIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733487817; x=1734092617; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kV9Q8AplLR54rpnmL86qPqWcrMhw/ws9iN4I48sWE2k=; b=Ljz+1phNLFqzCYgJ2ihpFP0W+uHXFsaszupSPF8l7NoM5TZ2LWVzDFqh4UVCe18awc pORuUBC7WPU9tr6hiQT/U3Lu5h78Pq8CojD56odKmqg8WZ3AOkgxk9sR2f0Ck1z0J9af Y9X7KYu+EPA4fIIWO/3hugyxL1pPggu9eGQ32DyYTq1FSdbf67s542TVjCwa2GVH9DV1 QxGhxZR57eDNmzMolQw/ehnYboHsIXIS8QAPC3twvCUuWoLaAgnUeSBUpmerT8cq538B cUpXudc7nej/kfSOA8+xtZ/XZqR9mmLz4KfN3rV/K9jFEA+WSF/8uMnYf4ccmJgD36uw 15vw== X-Gm-Message-State: AOJu0YwwTjbPmtJ+rge5LFprDOzqgbTie9wR1HdaTQD4fLo6PFqb6R2V kw2S4BGrRyOSvmRsm9td3RFUonJVr/6duy/lPwH86CKsIznkPfF2I4Ni7InK2k9Tt3mvL//Nk0i O59KrRHocNPs8P6mdvned9qnUJhykkNdjyabD4K258tY= X-Gm-Gg: ASbGnctMYhVhmIa6X35AmVHiCbBUIrEQtW6tiYWWDUwB8dnouA1FVKAy0ntEBACqjHz 7+JKPFJ6iuPrLgftbDGf7iA4wr8ppU2c= X-Google-Smtp-Source: AGHT+IHF532ZhI6a3WzvIfBY0uaiCJg3kYQwbSxEcZY/X/JSSWQq4XwrCy9FlE+3jUYxeqVhxuDLr5F6BPLQ3l+KBNg= X-Received: by 2002:a05:690c:6a0c:b0:6ef:4a57:fc7c with SMTP id 00721157ae682-6efe3bfae81mr24175717b3.16.1733487816723; Fri, 06 Dec 2024 04:23:36 -0800 (PST) MIME-Version: 1.0 From: "H.J. Lu" Date: Fri, 6 Dec 2024 20:23:00 +0800 Message-ID: Subject: [PATCH v4] Add TEST_CC and TEST_CXX support To: GNU C Library 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 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. Rebase against master. It doesn't work with older GCC yet. From 7152149742735940489f57d161a59329b33e92d9 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 6 Dec 2024 04:44:05 +0800 Subject: [PATCH v4] 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 e99c0d23af..2e622ccb13 100755 --- a/configure +++ b/configure @@ -641,15 +641,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 +710,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 +827,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 +1533,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 +3818,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 +4296,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 +4381,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 +7155,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,9 +7281,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 #( @@ -7249,10 +7346,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; } @@ -7430,6 +7563,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 +7654,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 +7948,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 06a9c3f252..3a90526b5d 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,12 +1363,39 @@ 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 + libc_cv_test_wno_ignored_attributes, [dnl cat > conftest.c < conftest.c <