From patchwork Mon May 11 22:10:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 38954 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 2F858388F04F; Mon, 11 May 2020 22:10:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F858388F04F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589235022; bh=IllliDXzntH7ynl+xQRL81IXfEIOiDzTIFd1oRNsAQc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lI9qtWFUB5A96FmLfRFb/PKVxqfGpqj841ilf8BOOAWHKk35YMqiPCHDiHr+hdHva 1MFnpAxV9Znv3yvFKzB6WmEZGcWYcujznL9HfxpZ/8Ze47nbMkPOECnM4KuWyX2CzO bcpEJ+/KRBwWf6vPBYCQyIH7iK4TX/vgZJzvoUCQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 45E16386F81C for ; Mon, 11 May 2020 22:10:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 45E16386F81C Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BM27CX077342 for ; Mon, 11 May 2020 18:10:15 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 30y8wsugwp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 May 2020 18:10:15 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04BM9oaC023949 for ; Mon, 11 May 2020 22:10:14 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma02wdc.us.ibm.com with ESMTP id 30wm56ckbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 May 2020 22:10:14 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04BMAC4R10027270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 11 May 2020 22:10:12 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5309C7809B for ; Mon, 11 May 2020 22:10:13 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1C967809E for ; Mon, 11 May 2020 22:10:12 +0000 (GMT) Received: from brokenarrow.ibmuc.com (unknown [9.85.170.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP for ; Mon, 11 May 2020 22:10:12 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCHv3] powerpc: Automatic CPU detection in preconfigure Date: Mon, 11 May 2020 17:10:12 -0500 Message-Id: <20200511221012.293305-1-murphyp@linux.vnet.ibm.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_10:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 phishscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110161 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Paul E. Murphy via Libc-alpha" From: "Paul E. Murphy" Reply-To: "Paul E. Murphy" Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Changes for 3: * update conditional to avoid running on non-ppc machines Followup from Changes: * Scan for the first instance of .machine or -mcpu= within the generated assembly file. * Don't try to be smart when guessing. Only choose valid targets. * Don't make any extra noise * Remove comment about trying to pretty print an error message, just fail in the usual autoconf way. Followup from ---8<--- Added a check to detect the CPU value in preconfigure, so that glibc is built with the correct --with-cpu value. And move existing checks into preconfigure.ac. Co-Authored-By: Carlos Eduardo Seo Co-Authored-By: Tulio Magno Quites Machado Filho --- sysdeps/powerpc/preconfigure | 62 +++++++++++++++++++++++++++++---- sysdeps/powerpc/preconfigure.ac | 58 ++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 sysdeps/powerpc/preconfigure.ac diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure index a0ea745bb4..0e7920f6de 100644 --- a/sysdeps/powerpc/preconfigure +++ b/sysdeps/powerpc/preconfigure @@ -1,4 +1,5 @@ -# preconfigure fragment for powerpc. +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! + # Local preconfigure fragment for sysdeps/powerpc case "$machine" in powerpc64le) @@ -13,12 +14,59 @@ powerpc*) case "$host_os" in *gnuspe*) # SPE support was dropped in glibc 2.30. - # We can't use AC_MSG_ERROR here. - # The parent script is in the middle of printing the - # "checking for sysdeps preconfigure fragments" line. - echo >&2 - echo "Host system type $host is no longer supported." >&2 - exit 1 + as_fn_error $? "Host system type $host is no longer supported." "$LINENO" 5 + ;; + esac + ;; +esac + +# Lets ask the compiler which Power processor we've got, in case the user did +# not choose a --with-cpu value. Scan a trivial generated assembly program +# and scrape the first +# .machine +# or +# .ascii "-mcpu=" +# directive which shows up, and try using it. +case "${machine}:${submachine}" in +*powerpc*:) + archcpu=`echo "int foo () { return 0; }" \ + | $CC $CFLAGS $CPPFLAGS -S -frecord-gcc-switches -xc -o - - \ + | grep -E "mcpu=|.machine" -m 1 \ + | sed -e "s/.*machine /mcpu=/" -e "s/.*mcpu=\(.*\)\"/\1/"` + # Note if you add patterns here you must ensure that an appropriate + # directory exists in sysdeps/powerpc. Likewise, if we find a + # cpu, don't let the generic configure append extra compiler options. + case "$archcpu" in + 405fp|440fp|464fp|476fp) + submachine=${archcpu%fp} + if ${libc_cv_cc_submachine+:} false; then : + $as_echo_n "(cached) " >&6 +else + libc_cv_cc_submachine="" +fi + + ;; + 405|440|464|476) + submachine=${archcpu} + if ${libc_cv_cc_submachine+:} false; then : + $as_echo_n "(cached) " >&6 +else + libc_cv_cc_submachine="" +fi + + ;; + + a2|970|power[4-9]|power5x|power6+) + submachine=${archcpu} + if ${libc_cv_cc_submachine+:} false; then : + $as_echo_n "(cached) " >&6 +else + libc_cv_cc_submachine="" +fi + + ;; + *) + # We couldn't figure it out, assume none ;; esac ;; diff --git a/sysdeps/powerpc/preconfigure.ac b/sysdeps/powerpc/preconfigure.ac new file mode 100644 index 0000000000..12e9fa5fad --- /dev/null +++ b/sysdeps/powerpc/preconfigure.ac @@ -0,0 +1,58 @@ +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. +# Local preconfigure fragment for sysdeps/powerpc + +case "$machine" in +powerpc64le) + base_machine=powerpc machine=powerpc/powerpc64/le + ;; +powerpc64*) + base_machine=powerpc machine=powerpc/powerpc64/be + ;; +powerpc*) + base_machine=powerpc machine=powerpc/powerpc32 + with_fp_cond="!defined __NO_FPRS__" + case "$host_os" in + *gnuspe*) + # SPE support was dropped in glibc 2.30. + AC_MSG_ERROR([Host system type $host is no longer supported.]) + ;; + esac + ;; +esac + +# Lets ask the compiler which Power processor we've got, in case the user did +# not choose a --with-cpu value. Scan a trivial generated assembly program +# and scrape the first +# .machine +# or +# .ascii "-mcpu=" +# directive which shows up, and try using it. +case "${machine}:${submachine}" in +*powerpc*:) + archcpu=`echo "int foo () { return 0; }" \ + | $CC $CFLAGS $CPPFLAGS -S -frecord-gcc-switches -xc -o - - \ + | grep -E "mcpu=|[.]machine" -m 1 \ + | sed -e "s/.*machine /mcpu=/" -e "s/.*mcpu=\(.*\)\"/\1/"` + # Note if you add patterns here you must ensure that an appropriate + # directory exists in sysdeps/powerpc. Likewise, if we find a + # cpu, don't let the generic configure append extra compiler options. + case "$archcpu" in + 405fp|440fp|464fp|476fp) + submachine=${archcpu%fp} + AC_CACHE_VAL(libc_cv_cc_submachine,libc_cv_cc_submachine="") + ;; + 405|440|464|476) + submachine=${archcpu} + AC_CACHE_VAL(libc_cv_cc_submachine,libc_cv_cc_submachine="") + ;; + + a2|970|power[[4-9]]|power5x|power6+) + submachine=${archcpu} + AC_CACHE_VAL(libc_cv_cc_submachine,libc_cv_cc_submachine="") + ;; + *) + # We couldn't figure it out, assume none + ;; + esac + ;; +esac