Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2406244ioo; Sat, 28 May 2022 12:36:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyvdx1zq5niY92Vg+l0WhDmAwCm8t+fLSRN/lsWlceYr0RcAUgYqLAjzaWilwKGdVp2Q2L X-Received: by 2002:a17:90a:ce89:b0:1e0:9c9c:3b00 with SMTP id g9-20020a17090ace8900b001e09c9c3b00mr14929676pju.94.1653766610273; Sat, 28 May 2022 12:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653766610; cv=none; d=google.com; s=arc-20160816; b=HgG/SXi6lqF+1BwFPTFd89pciLOYKEkNqZJto4YuWDonNb5I1cZ7uJx+1cQeJ2YJIG 5o8IkkxPvUlEgQLZ0dlcVMxOnwpNP0HPdgWpi2c/0V3nZAayaP61UDYQJm7efOnIqYpO b2Vng2qGjiUV8xuY5p8N48e6PRI8cLbv+Y4wKaMuOn7nS6PFT0pm2xiyEdRpQKOeb5X9 EEA+ErQO3IOtpddioZald9gOZYuFVAJS1wKpXkakT3ajav/nPNY099cvhpy5VALt7pZh H4PkzAYuSUQmA6VXIQX2v0wYGWa6gqXJoZl4ykYd1vEWwWZAnC63aAtPQ8ijlFSS0o66 o5Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=lzVWvECCOZsacdR7KHB6uHM1pLjtRFbtueLQDrZI18Y=; b=eySqJaCFbBM9bn9DTyL5yuhI2gHhXR6oIWclTB2IJhJz6q2L0D/wpOL7FViiWa2F8q YTnpiHN/yYaeC/AbNWaUa+yE//v4xvL24sl4kobEdXwvACxJO6UUjd/lZNodyEsC1MdX Lc7z9k601YgMs7laZmO37IEoKoYweNauPcZkU1b0ephpm5GoH9XsTolFsgZ2tM367rNn um2eyUstcmha6q3jMqHFgEJ0lCDPqfV1LyG2dCmb993qpEI9b3D7npm71Koh5Ju9b/Af GuVRJcDXsfimY6Kb1Keh48VWl9l/NFk5ttdJ5Nd36WGSaCsikbbIHjWjALL9TD4nhdVT QzXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=HQymCyj5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e193-20020a6369ca000000b003c67a501c74si10739387pgc.636.2022.05.28.12.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:36:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=HQymCyj5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 763B55AEDA; Sat, 28 May 2022 12:02:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352845AbiE0N6K (ORCPT + 99 others); Fri, 27 May 2022 09:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240514AbiE0N6J (ORCPT ); Fri, 27 May 2022 09:58:09 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A72613CD4; Fri, 27 May 2022 06:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1653659861; bh=sguvIpamEs+8ZftKok+OD4Ae+fTk7JTH8TB8h2DNyw4=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=HQymCyj5my8UySLozJjhivzXzt2O0D3r/5PfQ3jcl8OQgtvEq5KzA3SFtU7DNS3Hp PWh49sZU3Q7PmNJ+MebkwMDkQ/CbWc/xig115tEzeosFMDkMm9JdfIwVlHhq+2O6/+ 1CaeBDR74w3UZxlqMNdnEVPOd3QKUJjfKEzSsvyY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.153.1]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mkpav-1nYD1e2jCZ-00mLHH; Fri, 27 May 2022 15:57:41 +0200 Message-ID: <1c12cd26-d8aa-4498-f4c0-29478b9578fe@gmx.de> Date: Fri, 27 May 2022 15:57:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v7 3/8] parisc: fix the exit status of arch/parisc/nm Content-Language: en-US To: Masahiro Yamada , linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Josh Poimboeuf , llvm@lists.linux.dev, linux-parisc@vger.kernel.org, "James E.J. Bottomley" References: <20220527100155.1996314-1-masahiroy@kernel.org> <20220527100155.1996314-4-masahiroy@kernel.org> From: Helge Deller In-Reply-To: <20220527100155.1996314-4-masahiroy@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:rnzEX+fIh/b7XvFHwFrUOvS+E6bfr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sJ7izdVa04BEwVkfbKT/acXoN9d9trj+uJIeksLiZO61oF8qww4yFz HF73JFkJKrDT4pLJX+HR8gnCHLhlSA4fnhj8rzjV/lwCJPMr+ymnLtheTlczF9lk/YlHmynVB pEuHsx8P/fv2Sns08Ipp2hyC9dEfKVVdpLfk/xljEhZVFhgcuSiDIrSNgBnnsFxfiL51oNfRQ /PVYhx36fXwKU/ICxvqjuG8jgBRYYK2/NRGL1uOQqqEZ+TwG2k0QD3PxASD1U4QyjdstUYLZ6 Me0dcmpD2Uv65lQIFqL8x4pj6Ew9Mvx4Be3eoepPyNGoTqv3sg1UZdGlA== X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Masahiro, On 5/27/22 12:01, Masahiro Yamada wrote: > parisc overrides 'nm' with a shell script. I do not know the reason, > but anyway it is how it has worked since 2003. [1] I don't know the reason either... I assume it was that the older toolchains had bugs and kept lots of local symbols like .LC? in the object files. I did a small build without the nm script (and removed it's reference in the Makefile), and it did not seem to break anything. > A problem is that this script returns the exit code of grep instead of > ${CROSS_COMPILE}nm. Instead of fixing this, I'd suggest that you simply remove the nm script alltogether. If you like I can apply such a patch in the parisc git tree, and you just drop this specific patch. Or you change your patch to remove = it. Just let me know what you prefer. Helge > grep(1) says: > Normally the exit status is 0 if a line is selected, 1 if no lines > were selected, and 2 if an error occurred. However, if the -q or > --quiet or --silent is used and a line is selected, the exit status > is 0 even if an error occurred. > > When the given object has no symbol, grep returns 1, while the true nm > returns 0. Hence, build rules using ${NM} fail on ARCH=3Dparisc even if > the given object is valid. > > This commit corrects the exit status of the script. > > - A pipeline returns the exit status of the last command (here, grep). > The exit status of ${CROSS_COMPILE}nm is just ignored. Use bash's > pipefail flag to catch errors of ${CROSS_COMPILE}nm. > > - If grep returns 1, this script should return 0 in order to mimic > true nm. If grep returns 2, it is a real and fatal error. Return > it as is. > > [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git= /commit/?id=3D36eaa6e4c0e0b6950136b956b72fd08155b92ca3 > > Signed-off-by: Masahiro Yamada > --- > > Changes in v7: > - New patch > > arch/parisc/Makefile | 2 +- > arch/parisc/nm | 12 ++++++++++-- > 2 files changed, 11 insertions(+), 3 deletions(-) > mode change 100644 =3D> 100755 arch/parisc/nm > > diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile > index aca1710fd658..e7139955367d 100644 > --- a/arch/parisc/Makefile > +++ b/arch/parisc/Makefile > @@ -18,7 +18,7 @@ > boot :=3D arch/parisc/boot > KBUILD_IMAGE :=3D $(boot)/bzImage > > -NM =3D sh $(srctree)/arch/parisc/nm > +NM =3D $(srctree)/arch/parisc/nm > CHECKFLAGS +=3D -D__hppa__=3D1 > > ifdef CONFIG_64BIT > diff --git a/arch/parisc/nm b/arch/parisc/nm > old mode 100644 > new mode 100755 > index c788308de33f..3e72238a91f3 > --- a/arch/parisc/nm > +++ b/arch/parisc/nm > @@ -1,6 +1,14 @@ > -#!/bin/sh > +#!/bin/bash > ## > # Hack to have an nm which removes the local symbols. We also rely > # on this nm being hidden out of the ordinarily executable path > ## > -${CROSS_COMPILE}nm $* | grep -v '.LC*[0-9]*$' > + > +# use pipefail to catch error of ${CROSS_COMPILE}nm > +set -o pipefail > + > +# grep exits with 1 if no lines were selected. > +# If the given object has no symbol, grep returns 1, but it is not an e= rror. > + > +${CROSS_COMPILE}nm "$@" | > +{ grep -v '.LC*[0-9]*$' || { exit_code=3D$?; test $exit_code -eq 1 || e= xit $exit_code; } }