From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 46E97385DC00 for ; Mon, 8 Jun 2020 15:15:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 46E97385DC00 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 058EXcnf015860 for ; Mon, 8 Jun 2020 11:15:07 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 31g713j46a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 08 Jun 2020 11:15:06 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 058F4UVs014105 for ; Mon, 8 Jun 2020 15:15:06 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma02dal.us.ibm.com with ESMTP id 31g2s9fahg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 08 Jun 2020 15:15:06 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 058FF5Wp26018200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Jun 2020 15:15:05 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3373BE071; Mon, 8 Jun 2020 15:15:04 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 88A7ABE061; Mon, 8 Jun 2020 15:15:03 +0000 (GMT) Received: from localhost.localdomain (unknown [9.65.240.114]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 8 Jun 2020 15:15:03 +0000 (GMT) Subject: Re: [PATCHv3] powerpc: Automatic CPU detection in preconfigure To: "Paul E. Murphy" , libc-alpha@sourceware.org References: <20200511221012.293305-1-murphyp@linux.vnet.ibm.com> From: Matheus Castanho Message-ID: <6c6f72c2-9769-94a5-6557-54a0a8960fc7@linux.ibm.com> Date: Mon, 8 Jun 2020 12:15:01 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200511221012.293305-1-murphyp@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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_13:2020-06-08, 2020-06-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 suspectscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 spamscore=0 mlxscore=0 phishscore=0 bulkscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006080109 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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-List-Received-Date: Mon, 08 Jun 2020 15:15:08 -0000 Hi Paul, On 5/11/20 7:10 PM, Paul E. Murphy via Libc-alpha wrote: > 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 > [..] > +# 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/"` I believe this last pattern is not parsing the machine name correctly when .machine is used. I found the problem when testing with actual output from GCC, but below I'm just emulating the problem with a simple echo. With .ascii it's OK: $ echo '.ascii "-mcpu=power9"' | grep -E "mcpu=|[.]machine" -m 1 | sed -e "s/.*machine /mcpu=/" -e "s/.*mcpu=\(.*\)\"/\1/" power9 But when .machine is used: $ echo '.machine power9' | grep -E "mcpu=|[.]machine" -m 1 | sed -e "s/.*machine /mcpu=/" -e "s/.*mcpu=\(.*\)\"/\1/" mcpu=power9 The last pattern expects a closing ", which the .machine case does not have. You could drop the \" and just remove all quotes prior to invoking sed: $ echo '.machine power9' | grep -E "mcpu=|[.]machine" -m 1 | tr -d '"' | sed -e "s/.*machine /mcpu=/" -e "s/.*mcpu=\(.*\)/\1/" power9 $ echo '.ascii "-mcpu=power9"' | grep -E "mcpu=|[.]machine" -m 1 | tr -d '"' | sed -e "s/.*machine /mcpu=/" -e "s/.*mcpu=\(.*\)/\1/" power9 Instead of using tr, an extra -e 's/"//g' before the others should also do the trick. -- Matheus Castanho