@@ -6,7 +6,7 @@ use std::fs::{File, OpenOptions, read};
66use std:: io:: { BufWriter , Write } ;
77use std:: ops:: { ControlFlow , Deref } ;
88use std:: path:: { Path , PathBuf } ;
9- use std:: process:: { ExitStatus , Output , Stdio } ;
9+ use std:: process:: { Output , Stdio } ;
1010use std:: { env, fmt, fs, io, mem, str} ;
1111
1212use cc:: windows_registry;
@@ -736,13 +736,10 @@ fn link_natively(
736736
737737 // Invoke the system linker
738738 info ! ( "{cmd:?}" ) ;
739- let retry_on_segfault = env:: var ( "RUSTC_RETRY_LINKER_ON_SEGFAULT" ) . is_ok ( ) ;
740739 let unknown_arg_regex =
741740 Regex :: new ( r"(unknown|unrecognized) (command line )?(option|argument)" ) . unwrap ( ) ;
742741 let mut prog;
743- let mut i = 0 ;
744742 loop {
745- i += 1 ;
746743 prog = sess. time ( "run_linker" , || exec_linker ( sess, & cmd, out_filename, flavor, tmpdir) ) ;
747744 let Ok ( ref output) = prog else {
748745 break ;
@@ -858,54 +855,7 @@ fn link_natively(
858855 continue ;
859856 }
860857
861- // Here's a terribly awful hack that really shouldn't be present in any
862- // compiler. Here an environment variable is supported to automatically
863- // retry the linker invocation if the linker looks like it segfaulted.
864- //
865- // Gee that seems odd, normally segfaults are things we want to know
866- // about! Unfortunately though in rust-lang/rust#38878 we're
867- // experiencing the linker segfaulting on Travis quite a bit which is
868- // causing quite a bit of pain to land PRs when they spuriously fail
869- // due to a segfault.
870- //
871- // The issue #38878 has some more debugging information on it as well,
872- // but this unfortunately looks like it's just a race condition in
873- // macOS's linker with some thread pool working in the background. It
874- // seems that no one currently knows a fix for this so in the meantime
875- // we're left with this...
876- if !retry_on_segfault || i > 3 {
877- break ;
878- }
879- let msg_segv = "clang: error: unable to execute command: Segmentation fault: 11" ;
880- let msg_bus = "clang: error: unable to execute command: Bus error: 10" ;
881- if out. contains ( msg_segv) || out. contains ( msg_bus) {
882- warn ! (
883- ?cmd, %out,
884- "looks like the linker segfaulted when we tried to call it, \
885- automatically retrying again",
886- ) ;
887- continue ;
888- }
889-
890- if is_illegal_instruction ( & output. status ) {
891- warn ! (
892- ?cmd, %out, status = %output. status,
893- "looks like the linker hit an illegal instruction when we \
894- tried to call it, automatically retrying again.",
895- ) ;
896- continue ;
897- }
898-
899- #[ cfg( unix) ]
900- fn is_illegal_instruction ( status : & ExitStatus ) -> bool {
901- use std:: os:: unix:: prelude:: * ;
902- status. signal ( ) == Some ( libc:: SIGILL )
903- }
904-
905- #[ cfg( not( unix) ) ]
906- fn is_illegal_instruction ( _status : & ExitStatus ) -> bool {
907- false
908- }
858+ break ;
909859 }
910860
911861 match prog {
0 commit comments