Skip to content

Commit 4fce906

Browse files
authored
Rollup merge of rust-lang#141749 - Noratrieb:RUSTC_ACTUALLY_DO_NOT_RETRY_LINKER_ON_SEGFAULT, r=petrochenkov
Remove RUSTC_RETRY_LINKER_ON_SEGFAULT hack It looks like this was added in rust-lang#40422 6 years ago because of issues with the MacOS linker. MacOS got a new linker in the meantime, so that should probably be resolved now. Hopefully. r? petrochenkov
2 parents 4aac899 + f177807 commit 4fce906

File tree

2 files changed

+2
-57
lines changed

2 files changed

+2
-57
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::fs::{File, OpenOptions, read};
66
use std::io::{BufWriter, Write};
77
use std::ops::{ControlFlow, Deref};
88
use std::path::{Path, PathBuf};
9-
use std::process::{ExitStatus, Output, Stdio};
9+
use std::process::{Output, Stdio};
1010
use std::{env, fmt, fs, io, mem, str};
1111

1212
use 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 {

src/ci/github-actions/jobs.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ envs:
7272
env-x86_64-apple-tests: &env-x86_64-apple-tests
7373
SCRIPT: ./x.py check compiletest --set build.compiletest-use-stage0-libtest=true && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
7474
RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc
75-
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
7675
# Ensure that host tooling is tested on our minimum supported macOS version.
7776
MACOSX_DEPLOYMENT_TARGET: 10.12
7877
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
@@ -402,7 +401,6 @@ auto:
402401
env:
403402
SCRIPT: ./x.py dist bootstrap --include-default-paths --host=x86_64-apple-darwin --target=x86_64-apple-darwin
404403
RUST_CONFIGURE_ARGS: --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set rust.lto=thin --set rust.codegen-units=1
405-
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
406404
# Ensure that host tooling is built to support our minimum support macOS version.
407405
MACOSX_DEPLOYMENT_TARGET: 10.12
408406
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
@@ -420,7 +418,6 @@ auto:
420418
# Mac Catalyst cannot currently compile the sanitizer:
421419
# https://github.com/rust-lang/rust/issues/129069
422420
RUST_CONFIGURE_ARGS: --enable-sanitizers --enable-profiler --set rust.jemalloc --set target.aarch64-apple-ios-macabi.sanitizers=false --set target.x86_64-apple-ios-macabi.sanitizers=false
423-
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
424421
# Ensure that host tooling is built to support our minimum support macOS version.
425422
# FIXME(madsmtm): This might be redundant, as we're not building host tooling here (?)
426423
MACOSX_DEPLOYMENT_TARGET: 10.12
@@ -453,7 +450,6 @@ auto:
453450
--set llvm.ninja=false
454451
--set rust.lto=thin
455452
--set rust.codegen-units=1
456-
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
457453
SELECT_XCODE: /Applications/Xcode_15.4.app
458454
USE_XCODE_CLANG: 1
459455
# Aarch64 tooling only needs to support macOS 11.0 and up as nothing else
@@ -476,7 +472,6 @@ auto:
476472
--enable-sanitizers
477473
--enable-profiler
478474
--set rust.jemalloc
479-
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
480475
SELECT_XCODE: /Applications/Xcode_15.4.app
481476
USE_XCODE_CLANG: 1
482477
# Aarch64 tooling only needs to support macOS 11.0 and up as nothing else

0 commit comments

Comments
 (0)