From nobody Thu Apr 2 15:36:14 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 7B3D0326D63 for ; Sat, 28 Mar 2026 01:19:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774660777; cv=none; b=m8OvCZUTqK1E285j8YeBnybs5c+T4KGM4jJSChOB7kKd4HXjeM6pWpxMfo4WoS0jeukYO0qvuRxIxuP0RREdvNVYJnfxT5OG8MyPcZoQbJbc9NImqCWQ7bmECZeP/SJ29j6da0wAOjZfCdwsp52iLfNrhwM+Bve+rZ/6ulmicR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774660777; c=relaxed/simple; bh=pLb70nUROcDCtC8MsDxGNVPoPBV2zge0oM7aB3yEADQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pBjj6goBvPRFGNLpBbaS9qQXLob/is/QItjZqpGOAWvEpCNDtZ0tgD/izDa9/62aJxR/QCUPLUQDt2j8j40sArwgr2eRBsuXPllq0LiekuM7pRL1Ch0W5AInZQ6SVlZcQlpyFV3MDtyi6c7TPKJJPTbs6OHwc4y/gAJK450eEDE= 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=H+XAHEi4; arc=none smtp.client-ip=74.125.82.202 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="H+XAHEi4" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so2799030eec.1 for ; Fri, 27 Mar 2026 18:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774660773; x=1775265573; 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=77Ac1GrJdreMNETx1ERKI8GGaFAhTfW3lT0AoWZDZpU=; b=H+XAHEi48nEBCGCZFocFTrqbnMlbvl4ky9TExpBw3+lKKVNQ+NEWCFEq50jBNOE+rQ G7GnwdoQLjMqwPoReBjGsKYXwadjLaWjxc9jwcWfXgKAElQ4ThNgXt4FyRkTEoPWGreQ JA3wYGYqygHRyVh8iwASj7jkQg2gQ8diQ5M8Va+dsEqeQ/i6+7tmOCE0+GCWKzxZps9t ZgvfJgMGwpcoaA4766MBJ6y5kNrXZZ7UOAEgCwrTVZLwdWSNl8HZSgxcFUBWk1b4l9tA E/SuLr74/du8oHPuFPj4Sd+NmkOkJVOtVveL9Zqc4blqFHtlvCsC/PeG6GIv/0cmzInO Ysug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774660773; x=1775265573; 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=77Ac1GrJdreMNETx1ERKI8GGaFAhTfW3lT0AoWZDZpU=; b=YzBevpINfBPlK7MgOeMBPuAi96ozz+EDdLHRVN0i4DMYwYkr/9daWi3Mf3PU1pToyQ YYLU8qaO9udRd+7C8mjKzh3/ZQCXD1YPT6Lv9pmV2Pv7xLSk6GEN3J1mG3Z9M9l6Kg+9 kEot6frfFJxRd9KqbSTUqvKyi2U93uyYzoKttodQ2k9yFjCsM92qUJgaTiHRb6stDsZE hXI9QMZv4e2omEmTAXL8y2OiwooobcTOnwv7eDiIccwkxxBIOXfRz40SJP6zP5HFtvUP miSkOqUOMe+MPvEJsEsB9dtpblrxOMOXFNBoFpIAWpHb7fh2iBWcBZL94hdHnEAr8lct 7IUQ== X-Gm-Message-State: AOJu0Yzee8w7doNg+BsUSdRhKRSD9O1ewAVBYAJ2RWDreDbg0PI7zFeO rVeZf6r9euHSy/pinh1nEBuw7o7vpVKszvd5x6vG4kUadf83eU6pFuhluKgCdatgVFFwsQ== X-Received: from dleb17-n2.prod.google.com ([2002:a05:701b:4251:20b0:128:e734:a2bd]) (user=xur job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:b8a:b0:123:330b:3a0 with SMTP id a92af1059eb24-12ab28617bamr2690906c88.14.1774660772475; Fri, 27 Mar 2026 18:19:32 -0700 (PDT) Date: Sat, 28 Mar 2026 01:19:25 +0000 In-Reply-To: <20260328011927.3569802-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: <20260328011927.3569802-1-xur@google.com> X-Mailer: git-send-email 2.53.0.1018.g2bb0e51243-goog Message-ID: <20260328011927.3569802-2-xur@google.com> Subject: [PATCH v7 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 , 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-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 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 a8d8ed711f9b..69ccf9b8507d 100644 --- a/Makefile +++ b/Makefile @@ -1264,7 +1264,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 @@ -1273,16 +1273,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 000000000000..9774f02b43b2 --- /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.53.0.1018.g2bb0e51243-goog