@@ -473,7 +473,7 @@ def needsBuild(self, newestInput) -> Tuple[bool, str]:
473
473
ts = TimeStampFile (self .subject .output_file ())
474
474
if not ts .exists ():
475
475
return True , f"{ ts .path } does not exist"
476
- if ts .isOlderThan (newestInput ):
476
+ if newestInput and ts .isOlderThan (newestInput ):
477
477
return True , f"{ ts } is older than { newestInput } "
478
478
previous_build_args = []
479
479
command_file = self ._get_command_file ()
@@ -565,9 +565,14 @@ def __init__(self, suite, name, deps, workingSets, theLicense=None, **kw_args):
565
565
self .relative_extracted_lib_paths = {k : v .replace ('/' , os .sep ) for k , v in kw_args .pop ('relative_extracted_lib_paths' , {}).items ()}
566
566
self .liblang_relpath = _pop_path (kw_args , 'relative_liblang_path' , None )
567
567
self .setup_relative_resources = kw_args .pop ('setup_relative_resources' , None )
568
- # We use our LLVM toolchain on Linux because we want to statically link the C++ standard library,
569
- # and the system toolchain rarely has libstdc++.a installed (it would be an extra CI & dev dependency).
570
- toolchain = 'sdk:LLVM_NINJA_TOOLCHAIN' if mx .is_linux () else 'mx:DEFAULT_NINJA_TOOLCHAIN'
568
+
569
+ if not kw_args .get ('multitarget' ):
570
+ # We use our LLVM toolchain on Linux by default because we want to statically link the C++ standard library,
571
+ # and the system toolchain rarely has libstdc++.a installed (it would be an extra CI & dev dependency).
572
+ toolchain = 'sdk:LLVM_NINJA_TOOLCHAIN' if mx .is_linux () else 'mx:DEFAULT_NINJA_TOOLCHAIN'
573
+ else :
574
+ toolchain = None
575
+
571
576
super ().__init__ (
572
577
suite ,
573
578
name ,
@@ -598,6 +603,15 @@ def isJDKDependent(self):
598
603
# This must always be False, the compiled thin launchers need to work on both latest LTS JDK and jdk-latest
599
604
return False
600
605
606
+ @property
607
+ def uses_llvm_toolchain (self ):
608
+ return len (self .toolchains ) == 1 and mx .dependency ('LLVM_NINJA_TOOLCHAIN' , fatalIfMissing = False ) == self .toolchains [0 ].toolchain_dist
609
+
610
+ @property
611
+ def uses_musl_swcfi_toolchain (self ):
612
+ # once GR-67435 is fixed we can revisit if we can statically link just like in the branches guarded by uses_llvm_toolchain
613
+ return len (self .toolchains ) == 1 and mx .dependency ('BOOTSTRAP_MUSL_SWCFI_NINJA_TOOLCHAIN' , fatalIfMissing = False ) == self .toolchains [0 ].toolchain_dist
614
+
601
615
@property
602
616
def cflags (self ):
603
617
_dynamic_cflags = [
@@ -610,7 +624,7 @@ def cflags(self):
610
624
if not mx .is_windows ():
611
625
_dynamic_cflags += ['-pthread' ]
612
626
_dynamic_cflags += ['-Werror=undef' ] # fail on undefined macro used in preprocessor
613
- if mx .is_linux ():
627
+ if mx .is_linux () and self . uses_llvm_toolchain :
614
628
_dynamic_cflags += ['-stdlib=libc++' ] # to link libc++ statically, see ldlibs
615
629
if mx .is_darwin ():
616
630
_dynamic_cflags += ['-ObjC++' ]
@@ -719,12 +733,18 @@ def ldflags(self):
719
733
_dynamic_ldflags = []
720
734
if not mx .is_windows ():
721
735
_dynamic_ldflags += ['-pthread' ]
736
+ if self .uses_musl_swcfi_toolchain :
737
+ # Use $$ to escape the $ from expansion by mx. If we use musl swcfi
738
+ # and their libc, the libc++, libc++abi and libunwind must be
739
+ # either in the LD_LIBRARY_PATH (which takes precedence) or in the
740
+ # lib folder of the standalone.
741
+ _dynamic_ldflags .append (r"-Wl,-rpath,'$$ORIGIN/../lib'" )
722
742
return super ().ldflags + _dynamic_ldflags
723
743
724
744
@property
725
745
def ldlibs (self ):
726
746
_dynamic_ldlibs = []
727
- if mx .is_linux ():
747
+ if mx .is_linux () and self . uses_llvm_toolchain :
728
748
# Link libc++ statically
729
749
_dynamic_ldlibs += [
730
750
'-stdlib=libc++' ,
0 commit comments