From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EBBAC79FAA for ; Tue, 8 Sep 2026 20:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PcIlF+yWye+TojEf+vHH6LOUUrs8nmn+kyG88+Z5Ni0=; b=rTNHC/tT46Ndqv TmJodzFbmQw4w3Qkg5WKgybr4g28g9Oa8nP8kdzuLLcdEiOV9+qKod1/zW9ZYRzSiokaj5rnTvwcp fCR9ECr+zTLtpECVN+Pvv30+sWueluaQZon5jvvpHr353w48zFA1bpqfqKUwiazv+EiWxiZjQ348R cBQbSQtUzhp/tdGlI9fIpqWBr38B9BwDYsz709VDRcsIoaV4LVxCA18eJesdi4VnHBc2jpy2RgMR5 GBi7STrRofBZV580BIiGKj9YvYsUAhcadVVdemqd+VATuSN8ssiar5mHZb9lQ1pycCNA4ENrAt3ND KfokDIR6F77fKR4Lu0Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x42ry-0000000AF6j-3sc8; Tue, 08 Sep 2026 20:56:42 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x42rw-0000000AF59-4BdB; Tue, 08 Sep 2026 20:56:41 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 6E144601DE; Tue, 8 Sep 2026 20:56:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D80F1F00A3A; Tue, 8 Sep 2026 20:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788901000; bh=i4mmShyVZGlgCcDLfFsSbEgGMvI3VWrUjGiN2LoMKxY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Ia7otobCwNkhAtHa/irExbcNB39utNz/W3ids/Ovxn6+xF9yjVuSRttrN3bvH3Q88 eEUZ47xB5oUWgq73QBzX+L5v4SNhDmB8A/tobfOM2Lr2Ctw13MxEcooPf/B9vpxj8S Co85Z+fqnbnrJIWyihZVcv2KJwi5weDsPwwhfZaANjyYd7nkLmO98km3QVVAIBkz2K bunSAccE/1l/tzbk6UQMnLrwAFgBjckXWiBugdVPaiP19tJHqEDaYifEUYetj4UK6q sy0IFHIS+L1yHhDjd62WWvz0/Y0QNHUXwZqBsJJXLEpJ+2RnYopzAk7D70CoL42Gj/ uL3Jpl3v1nl8A== From: "Lorenzo Stoakes (ARM)" Date: Tue, 08 Sep 2026 21:55:06 +0100 Subject: [PATCH 06/23] kbuild: only emit vmlinux relocations when required MIME-Version: 1.0 Message-Id: <20260908-build-speedup-v1-6-5dc1ac01672d@kernel.org> References: <20260908-build-speedup-v1-0-5dc1ac01672d@kernel.org> In-Reply-To: <20260908-build-speedup-v1-0-5dc1ac01672d@kernel.org> To: Linus Torvalds , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Masahiro Yamada , Alexey Gladkov , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Arnd Bergmann , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Ilias Apalodimas , Josh Poimboeuf , Peter Zijlstra , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= , Jonathan Corbet , Randy Dunlap Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, Jens Axboe , "Lorenzo Stoakes (ARM)" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3331; i=ljs@kernel.org; h=from:subject:message-id; bh=N13ZqN50eOU7uY3QR0adbXAgcslOg42oxhOb+TbiiNY=; b=owGbwMvMwCV2fu7ZrsZH9SKMp9WSGLIWlJkt3xWaebJaeGL+Iy2LKP8PquXzJH3nb+NPU+v7v +ri19ncHaUsDGJcDLJiiizPv4jvDxIJm9d5wd8NZg4rE8gQBi5OAZhIVSYjw28ziSzFyOPHLuxN d+HOdz7m1O692N/s6NnTf+UL4/Q0VzD8s3+t5hF984P3AqmC154yZ368DXzBtN93Ts1vtiDP7ms R/AA= X-Developer-Key: i=ljs@kernel.org; a=openpgp; fpr=E7F417BF5214569E89D04F46CF9DCD8A81E27F14 X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org A kernel build consists of more than one linking pass on vmlinux.o and vmlinux, at minimum two, and with CONFIG_KALLSYMS and BTF enabled on x86-64 for example there are 5 such stages. For architectures that build their own relocation tables (x86, riscv, mips, s390), vmlinux is linked with the --emit-relocs parameter specified. However, this is only required on the final vmlinux link. Symbol tables of trial links preceding it don't need it because they already check that System.map matches kallsyms symbols on each build. GNU ld is slow at emitting relocation tables, so this results in a reduction in build time. Whole build, 128-thread Threadripper 9980X, best of N runs: before after delta ------------------------------- x86 defconfig, touch mm/vma.c, gcc 9.8s 9.4s -0.43s (-4%) x86 defconfig, clean, gcc 28.6s 28.1s -0.47s (-2%) x86 allmodconfig, touch mm/vma.c, gcc 44.0s 42.7s -1.3s (-3%) Note that this has little impact on LLVM ld which performs this operation more efficiently. Assisted-by: LLM Signed-off-by: Lorenzo Stoakes (ARM) --- Makefile | 4 +++- scripts/Makefile.vmlinux | 3 ++- scripts/link-vmlinux.sh | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 66654fa71655..85eb2fd026cb 100644 --- a/Makefile +++ b/Makefile @@ -1263,8 +1263,10 @@ LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) endif ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),) -LDFLAGS_vmlinux += --emit-relocs --discard-none +LDFLAGS_vmlinux += --discard-none +LDFLAGS_vmlinux_relocs := --emit-relocs endif +export LDFLAGS_vmlinux_relocs # Align the architecture of userspace programs with the kernel USERFLAGS_FROM_KERNEL := --target=% diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index fcae1e432d9a..4b54aaeca65d 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -64,7 +64,8 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) # Final link of vmlinux with optional arch pass after final link cmd_link_vmlinux = \ - $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ + $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@" \ + "$(LDFLAGS_vmlinux_relocs)"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) targets += vmlinux.unstripped .vmlinux.export.o diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 970ca10f8fa9..09c5222ccb94 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -32,6 +32,7 @@ LD="$1" KBUILD_LDFLAGS="$2" LDFLAGS_vmlinux="$3" VMLINUX="$4" +LDFLAGS_vmlinux_relocs="$5" is_enabled() { grep -q "^$1=y" include/config/auto.conf @@ -96,6 +97,11 @@ vmlinux_link() ldflags="${ldflags} ${wl}--strip-debug" fi + # Only the final link actually requires the relocations. + if [ "${output}" = "${VMLINUX}" ] && [ -n "${LDFLAGS_vmlinux_relocs}" ]; then + ldflags="${ldflags} ${wl}${LDFLAGS_vmlinux_relocs}" + fi + if [ -n "${generate_map}" ]; then ldflags="${ldflags} ${wl}-Map=vmlinux.map" fi -- 2.55.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv