From nobody Mon Feb 9 23:20:06 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 671CC34F261 for ; Tue, 28 Oct 2025 18:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761676121; cv=none; b=JF6NnTm23ZmxV/jgZswH0N47oU6+Q1me2PU9bAdNTax6KCovF6PvE1bupws8kxLWvMb9NeBe5DY6FiT7NWTiqoMGgdfXH9TsO+WSFZb1YtI23m1x7xv7iSKL4utgxT9eI4e3rKOM9zEoyAb8Vx1hDjszEeKnlOtNMQS8hh6204o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761676121; c=relaxed/simple; bh=WgKzjafwH7TVHq/wIftKYDsK8eXAkXDqosj1lO8Z+ss=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=muiOQZMOI8JzRHqcyMQn8qVfWrt0t7JLoYYCrNZFZuTtx43trsQjAo0VLZAvjWmU3JAZcJr4Y0wFIfTM7XagNLTrsgZzG86LZ85A8CmAvgKKawHuFLx6OThRFip+ZLyDse5X3OQZTm3DZhy1q4UH3q5BjjWpF6XPEt+PoXZWUR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--xur.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Yjy9hv5y; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--xur.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Yjy9hv5y" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-33baf262850so5802180a91.0 for ; Tue, 28 Oct 2025 11:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761676119; x=1762280919; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/650juIRrFR+/zBE4AsJfIehjRLeu/NobhGC5TTIp60=; b=Yjy9hv5y6YEXiFjmqCaK8bd3Mdk2+a/BHFeeLWSri7G+dAkx1NzABNtAbMWiYWgsUI 79Szul/WJ1nr/RgZXcFDRUK7F6TutT21hx2xlMD482BqckzBoMFIFXAkgZF/xIuF/Bm6 Mm9ou7+fUkpyyIcz33oPLj3L44EgFnbEEyNAYaqrY/nyEFx4ybMFzh7arS6madnaa3u4 sJo/LfsIB9muF4NAR5rHKx7fb0cY09jluo5drIgarcs1Gd7BWh5Iw8Z1n0M90mPaGACG t40/I+Fa3lTubDV5eM4C8TFl5xDd/S1m1fSO6Q4Ja8x1f9deZOTewbI085vjvep1Mtca ck2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761676119; x=1762280919; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/650juIRrFR+/zBE4AsJfIehjRLeu/NobhGC5TTIp60=; b=s9vgIlV6j38uFq8f34b4Z4/K/KLzMgNSkZhrju8ESv01Dn/miAmNI6HWtRaHZEo+q6 QSulNbdiDAHIGF1Pbe0GU9/JF+8EIr84MOvCyCi7taxc1fZQZ0szzJ9TTyhdT9vyGeHk /lc65pch/wxOfchQLpgjaM+8fgKzjLNrIBtAcYiVcFxUWNGFbzzh+ReHAJbJO2YHzCR0 GzkdTDhb4NUNCPXX9SIsI4X9YbBcKSyLn3AxoNI/opXunaiRlfJkEfSzbT4PETPJk+xp dXMTNzc0+fOj9pW+HkO7TJhU/JKi5FDmKvAurQ9gckDeiNkiBSSsccvgD1/WH8Mc/Vmf gHPw== X-Gm-Message-State: AOJu0YxTTbJmoFs9ipzSYpZcMTLCUL9BPRXZ58ZuZUsj4k6MyjaUcqRm BNjwb16e2yrKfLokxOh4kZ9K85vD2bNnV8PDbZFyXtJLXUxBBvs9ffqMjdDAyN16Okt0Bg== X-Google-Smtp-Source: AGHT+IEuaqPA4h6d9Z15XGnhnp3xsDJZ2pRkvpl/6jf0iWxm9m5r06Z5/t55EDVczMXO06zO/bVxqNA= X-Received: from pjbru2.prod.google.com ([2002:a17:90b:2bc2:b0:33b:a0ae:940]) (user=xur job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1c8a:b0:330:797a:f504 with SMTP id 98e67ed59e1d1-3403a15d128mr7164a91.3.1761676118599; Tue, 28 Oct 2025 11:28:38 -0700 (PDT) Date: Tue, 28 Oct 2025 18:28:21 +0000 In-Reply-To: <20251028182822.3210436-1-xur@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251028182822.3210436-1-xur@google.com> X-Mailer: git-send-email 2.51.1.851.g4ebd6896fd-goog Message-ID: <20251028182822.3210436-2-xur@google.com> Subject: [PATCH v5 1/2] kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a From: xur@google.com To: Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Miguel Ojeda , Thomas Gleixner , Alice Ryhl , Sami Tolvanen , "Mike Rapoport (Microsoft)" , Rafael Aquini , Michael Ellerman , Stafford Horne , Christophe Leroy , Piotr Gorski , Rong Xu , Teresa Johnson Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Rong Xu From: Masahiro Yamada Move the build rule for vmlinux.a to a separate file in preparation for supporting distributed builds with Clang ThinLTO. Signed-off-by: Masahiro Yamada Tested-by: Rong Xu --- Makefile | 16 +++++-------- scripts/Makefile.vmlinux_a | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 scripts/Makefile.vmlinux_a diff --git a/Makefile b/Makefile index b34a1f4c03967..89a25bac2bbab 100644 --- a/Makefile +++ b/Makefile @@ -1198,7 +1198,7 @@ export ARCH_DRIVERS :=3D $(drivers-y) $(drivers-m) KBUILD_VMLINUX_OBJS :=3D built-in.a $(patsubst %/, %/lib.a, $(filter %/, $= (libs-y))) KBUILD_VMLINUX_LIBS :=3D $(filter-out %/, $(libs-y)) =20 -export KBUILD_VMLINUX_LIBS +export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS export KBUILD_LDS :=3D arch/$(SRCARCH)/kernel/vmlinux.lds =20 ifdef CONFIG_TRIM_UNUSED_KSYMS @@ -1207,16 +1207,12 @@ ifdef CONFIG_TRIM_UNUSED_KSYMS KBUILD_MODULES :=3D y endif =20 -# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <=3D 14 -quiet_cmd_ar_vmlinux.a =3D AR $@ - cmd_ar_vmlinux.a =3D \ - rm -f $@; \ - $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \ - $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(src= tree)/scripts/head-object-list.txt) +PHONY +=3D vmlinux_a +vmlinux_a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_a =20 -targets +=3D vmlinux.a -vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE - $(call if_changed,ar_vmlinux.a) +vmlinux.a: vmlinux_a + @: =20 PHONY +=3D vmlinux_o vmlinux_o: vmlinux.a $(KBUILD_VMLINUX_LIBS) diff --git a/scripts/Makefile.vmlinux_a b/scripts/Makefile.vmlinux_a new file mode 100644 index 0000000000000..9774f02b43b2f --- /dev/null +++ b/scripts/Makefile.vmlinux_a @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0-only + +PHONY :=3D __default +__default: vmlinux.a + +include include/config/auto.conf +include $(srctree)/scripts/Kbuild.include +include $(srctree)/scripts/Makefile.lib + +# Link of built-in-fixup.a +# ------------------------------------------------------------------------= --- + +# '$(AR) mPi' needs --thin to workaround the bug of llvm-ar <=3D 14 +quiet_cmd_ar_builtin_fixup =3D AR $@ + cmd_ar_builtin_fixup =3D \ + rm -f $@; \ + $(AR) cDPrS --thin $@ $(KBUILD_VMLINUX_OBJS); \ + $(AR) mPi --thin $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f= $(srctree)/scripts/head-object-list.txt) + +targets +=3D built-in-fixup.a +built-in-fixup.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE + $(call if_changed,ar_builtin_fixup) + +# vmlinux.a +# ------------------------------------------------------------------------= --- + +targets +=3D vmlinux.a +vmlinux.a: built-in-fixup.a FORCE + $(call if_changed,copy) + +# Add FORCE to the prerequisites of a target to force it to be always rebu= ilt. +# ------------------------------------------------------------------------= --- + +PHONY +=3D FORCE +FORCE: + +# Read all saved command lines and dependencies for the $(targets) we +# may be building above, using $(if_changed{,_dep}). As an +# optimization, we don't need to read them if the target does not +# exist, we will rebuild anyway in that case. + +existing-targets :=3D $(wildcard $(sort $(targets))) + +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) + +.PHONY: $(PHONY) --=20 2.51.1.851.g4ebd6896fd-goog