Skip to content

Commit c12c42d

Browse files
committed
Auto merge of #30913 - brson:nogold, r=alexcrichton
This reverts commit 34dc0e0. cc #30783 #30784 #29974 r? @alexcrichton
2 parents e5bab5d + 4bcca8b commit c12c42d

File tree

3 files changed

+0
-57
lines changed

3 files changed

+0
-57
lines changed

src/librustc/session/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,6 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
541541
"explicitly enable the cfg(debug_assertions) directive"),
542542
inline_threshold: Option<usize> = (None, parse_opt_uint,
543543
"set the inlining threshold for"),
544-
disable_gold: bool = (false, parse_bool,
545-
"disable use of the ld.gold linker"),
546544
}
547545

548546

src/librustc_trans/back/link.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,6 @@ fn link_args(cmd: &mut Linker,
10631063
cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
10641064
}
10651065

1066-
// Use the gold linker if possible instead of ld. It is much
1067-
// faster.
1068-
cmd.try_gold_linker();
1069-
10701066
// Finally add all the linker arguments provided on the command line along
10711067
// with any #[link_args] attributes found inside the crate
10721068
if let Some(ref args) = sess.opts.cg.link_args {

src/librustc_trans/back/linker.rs

-51
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::env;
1211
use std::ffi::OsString;
1312
use std::fs::{self, File};
1413
use std::io::{self, BufWriter};
@@ -57,7 +56,6 @@ pub trait Linker {
5756
fn no_whole_archives(&mut self);
5857
fn export_symbols(&mut self, sess: &Session, trans: &CrateTranslation,
5958
tmpdir: &Path);
60-
fn try_gold_linker(&mut self);
6159
}
6260

6361
pub struct GnuLinker<'a> {
@@ -201,53 +199,6 @@ impl<'a> Linker for GnuLinker<'a> {
201199
fn export_symbols(&mut self, _: &Session, _: &CrateTranslation, _: &Path) {
202200
// noop, visibility in object files takes care of this
203201
}
204-
205-
fn try_gold_linker(&mut self) {
206-
// Only use gold under specific conditions that we know work
207-
208-
let gold_exists = match env::var_os("PATH") {
209-
Some(ref env_path) => {
210-
env::split_paths(env_path).any(|mut p| {
211-
p.push("ld.gold");
212-
p.exists()
213-
})
214-
}
215-
None => false
216-
};
217-
let host_is_linux = cfg!(target_os = "linux");
218-
// Defensively prevent trying to use gold for bogus cross-targets.
219-
let target_is_host_compatible = {
220-
let host_os_is_target_os = self.sess.target.target.target_os == env::consts::OS;
221-
let host_arch_is_target_arch = self.sess.target.target.arch == env::consts::ARCH;
222-
// Support x86_64->i686 and reverse
223-
let host_and_target_are_x86ish =
224-
(self.sess.target.target.arch == "x86" ||
225-
self.sess.target.target.arch == "x86_64") &&
226-
(env::consts::ARCH == "x86" ||
227-
env::consts::ARCH == "x86_64");
228-
host_os_is_target_os && (host_arch_is_target_arch || host_and_target_are_x86ish)
229-
};
230-
// We have strong confidence that x86 works, but not much
231-
// visibility into other architectures.
232-
let target_works_with_gold =
233-
self.sess.target.target.arch == "x86" ||
234-
self.sess.target.target.arch == "x86_64";
235-
let opt_out = self.sess.opts.cg.disable_gold;
236-
237-
let can_use_gold =
238-
gold_exists &&
239-
host_is_linux &&
240-
target_is_host_compatible &&
241-
target_works_with_gold &&
242-
!opt_out;
243-
244-
if can_use_gold {
245-
info!("linking with ld.gold");
246-
self.cmd.arg("-fuse-ld=gold");
247-
} else {
248-
info!("linking with ld");
249-
}
250-
}
251202
}
252203

253204
pub struct MsvcLinker<'a> {
@@ -407,6 +358,4 @@ impl<'a> Linker for MsvcLinker<'a> {
407358
arg.push(path);
408359
self.cmd.arg(&arg);
409360
}
410-
411-
fn try_gold_linker(&mut self) {}
412361
}

0 commit comments

Comments
 (0)