Skip to content

Commit

Permalink
Use same toolchain throughout pgo+bolt build (JuliaLang#55460)
Browse files Browse the repository at this point in the history
Also, I added the pgo flags to the `finish_stage2` target in case they
are or become useful there.
  • Loading branch information
Zentrik authored Aug 15, 2024
1 parent 015c2cb commit 6916eb7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions contrib/pgo-lto-bolt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -99,15 +99,15 @@ 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 $@
@echo $(AFTER_STAGE1_MESSAGE)

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 \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 6916eb7

Please sign in to comment.