Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4429260rwd; Sat, 17 Jun 2023 13:37:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KE1DZZono6nlepMM1RiCHVO6/kXtSDeLhwzJIylmvxudSQe3d7V0EvvIObtsoxPTdx2c7 X-Received: by 2002:a05:6a20:7349:b0:11c:d2d0:6439 with SMTP id v9-20020a056a20734900b0011cd2d06439mr16164539pzc.25.1687034266966; Sat, 17 Jun 2023 13:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687034266; cv=none; d=google.com; s=arc-20160816; b=qcoTAXFUXeTBXuRSA/NLNg7J0iYpBD/8RVVFRM9WIq2clHKDtEkhN5nE56ozVCGu+X 5C63YONypsgIa7b6xkLWOGw/MXer/Jh65S7Outdgv8YQS+YxqAqIZA3dsM4z7ZPry/6w dhldvRSvMfILQXR/sgL7ly/l+keBFcYCLqR8WRuqmuXPMIPj+jQMzWPddBK/pzXEpjcU He33BVcvrg3ndzDKQtExSScs4OyAETEhcMOhH5cmOV1erSfOS2HkUcn9Gwu3VtbX9SXi 4SxwRNPAUlWTq/yn/Z3xW2FsKVcAY3nVf59s5BSlmzzi7l45cnIBILXQwUJ/+1RoSOyv zWjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ZSqdOwl2Rh568ACtqpd93qLlpsd4kju38sNnekee5T8=; b=OpD6rKaRzLYdDc8n9E3nlf4v841oCypjTQ3myeNYoK32cGsQC6BFCeegPDUnjoiHB8 qod6IqeDTVmtvkZBvLo8JWQ2aA7A6X7FGxcyMzryHi87/fvZ5OKwq16md+jhKFjsGPVY wECy89kEjmXfT2khJ8TdQvK1Lg/bHwzmFLERR2HUASb2pWfeb3rsnPsOSZ2JwliRYjDZ moOSJI7pz4IN9xfss3Zd1M33ayid23CSqht8yFsd4CKf9yxcEQOb0LUIZA5zIASZvqkL RjyDfpGBVLcmoqK+AWG10qCT6yvx0T9i0sv9Vk6ZOacDOcd9lU0nimYNtR/HQ7kpKFGH wI+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r70-20020a632b49000000b00517a4a75528si4807871pgr.162.2023.06.17.13.37.34; Sat, 17 Jun 2023 13:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346348AbjFQUOW (ORCPT + 99 others); Sat, 17 Jun 2023 16:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjFQUOV (ORCPT ); Sat, 17 Jun 2023 16:14:21 -0400 X-Greylist: delayed 433 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 17 Jun 2023 13:14:20 PDT Received: from hi1smtp01.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E29AE6A for ; Sat, 17 Jun 2023 13:14:20 -0700 (PDT) Received: from hi2exch02.adit-jv.com (hi2exch02.adit-jv.com [10.72.92.28]) by hi1smtp01.de.adit-jv.com (Postfix) with ESMTP id E9926520331; Sat, 17 Jun 2023 22:07:04 +0200 (CEST) Received: from lxhi-065 (10.72.94.8) by hi2exch02.adit-jv.com (10.72.92.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Sat, 17 Jun 2023 22:07:04 +0200 Date: Sat, 17 Jun 2023 22:07:00 +0200 From: Eugeniu Rosca To: Masahiro Yamada CC: , , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Eugeniu Rosca , Eugeniu Rosca Subject: Re: [PATCH] kbuild: make clean rule robust against too long argument error Message-ID: <20230617200700.GA31221@lxhi-065> References: <20230617153025.1653851-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230617153025.1653851-1-masahiroy@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.72.94.8] X-ClientProxiedBy: hi2exch02.adit-jv.com (10.72.92.28) To hi2exch02.adit-jv.com (10.72.92.28) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,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 Yamada-san, Many thanks for your feedback and for your patch. It indeed addresses the issue I have reported in [1]. On Sun, Jun 18, 2023 at 12:30:25AM +0900, Masahiro Yamada wrote: > Commit cd968b97c492 ("kbuild: make built-in.a rule robust against too > long argument error") made a build rule robust against "Argument list > too long" error. > > Eugeniu Rosca reported the same error occurred when cleaning an external > module. > > The $(obj)/ prefix can be a very long path for external modules. Confirmed. I am seeing an instance of $(obj) being 150 characters long, due to an out-of-tree module deeply buried in a specific Yocto build. In the current vanilla version of 'make clean' (w/o this patch), the $(obj) prefix is applied to each and every file being removed, dramatically increasing the strlen of arguments passed to 'rm -rf'. > > Apply a similar solution to 'make clean'. > > Reported-by: Eugeniu Rosca > Signed-off-by: Masahiro Yamada > --- > > scripts/Makefile.clean | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean > index 3649900696dd..235408a44f90 100644 > --- a/scripts/Makefile.clean > +++ b/scripts/Makefile.clean > @@ -37,8 +37,9 @@ __clean-files := $(wildcard $(addprefix $(obj)/, $(__clean-files))) > > # ========================================================================== > > +# Use xargs to make this robust against "Argument list too long" error Please, correct me if I am wrong, but it looks like the magic/brilliance is in the 'patsubst' function, since below version also fails for me: NOK: cmd_clean = printf '%s ' $(__clean-files) | xargs rm -rf When running 'make clean' for my particular out-of-tree kernel module, 'patsubst' is able to decrease the total number of characters passed to the shell's argument list from ~204k to ~47k, which elegantly prevents the "Argument list too long" error. > quiet_cmd_clean = CLEAN $(obj) > - cmd_clean = rm -rf $(__clean-files) > + cmd_clean = printf '$(obj)/%s ' $(patsubst $(obj)/%,%,$(__clean-files)) | xargs rm -rf > > __clean: $(subdir-ymn) > ifneq ($(strip $(__clean-files)),) > -- > 2.39.2 > Since it fixes the problem reported in [1] (much appreciated): Reviewed-by: Eugeniu Rosca Tested-by: Eugeniu Rosca [1] https://lore.kernel.org/linux-kbuild/20230616194505.GA27753@lxhi-065/ -- Best regards, Eugeniu Rosca