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 1EECB2BF3E2 for ; Thu, 28 May 2026 20:39:09 +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=1780000750; cv=none; b=GJI/MhvYAcN6Wd1+1/Kmu8Huxhlsr1uA36lpYo65rqojgsVNNIMcjLVmupD05ZzN9JthXSKfS7YMKJe8+RMib3JmciZNpNUn1YQO1+LAP4aMbVX31HPvdC7RMrPn5fndoTAPz/o0n11wyDx2k7pcs6I7HfZjAClpR3uZTOFhqZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780000750; c=relaxed/simple; bh=nM3I23N6J3rf1+A39I1UKYCnI6r93ke/uZ68ANA8cws=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QjiQsC+z45msRUKhM14OnItJkf2Yap0lY6/j2i/WsPij7KfD7PLkd5HImMgg+KfoU8eCFuR+pepZmZ3I4tF1/8UL9p7RMxzlTTPKPF+y+d8f4s6txWJWpVlOi5dABf112/YhLF5rqUEuM8Of8mypcjBfSauU2sGaYtOq7CKKF1A= 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=dn0bIEPK; 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="dn0bIEPK" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-13536592ebeso745089c88.0 for ; Thu, 28 May 2026 13:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780000748; x=1780605548; 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=dn0bIEPKnLt1d5GmjT4VWVovZCV+r9PLwV4TtPsTc8EzyOtTvDnwCyKoTaOK8dJlsy gY2Kht39cRo6P/3HBQC53ktThrJepdR/8APib3keln0m65Wf91J7Jzu4RSbqRDebEVXO NBaswzthbQNgD5MjbtLmt7j86J1p6wfCT1JCjU1UESR5OkUsoNIpCDSsPTfKDQcGg9l7 ots97ncWLN+Lfp4WROkLJjQzGfpi+xBTLgED6OICNbWdp+4E/YU5rvkDlNecJt40DeH6 Q2hqFZbbNz8xrLdKtzRiQyDrqBIHWY+yGpl/Py1sDgjEERWmo/lhdwhsxYOaSDiGYFrQ xdnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780000748; x=1780605548; 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=TDPyLvT2Kkna9vXC8ZW6McJSEGzz6e4cANNcDdAOKmgK+yY9z935SCW24pnAVb0Lv3 GcUt0rj3Zg141RdHyzPkdWIAkI5gIxs0iIHSANx6yMSb1G9WxtCWp58WSEujz/I9bZ8F 4mXqFylR+ntsm0Kjb2d4LnyHDL6eT8pAfsUBhCB0Cpou/BCqYp8r30YlSs1Bq9LWRgsh I2754IwXubptBo2xdUB/40Wt3DRnQl9EyTuPtmUGlalHCLL8aCET1gR7Kcu9V0sT1a7v geJBXcxqzpwGirmMU7qKQHo7P5bFwB07eQu/tEjdNkm63WzTT+X6wbo9PZuJtzc10FfD SJEA== X-Forwarded-Encrypted: i=1; AFNElJ8wozC+FN9w1LNVnYAXYLY5QMtGMszOpmOmD9FBONfTnpqzVklIh5/+QN9AX2akNNbsq3VkWaIvajlG8fA=@vger.kernel.org X-Gm-Message-State: AOJu0YzpG47wpj27saQBwrboZnc6N9T9FSP2KZSFGAVymxkWdwiBFXMJ 2/ZRjpggfCZpg79ipHj0WZPkHzcAqbM8hvWVkcrsK4140m9SssXOIcLOl+nHGW8W7ayaGQ== X-Received: from dlbvc11.prod.google.com ([2002:a05:7022:fe0b:b0:132:8d92:4d65]) (user=xur job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:241c:b0:136:72f0:6c54 with SMTP id a92af1059eb24-137a903c8f5mr115927c88.29.1780000748077; Thu, 28 May 2026 13:39:08 -0700 (PDT) Date: Thu, 28 May 2026 13:39:03 -0700 In-Reply-To: <20260528203905.687687-1-xur@google.com> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260528203905.687687-1-xur@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260528203905.687687-2-xur@google.com> Subject: [PATCH v11 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