From 2ffcb2d6a882626d831b88d26e4c653c53efc38e Mon Sep 17 00:00:00 2001 From: Ilya Kurdyukov <59548320+ilyakurdyukov@users.noreply.github.com> Date: Wed, 5 Oct 2022 17:32:16 +0700 Subject: [PATCH] fixed zstd-pgo target for GCC 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index 7a3d3e0d8..0391af76d 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -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