From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.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 DF671421A09 for ; Fri, 29 May 2026 18:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780080836; cv=none; b=H4ZLAodqyB5hrLgN1Oh/+YpZbXTZkmHsR6filZUG98hMrALIUYCGzKJ1acJmn4lNtoRVRrtbUF1JIMqxhXRU3dI5G8Q3gl4KJG3Arg1sb7B6Kd9As5fyjqF+oXc3Hh7Eo44LPWxkUuNtmVGlhcLPEbV/Hi3078GGcJfSHJqUpGU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780080836; c=relaxed/simple; bh=nM3I23N6J3rf1+A39I1UKYCnI6r93ke/uZ68ANA8cws=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Hd9vypjzywfmhKK+3IEB/Fim7tHOF8EJRWxfBArK+tSEV13UjDW4pitnhjJpbr/RCpFWTQFCsIye7gEfGuxs1h7M0OCwy6Xf4hT4fhqqkDAUq1dFishJ4U7QKksJnyb03JWKDa8sw0R8VmMLcoKgylkkZ8Piqlo5A6DjZ+5QUwk= 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=Hzzgfa8G; arc=none smtp.client-ip=74.125.82.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="Hzzgfa8G" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-135fe34cb98so15687224c88.0 for ; Fri, 29 May 2026 11:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780080831; x=1780685631; 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=rYiHWgzyN9qEbPXmYY6E8njhDvnt+Sz3conx1MK3jyc=; b=Hzzgfa8GDLRPQXGci/YeItUMo6sqIXzJyKz7wgxFBKwvvJdBhos0nU+LYcPyuFUwEz BG86cvmK1aTicvd2llrhMLf4Kum0sPs/sSMZaSoQ2nT6Gs99x/qPFZk/Y7Q5IBYu78jU po65c6MzvoOXHLrIF93r3nWWTHonuA3gc0qRP1s8QBPwyy3jJDueJngyJd+IOBie2CnV xv2DE3bHaLE9rP/HDpgO74s3J2GMCH2KQZjIwE6au2ad83KJ2bD6ZGd2mD0H7Ct3NjJi L+kHkTzDKYYgNDNOxG3o6rBtGO6/G3ujshWIpgq2V7PviXwn7skNFTLHRZKHSr9qT2Jh WzjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780080831; x=1780685631; 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=rYiHWgzyN9qEbPXmYY6E8njhDvnt+Sz3conx1MK3jyc=; b=a1njrUljg4muTdC/mS1q6s0ipRBNxGDL2wheitndpl+Nk0NiSEJxaul5gcyuqyHC++ vCxtBhpUdQwCZdpDU/zqoAcyInqWO59TGnbNwjrVVfUuL5W3RVrG9TUtuCn74eKeHG87 CYw9twZhendqPX7rb8Kc/b+lxYk75lzHGaOohZc4hxJ6/A0z6U3UAdsbRR44Y5hA3Xok bC9rexFcz8hclS3fijBmU5B/xiL645yHlyNlmwmITaUu488hNU+4BnjRgqKSuWULQDZh xPbAYqhWwHinwyVCkcEykLnH1hKyGaHH+vF66v09AQzOLoUFUutP7viLAFjJyVagncOZ peXw== X-Gm-Message-State: AOJu0YxRnSEx/QELISgjRNwlb+FsJb26TIMZwZENce+NDNxoI4G6gONR X9VX1iLvhvmgxOk8ub2wg56LK1VidD4l2bK33RPywx0IqOIKlOI3Hv96PhYUeWYo1Dmr4w== X-Received: from dlea10-n2.prod.google.com ([2002:a05:701b:420a:20b0:136:6230:5814]) (user=xur job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:60a4:b0:137:6781:7dc5 with SMTP id a92af1059eb24-137d412b5cdmr466972c88.24.1780080830650; Fri, 29 May 2026 11:53:50 -0700 (PDT) Date: Fri, 29 May 2026 11:53:44 -0700 In-Reply-To: <20260529185347.2418373-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: <20260529185347.2418373-1-xur@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260529185347.2418373-2-xur@google.com> Subject: [PATCH v12 1/3] kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a From: xur@google.com To: Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Yonghong Song , 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 , Venkat Rao Bagalkote , Miguel Ojeda , Teresa Johnson Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev 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 Tested-by: Piotr Gorski Tested-by: Nathan Chancellor Signed-off-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 e27c91ea56fc..0fce9557a115 100644 --- a/Makefile +++ b/Makefile @@ -1291,7 +1291,7 @@ export ARCH_DRIVERS := $(drivers-y) $(drivers-m) KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y)) -export KBUILD_VMLINUX_LIBS +export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds ifdef CONFIG_TRIM_UNUSED_KSYMS @@ -1300,16 +1300,12 @@ ifdef CONFIG_TRIM_UNUSED_KSYMS KBUILD_MODULES := y endif -# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14 -quiet_cmd_ar_vmlinux.a = AR $@ - cmd_ar_vmlinux.a = \ - rm -f $@; \ - $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \ - $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt) +PHONY += vmlinux_a +vmlinux_a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_a -targets += vmlinux.a -vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE - $(call if_changed,ar_vmlinux.a) +vmlinux.a: vmlinux_a + @: PHONY += 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 000000000000..9774f02b43b2 --- /dev/null +++ b/scripts/Makefile.vmlinux_a @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0-only + +PHONY := __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 <= 14 +quiet_cmd_ar_builtin_fixup = AR $@ + cmd_ar_builtin_fixup = \ + 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 += 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 += 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 rebuilt. +# --------------------------------------------------------------------------- + +PHONY += 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 := $(wildcard $(sort $(targets))) + +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) + +.PHONY: $(PHONY) -- 2.54.0.823.g6e5bcc1fc9-goog