From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 4978E383E83D for ; Tue, 6 Jul 2021 19:37:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4978E383E83D Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 166JQ8k9012733; Tue, 6 Jul 2021 19:37:34 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39kq8ebn6n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 19:37:34 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 166JUJap118993; Tue, 6 Jul 2021 19:37:33 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by aserp3020.oracle.com with ESMTP id 39jfq946nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 19:37:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dovj4+A9qDDKQCKvxZQCh9OaY7auz25YSU/7mecuqes+OmKp2KZ3BbiuA1DgoleYSqIOtTtQ48GrP/U+rOcw4Zu8xCmk7tfdncukB+bG8zNCgUEFCLO65Y9bCvglp24qcdZsL4AgARmxPdm5VQWWNPxCN0w8fBl88juVLsmls4bhybd7RplvoJMOU1/fcamGSFXeywK1YCxyse0PawHgiI3DcQpQdM4iZNR+3a0Iyb7fmQlRiOlW7Nywp3NfdhuniDIQvqhiSNDWkaNmSVB1ii4wlr/QwHpEqtiCr7hEgRVCA9UmL7c+Gm0lNNOHhYx0L9AZ8EY4r/NuVhb71SLlAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uX4LAqRM5vZXb+Kw3uiylz1W4H1GbfDYH1TD+Hrc75g=; b=W3uUQq88Uxfrt8xNLg6/rXVICtvOLylE+HTQgZJ36wPBwh6fSpUu1KJhhWZ7jYcDIIZfj57KNotDXa/gqbJ+WcFq1CYZBn91UeFkar197/1z3GcpFINOP+n3O1PQP3dGhZrqN5UYdz2GMTkUlkJKwHfJn464k4jzZlLRvQcoekpE0KVeWzZYCpyPch+Xa6GAUrLAkbG6xKiTA81mfC8IRJ7zUbPacjtGBG3hr2Okh+SdtPViOWvg+j0BcGi1HQ07IiV29RB8UzthgbvRhNW6C9+EipFcpgiv7oNDU5ZUG/HPOcSijl0mu94a8As5/40034jeDX7fCEyYznCJZGvviw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from SA2PR10MB4715.namprd10.prod.outlook.com (2603:10b6:806:fb::10) by SA2PR10MB4619.namprd10.prod.outlook.com (2603:10b6:806:11e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.27; Tue, 6 Jul 2021 19:37:31 +0000 Received: from SA2PR10MB4715.namprd10.prod.outlook.com ([fe80::956e:3ceb:9de9:8854]) by SA2PR10MB4715.namprd10.prod.outlook.com ([fe80::956e:3ceb:9de9:8854%3]) with mapi id 15.20.4287.033; Tue, 6 Jul 2021 19:37:31 +0000 From: Nick Alcock To: binutils@sourceware.org Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection References: <20210625161335.4831-1-nick.alcock@oracle.com> <20210625161335.4831-3-nick.alcock@oracle.com> Emacs: there's a reason it comes with a built-in psychotherapist. Date: Tue, 06 Jul 2021 20:37:26 +0100 In-Reply-To: <20210625161335.4831-3-nick.alcock@oracle.com> (Nick Alcock via Binutils's message of "Fri, 25 Jun 2021 17:13:33 +0100") Message-ID: <87fswrdyix.fsf@esperi.org.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2.50 (gnu/linux) Content-Type: text/plain X-ClientProxiedBy: LO4P123CA0490.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::9) To SA2PR10MB4715.namprd10.prod.outlook.com (2603:10b6:806:fb::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from loom (2001:8b0:1101:10::2) by LO4P123CA0490.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20 via Frontend Transport; Tue, 6 Jul 2021 19:37:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3440e143-3c10-4a83-f211-08d940b57ef4 X-MS-TrafficTypeDiagnostic: SA2PR10MB4619: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v98VHX4wfNfRi3lDSF1t3xWB2GazK7Mk3v/Ysk3BOkSVSHfo55WAbGLkZiPCluav04L+NNHuR1ON8N13MIGjpn3BSp2lz9BjD66mSYIZhgtSXHNf0KE60YZhkdWjU60t4KcJLSGQxkBF7knkJ2Ae/Eir7eYUH2/8mKQZi9YghzuaKV8NSMG6IfbWeq6Ya3unIMAofgQcmaSiC+eXFoRg91yhgjrCoO0gn72dtjmvu2cpJdrUaVDZzr+wD0bH3UGY7yvrJzyQraunyQ6CYoYsuHkEcq/VMZxRVw1GYmrzTb61v+uT2/XXmiYCRO/w+5ukW6BBmaTWBflgSzV7ViTWgXuE5XsOkvSAldPN41BuLVL36TQ/GwnrSSBpYcHiEL+yKiRO4fil479fipuFumb94d43eW7pDTLi0NZntr23YmqUprPyHU8++IbDTE60r/aaFUhmDG4vKUasBBOQQc04kH21H1uurmaBO3JSdSbBFU9SDr7ngHx8UlKOnI6COeyUEEXBBZVO/Zr5gcnKPYYkG1xeEJzwh825EV7AHux1lLuWg8RSLrmoQpoQgRyY7LpDkTYfw7/3qjBkb6Q9NdhOyQKBhGQRKB3r3fm1kCXPiH7AfFf2VjHlwh/4QGx8/N6D2UcrZOKNJq9djPIYTSxykg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4715.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(366004)(396003)(346002)(376002)(136003)(8676002)(6486002)(6666004)(8936002)(86362001)(5660300002)(6916009)(66476007)(316002)(38100700002)(44832011)(83380400001)(6496006)(478600001)(4326008)(186003)(36756003)(66946007)(2906002)(9686003)(66556008)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?nrAJl0RX85Fd01mLdbr9WdBvdcup//VA0WSBddMoxJfnsua1M5xqNsQ9WYn0?= =?us-ascii?Q?f4PaFDOcLEmYcMip+aJoVF5I5s0J5rlmJyaNPy85V9RB7KYoClu9kzZ1vzBH?= =?us-ascii?Q?5QujDWLyYoTAuMUq/iptmZR+yU1FmPcA7frAMPt9jERM0kIQV6Q6v0sNOZFY?= =?us-ascii?Q?b2I2/TFQWaUnYjhfJExu0gNDq0vP1Hqv4hHz9epzY1QiXO7AgK9SypDgOMLG?= =?us-ascii?Q?eH1JeWgcIvMOLAqdIAPimaNmb1YL0B0zzbL/ynZJ9/II5pX5cmAYt3XmAFUr?=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JxqCfjfRLWPHABc2cSvTWmZpxi862+XAts?= =?us-ascii?Q?jq+R90W74HmUsMEcPnw6+igZEbr2ETF02aKy4OzDJ08gHDrmiVaq0Fbrj9M6?= =?us-ascii?Q?0IsR+GSb82nGTDC3uApKBRYnCzI6o49sMh8ugvPkg9r1dl5LGc08bnnH8f/3?= =?us-ascii?Q?Zm88IsP1fLHxnVBhQXfqqKnkStvMhrcmmn57sZLkoYTidA=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3440e143-3c10-4a83-f211-08d940b57ef4 X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4715.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 19:37:31.5126 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qpAO7OYKVjK2G1evhtwKhoPjwoSAAMS08vlAnYrNAOk9M2gPcsmXzLlX0xxu0ylsoMHWyEeUZCPyhXb7D5KcMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4619 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107060091 X-Proofpoint-GUID: 3kEpqWPtn_kS55aMQ0m82WN5T2PPI1W7 X-Proofpoint-ORIG-GUID: 3kEpqWPtn_kS55aMQ0m82WN5T2PPI1W7 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jul 2021 19:37:40 -0000 Ping? On 25 Jun 2021, Nick Alcock via Binutils said this: > Libtool needs to get BSD-format (or MS-format) output out of the system > nm, so that it can scan generated object files for symbol names for > -export-symbols-regex support. Some nms need specific flags to turn on > BSD-formatted output, so libtool checks for this in its AC_PATH_NM. > Unfortunately the code to do this has a pair of interlocking flaws: > > - it runs the test by doing an nm of /dev/null. Some platforms > reasonably refuse to do an nm on a device file, but before now this > has only been worked around by assuming that the error message has a > specific textual form emitted by Tru64 nm, and that getting this > error means this is Tru64 nm and that nm -B would work to produce > BSD-format output, even though the test never actually got anything > but an error message out of nm -B. This is fixable by nm'ing *nm > itself* (since we necessarily have a path to it). > > - the test is entirely skipped if NM is set in the environment, on the > grounds that the user has overridden the test: but the user cannot > reasonably be expected to know that libtool wants not only nm but > also flags forcing BSD-format output. Worse yet, one such "user" is > the top-level Cygnus configure script, which neither tests for > nor specifies any BSD-format flags. So platforms needing BSD-format > flags always fail to set them when run in a Cygnus tree, breaking > -export-symbols-regex on such platforms. Libtool also needs to > augment $LD on some platforms, but this is done unconditionally, > augmenting whatever the user specified: the nm check should do the > same. > > One wrinkle: if the user has overridden $NM, a path might have been > provided: so we use the user-specified path if there was one, and > otherwise do the path search as usual. (If the nm specified doesn't > work, this might lead to a few extra pointless path searches -- but > the test is going to fail anyway, so that's not a problem.) > > (Tested with NM unset, and set to nm, /usr/bin/nm, my-nm where my-nm is a > symlink to /usr/bin/nm on the PATH, and /not-on-the-path/my-nm where > *that* is a symlink to /usr/bin/nm.) > > Cc: gcc-patches@gcc.gnu.org > > ChangeLog > 2021-06-22 Nick Alcock > > PR libctf/27482 > * libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided > NM, if there is one. Run nm on itself, not on /dev/null, to avoid > errors from nms that refuse to work on non-regular files. Remove > other workarounds for this problem. Strip out blank lines from the > nm output. > --- > libtool.m4 | 88 ++++++++++++++++++++++++++++-------------------------- > 1 file changed, 45 insertions(+), 43 deletions(-) > > diff --git a/libtool.m4 b/libtool.m4 > index b0a56917497..29dce1f8239 100644 > --- a/libtool.m4 > +++ b/libtool.m4 > @@ -3200,53 +3200,55 @@ _LT_DECL([], [file_magic_cmd], [1], > > # LT_PATH_NM > # ---------- > -# find the pathname to a BSD- or MS-compatible name lister > +# find the pathname to a BSD- or MS-compatible name lister, and any flags > +# needed to make it compatible > AC_DEFUN([LT_PATH_NM], > [AC_REQUIRE([AC_PROG_CC])dnl > AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, > [if test -n "$NM"; then > - # Let the user override the test. > - lt_cv_path_NM="$NM" > -else > - lt_nm_to_check="${ac_tool_prefix}nm" > - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then > - lt_nm_to_check="$lt_nm_to_check nm" > - fi > - for lt_tmp_nm in $lt_nm_to_check; do > - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR > - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do > - IFS="$lt_save_ifs" > - test -z "$ac_dir" && ac_dir=. > - tmp_nm="$ac_dir/$lt_tmp_nm" > - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then > - # Check to see if the nm accepts a BSD-compat flag. > - # Adding the `sed 1q' prevents false positives on HP-UX, which says: > - # nm: unknown option "B" ignored > - # Tru64's nm complains that /dev/null is an invalid object file > - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in > - */dev/null* | *'Invalid file or object type'*) > - lt_cv_path_NM="$tmp_nm -B" > - break > - ;; > - *) > - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in > - */dev/null*) > - lt_cv_path_NM="$tmp_nm -p" > - break > - ;; > - *) > - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but > - continue # so that we can try to find one that supports BSD flags > - ;; > - esac > - ;; > - esac > - fi > - done > - IFS="$lt_save_ifs" > - done > - : ${lt_cv_path_NM=no} > -fi]) > + # Let the user override the nm to test. > + lt_nm_to_check="$NM" > + else > + lt_nm_to_check="${ac_tool_prefix}nm" > + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then > + lt_nm_to_check="$lt_nm_to_check nm" > + fi > + fi > + for lt_tmp_nm in $lt_nm_to_check; do > + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR > + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do > + IFS="$lt_save_ifs" > + test -z "$ac_dir" && ac_dir=. > + case "$lt_tmp_nm" in > + */*|*\\*) tmp_nm="$lt_tmp_nm";; > + *) tmp_nm="$ac_dir/$lt_tmp_nm";; > + esac > + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then > + # Check to see if the nm accepts a BSD-compat flag. > + # Adding the `sed 1q' prevents false positives on HP-UX, which says: > + # nm: unknown option "B" ignored > + case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in > + *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B" > + break > + ;; > + *) > + case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in > + *$tmp_nm*) > + lt_cv_path_NM="$tmp_nm -p" > + break > + ;; > + *) > + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but > + continue # so that we can try to find one that supports BSD flags > + ;; > + esac > + ;; > + esac > + fi > + done > + IFS="$lt_save_ifs" > + done > + : ${lt_cv_path_NM=no}]) > if test "$lt_cv_path_NM" != "no"; then > NM="$lt_cv_path_NM" > else