@@ -157,6 +157,12 @@ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target:
157157 copy_and_stamp ( Path :: new ( & src) , "libunwind.a" ) ;
158158 }
159159
160+ if builder. config . sanitizers && compiler. stage != 0 {
161+ // The sanitizers are only copied in stage1 or above,
162+ // to avoid creating dependency on LLVM.
163+ target_deps. extend ( copy_sanitizers ( builder, & compiler, target) ) ;
164+ }
165+
160166 target_deps
161167}
162168
@@ -264,32 +270,30 @@ impl Step for StdLink {
264270 let libdir = builder. sysroot_libdir ( target_compiler, target) ;
265271 let hostdir = builder. sysroot_libdir ( target_compiler, compiler. host ) ;
266272 add_to_sysroot ( builder, & libdir, & hostdir, & libstd_stamp ( builder, compiler, target) ) ;
267-
268- if builder. config . sanitizers && compiler. stage != 0 {
269- // The sanitizers are only copied in stage1 or above,
270- // to avoid creating dependency on LLVM.
271- copy_sanitizers ( builder, & target_compiler, target) ;
272- }
273273 }
274274}
275275
276276/// Copies sanitizer runtime libraries into target libdir.
277- fn copy_sanitizers ( builder : & Builder < ' _ > , target_compiler : & Compiler , target : Interned < String > ) {
277+ fn copy_sanitizers ( builder : & Builder < ' _ > ,
278+ compiler : & Compiler ,
279+ target : Interned < String > ) -> Vec < PathBuf > {
280+ let mut target_deps = Vec :: new ( ) ;
281+
278282 let sanitizers = supported_sanitizers ( target) ;
279283 if sanitizers. is_empty ( ) {
280- return ;
284+ return target_deps ;
281285 }
282286
283287 let llvm_config: PathBuf = builder. ensure ( native:: Llvm {
284- target : target_compiler . host ,
288+ target : compiler . host ,
285289 } ) ;
286290 if builder. config . dry_run {
287- return ;
291+ return target_deps ;
288292 }
289293
290294 // The compiler-rt installs sanitizer runtimes into clang resource directory.
291295 let clang_resourcedir = clang_resourcedir ( & llvm_config) ;
292- let libdir = builder. sysroot_libdir ( * target_compiler , target) ;
296+ let libdir = builder. sysroot_libdir ( * compiler , target) ;
293297
294298 for ( path, name) in & sanitizers {
295299 let src = clang_resourcedir. join ( path) ;
@@ -310,7 +314,11 @@ fn copy_sanitizers(builder: &Builder<'_>, target_compiler: &Compiler, target: In
310314 . expect ( "failed to execute `install_name_tool`" ) ;
311315 assert ! ( status. success( ) ) ;
312316 }
317+
318+ target_deps. push ( dst) ;
313319 }
320+
321+ target_deps
314322}
315323
316324/// Returns path to clang's resource directory.
0 commit comments