From: xur@google.com
To: "Alexey Gladkov" <legion@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Bill Wendling" <morbo@google.com>,
"Han Shen" <shenhan@google.com>, "Ingo Molnar" <mingo@kernel.org>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Justin Stitt" <justinstitt@google.com>,
"Kees Cook" <kees@kernel.org>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Nicolas Schier" <nicolas.schier@linux.dev>,
"Peter Zijlstra" <peterz@infradead.org>,
"Tamir Duberstein" <tamird@gmail.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Yabin Cui" <yabinc@google.com>,
"Sriraman Tallam" <tmsriram@google.com>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Rong Xu <xur@google.com>
Subject: [PATCH v2 2/4] kbuild: Disable AutoFDO and Propeller flags for kernel modules
Date: Tue, 14 Oct 2025 19:11:54 +0000 [thread overview]
Message-ID: <20251014191156.3836703-3-xur@google.com> (raw)
In-Reply-To: <20251014191156.3836703-1-xur@google.com>
From: Rong Xu <xur@google.com>
AutoFDO and Propeller build currently does not support kernel modules,
but the corresponding build flags are still being set.
This change suppresses these build flags for modules. These flags can
be re-enabled once Propeller support for kernel modules is added.
Change-Id: I3f8bf88ff1fb435f903ba861a7b9a87f6123fa0c
Signed-off-by: Rong Xu <xur@google.com>
---
Makefile | 9 +++++----
scripts/Makefile.autofdo | 9 ++++++---
scripts/Makefile.lib | 9 ++++++---
scripts/Makefile.propeller | 12 ++++++++----
scripts/Makefile.vmlinux_o | 3 ++-
5 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index 17cfa11ca7163..3fd0c364ff84e 100644
--- a/Makefile
+++ b/Makefile
@@ -1230,14 +1230,15 @@ PHONY += vmlinux
# not for decompressors. LDFLAGS_vmlinux in arch/*/boot/compressed/Makefile is
# unrelated; the decompressors just happen to have the same base name,
# arch/*/boot/compressed/vmlinux.
-# Export LDFLAGS_vmlinux only to scripts/Makefile.vmlinux.
+# Export LDFLAGS_vmlinux only to scripts/Makefile.vmlinux, and
+# scripts/Makefile.vmlinux_o.
#
# _LDFLAGS_vmlinux is a workaround for the 'private export' bug:
# https://savannah.gnu.org/bugs/?61463
# For Make > 4.4, the following simple code will work:
-# vmlinux: private export LDFLAGS_vmlinux := $(LDFLAGS_vmlinux)
-vmlinux: private _LDFLAGS_vmlinux := $(LDFLAGS_vmlinux)
-vmlinux: export LDFLAGS_vmlinux = $(_LDFLAGS_vmlinux)
+# vmlinux vmlinux_o: private export LDFLAGS_vmlinux := $(LDFLAGS_vmlinux)
+vmlinux vmlinux_o: private _LDFLAGS_vmlinux := $(LDFLAGS_vmlinux)
+vmlinux vmlinux_o: export LDFLAGS_vmlinux = $(_LDFLAGS_vmlinux)
vmlinux: vmlinux.o $(KBUILD_LDS) modpost
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo
index 1caf2457e585c..5bcfcef273745 100644
--- a/scripts/Makefile.autofdo
+++ b/scripts/Makefile.autofdo
@@ -14,11 +14,14 @@ ifdef CLANG_AUTOFDO_PROFILE
endif
ifdef CONFIG_LTO_CLANG_THIN
+ _ldflags_autofdo := --mllvm=-enable-fs-discriminator=true --mllvm=-improved-fs-discriminator=true -plugin-opt=thinlto
+ _ldflags_autofdo += -plugin-opt=-split-machine-functions
ifdef CLANG_AUTOFDO_PROFILE
- KBUILD_LDFLAGS += --lto-sample-profile=$(CLANG_AUTOFDO_PROFILE)
+ _ldflags_autofdo += --lto-sample-profile=$(CLANG_AUTOFDO_PROFILE)
endif
- KBUILD_LDFLAGS += --mllvm=-enable-fs-discriminator=true --mllvm=-improved-fs-discriminator=true -plugin-opt=thinlto
- KBUILD_LDFLAGS += -plugin-opt=-split-machine-functions
+ # TODO: change LDFLAGS_vmlinux to KBUILD_LDFLAGS when kernel modules
+ # are supported.
+ LDFLAGS_vmlinux += $(_ldflags_autofdo)
endif
export CFLAGS_AUTOFDO_CLANG
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 53c02fc3b348a..0f6874e8d584d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -108,20 +108,23 @@ endif
#
# Enable AutoFDO build flags except some files or directories we don't want to
# enable (depends on variables AUTOFDO_PROFILE_obj.o and AUTOFDO_PROFILE).
-#
+# TODO: change '$(part-of-builtin)' to '$(is-kernel-object)' when the AutoFDO
+# build supports modules.
ifeq ($(CONFIG_AUTOFDO_CLANG),y)
_c_flags += $(if $(patsubst n%,, \
- $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(is-kernel-object)), \
+ $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(part-of-builtin)), \
$(CFLAGS_AUTOFDO_CLANG))
endif
#
# Enable Propeller build flags except some files or directories we don't want to
# enable (depends on variables AUTOFDO_PROPELLER_obj.o and PROPELLER_PROFILE).
+# TODO: change '$(part-of-builtin)' to '$(is-kernel-object)' when the Propeller
+# build supports modules.
#
ifdef CONFIG_PROPELLER_CLANG
_c_flags += $(if $(patsubst n%,, \
- $(PROPELLER_PROFILE_$(target-stem).o)$(PROPELLER_PROFILE)$(is-kernel-object)), \
+ $(PROPELLER_PROFILE_$(target-stem).o)$(PROPELLER_PROFILE)$(part-of-builtin)), \
$(CFLAGS_PROPELLER_CLANG))
endif
diff --git a/scripts/Makefile.propeller b/scripts/Makefile.propeller
index 48a660128e256..fa018098506b8 100644
--- a/scripts/Makefile.propeller
+++ b/scripts/Makefile.propeller
@@ -3,7 +3,7 @@
# Enable available and selected Clang Propeller features.
ifdef CLANG_PROPELLER_PROFILE_PREFIX
CFLAGS_PROPELLER_CLANG := -fbasic-block-sections=list=$(CLANG_PROPELLER_PROFILE_PREFIX)_cc_profile.txt -ffunction-sections
- KBUILD_LDFLAGS += --symbol-ordering-file=$(CLANG_PROPELLER_PROFILE_PREFIX)_ld_profile.txt --no-warn-symbol-ordering
+ _ldflags_propeller := --symbol-ordering-file=$(CLANG_PROPELLER_PROFILE_PREFIX)_ld_profile.txt --no-warn-symbol-ordering
else
# Starting with Clang v20, the '-fbasic-block-sections=labels' option is
# deprecated. Use the recommended '-fbasic-block-address-map' option.
@@ -26,14 +26,18 @@ endif
ifdef CONFIG_LTO_CLANG_THIN
ifdef CLANG_PROPELLER_PROFILE_PREFIX
- KBUILD_LDFLAGS += --lto-basic-block-sections=$(CLANG_PROPELLER_PROFILE_PREFIX)_cc_profile.txt
+ _ldflags_propeller += --lto-basic-block-sections=$(CLANG_PROPELLER_PROFILE_PREFIX)_cc_profile.txt
else
ifeq ($(call test-ge, $(CONFIG_LLD_VERSION), 200000),y)
- KBUILD_LDFLAGS += --lto-basic-block-address-map
+ _ldflags_propeller += --lto-basic-block-address-map
else
- KBUILD_LDFLAGS += --lto-basic-block-sections=labels
+ _ldflags_propeller += --lto-basic-block-sections=labels
endif
endif
endif
+# TODO: change LDFLAGS_vmlinux to KBUILD_LDFLAGS when kernel modules
+# are supported.
+LDFLAGS_vmlinux += $(_ldflags_propeller)
+
export CFLAGS_PROPELLER_CLANG
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index 23c8751285d79..ee070bf35385a 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -56,7 +56,8 @@ vmlinux-o-ld-args-$(CONFIG_BUILTIN_MODULE_RANGES) += -Map=$@.map
quiet_cmd_ld_vmlinux.o = LD $@
cmd_ld_vmlinux.o = \
- $(LD) ${KBUILD_LDFLAGS} -r -o $@ \
+ $(LD) $(KBUILD_LDFLAGS) \
+ $(filter-out -pie, $(LDFLAGS_vmlinux)) -r -o $@ \
$(vmlinux-o-ld-args-y) \
$(addprefix -T , $(initcalls-lds)) \
--whole-archive vmlinux.a --no-whole-archive \
--
2.51.0.788.g6d19910ace-goog
next prev parent reply other threads:[~2025-10-14 19:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 19:11 [PATCH v2 0/4] kbuild: Fixes for AutoFDO and Propeller builds xur
2025-10-14 19:11 ` [PATCH v2 1/4] kbuild: Fix Propeller flags xur
2025-10-14 19:11 ` xur [this message]
2025-10-16 1:29 ` [PATCH v2 2/4] kbuild: Disable AutoFDO and Propeller flags for kernel modules kernel test robot
2025-10-16 2:38 ` kernel test robot
2025-10-14 19:11 ` [PATCH v2 3/4] kbuild: Remove MFS flags from Propeller profile generate builds xur
2025-10-14 19:11 ` [PATCH v2 4/4] kbuild: Add config to assert profile accuracy for aggressive optimization xur
2025-10-15 3:38 ` Han Shen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251014191156.3836703-3-xur@google.com \
--to=xur@google.com \
--cc=aliceryhl@google.com \
--cc=ardb@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=legion@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=mingo@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nicolas.schier@linux.dev \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=shenhan@google.com \
--cc=tamird@gmail.com \
--cc=tglx@linutronix.de \
--cc=thomas.weissschuh@linutronix.de \
--cc=tmsriram@google.com \
--cc=yabinc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox