Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8125160rwl; Fri, 30 Dec 2022 23:22:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXupSAQ1M670mH7I3OXp0NRJPdmziXpxaqjd4WwvS1FHyQiFV9lfsWB97BCNz+vWam1vJ3Be X-Received: by 2002:a17:907:b9d5:b0:7c1:f6c:dd4e with SMTP id xa21-20020a170907b9d500b007c10f6cdd4emr29064119ejc.40.1672471378701; Fri, 30 Dec 2022 23:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672471378; cv=none; d=google.com; s=arc-20160816; b=VcVUn8kgT907EFCG/wQoEwKfVtX+mghoC0tTNuiYGo4+HkQAP1gyJW8ZYxKjwcxq8h VEkXGNe3ty1w8fL8lKZjg3qwOOET0PsBcEEdSjOVhbqMJb2xAYVHcUuigTlvuZYFqThA 2MJ6FfhKXmwNTI20Q31RtODqdvkOA7Cmqaa7IJ/0hnJ2GaT8/PN9SsDD3f0iq/IOLVCg JQNvCBPytdIVHlYTHgNsMW0VQLFyjUI8Df11533FYrP7JE2RDFXsSZA1dD86LmvwBDR6 3bhWjS7zK6AxtETIXIMRNKQY6CAI++ofSNITE6eHDFek+Jant5N0gAFUu1rCzfSUYDwp +YZw== 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; bh=DyvBvZjd+CYM/B16zyuDoXPa9QvQw53x3uoHqOi2jzI=; b=KeXb7FetpkJbNcUEqqEqG5exqo4VgS/N6iae5lxGgVwVxlXOSebZ7RFjWtqCU+CkAz sqqM7PB4x1OW5MAdhqWcYkqTzorrDdKmLq2+5Z3Ol+DtiXHDiSIr7rv7uauPmbvKlK4Q CEOEAxqGafb/UUTz5zsuBjJygPdKA4Fbbo8lh1uJY553NFzB8vAaIqYKd8DitBcB9gLZ Ok2c2AiZ3fBWLGVegRpr6f1nv8xCxR2MTCl/paROXV2rl+rlzwnG05CKDAUo3Ur9mYFX RVns1aZIKcVJORdPPcghmwhGfHLEZJDTIJu9rLT8F19/jgg8+h34gI9se7gEIMqTl+bo DBOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CjVgtKIE; 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 dr14-20020a170907720e00b007c6be26824bsi17581616ejc.544.2022.12.30.23.22.43; Fri, 30 Dec 2022 23:22:58 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=CjVgtKIE; 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 S235614AbiLaGmq (ORCPT + 62 others); Sat, 31 Dec 2022 01:42:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231508AbiLaGmb (ORCPT ); Sat, 31 Dec 2022 01:42:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FE0DF1E; Fri, 30 Dec 2022 22:42:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 18E8060907; Sat, 31 Dec 2022 06:42:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05A2DC43398; Sat, 31 Dec 2022 06:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672468949; bh=pPtNFbrwZDEe7R9hGihgBI1Cy7TXHMHG4P1tYoFNjZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CjVgtKIEuSKQV5RCpmNW/O1yoF8JI3xd4McrQbIA1czpfqaWgRrk6xd17BGHx0PCm DFolHEM19x+a1P2/nb6IRjgHxdQ8jIa4JXX7AlN3oWWhy7oYUZ6IDqVWRWnxdn3lT+ asNw5BnhqGchSuGcSLoup/1h6PO6BKWS0EVdJye5wpTpFPNymP3pn5cjdKHPre+bd9 i35/ppuKtMFTmAhI3VmsvfST7UgTpDXRHbURyPRtzHGmFoOYYzhDhHX3By9gt+HH3z YhVjAzGUxc7HxAFwbKQKjw8jiN3dmx4LDphYdntmnQp1Q9PG2Z4nQZg5z9mLoJDfwK 8aJdtTZBiB4Jw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Masahiro Yamada , Alex Gaynor , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Boqun Feng , Gary Guo , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Wedson Almeida Filho , rust-for-linux@vger.kernel.org Subject: [PATCH 5/6] fixdep: avoid parsing the same file over again Date: Sat, 31 Dec 2022 15:42:02 +0900 Message-Id: <20221231064203.1623793-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221231064203.1623793-1-masahiroy@kernel.org> References: <20221231064203.1623793-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 The dep files (*.d files) emitted by C compilers usually contain the deduplicated list of included files. There is an exceptional case; if a header is included by the -include command line option, and also by #include directive, it appears twice in the *.d file. For example, the top Makefile specifies the command line option, -include $(srctree)/include/linux/kconfig.h. You do not need to add #include in every source file. In fact, include/linux/kconfig.h is listed twice in many .*.cmd files due to include/linux/xarray.h including . I did not fix that since it is a small redundancy. However, this is more annoying for rustc. rustc emits the dependency for each emission type. For example, cmd_rustc_library emits dep-info, obj, and metadata. So, the emitted *.d file contains the dependency for those 3 targets, which makes fixdep parse the same file 3 times. $ grep rust/alloc/raw_vec.rs rust/.alloc.o.cmd rust/alloc/raw_vec.rs \ rust/alloc/raw_vec.rs \ rust/alloc/raw_vec.rs \ To skip the second parsing, this commit adds a hash table for parsed files, just like we did for CONFIG options. Signed-off-by: Masahiro Yamada --- scripts/basic/fixdep.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index b20777b888d7..cc8f6d34c2ca 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -113,7 +113,7 @@ struct item { }; #define HASHSZ 256 -static struct item *config_hashtab[HASHSZ]; +static struct item *config_hashtab[HASHSZ], *file_hashtab[HASHSZ]; static unsigned int strhash(const char *str, unsigned int sz) { @@ -361,6 +361,10 @@ static void parse_dep_file(char *p, const char *target) * name, which will be the original one, and ignore any * other source names, which will be intermediate * temporary files. + * + * rustc emits the same dependency list for each + * emission type. It is enough to list the source name + * just once. */ if (!saw_any_target) { saw_any_target = true; @@ -368,7 +372,8 @@ static void parse_dep_file(char *p, const char *target) printf("deps_%s := \\\n", target); need_parse = true; } - } else if (!is_ignored_file(p, q - p)) { + } else if (!is_ignored_file(p, q - p) && + !in_hashtable(p, q - p, file_hashtab)) { printf(" %s \\\n", p); need_parse = true; } -- 2.34.1