Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2738720pxb; Tue, 9 Mar 2021 09:37:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9fSy8V2YQFr4spPvPkHgTrery8yEZeYtESM50T1lkibhDw2tuwC5J99u0syca3YAQKf4U X-Received: by 2002:a17:906:388d:: with SMTP id q13mr21909067ejd.34.1615311459470; Tue, 09 Mar 2021 09:37:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615311459; cv=none; d=google.com; s=arc-20160816; b=kCHCJiC7QJqnrpe9+BD38CQ8/umsPHz12H8tPEhN07lOVDU6WeV0wuCK9GYdpbw5iE nTJjmRxYPpzYNHw9JTuAzwisySjBwm7IlJg+EZGX670+5N9hZGJScmAiLPtEayGmth22 z/G39mLeewrFMhyQWzpAJEhbMfhEb+duyApOw/iJofxg0QEHA5y/Yz/E/OXDmADOiDHN wMkNMqsk/NUzVzMSaUTAeJS3mpUyZzZ+ibeTcnM3sijD1F0wxrBX0A6AdwDHda3VrDFs 43B49f2JRgTkc9HdBDGUjzqkRbAqkmccjqvwz3lAm0CQOx6X//PuS66xfKvn3/eK0TVh dgaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=xznurfphUjaMW1HbmV/JfxzqH+D/sie7qCAPaGr7+MM=; b=M4/nt/FiM4KFmOJMrRO8DWO2Hetrb67SsdeysFCkll+5gPpsbjBNm/W8lO0cG+fKA9 9Z06enDgGHj3j2nM+klP3NH2JQ1/sRO4ouydOZ3lGR1Rcfn81IYBZlDy+5Xq9m87z3vS 0xC96+bvt+nvvQl909IJ3ygEulbSeBxLxtYeAMpWVM1XJ7Qrg8lp0cmewO6FWvdBc5Cz Du7PsaKC3b6CNQPJ9vuc+6zFne985+iwsuY9Jy4EHJAJ4CDHe4yrj4zBuwRXI9aoxY2c 8YCVLhHbt2EcVj0xlGd4SPcOm29t+XQMjo9TupjsXlU9jfNpZQQzi/1FFjqcm4zfVDcV na+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=Q6DrNAYY; dkim=pass header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=qGHNc3tC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si9942064edr.249.2021.03.09.09.37.16; Tue, 09 Mar 2021 09:37:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=Q6DrNAYY; dkim=pass header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=qGHNc3tC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbhCIRgS (ORCPT + 99 others); Tue, 9 Mar 2021 12:36:18 -0500 Received: from pb-smtp1.pobox.com ([64.147.108.70]:52345 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbhCIRgS (ORCPT ); Tue, 9 Mar 2021 12:36:18 -0500 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id EDE84AA116; Tue, 9 Mar 2021 12:36:16 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=Q5bTVZkC+LzcSiiWD+vXAhphew4=; b=Q6DrNA YYGURgXv6Uca99oe6ghQ1nckzyPBv7KKfjpV95WIn4SI0P/7zhal3p9eKTUudfuw U6DuI0KHCQJh+yzMXiC/NnOk4k9u3SEApnI8YeYizcBqw7La/ETU8UOy6reSJ3La MMgXyyUO+G9DlMmwqRjTsvDmHm0HxjrV2y/GQ= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id E4892AA115; Tue, 9 Mar 2021 12:36:16 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=DdhtRSv6lLEXu3vP9THOvIdQg+N3RK8guLnDMEzAdlA=; b=qGHNc3tCviaiGK1DTsFSW8Jad23GqNat6z+AFXE7Xm0tuDn+nc6igjzClCsrf0Pm+xtu7+LKkKcigufcSTfICY53MJ2uz+oZ4QXugjWgTup4pjDezdE4FHfpsXFUrTGx8i/XKzpDEGGrlVx9bR+a/9oKcpiiBALUHRJqLPpAbtk= Received: from yoda.home (unknown [24.203.50.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 66A89AA114; Tue, 9 Mar 2021 12:36:16 -0500 (EST) (envelope-from nico@fluxnic.net) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id 856AB2DA017E; Tue, 9 Mar 2021 12:36:15 -0500 (EST) Date: Tue, 9 Mar 2021 12:36:15 -0500 (EST) From: Nicolas Pitre To: Masahiro Yamada cc: linux-kbuild@vger.kernel.org, Christoph Hellwig , Linus Torvalds , Jessica Yu , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH v2 3/4] kbuild: re-implement CONFIG_TRIM_UNUSED_KSYMS to make it work in one-pass In-Reply-To: <20210309151737.345722-4-masahiroy@kernel.org> Message-ID: <354sr3np-67o8-oss9-813s-p2qoro06p4o@syhkavp.arg> References: <20210309151737.345722-1-masahiroy@kernel.org> <20210309151737.345722-4-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Pobox-Relay-ID: F372C0B8-80FD-11EB-B49F-D152C8D8090B-78420484!pb-smtp1.pobox.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 10 Mar 2021, Masahiro Yamada wrote: > Commit a555bdd0c58c ("Kbuild: enable TRIM_UNUSED_KSYMS again, with some > guarding") re-enabled this feature, but Linus is still unhappy about > the build time. > > The reason of the slowness is the recursion - this basically works in > two loops. > > In the first loop, Kbuild builds the entire tree based on the temporary > autoksyms.h, which contains macro defines to control whether their > corresponding EXPORT_SYMBOL() is enabled or not, and also gathers all > symbols required by modules. After the tree traverse, Kbuild updates > autoksyms.h and triggers the second loop to rebuild source files whose > EXPORT_SYMBOL() needs flipping. > > This commit re-implements CONFIG_TRIM_UNUSED_KSYMS to make it work in > one pass. In the new design, unneeded EXPORT_SYMBOL() instances are > trimmed by the linker instead of the preprocessor. > > After the tree traverse, a linker script snippet > is generated. It feeds the list of necessary sections to vmlinus.lds.S > and modules.lds.S. The other sections fall into /DISCARD/. > > Signed-off-by: Masahiro Yamada I'm not sure I do understand every detail here, especially since it is so far away from the version that I originally contributed. But the concept looks good. I still think that there is no way around a recursive approach to get the maximum effect with LTO, but given that true LTO still isn't applied to mainline after all those years, the recursive approach brings nothing. Maybe that could be revisited if true LTO ever makes it into mainline, and the desire to reduce the binary size is still relevant enough to justify it. Acked-by: Nicolas Pitre Nicolas