From 6916eb742055b47a0c52de855f5d0ecd4d0769ef Mon Sep 17 00:00:00 2001 From: Zentrik Date: Fri, 16 Aug 2024 00:07:21 +0100 Subject: [PATCH] Use same toolchain throughout pgo+bolt build (#55460) Also, I added the pgo flags to the `finish_stage2` target in case they are or become useful there. --- contrib/pgo-lto-bolt/Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contrib/pgo-lto-bolt/Makefile b/contrib/pgo-lto-bolt/Makefile index fa88cdcd3d6a7..2114b14991184 100644 --- a/contrib/pgo-lto-bolt/Makefile +++ b/contrib/pgo-lto-bolt/Makefile @@ -83,7 +83,7 @@ TOOLCHAIN_FLAGS = $\ "RANLIB=$(STAGE0_TOOLS)llvm-ranlib" $\ "CFLAGS+=$(PGO_CFLAGS)" $\ "CXXFLAGS+=$(PGO_CXXFLAGS)" $\ - "LDFLAGS+=$(PGO_LDFLAGS)" + "LDFLAGS+=-fuse-ld=lld $(PGO_LDFLAGS)" $(STAGE0_BUILD) $(STAGE1_BUILD) $(STAGE2_BUILD): $(MAKE) -C $(JULIA_ROOT) O=$@ configure @@ -99,7 +99,7 @@ stage0: | $(STAGE0_BUILD) $(STAGE1_BUILD): stage0 stage1: PGO_CFLAGS:=-fprofile-generate=$(PGO_PROFILE_DIR) -Xclang -mllvm -Xclang -vp-counters-per-site=$(COUNTERS_PER_SITE) stage1: PGO_CXXFLAGS:=-fprofile-generate=$(PGO_PROFILE_DIR) -Xclang -mllvm -Xclang -vp-counters-per-site=$(COUNTERS_PER_SITE) -stage1: PGO_LDFLAGS:=-fuse-ld=lld -flto=thin -fprofile-generate=$(PGO_PROFILE_DIR) +stage1: PGO_LDFLAGS:=-flto=thin -fprofile-generate=$(PGO_PROFILE_DIR) stage1: export USE_BINARYBUILDER_LLVM=0 stage1: | $(STAGE1_BUILD) $(MAKE) -C $(STAGE1_BUILD) $(TOOLCHAIN_FLAGS) && touch $@ @@ -107,7 +107,7 @@ stage1: | $(STAGE1_BUILD) stage2: PGO_CFLAGS:=-fprofile-use=$(PGO_PROFILE_FILE) stage2: PGO_CXXFLAGS:=-fprofile-use=$(PGO_PROFILE_FILE) -stage2: PGO_LDFLAGS:=-fuse-ld=lld -flto=thin -fprofile-use=$(PGO_PROFILE_FILE) -Wl,--icf=safe +stage2: PGO_LDFLAGS:=-flto=thin -fprofile-use=$(PGO_PROFILE_FILE) -Wl,--icf=safe stage2: export USE_BINARYBUILDER_LLVM=0 stage2: $(PGO_PROFILE_FILE) | $(STAGE2_BUILD) $(MAKE) -C $(STAGE2_BUILD) $(TOOLCHAIN_FLAGS) $(BOLT_FLAGS) julia-src-release julia-symlink julia-libccalltest \ @@ -135,10 +135,13 @@ bolt_instrument: copy_originals # We don't want to rebuild julia-src as then we lose the bolt instrumentation # So we have to manually build the sysimage and package image +finish_stage2: PGO_CFLAGS:=-fprofile-use=$(PGO_PROFILE_FILE) +finish_stage2: PGO_CXXFLAGS:=-fprofile-use=$(PGO_PROFILE_FILE) +finish_stage2: PGO_LDFLAGS:=-flto=thin -fprofile-use=$(PGO_PROFILE_FILE) -Wl,--icf=safe finish_stage2: stage2 - $(MAKE) -C $(STAGE2_BUILD) julia-base-cache && \ - $(MAKE) -C $(STAGE2_BUILD) -f sysimage.mk sysimg-release && \ - $(MAKE) -C $(STAGE2_BUILD) -f pkgimage.mk release + $(MAKE) -C $(STAGE2_BUILD) $(TOOLCHAIN_FLAGS) julia-base-cache && \ + $(MAKE) -C $(STAGE2_BUILD) $(TOOLCHAIN_FLAGS) -f sysimage.mk sysimg-release && \ + $(MAKE) -C $(STAGE2_BUILD) $(TOOLCHAIN_FLAGS) -f pkgimage.mk release merge_data: bolt_instrument for file in $(FILES_TO_OPTIMIZE); do \