1# SPDX-License-Identifier: GPL-2.0 2 3# Enable available and selected Clang AutoFDO features. 4 5CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true 6RUSTFLAGS_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 7 8ifndef CONFIG_DEBUG_INFO 9 CFLAGS_AUTOFDO_CLANG += -gmlt 10 RUSTFLAGS_AUTOFDO_CLANG += -Cdebuginfo=line-tables-only 11endif 12 13ifdef CLANG_AUTOFDO_PROFILE 14 CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections 15 CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions 16 RUSTFLAGS_AUTOFDO_CLANG += -Zprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -Zfunction-sections=y 17 RUSTFLAGS_AUTOFDO_CLANG += -Cllvm-args=-split-machine-functions 18endif 19 20ifdef CONFIG_LTO_CLANG_THIN 21 ifdef CLANG_AUTOFDO_PROFILE 22 KBUILD_LDFLAGS += --lto-sample-profile=$(CLANG_AUTOFDO_PROFILE) 23 endif 24 KBUILD_LDFLAGS += --mllvm=-enable-fs-discriminator=true --mllvm=-improved-fs-discriminator=true -plugin-opt=thinlto 25 KBUILD_LDFLAGS += -plugin-opt=-split-machine-functions 26endif 27 28export CFLAGS_AUTOFDO_CLANG RUSTFLAGS_AUTOFDO_CLANG 29