2024-11-02 10:51:08 -07:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
|
|
# Enable available and selected Clang AutoFDO features.
|
|
|
|
|
|
|
|
|
|
CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true
|
2026-06-02 17:16:38 +02:00
|
|
|
RUSTFLAGS_AUTOFDO_CLANG := $(if $(call rustc-min-version,109800),-Zdebuginfo-for-profiling,-Zdebug-info-for-profiling) -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true
|
2024-11-02 10:51:08 -07:00
|
|
|
|
|
|
|
|
ifndef CONFIG_DEBUG_INFO
|
|
|
|
|
CFLAGS_AUTOFDO_CLANG += -gmlt
|
2026-03-31 10:57:49 +00:00
|
|
|
RUSTFLAGS_AUTOFDO_CLANG += -Cdebuginfo=line-tables-only
|
2024-11-02 10:51:08 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifdef CLANG_AUTOFDO_PROFILE
|
2024-11-02 10:51:12 -07:00
|
|
|
CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections
|
2024-11-02 10:51:13 -07:00
|
|
|
CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions
|
2026-03-31 10:57:49 +00:00
|
|
|
RUSTFLAGS_AUTOFDO_CLANG += -Zprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -Zfunction-sections=y
|
|
|
|
|
RUSTFLAGS_AUTOFDO_CLANG += -Cllvm-args=-split-machine-functions
|
2024-11-02 10:51:08 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifdef CONFIG_LTO_CLANG_THIN
|
|
|
|
|
ifdef CLANG_AUTOFDO_PROFILE
|
|
|
|
|
KBUILD_LDFLAGS += --lto-sample-profile=$(CLANG_AUTOFDO_PROFILE)
|
|
|
|
|
endif
|
|
|
|
|
KBUILD_LDFLAGS += --mllvm=-enable-fs-discriminator=true --mllvm=-improved-fs-discriminator=true -plugin-opt=thinlto
|
2024-11-02 10:51:13 -07:00
|
|
|
KBUILD_LDFLAGS += -plugin-opt=-split-machine-functions
|
2024-11-02 10:51:08 -07:00
|
|
|
endif
|
|
|
|
|
|
2026-03-31 10:57:49 +00:00
|
|
|
export CFLAGS_AUTOFDO_CLANG RUSTFLAGS_AUTOFDO_CLANG
|