Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2097973rwl; Fri, 6 Jan 2023 01:43:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXteL0rhWzbAOAykyoGxNPifJoR+mgDVIkWD06r6pNzngGreUIcrDErw6q95yTnHHoa6I2No X-Received: by 2002:a17:902:904b:b0:186:95c9:ddc9 with SMTP id w11-20020a170902904b00b0018695c9ddc9mr67232875plz.55.1672998183904; Fri, 06 Jan 2023 01:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672998183; cv=none; d=google.com; s=arc-20160816; b=y6Qelx7Syj88kQX28tmNdggpS89T0XB/AF4zazQlUZPLzcBY8zl2ijfRLE/w4OjfxP Exq4iMGJzfg5vNMIhPOThW+yRKUYFxpAdCKTrOKm4oyMaOii43K8zp3PPE+aqB9vqpgY jhPSyl8Dd/tYjzkLG59MYN/r4/riFTT4yp3JM0PLVYvauHYUapRaLAhNSWqq/iSk8VQ+ q272bnAzifA0OgoAuNTjk3WVVFcWrBIVWfNOklNQdKXzWZH3PbtuW//Wm4dyqvFj2N4+ FImExmpdRWfhT2kvvt4AIy3iu6hFBHtwWxY7K0XvNweaH9zzlKTM433yMY89Mk8YJg42 JqSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:to:from:subject:cc :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=th0WEGaeBwuDgYUOSMw9cNMnaXqVuZ+hnr9Z3HPgsnM=; b=PqpzS3GY5Jl6Mvx323YgqKUPJ1UasiuxrcN1tjIEsfOID1fbyGio7Fk0c6CDjZzHNw TYrrfzC1XMsJ6pFGhnynzM7ZGeMgVkSeZ+duvnfjl618kvjMJefPJVYYWlfjddRILeMJ Okh9Pqwnl5upFX6BtG4BWhn+Y90xlNpffT2LS4N3b5E3pFu6YvKNuFs5Pon9dOQBSMC6 fRZi26jtWk0l72Df9fbgLmx1SHRGqtdJ00xteZgGeUnZXOVT06IBu8Jnsgnzx9C17zxn byVlW4jOJHhJ/btg1bR5xajXufIfGhFfRHT1qi2/RDHJ3aaQbCZK0k8rbUq3UAt7gBhf ZaGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=P4h1nCH0; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a170902cecb00b001897bfe1ec1si659784plg.345.2023.01.06.01.42.56; Fri, 06 Jan 2023 01:43:03 -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=@gmail.com header.s=20210112 header.b=P4h1nCH0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232328AbjAFJkH (ORCPT + 54 others); Fri, 6 Jan 2023 04:40:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233361AbjAFJjb (ORCPT ); Fri, 6 Jan 2023 04:39:31 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 149C243E6A; Fri, 6 Jan 2023 01:31:54 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id bk16so733011wrb.11; Fri, 06 Jan 2023 01:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=th0WEGaeBwuDgYUOSMw9cNMnaXqVuZ+hnr9Z3HPgsnM=; b=P4h1nCH0pNXiBh97+05WMCCCnvwVd+8Qh+qHWdt1XOsIvPsTIN0gDOv2ElSVJbpQtZ iTdW/+Nq9eQl0f42F355euMRrZjwsE8nmdAQRXaVRsEdeqE2DAOa0Knnbe9xH0fHG3nJ p9jp3CGQYctIYOjq/CprJVeVqL7M8iLfNh4W34JBFu64O7yH0FzAW0dXdSLCAl2CGoLS xqcn5wBkgx/Cms+7GNI7mwmjSCMtuC6mtc69nZkB8J+Drfu3ru7eew11rx2M+vVjtZks jQXATSqYyaYguuYnDDSjWaLSklo/pdCK1RdJkZHOvBx9FlXqvYIM1+03RaQp32sco2pU h6TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=th0WEGaeBwuDgYUOSMw9cNMnaXqVuZ+hnr9Z3HPgsnM=; b=Utyiwl/aBq1cbnir5oTbyw0jHlNu17lwg29DMxCYr47WJWrE3nmMXN/Vn4l6MuwMhh 21TFuAHeHozzFAD9xOrCRadl++wVnrEXNJ/TRw5wN03HNoVkIpKLAZOB4rSDBmFeQP8D IF1o5v5CBMw8Zp7C7FpeJJejIik1eMc34MjLi2K3BPYWJkayqNsTafBGs9ECDK5xgnN8 Vki9bKsI6O7VwvcqrSjVnXke+4t8BXV6Wq/wG9qBT3h+O9AE9CTQ2BNqpRsBE3MhOqzd tjCxGZSnEOJFLUAQuh5OmcdVe/L10OVGgkXqW7YKcPjojaIIIBN/WQhY2zoZQyd6fSfX atAg== X-Gm-Message-State: AFqh2krNIoZKmhrekrm/bZ+E6Yqj/Qe5Vx6+mW9BynLMAC3yBV9LUynu 8qZHY02K2sNr9uPslZRSzy8= X-Received: by 2002:a5d:4950:0:b0:26e:7604:6575 with SMTP id r16-20020a5d4950000000b0026e76046575mr31432386wrs.65.1672997512513; Fri, 06 Jan 2023 01:31:52 -0800 (PST) Received: from localhost ([217.138.219.182]) by smtp.gmail.com with ESMTPSA id bj27-20020a0560001e1b00b0023659925b2asm659623wrb.51.2023.01.06.01.31.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Jan 2023 01:31:52 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 06 Jan 2023 10:31:49 +0100 Message-Id: Cc: , "Miguel Ojeda" , "Alex Gaynor" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Boqun Feng" , "Gary Guo" , "Nathan Chancellor" , "Nick Desaulniers" , "Nicolas Schier" , "Wedson Almeida Filho" , Subject: Re: [PATCH 5/6] fixdep: avoid parsing the same file over again From: "Vincenzo" To: "Masahiro Yamada" , X-Mailer: aerc 0.8.2 References: <20221231064203.1623793-1-masahiroy@kernel.org> <20221231064203.1623793-6-masahiroy@kernel.org> In-Reply-To: <20221231064203.1623793-6-masahiroy@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Reviewed-by: Vincenzo Palazzo On Sat Dec 31, 2022 at 7:42 AM CET, Masahiro Yamada wrote: > 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 { > }; > =20 > #define HASHSZ 256 > -static struct item *config_hashtab[HASHSZ]; > +static struct item *config_hashtab[HASHSZ], *file_hashtab[HASHSZ]; > =20 > static unsigned int strhash(const char *str, unsigned int sz) > { > @@ -361,6 +361,10 @@ static void parse_dep_file(char *p, const char *targ= et) > * 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 =3D true; > @@ -368,7 +372,8 @@ static void parse_dep_file(char *p, const char *targe= t) > printf("deps_%s :=3D \\\n", target); > need_parse =3D 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 =3D true; > } > --=20 > 2.34.1