Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp415810iob; Wed, 11 May 2022 18:01:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnVvIrwaDV5QitePQAPMneiRCKL5hYN5DJQxu+HHltt/ipD9QPlSFwjJpbaDzs/3dnkmvT X-Received: by 2002:a63:27c1:0:b0:3c6:dde2:ee78 with SMTP id n184-20020a6327c1000000b003c6dde2ee78mr11032044pgn.95.1652317312049; Wed, 11 May 2022 18:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652317312; cv=none; d=google.com; s=arc-20160816; b=Xn9xgNQI5yQ+r0Wl2tb2k+FARM8w76mmJilM/41+wMncn686hkVNwkPV/zYb/YnV3X z6c/oxdMuUpf3Sx2024wPSVg3eJudekn89HTs1qzabkJszkYIRoFLbMudXnwLi5bEgFt yLY8PjweA4qa4wiPm+3ylLTslkHZa82N582B60z/S8RpnsoBOInjcG4wS9lKbTjmJs1N 6bO6mI86AkPxybVxSUaj80VV7RgCF68wF7zS013bbGAd+GdFo/2QyIjWFjAvQ1ejc13c iR789ajHXODDMa5fWBrQfE1Bz1FFxKFTtnESWm/HzFKM61Wefbj2hJImvy0i7gXci8bh rNfw== 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=OcOEuS6jEbLubdZRYm9mI6nzM08ugGxo0tuefY4hIgE=; b=pl+XPZpeoZg/mfoKEpn+S2Tsa/23ubzUt9PwUDZFs709nkWzb/ECDDomQZ5yugsGwM /r6CgtQjrad73GeS1EH/lkSHEM6dw/y3cuw4O42e0/kysdXJWlcVKI4IVsT0WN/tL0Ho K9/Eq+lY1KDV0zkibP5WVz06o1ImLPy13VmzH7t3xY6dFGArZGSSGy4SudGkJATPWv3t a8MZLZnEpuBpMJ2jrvDssUAz5pvWPna//OAUGMNqRYJ7EFf1zfvw6rzGdaC9PHfphLYD cBYHlxzdjk5xWHY1qulCGLUrFtLaH/fyJL3+B4tDuInAUM6Dw//qYQa2sxqdLUkqUchj loDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jXi1gJPH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw7-20020a17090b4d0700b001d7568cc0c8si2082390pjb.145.2022.05.11.18.01.39; Wed, 11 May 2022 18:01:52 -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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jXi1gJPH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345059AbiEKQtt (ORCPT + 99 others); Wed, 11 May 2022 12:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233496AbiEKQtm (ORCPT ); Wed, 11 May 2022 12:49:42 -0400 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAF9A93982; Wed, 11 May 2022 09:49:40 -0700 (PDT) Received: from grover.jp (133-32-177-133.west.xps.vectant.ne.jp [133.32.177.133]) (authenticated) by conuserg-08.nifty.com with ESMTP id 24BGlWc5031975; Thu, 12 May 2022 01:47:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 24BGlWc5031975 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1652287663; bh=OcOEuS6jEbLubdZRYm9mI6nzM08ugGxo0tuefY4hIgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jXi1gJPHIE2xagfeR2MNcfLTDFlg9D5O9cnkBMlaoyva8Do8oJfp6T+S9S4xs+LXI mbrFTqdzrHF0wP0OVeZc1gHvb856yx+ZfDsW6UnXoSwnaZLi6xTmLkkNem16UBBP7G Mv9n97/BoZmFifFt7YxrYZJQzzWpLiqvfELN1kUyI23LFUQWDtOBBq+cP+7B+29kaS heJui4xv66QP7cK5llyJUm9hDLvTD/WnVJAdHb5C1xVoNZfo0IQHttkWQBZvPgU0k4 LhNu07C+jWfwR7Z1xyAiP00Tzt2EkDe7UTV97+1Ytkg7hTmnpbuDpNBg7j27PDMu7c tiqDnu6ifEqMQ== X-Nifty-SrcIP: [133.32.177.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Peter Zijlstra , linux-modules@vger.kernel.org, llvm@lists.linux.dev, Ard Biesheuvel , Sami Tolvanen , Masahiro Yamada Subject: [PATCH v5 10/12] kbuild: make *.mod rule robust against too long argument error Date: Thu, 12 May 2022 01:45:12 +0900 Message-Id: <20220511164514.2741934-11-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220511164514.2741934-1-masahiroy@kernel.org> References: <20220511164514.2741934-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Like built-in.a, the command length of the *.mod rule scales with the depth of the directory times the number of objects in the Makefile. Add $(obj)/ by the shell command (awk) instead of by Make's builtin function. In-tree modules still have some room to the limit (ARG_MAX=2097152), but this is more future-proof for big modules in a deep directory. For example, you can build i915 as a module (CONFIG_DRM_I915=m) and compare drivers/gpu/drm/i915/.i915.mod.cmd with/without this commit. The issue is more critical for external modules because the M= path can be very long as Jeff Johnson reported before [1]. [1] https://lore.kernel.org/linux-kbuild/4c02050c4e95e4cb8cc04282695f8404@codeaurora.org/ Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Nathan Chancellor --- (no changes since v2) Changes in v2: - New patch scripts/Makefile.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 8f1a355df7aa..f546b5f1f33f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -270,8 +270,8 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call if_changed_rule,cc_o_c) $(call cmd,force_checksrc) -cmd_mod = echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)) | \ - $(AWK) -v RS='( |\n)' '!x[$$0]++' > $@ +cmd_mod = echo $(call real-search, $*.o, .o, -objs -y -m) | \ + $(AWK) -v RS='( |\n)' '!x[$$0]++ { print("$(obj)/"$$0) }' > $@ $(obj)/%.mod: FORCE $(call if_changed,mod) -- 2.32.0