Commit db5f3612 authored by Ben Walker's avatar Ben Walker Committed by Konrad Sztyber
Browse files

build: Allow user to specify path for PGO data



This is useful if you are building SPDK as part of a much larger
application and you want all PGO output to go to the same place.

Change-Id: I4bc4504462a1eabc3e21712a1cd06f2b6f0c4687
Signed-off-by: default avatarBen Walker <ben@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21959


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 34d07fe5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ CONFIG_PGO_CAPTURE=n
# Use profile guided optimization data.
CONFIG_PGO_USE=n

# Place profile data in this directory
CONFIG_PGO_DIR=

# Build with code coverage instrumentation.
CONFIG_COVERAGE=n

+18 −4
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ function usage() {
	echo " --enable-ubsan            Enable undefined behavior sanitizer"
	echo " --enable-coverage         Enable code coverage tracking"
	echo " --enable-lto              Enable link-time optimization"
	echo " --enable-pgo-capture      Enable generation of profile guided optimization data"
	echo " --enable-pgo-use          Use previously captured profile guided optimization data"
	echo " --enable-pgo-capture[=PATH]      Enable generation of profile guided optimization data"
	echo " --enable-pgo-use[=PATH]   Use previously captured profile guided optimization data"
	echo " --enable-cet              Enable Intel Control-flow Enforcement Technology (CET)"
	echo " --disable-tests           Disable building of functional tests"
	echo " --disable-unit-tests      Disable building of unit tests"
@@ -336,12 +336,20 @@ for i in "$@"; do
		--enable-pgo-capture)
			CONFIG[PGO_CAPTURE]=y
			;;
		--enable-pgo-capture=*)
			CONFIG[PGO_CAPTURE]=y
			CONFIG[PGO_DIR]="${i#*=}"
			;;
		--disable-pgo-capture)
			CONFIG[PGO_CAPTURE]=n
			;;
		--enable-pgo-use)
			CONFIG[PGO_USE]=y
			;;
		--enable-pgo-use=*)
			CONFIG[PGO_USE]=y
			CONFIG[PGO_DIR]="${i#*=}"
			;;
		--disable-pgo-use)
			CONFIG[PGO_USE]=n
			;;
@@ -1126,11 +1134,17 @@ fi
if [[ "${CONFIG[PGO_CAPTURE]}" = "y" && "${CONFIG[PGO_USE]}" = "y" ]]; then
	echo "ERROR: --enable-pgo-capture and --enable-pgo-use are mutually exclusive."
	exit 1
elif [[ "${CONFIG[PGO_USE]}" = "y" ]]; then
elif [[ "${CONFIG[PGO_CAPTURE]}" = "y" || "${CONFI[PGO_USE]}" = "y" ]]; then
	if [[ -z "${CONFIG[PGO_DIR]}" ]]; then
		CONFIG[PGO_DIR]=$(realpath $rootdir/build/pgo)
	fi
fi

if [[ "${CONFIG[PGO_USE]}" = "y" ]]; then
	if [[ "$CC_TYPE" = "clang" ]]; then
		# For clang we need to run an extra step on gathered profiling data.
		echo "Generating suitable profile data"
		llvm-profdata merge -output=build/pgo/default.profdata build/pgo
		llvm-profdata merge -output=${CONFIG[PGO_DIR]}/default.profdata ${CONFIG[PGO_DIR]}
	fi
fi

+4 −4
Original line number Diff line number Diff line
@@ -102,13 +102,13 @@ LDFLAGS += -flto=auto
endif

ifeq ($(CONFIG_PGO_CAPTURE),y)
COMMON_CFLAGS += -fprofile-generate=$(SPDK_ROOT_DIR)/build/pgo
LDFLAGS += -fprofile-generate=$(SPDK_ROOT_DIR)/build/pgo
COMMON_CFLAGS += -fprofile-generate=$(CONFIG_PGO_DIR)
LDFLAGS += -fprofile-generate=$(CONFIG_PGO_DIR)
endif

ifeq ($(CONFIG_PGO_USE),y)
COMMON_CFLAGS += -fprofile-use=$(SPDK_ROOT_DIR)/build/pgo
LDFLAGS += -fprofile-use=$(SPDK_ROOT_DIR)/build/pgo
COMMON_CFLAGS += -fprofile-use=$(CONFIG_PGO_DIR)
LDFLAGS += -fprofile-use=$(CONFIG_PGO_DIR)
endif

ifeq ($(CONFIG_CET),y)