From patchwork Thu Dec 5 23:35:14 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: 102503 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 E10A63858CDA for ; Thu, 5 Dec 2024 23:36:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E10A63858CDA 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=XXU6kfeg 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 B71153858D21 for ; Thu, 5 Dec 2024 23:35:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B71153858D21 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 B71153858D21 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=1733441751; cv=none; b=qWFDJ4naiotL+b3NZxAW1jFTf6kaYQXTdpSjefhBzyU0zMDcOPEByNciaLhi620kvoUJqNJ8J7e48eGEOsuxFllxHkGxJWFqiegP4v+u6sjomCCzaW3qbt7+8jmnk49mF/zlgUri+Xz+LOLdvNguoDZzuOKiR0n3PBTP0CvPOJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733441751; c=relaxed/simple; bh=lafS9yF9FGgU0HDuf/ykxpb+CeEKjP4xRO6i1bZKgg8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=aBbD42U//PPIEWmmvXcCR4ZDxcXceXktwfvoc7l7//v4EEG9Z55QUFccJtI8ByfK+SWcj0HNRMuyzvz4RaCQaFfMbjobP5ktYPXtu6U727bCOom12zk5Z4KOZW09lkV2Hiox1ka4wdIkYrTgY9+9E/6Z1IAeKQoqlUyauoK3h6Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B71153858D21 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-6ef7f8acc33so10825957b3.1 for ; Thu, 05 Dec 2024 15:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733441751; x=1734046551; darn=sourceware.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=BuVTKma80/YU79B/xIo/wZvcXjHBSPqS170018rFmnI=; b=XXU6kfegmvqZsxeDEivwRMyOHT5tVczqXli7gCFuBSA1WfHrNkqjOsyjHxdbJxEucc N2ePGo7fxGvTxh6+ycgA+Vp7OuFPrEhFUetwSqy8fk1zS+HqnPzRA2+b75V0QAA8rNqf uKvxOp8PTaLEiH3EEklRsDkGQTybUn2cCKlm9vOACHE3jFZ5yH8Jd6p0czsl0poLv8Am zP+Yxf47KT2HzSZ7SKBUKhnCUm5mrgIqUfp/Y92cqG/oj06RnwyzScrHK7LSSU5cZLWc 9dA/PUzuFnz3DXFSmv9lYO7oN0UXTibex8b+KZUZfm7tB2+gKaY7aS0gOW6k8ZS0SPct TW4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733441751; x=1734046551; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BuVTKma80/YU79B/xIo/wZvcXjHBSPqS170018rFmnI=; b=tsPuJSXQULDCT0r5lAFdmJ/Ek5O3M0qRD0YIcvgnmxiJ9lkmtEnr6ps8C6teiyvZk1 YaJzdfJiIV20GgqR/EBzebi8kzxMicqASoQT+vRfVjCNoLlnylXNzhSvXN4lTbRuSBKp kH1kw/Hx4tpA9+yVPYCBEVpFJTBCPrDG4jfH7pwz/EnfKx/vv/hjs+Q413j08ReZ5hFw y81jjiKKdoXRJvT+apkiunJLA2OoazIMr8HdSfO8KX6Ou4pUeTdSNxD/XJmNX52PuQm/ 7XwnuEg0prkY8mP8c5fRwBM2mcqPTHI8uYvrYRD/4m9HePpDVQuVJ5WJlgoGdQkz++Fm gylA== X-Gm-Message-State: AOJu0YxBvnLBk9J/ynxpPQvfTzPMV84zFW7nnGtRYm4jG2hQAyCy0NKW sptXJKd3ak1KVRF4sLANm8eFM2Q3tklDOIUgf3FWrPIPNlhsQvs0kD6ptuYTFb/Mky3t5VtO06U 9Rv6bPILayr/UxBpM31ESC9Y/OHMnDuevMwwt+xnIT2M= X-Gm-Gg: ASbGncvgoowb505Rps/RLYUBLVIzWg/c7w/H4JzvHy4f8hnh2V4aQ7Npr79zBedwvp3 +dwbaGZG4c/qvMd/hZPiA+hcQrguS7Yc= X-Google-Smtp-Source: AGHT+IHyxQ3Gduc0E0U6HaFUeIZ2/lx+2RKaYHDwavL3p2ljjqZgPebAsB0qSS+o63U7oS3WyXcazBiEkFcEy7FynDE= X-Received: by 2002:a05:690c:3583:b0:6ef:6c57:ddc6 with SMTP id 00721157ae682-6efe3cdb4d2mr14038707b3.34.1733441750974; Thu, 05 Dec 2024 15:35:50 -0800 (PST) MIME-Version: 1.0 From: "H.J. Lu" Date: Fri, 6 Dec 2024 07:35:14 +0800 Message-ID: Subject: [PATCH] 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 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. From 0075be97d49a5a4cff511f00ebfff434bfcb83da Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 6 Dec 2024 04:44:05 +0800 Subject: [PATCH] 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 | 10 ++++ configure | 130 +++++++++++++++++++++++++++++++++++++++++++- configure.ac | 86 +++++++++++++++++++++++++++++ manual/install.texi | 9 +++ 5 files changed, 240 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..c4d2c8cfc1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,9 @@ srcdir = @srcdir@ +TEST_CC = @TEST_CC@ +TEST_CXX = @TEST_CXX@ +have-test-static-pie = @libc_cv_have_test_static_pie@ + # Uncomment the line below if you want to do parallel build. # PARALLELMFLAGS = -j 4 @@ -8,6 +12,12 @@ 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) \ + 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..0fc0407728 100755 --- a/configure +++ b/configure @@ -651,6 +651,7 @@ libc_cv_cc_nofma 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 +706,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 +823,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 +1529,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 +3814,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 +4292,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 +4377,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 +7151,26 @@ 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" + 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 + CC="$saved_CC" +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -fpie" >&5 printf %s "checking for -fpie... " >&6; } @@ -7222,6 +7264,32 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mtls_descriptor" >&5 printf "%s\n" "$libc_cv_mtls_descriptor" >&6; } +if test "$TEST_CC" != "$CC" \ + -a "$libc_cv_mtls_descriptor" != no; then + saved_CC="$CC" + CC="$TEST_CC" + 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_mtls_descriptor=$mtls_descriptor + else + libc_cv_mtls_descriptor=no + fi + rm -f conftest* + CC="$saved_CC" +fi config_vars="$config_vars have-mtls-descriptor = $libc_cv_mtls_descriptor" @@ -7253,6 +7321,30 @@ esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_wno_ignored_attributes" >&5 printf "%s\n" "$libc_cv_wno_ignored_attributes" >&6; } +if test "$TEST_CC" != "$CC" \ + -a -n "$libc_cv_wno_ignored_attribute"; then + saved_CC="$CC" + CC="$TEST_CC" + 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* + CC="$saved_CC" +fi config_vars="$config_vars config-cflags-wno-ignored-attributes = $libc_cv_wno_ignored_attributes" @@ -7430,6 +7522,24 @@ esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_signaling_nans" >&5 printf "%s\n" "$libc_cv_cc_signaling_nans" >&6; } +if test "$TEST_CC" != "$CC" \ + -a -n "$libc_cv_cc_signaling_nans"; then + saved_CC="$CC" + CC="$TEST_CC" + 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_cc_signaling_nans=-fsignaling-nans +else case e in #( + e) libc_cv_cc_signaling_nans= ;; +esac +fi + CC="$saved_CC" +fi config_vars="$config_vars config-cflags-signaling-nans = $libc_cv_cc_signaling_nans" @@ -7490,6 +7600,24 @@ esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_wimplicit_fallthrough" >&5 printf "%s\n" "$libc_cv_cc_wimplicit_fallthrough" >&6; } +if test "$TEST_CC" != "$CC" \ + -a -n "$libc_cv_cc_wimplicit_fallthrough"; then + saved_CC="$CC" + CC="$TEST_CC" + 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_cc_wimplicit_fallthrough=-Wimplicit-fallthrough +else case e in #( + e) libc_cv_cc_wimplicit_fallthrough= ;; +esac +fi + CC="$saved_CC" +fi config_vars="$config_vars cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough" diff --git a/configure.ac b/configure.ac index 895bd5267d..7e45cde010 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,17 @@ 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" + 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]) @@ -1332,6 +1360,27 @@ else fi rm -f conftest*]) AC_SUBST(libc_cv_mtls_descriptor) +if test "$TEST_CC" != "$CC" \ + -a "$libc_cv_mtls_descriptor" != no; then + saved_CC="$CC" + CC="$TEST_CC" + cat > conftest.c <&AS_MESSAGE_LOG_FD]) + then + libc_cv_mtls_descriptor=$mtls_descriptor + else + libc_cv_mtls_descriptor=no + fi + rm -f conftest* + CC="$saved_CC" +fi LIBC_CONFIG_VAR([have-mtls-descriptor], [$libc_cv_mtls_descriptor]) dnl clang emits an warning for a double alias redirection, to warn the @@ -1353,6 +1402,25 @@ then libc_cv_wno_ignored_attributes="-Wno-ignored-attributes" fi rm -f conftest*]) +if test "$TEST_CC" != "$CC" \ + -a -n "$libc_cv_wno_ignored_attribute"; then + saved_CC="$CC" + CC="$TEST_CC" + cat > conftest.c <