]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed zstd-pgo target for GCC
authorIlya Kurdyukov <59548320+ilyakurdyukov@users.noreply.github.com>
Wed, 5 Oct 2022 10:32:16 +0000 (17:32 +0700)
committerGitHub <noreply@github.com>
Wed, 5 Oct 2022 10:32:16 +0000 (17:32 +0700)
Since your Makefile uses obj/$(HASH_DIR) for object files, this code does not work correctly for GCC. Because profiles are saved in one directory, and are expected in another when reading.

`$(RM) zstd *.o` - this line doesn't delete object files.

Clang stores profiles in the current directory, so the problem doesn't appear when compiling with Clang.

Also this code will work if BUILD_DIR is set.

programs/Makefile

index 7a3d3e0d81b39a08a3fcb5a442623470371b9549..0391af76d0e3a309e2ae5a00c5f359841b0b09a5 100644 (file)
@@ -232,17 +232,21 @@ zstd-dll : zstd
 ## zstd-pgo: zstd executable optimized with PGO.
 .PHONY: zstd-pgo
 zstd-pgo :
-       $(MAKE) clean
-       $(MAKE) zstd MOREFLAGS=-fprofile-generate
+       $(MAKE) clean HASH_DIR=$(HASH_DIR)
+       $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS=-fprofile-generate
        ./zstd -b19i1 $(PROFILE_WITH)
        ./zstd -b16i1 $(PROFILE_WITH)
        ./zstd -b9i2 $(PROFILE_WITH)
        ./zstd -b $(PROFILE_WITH)
        ./zstd -b7i2 $(PROFILE_WITH)
        ./zstd -b5 $(PROFILE_WITH)
-       $(RM) zstd *.o
+ifndef BUILD_DIR
+       $(RM) zstd obj/$(HASH_DIR)/*.o
+else
+       $(RM) 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 MOREFLAGS=-fprofile-use
+       $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS=-fprofile-use
 
 ## zstd-small: minimal target, supporting only zstd compression and decompression. no bench. no legacy. no other format.
 CLEAN += zstd-small zstd-frugal