diff --git a/Makefile b/Makefile index dd58fca65c9f..d9a48279c4d5 100644 --- a/Makefile +++ b/Makefile @@ -660,7 +660,8 @@ endif # KBUILD_EXTMOD all: vmlinux CFLAGS_PGO_CLANG := -fprofile-generate -export CFLAGS_PGO_CLANG +CFLAGS_PGO_CLANG_PROFDATA := -fprofile-use=vmlinux.profdata +export CFLAGS_PGO_CLANG CFLAGS_PGO_CLANG_PROFDATA CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \ $(call cc-option,-fno-tree-loop-im) \ diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index 383853e32f67..3268d1ee6e45 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile @@ -72,6 +72,7 @@ KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables GCOV_PROFILE := n PGO_PROFILE := n +PGO_PROFDATA := n UBSAN_SANITIZE := n $(obj)/bzImage: asflags-y := $(SVGA_MODE) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index ed12ab65f606..707c4034aef7 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -55,6 +55,7 @@ CFLAGS_sev-es.o += -I$(objtree)/arch/x86/lib/ KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ GCOV_PROFILE := n PGO_PROFILE := n +PGO_PROFDATA := n UBSAN_SANITIZE :=n KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile index baa14f83edae..1b2cb9142672 100644 --- a/arch/x86/crypto/Makefile +++ b/arch/x86/crypto/Makefile @@ -5,6 +5,7 @@ OBJECT_FILES_NON_STANDARD := y PGO_PROFILE_curve25519-x86_64.o := n +PGO_PROFDATA_curve25519-x86_64.o := n obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o twofish-i586-y := twofish-i586-asm_32.o twofish_glue.o diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index f7421e44725a..67860ecde542 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -181,6 +181,7 @@ VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 \ $(call ld-option, --eh-frame-hdr) -Bsymbolic GCOV_PROFILE := n PGO_PROFILE := n +PGO_PROFDATA := n quiet_cmd_vdso_and_check = VDSO $@ cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check) diff --git a/arch/x86/platform/efi/Makefile b/arch/x86/platform/efi/Makefile index 5f22b31446ad..5d64b728a0a0 100644 --- a/arch/x86/platform/efi/Makefile +++ b/arch/x86/platform/efi/Makefile @@ -3,6 +3,7 @@ OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y KASAN_SANITIZE := n GCOV_PROFILE := n PGO_PROFILE := n +PGO_PROFDATA := n obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index 36f20e99da0b..99f2e4c1886e 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -24,6 +24,7 @@ targets += purgatory.ro purgatory.chk # Sanitizer, etc. runtimes are unavailable and cannot be linked here. GCOV_PROFILE := n PGO_PROFILE := n +PGO_PROFDATA := n KASAN_SANITIZE := n UBSAN_SANITIZE := n KCSAN_SANITIZE := n diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile index 21797192f958..a495890e9b11 100644 --- a/arch/x86/realmode/rm/Makefile +++ b/arch/x86/realmode/rm/Makefile @@ -77,4 +77,5 @@ KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables GCOV_PROFILE := n PGO_PROFILE := n +PGO_PROFDATA := n UBSAN_SANITIZE := n diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile index 54f5768f5853..2e9cdc137ade 100644 --- a/arch/x86/um/vdso/Makefile +++ b/arch/x86/um/vdso/Makefile @@ -65,6 +65,7 @@ quiet_cmd_vdso = VDSO $@ VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv GCOV_PROFILE := n PGO_PROFILE := n +PGO_PROFDATA := n # # Install the unstripped copy of vdso*.so listed in $(vdso-install-y). diff --git a/kernel/pgo/Kconfig b/kernel/pgo/Kconfig index 5fe9635ac64c..ce1e1c061a98 100644 --- a/kernel/pgo/Kconfig +++ b/kernel/pgo/Kconfig @@ -32,4 +32,8 @@ config PGO_CLANG Note that the debugfs filesystem has to be mounted to access profiling data. +config PGO_CLANG_PROFDATA + bool "Use vmlinux.profdata profile file" + depends on !PGO_CLANG + endmenu diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 12fed825ab4b..14169a575b64 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -154,6 +154,12 @@ _c_flags += $(if $(patsubst n%,, \ $(PGO_PROFILE_$(basetarget).o)$(PGO_PROFILE)y), \ $(CFLAGS_PGO_CLANG)) endif +# Use vmlinux.profdata profile file +ifeq ($(CONFIG_PGO_CLANG_PROFDATA),y) +_c_flags += $(if $(patsubst n%,, \ + $(PGO_PROFDATA_$(basetarget).o)$(PGO_PROFDATA)y), \ + $(CFLAGS_PGO_CLANG_PROFDATA)) +endif # # Enable address sanitizer flags for kernel except some files or directories