Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2402197ioo; Sat, 28 May 2022 12:29:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmB1EL0EpER5BS9M+zXDdqa9DG6jturBK9ox4pR891BMRLKUfBFsoxwTvR18uRH4b5eBBf X-Received: by 2002:a05:6a00:8c5:b0:510:6eae:6fa1 with SMTP id s5-20020a056a0008c500b005106eae6fa1mr48940360pfu.12.1653766161127; Sat, 28 May 2022 12:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653766161; cv=none; d=google.com; s=arc-20160816; b=JpWNmhb7XhaWTXdi8qCnvSTmmL7XQ3E5AYzxN5OQNiJ4PgcQzRdAs4BpPcINweqhyk 9N29Bt6pKz3jfgyZbDi30gi2V/j7YcsP2l5n7wy8yujk4NuZo0Fy1swZYHRknhsr3A6+ NsE2D+EQ7GOp9b0U2Z2wsRK+GiUiUxFiMrC4onVsrIwP/tOHFXHlB842v2JIVq8Z6OVk 5pJaCHMdWBttxDADKoPSR1L2JZUdnbzDLdck4BfJB0k5r6ZABiT2JDevBhXlCqDih9ln 9TavvA7TTq48upmJtKdOD0UIt+9PYVEnZcICR/AkXAr3GWO+ViCysYtyI/Hfsc5FA3JZ +ZZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=cTEaVsseOx/T6+9eTNjc+bnIPuNDfidAbsIlj5Z4+nw=; b=LkQjT+7p9Xuz1GNm0QremkNgF5ED3Q/hdjbMs8ET39AknKk87shq+50cRjg4J9Ehqv ZnehHYZf3fpTVSKw/ozzz03XeeegsQJ2SM5OFxmieqBqMXL5BUfzk/ihZso47lXPoQ/c nYQifrn4uaBy4oHH59b5U9cL4q6UIVdV2x9o0fmRDWwNhWwBxtF3gXn2hJpuZa79VLTA W13J4w1NYhKVgVVcMOC+1sUQUvs2ZcGzf5XGmBA6zZNqffoKXAd/P84kyKSjQyKMtRup zRgya46+HaXeUuRov6O9evuQCg1tOR09EYqR4AnjSO3xL2eWW8fywXGWjhYJ5jbNaItT oFvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XpE7bhc4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j72-20020a638b4b000000b003fa3eb69da4si10611886pge.287.2022.05.28.12.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XpE7bhc4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C5D2A24F23; Sat, 28 May 2022 11:57:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350752AbiE0KEM (ORCPT + 99 others); Fri, 27 May 2022 06:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbiE0KEK (ORCPT ); Fri, 27 May 2022 06:04:10 -0400 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746E6F137B; Fri, 27 May 2022 03:04:08 -0700 (PDT) Received: from grover.sesame (133-32-177-133.west.xps.vectant.ne.jp [133.32.177.133]) (authenticated) by conuserg-08.nifty.com with ESMTP id 24RA2hPT029808; Fri, 27 May 2022 19:02:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 24RA2hPT029808 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1653645767; bh=cTEaVsseOx/T6+9eTNjc+bnIPuNDfidAbsIlj5Z4+nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XpE7bhc4dasDj31nobFoqPZGgWiHTils8FMsJswF8sT3w9ijw0iw3nlSSVTozzRMi 5lR95zCyn+Nb62hZxhVHIqd5ZAWWXF0Ki8UEf5wX/DKFCjachHKy+d4+EMx1QH29X9 oB0Auu2Zn99EC92w3maEIK2Yd/bYMipg/OlwRvvXPBFznVlCCZRQlpjuNIpRGWqhTJ yYD5OJZlt7Nj2wfepXpIJl4EV+2ROJWGCiqydkPK73l7GS0SbhKeNPsVdHn0TyShTS C9wi5Jten3kQqzhIwYCejZtkdGYT2xGN5xyt4Licsl4OkoREvNk0Ini6mrNgcEehAh Jky+sznG4p0wQ== X-Nifty-SrcIP: [133.32.177.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Josh Poimboeuf , llvm@lists.linux.dev, Helge Deller , linux-parisc@vger.kernel.org, Masahiro Yamada , "James E.J. Bottomley" Subject: [PATCH v7 3/8] parisc: fix the exit status of arch/parisc/nm Date: Fri, 27 May 2022 19:01:50 +0900 Message-Id: <20220527100155.1996314-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220527100155.1996314-1-masahiroy@kernel.org> References: <20220527100155.1996314-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 parisc overrides 'nm' with a shell script. I do not know the reason, but anyway it is how it has worked since 2003. [1] A problem is that this script returns the exit code of grep instead of ${CROSS_COMPILE}nm. 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=parisc 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=36eaa6e4c0e0b6950136b956b72fd08155b92ca3 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 => 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 := arch/parisc/boot KBUILD_IMAGE := $(boot)/bzImage -NM = sh $(srctree)/arch/parisc/nm +NM = $(srctree)/arch/parisc/nm CHECKFLAGS += -D__hppa__=1 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 error. + +${CROSS_COMPILE}nm "$@" | +{ grep -v '.LC*[0-9]*$' || { exit_code=$?; test $exit_code -eq 1 || exit $exit_code; } } -- 2.32.0