Skip to content

Commit b30065b

Browse files
committed
Use correct libLLVM.so file
We need to instrument and optimize the stage2 libLLVM.so file.
1 parent 238be98 commit b30065b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ci/stage-build.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def cargo_stage_0(self) -> Path:
8080
def rustc_stage_2(self) -> Path:
8181
return self.build_artifacts() / "stage2" / "bin" / "rustc"
8282

83-
def lib_llvm(self) -> Path:
83+
def stage2_lib_llvm(self) -> Path:
8484
raise NotImplementedError()
8585

8686
def opt_artifacts(self) -> Path:
@@ -130,8 +130,11 @@ def downloaded_llvm_dir(self) -> Path:
130130
def build_root(self) -> Path:
131131
return self.checkout_path() / "obj"
132132

133-
def lib_llvm(self) -> Path:
134-
return (self.build_artifacts() / "llvm" / "lib" / "libLLVM.so").resolve()
133+
def stage2_lib_llvm(self) -> Path:
134+
stage2_lib_dir = self.build_artifacts() / "stage2" / "lib"
135+
lib_llvms = list(stage2_lib_dir.glob("libLLVM*"))
136+
assert len(lib_llvms) == 1, "There should be exactly one libLLVM file found"
137+
return lib_llvms[0]
135138

136139
def opt_artifacts(self) -> Path:
137140
return Path("/tmp/tmp-multistage/opt-artifacts")
@@ -629,19 +632,16 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, final_build_args: L
629632
env["LDFLAGS"] = "-Wl,-q"
630633

631634
# Stage 3: Build PGO optimized rustc + PGO optimized LLVM
632-
# TODO: Because "dist" is run here, I think we will end up packaging the libLLVM.so
635+
# FIXME: Because "dist" is run here, I think we will end up packaging the libLLVM.so
633636
# at this point, so the optimization below won't apply to the shipped artifacts.
634637
with timer.stage("Build rustc (rustc PGO use, LLVM PGO use)"):
635638
cmd(final_build_args, env)
636639

637640
# Stage 4: BOLT optimize LLVM.
638641
if pipeline.supports_bolt():
639-
lib_llvm = pipeline.lib_llvm()
642+
lib_llvm = pipeline.stage2_lib_llvm()
640643

641644
# Back up the original libLLVM shared object.
642-
# TODO: I think this is currently instrumenting the wrong libLLVM.so
643-
# This is the one in the llvm/ directory, while the one that actually get
644-
# used is something like stage2/lib/libLLVM-15-rust-1.69.0-nightly.so.
645645
orig_lib_llvm = pipeline.opt_artifacts() / "libLLVM.orig"
646646
shutil.move(lib_llvm, orig_lib_llvm)
647647

0 commit comments

Comments
 (0)