From: W. Felix Handte Date: Fri, 20 Jan 2023 22:32:49 +0000 (-0500) Subject: Add Additional Flags to PGO Build X-Git-Tag: v1.5.4^2~38^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87e169d05d75db5112df20361de33f7398ef27d5;p=thirdparty%2Fzstd.git Add Additional Flags to PGO Build In GCC, we can add a couple more flags to give us confidence that the profile data is actually being found and used. Also, my system for example doesn't have a binary installed under the name `llvm-profdata`, but it does have, e.g., `llvm-profdata-13`, etc. So this commit adds a variable that can be overridden. --- diff --git a/programs/Makefile b/programs/Makefile index b79b60b4f..fcff41dc1 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -231,9 +231,12 @@ zstd-dll : zstd ## zstd-pgo: zstd executable optimized with PGO. .PHONY: zstd-pgo +zstd-pgo : LLVM_PROFDATA?=llvm-profdata +zstd-pgo : PROF_GENERATE_FLAGS=-fprofile-generate $(if $(findstring gcc,$(CC)),-fprofile-dir=.) +zstd-pgo : PROF_USE_FLAGS=-fprofile-use $(if $(findstring gcc,$(CC)),-fprofile-dir=. -Werror=missing-profile -Wno-error=coverage-mismatch) zstd-pgo : $(MAKE) clean HASH_DIR=$(HASH_DIR) - $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS=-fprofile-generate + $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS="$(PROF_GENERATE_FLAGS)" ./zstd -b19i1 $(PROFILE_WITH) ./zstd -b16i1 $(PROFILE_WITH) ./zstd -b9i2 $(PROFILE_WITH) @@ -245,8 +248,8 @@ ifndef BUILD_DIR else $(RM) zstd $(BUILD_DIR)/zstd $(BUILD_DIR)/*.o endif - case $(CC) in *clang*) if ! [ -e default.profdata ]; then llvm-profdata merge -output=default.profdata default*.profraw; fi ;; esac - $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS=-fprofile-use + case $(CC) in *clang*) if ! [ -e default.profdata ]; then $(LLVM_PROFDATA) merge -output=default.profdata default*.profraw; fi ;; esac + $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS="$(PROF_USE_FLAGS)" ## zstd-small: minimal target, supporting only zstd compression and decompression. no bench. no legacy. no other format. CLEAN += zstd-small zstd-frugal