File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
compiler/rustc_codegen_ssa/src/back Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -799,6 +799,27 @@ fn link_natively(
799799 continue ;
800800 }
801801
802+ // Check if linking failed with an error message that indicates the driver didn't recognize
803+ // the `-fuse-ld=lld` option. If so, re-perform the link step without it. This avoids having
804+ // to spawn multiple instances on the happy path to do version checking, and ensures things
805+ // keep working on the tier 1 baseline of GLIBC 2.17+. That is generally understood as GCCs
806+ // circa RHEL/CentOS 7, 4.5 or so, whereas lld support was added in GCC 9.
807+ if matches ! ( flavor, LinkerFlavor :: Gnu ( Cc :: Yes , Lld :: Yes ) )
808+ && unknown_arg_regex. is_match ( & out)
809+ && out. contains ( "-fuse-ld=lld" )
810+ && cmd. get_args ( ) . iter ( ) . any ( |e| e. to_string_lossy ( ) == "-fuse-ld=lld" )
811+ {
812+ info ! ( "linker output: {:?}" , out) ;
813+ warn ! ( "The linker driver does not support `-fuse-ld=lld`. Retrying without it." ) ;
814+ for arg in cmd. take_args ( ) {
815+ if arg. to_string_lossy ( ) != "-fuse-ld=lld" {
816+ cmd. arg ( arg) ;
817+ }
818+ }
819+ info ! ( "{:?}" , & cmd) ;
820+ continue ;
821+ }
822+
802823 // Detect '-static-pie' used with an older version of gcc or clang not supporting it.
803824 // Fallback from '-static-pie' to '-static' in that case.
804825 if matches ! ( flavor, LinkerFlavor :: Gnu ( Cc :: Yes , _) )
You can’t perform that action at this time.
0 commit comments