@@ -402,7 +402,7 @@ def use_default_substitutions(self):
402
402
self .add_err_msg_substitutions ()
403
403
404
404
def use_llvm_tool (self , name , search_env = None , required = False , quiet = False ,
405
- use_installed = False ):
405
+ search_paths = None , use_installed = False ):
406
406
"""Find the executable program 'name', optionally using the specified
407
407
environment variable as an override before searching the build directory
408
408
and then optionally the configuration's PATH."""
@@ -413,8 +413,11 @@ def use_llvm_tool(self, name, search_env=None, required=False, quiet=False,
413
413
tool = self .config .environment .get (search_env )
414
414
415
415
if not tool :
416
- # Use the build directory version.
417
- tool = lit .util .which (name , self .config .llvm_tools_dir )
416
+ if search_paths is None :
417
+ search_paths = [self .config .llvm_tools_dir ]
418
+ # Use the specified search paths.
419
+ path = os .pathsep .join (search_paths )
420
+ tool = lit .util .which (name , path )
418
421
419
422
if not tool and use_installed :
420
423
# Otherwise look in the path, if enabled.
@@ -488,10 +491,10 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[],
488
491
'llvm_shlib_dir' ,
489
492
'llvm_libs_dir' ,
490
493
]
491
- paths = [getattr (self .config , pp ) for pp in lib_dir_props
492
- if getattr (self .config , pp , None )]
494
+ lib_paths = [getattr (self .config , pp ) for pp in lib_dir_props
495
+ if getattr (self .config , pp , None )]
493
496
494
- self .with_environment ('LD_LIBRARY_PATH' , paths , append_path = True )
497
+ self .with_environment ('LD_LIBRARY_PATH' , lib_paths , append_path = True )
495
498
496
499
shl = getattr (self .config , 'llvm_shlib_dir' , None )
497
500
pext = getattr (self .config , 'llvm_plugin_ext' , None )
@@ -503,7 +506,7 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[],
503
506
# Discover the 'clang' and 'clangcc' to use.
504
507
self .config .clang = self .use_llvm_tool (
505
508
'clang' , search_env = 'CLANG' , required = required ,
506
- use_installed = use_installed )
509
+ search_paths = paths , use_installed = use_installed )
507
510
if self .config .clang :
508
511
self .config .available_features .add ('clang' )
509
512
builtin_include_dir = self .get_clang_builtin_include_dir (
@@ -595,20 +598,24 @@ def use_lld(self, additional_tool_dirs=[], required=True,
595
598
596
599
lib_dir_props = [self .config .name .lower () + '_libs_dir' ,
597
600
'lld_libs_dir' , 'llvm_libs_dir' ]
598
- paths = [getattr (self .config , pp ) for pp in lib_dir_props
599
- if getattr (self .config , pp , None )]
601
+ lib_paths = [getattr (self .config , pp ) for pp in lib_dir_props
602
+ if getattr (self .config , pp , None )]
600
603
601
- self .with_environment ('LD_LIBRARY_PATH' , paths , append_path = True )
604
+ self .with_environment ('LD_LIBRARY_PATH' , lib_paths , append_path = True )
602
605
603
606
# Discover the LLD executables to use.
604
607
605
608
ld_lld = self .use_llvm_tool ('ld.lld' , required = required ,
609
+ search_paths = paths ,
606
610
use_installed = use_installed )
607
611
lld_link = self .use_llvm_tool ('lld-link' , required = required ,
612
+ search_paths = paths ,
608
613
use_installed = use_installed )
609
614
ld64_lld = self .use_llvm_tool ('ld64.lld' , required = required ,
615
+ search_paths = paths ,
610
616
use_installed = use_installed )
611
617
wasm_ld = self .use_llvm_tool ('wasm-ld' , required = required ,
618
+ search_paths = paths ,
612
619
use_installed = use_installed )
613
620
614
621
was_found = ld_lld and lld_link and ld64_lld and wasm_ld
0 commit comments