From patchwork Mon Jun 8 21:10:06 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: 1305416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=adHD1AiP; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49gm9h1t8cz9sRW for ; Tue, 9 Jun 2020 07:10:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 078283840C0D; Mon, 8 Jun 2020 21:10:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 078283840C0D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1591650614; bh=+gwm0ZJ8zu8WF56ekCnxPNEMwI04/DIs03sfIaB2aBQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=adHD1AiPJCHupFmCUF2SX1IS0xzzYp+mtCxETHJXP9KFk/MrVaPkWUjOlQMKrQhpQ 1R66uaHMjwBTZYORT6cRkmDBHlRmQFzt55xIa2BMozxIn4rDXCqsf2z70cLV9/6FWB dXFtCFDpeqQBIGEHroPsFa6xmrYM7YFHY/fnjzks= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 4257D385DC00 for ; Mon, 8 Jun 2020 21:10:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4257D385DC00 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 058L1c6B180913 for ; Mon, 8 Jun 2020 17:10:09 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 31huuyhwhd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 08 Jun 2020 17:10:08 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 058L0pLZ019542 for ; Mon, 8 Jun 2020 21:10:08 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma01wdc.us.ibm.com with ESMTP id 31g2s8n7bh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 08 Jun 2020 21:10:08 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 058LA56Y15008134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 8 Jun 2020 21:10:05 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B30C6A04D for ; Mon, 8 Jun 2020 21:10:07 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 266456A04F for ; Mon, 8 Jun 2020 21:10:07 +0000 (GMT) Received: from brokenarrow.ibmuc.com (unknown [9.163.55.222]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP for ; Mon, 8 Jun 2020 21:10:06 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCHv4] powerpc: Automatic CPU detection in preconfigure Date: Mon, 8 Jun 2020 16:10:06 -0500 Message-Id: <20200608211006.2803325-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.687 definitions=2020-06-08_17:2020-06-08, 2020-06-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 clxscore=1015 cotscore=-2147483648 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006080144 X-Spam-Status: No, score=-12.4 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 4; * replace broken machine -> mcpu wrapper regex with an orthogonal one to unswizzle the machine name. Changes for 3: * change test 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..1a40cb8a7e 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 \(.*\)/\1/" -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..ad3e7f9f0d --- /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 \(.*\)/\1/" -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