@@ -80,7 +80,7 @@ def cargo_stage_0(self) -> Path:
80
80
def rustc_stage_2 (self ) -> Path :
81
81
return self .build_artifacts () / "stage2" / "bin" / "rustc"
82
82
83
- def lib_llvm (self ) -> Path :
83
+ def stage2_lib_llvm (self ) -> Path :
84
84
raise NotImplementedError ()
85
85
86
86
def opt_artifacts (self ) -> Path :
@@ -130,8 +130,11 @@ def downloaded_llvm_dir(self) -> Path:
130
130
def build_root (self ) -> Path :
131
131
return self .checkout_path () / "obj"
132
132
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 ]
135
138
136
139
def opt_artifacts (self ) -> Path :
137
140
return Path ("/tmp/tmp-multistage/opt-artifacts" )
@@ -629,19 +632,16 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, final_build_args: L
629
632
env ["LDFLAGS" ] = "-Wl,-q"
630
633
631
634
# 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
633
636
# at this point, so the optimization below won't apply to the shipped artifacts.
634
637
with timer .stage ("Build rustc (rustc PGO use, LLVM PGO use)" ):
635
638
cmd (final_build_args , env )
636
639
637
640
# Stage 4: BOLT optimize LLVM.
638
641
if pipeline .supports_bolt ():
639
- lib_llvm = pipeline .lib_llvm ()
642
+ lib_llvm = pipeline .stage2_lib_llvm ()
640
643
641
644
# 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.
645
645
orig_lib_llvm = pipeline .opt_artifacts () / "libLLVM.orig"
646
646
shutil .move (lib_llvm , orig_lib_llvm )
647
647
0 commit comments