]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add Additional Flags to PGO Build
authorW. Felix Handte <w@felixhandte.com>
Fri, 20 Jan 2023 22:32:49 +0000 (17:32 -0500)
committerW. Felix Handte <w@felixhandte.com>
Fri, 20 Jan 2023 22:32:49 +0000 (17:32 -0500)
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.

programs/Makefile

index b79b60b4fb2b70703a44aba2be7be42efce77ac6..fcff41dc1b3e0f845cd890bffa9128b1a29952e5 100644 (file)
@@ -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