@@ -18,9 +18,7 @@ use std::process::Command;
1818
1919use object:: read:: archive:: ArchiveFile ;
2020use object:: BinaryFormat ;
21- use sha2:: Digest ;
2221
23- use crate :: bolt:: { instrument_with_bolt, optimize_with_bolt} ;
2422use crate :: builder:: { Builder , Kind , RunConfig , ShouldRun , Step } ;
2523use crate :: cache:: { Interned , INTERNER } ;
2624use crate :: channel;
@@ -1941,19 +1939,7 @@ fn install_llvm_file(builder: &Builder<'_>, source: &Path, destination: &Path) {
19411939 return ;
19421940 }
19431941
1944- // After LLVM is built, we modify (instrument or optimize) the libLLVM.so library file.
1945- // This is not done in-place so that the built LLVM files are not "tainted" with BOLT.
1946- // We perform the instrumentation/optimization here, on the fly, just before they are being
1947- // packaged into some destination directory.
1948- let postprocessed = if builder. config . llvm_bolt_profile_generate {
1949- builder. ensure ( BoltInstrument :: new ( source. to_path_buf ( ) ) )
1950- } else if let Some ( path) = & builder. config . llvm_bolt_profile_use {
1951- builder. ensure ( BoltOptimize :: new ( source. to_path_buf ( ) , path. into ( ) ) )
1952- } else {
1953- source. to_path_buf ( )
1954- } ;
1955-
1956- builder. install ( & postprocessed, destination, 0o644 ) ;
1942+ builder. install ( & source, destination, 0o644 ) ;
19571943}
19581944
19591945/// Maybe add LLVM object files to the given destination lib-dir. Allows either static or dynamic linking.
@@ -2038,117 +2024,6 @@ pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection
20382024 }
20392025}
20402026
2041- /// Creates an output path to a BOLT-manipulated artifact for the given `file`.
2042- /// The hash of the file is used to make sure that we don't mix BOLT artifacts amongst different
2043- /// files with the same name.
2044- ///
2045- /// We need to keep the file-name the same though, to make sure that copying the manipulated file
2046- /// to a directory will not change the final file path.
2047- fn create_bolt_output_path ( builder : & Builder < ' _ > , file : & Path , hash : & str ) -> PathBuf {
2048- let directory = builder. out . join ( "bolt" ) . join ( hash) ;
2049- t ! ( fs:: create_dir_all( & directory) ) ;
2050- directory. join ( file. file_name ( ) . unwrap ( ) )
2051- }
2052-
2053- /// Instrument the provided file with BOLT.
2054- /// Returns a path to the instrumented artifact.
2055- #[ derive( Clone , Debug , Eq , Hash , PartialEq ) ]
2056- pub struct BoltInstrument {
2057- file : PathBuf ,
2058- hash : String ,
2059- }
2060-
2061- impl BoltInstrument {
2062- fn new ( file : PathBuf ) -> Self {
2063- let mut hasher = sha2:: Sha256 :: new ( ) ;
2064- hasher. update ( t ! ( fs:: read( & file) ) ) ;
2065- let hash = hex:: encode ( hasher. finalize ( ) . as_slice ( ) ) ;
2066-
2067- Self { file, hash }
2068- }
2069- }
2070-
2071- impl Step for BoltInstrument {
2072- type Output = PathBuf ;
2073-
2074- const ONLY_HOSTS : bool = false ;
2075- const DEFAULT : bool = false ;
2076-
2077- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
2078- run. never ( )
2079- }
2080-
2081- fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
2082- if builder. build . config . dry_run ( ) {
2083- return self . file . clone ( ) ;
2084- }
2085-
2086- if builder. build . config . llvm_from_ci {
2087- println ! ( "warning: trying to use BOLT with LLVM from CI, this will probably not work" ) ;
2088- }
2089-
2090- println ! ( "Instrumenting {} with BOLT" , self . file. display( ) ) ;
2091-
2092- let output_path = create_bolt_output_path ( builder, & self . file , & self . hash ) ;
2093- if !output_path. is_file ( ) {
2094- instrument_with_bolt ( & self . file , & output_path) ;
2095- }
2096- output_path
2097- }
2098- }
2099-
2100- /// Optimize the provided file with BOLT.
2101- /// Returns a path to the optimized artifact.
2102- ///
2103- /// The hash is stored in the step to make sure that we don't optimize the same file
2104- /// twice (even under different file paths).
2105- #[ derive( Clone , Debug , Eq , Hash , PartialEq ) ]
2106- pub struct BoltOptimize {
2107- file : PathBuf ,
2108- profile : PathBuf ,
2109- hash : String ,
2110- }
2111-
2112- impl BoltOptimize {
2113- fn new ( file : PathBuf , profile : PathBuf ) -> Self {
2114- let mut hasher = sha2:: Sha256 :: new ( ) ;
2115- hasher. update ( t ! ( fs:: read( & file) ) ) ;
2116- hasher. update ( t ! ( fs:: read( & profile) ) ) ;
2117- let hash = hex:: encode ( hasher. finalize ( ) . as_slice ( ) ) ;
2118-
2119- Self { file, profile, hash }
2120- }
2121- }
2122-
2123- impl Step for BoltOptimize {
2124- type Output = PathBuf ;
2125-
2126- const ONLY_HOSTS : bool = false ;
2127- const DEFAULT : bool = false ;
2128-
2129- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
2130- run. never ( )
2131- }
2132-
2133- fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
2134- if builder. build . config . dry_run ( ) {
2135- return self . file . clone ( ) ;
2136- }
2137-
2138- if builder. build . config . llvm_from_ci {
2139- println ! ( "warning: trying to use BOLT with LLVM from CI, this will probably not work" ) ;
2140- }
2141-
2142- println ! ( "Optimizing {} with BOLT" , self . file. display( ) ) ;
2143-
2144- let output_path = create_bolt_output_path ( builder, & self . file , & self . hash ) ;
2145- if !output_path. is_file ( ) {
2146- optimize_with_bolt ( & self . file , & self . profile , & output_path) ;
2147- }
2148- output_path
2149- }
2150- }
2151-
21522027#[ derive( Clone , Debug , Eq , Hash , PartialEq ) ]
21532028pub struct LlvmTools {
21542029 pub target : TargetSelection ,
0 commit comments