Skip to content

Commit 83922fe

Browse files
committed
Auto merge of #45102 - petrochenkov:noar, r=alexcrichton
cleanup: rustc doesn't use an external archiver cc #45090 r? @alexcrichton
2 parents 02a24db + b434c84 commit 83922fe

15 files changed

+9
-65
lines changed

config.toml.example

+3-6
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,11 @@
250250
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
251251
#backtrace = true
252252

253-
# The default linker that will be used by the generated compiler. Note that this
254-
# is not the linker used to link said compiler.
253+
# The default linker that will be hard-coded into the generated compiler for
254+
# targets that don't specify linker explicitly in their target specifications.
255+
# Note that this is not the linker used to link said compiler.
255256
#default-linker = "cc"
256257

257-
# The default ar utility that will be used by the generated compiler if LLVM
258-
# cannot be used. Note that this is not used to assemble said compiler.
259-
#default-ar = "ar"
260-
261258
# The "channel" for the Rust build to produce. The stable/beta channels only
262259
# allow using stable features, whereas the nightly and dev channels allow using
263260
# nightly features

src/bootstrap/compile.rs

-3
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,6 @@ pub fn rustc_cargo(build: &Build,
560560
if let Some(ref s) = build.config.rustc_default_linker {
561561
cargo.env("CFG_DEFAULT_LINKER", s);
562562
}
563-
if let Some(ref s) = build.config.rustc_default_ar {
564-
cargo.env("CFG_DEFAULT_AR", s);
565-
}
566563
}
567564

568565
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/config.rs

-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ pub struct Config {
8888
pub rust_debuginfo_only_std: bool,
8989
pub rust_rpath: bool,
9090
pub rustc_default_linker: Option<String>,
91-
pub rustc_default_ar: Option<String>,
9291
pub rust_optimize_tests: bool,
9392
pub rust_debuginfo_tests: bool,
9493
pub rust_dist_src: bool,
@@ -262,7 +261,6 @@ struct Rust {
262261
use_jemalloc: Option<bool>,
263262
backtrace: Option<bool>,
264263
default_linker: Option<String>,
265-
default_ar: Option<String>,
266264
channel: Option<String>,
267265
musl_root: Option<String>,
268266
rpath: Option<bool>,
@@ -464,7 +462,6 @@ impl Config {
464462
set(&mut config.quiet_tests, rust.quiet_tests);
465463
set(&mut config.test_miri, rust.test_miri);
466464
config.rustc_default_linker = rust.default_linker.clone();
467-
config.rustc_default_ar = rust.default_ar.clone();
468465
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
469466

470467
match rust.codegen_units {

src/bootstrap/configure.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ def v(*args):
124124
"experimental LLVM targets to build")
125125
v("release-channel", "rust.channel", "the name of the release channel to build")
126126

127-
# Used on systems where "cc" and "ar" are unavailable
127+
# Used on systems where "cc" is unavailable
128128
v("default-linker", "rust.default-linker", "the default linker")
129-
v("default-ar", "rust.default-ar", "the default ar")
130129

131130
# Many of these are saved below during the "writing configuration" step
132131
# (others are conditionally saved).

src/bootstrap/dist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn make_win_dist(
176176
}
177177
}
178178

179-
let target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", "libwinpthread-1.dll"];
179+
let target_tools = ["gcc.exe", "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
180180
let mut rustc_dlls = vec!["libstdc++-6.dll", "libwinpthread-1.dll"];
181181
if target_triple.starts_with("i686-") {
182182
rustc_dlls.push("libgcc_s_dw2-1.dll");

src/doc/man/rustc.1

-3
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ never colorize output.
152152

153153
.SH CODEGEN OPTIONS
154154

155-
.TP
156-
\fBar\fR=\fI/path/to/ar\fR
157-
Path to the archive utility to use when assembling archives.
158155
.TP
159156
\fBlinker\fR=\fI/path/to/cc\fR
160157
Path to the linker utility to use when linking libraries, executables, and

src/librustc/session/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
864864
build_codegen_options, "C", "codegen",
865865
CG_OPTIONS, cg_type_desc, cgsetters,
866866
ar: Option<String> = (None, parse_opt_string, [UNTRACKED],
867-
"tool to assemble archives with (has no effect currently, \
868-
rustc doesn't use an external archiver)"),
867+
"this option is deprecated and does nothing"),
869868
linker: Option<String> = (None, parse_opt_string, [UNTRACKED],
870869
"system linker to link outputs with"),
871870
link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],

src/librustc_back/build.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111
fn main() {
1212
println!("cargo:rerun-if-changed=build.rs");
1313
println!("cargo:rerun-if-env-changed=CFG_DEFAULT_LINKER");
14-
println!("cargo:rerun-if-env-changed=CFG_DEFAULT_AR");
1514
}

src/librustc_back/target/asmjs_unknown_emscripten.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub fn target() -> Result<Target, String> {
2020

2121
let opts = TargetOptions {
2222
linker: cmd("emcc"),
23-
ar: cmd("emar"),
2423

2524
dynamic_linking: false,
2625
executables: true,

src/librustc_back/target/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ pub struct TargetOptions {
268268

269269
/// Linker to invoke. Defaults to "cc".
270270
pub linker: String,
271-
/// Archive utility to use when managing archives. Defaults to "ar".
272-
pub ar: String,
273271

274272
/// Linker arguments that are unconditionally passed *before* any
275273
/// user-defined libraries.
@@ -442,7 +440,6 @@ impl Default for TargetOptions {
442440
TargetOptions {
443441
is_builtin: false,
444442
linker: option_env!("CFG_DEFAULT_LINKER").unwrap_or("cc").to_string(),
445-
ar: option_env!("CFG_DEFAULT_AR").unwrap_or("ar").to_string(),
446443
pre_link_args: LinkArgs::new(),
447444
post_link_args: LinkArgs::new(),
448445
asm_args: Vec::new(),
@@ -684,7 +681,6 @@ impl Target {
684681

685682
key!(is_builtin, bool);
686683
key!(linker);
687-
key!(ar);
688684
key!(pre_link_args, link_args);
689685
key!(pre_link_objects_exe, list);
690686
key!(pre_link_objects_dll, list);
@@ -877,7 +873,6 @@ impl ToJson for Target {
877873

878874
target_option_val!(is_builtin);
879875
target_option_val!(linker);
880-
target_option_val!(ar);
881876
target_option_val!(link_args - pre_link_args);
882877
target_option_val!(pre_link_objects_exe);
883878
target_option_val!(pre_link_objects_dll);

src/librustc_back/target/wasm32_experimental_emscripten.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub fn target() -> Result<Target, String> {
2525

2626
let opts = TargetOptions {
2727
linker: cmd("emcc"),
28-
ar: cmd("emar"),
2928

3029
dynamic_linking: false,
3130
executables: true,

src/librustc_back/target/wasm32_unknown_emscripten.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub fn target() -> Result<Target, String> {
2222

2323
let opts = TargetOptions {
2424
linker: cmd("emcc"),
25-
ar: cmd("emar"),
2625

2726
dynamic_linking: false,
2827
executables: true,

src/librustc_back/target/windows_msvc_base.rs

-31
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,6 @@ pub fn opts() -> TargetOptions {
2121
TargetOptions {
2222
function_sections: true,
2323
linker: "link.exe".to_string(),
24-
// When taking a look at the value of this `ar` field, one might expect
25-
// `lib.exe` to be the value here! The `lib.exe` program is the default
26-
// tool for managing `.lib` archives on Windows, but unfortunately the
27-
// compiler cannot use it.
28-
//
29-
// To recap, we use `ar` here to manage rlibs (which are just archives).
30-
// LLVM does not expose bindings for modifying archives so we have to
31-
// invoke this utility for write operations (e.g. deleting files, adding
32-
// files, etc). Normally archives only have object files within them,
33-
// but the compiler also uses archives for storing metadata and
34-
// compressed bytecode, so we don't exactly fall within "normal use
35-
// cases".
36-
//
37-
// MSVC's `lib.exe` tool by default will choke when adding a non-object
38-
// file to an archive, which we do on a regular basis, making it
39-
// inoperable for us. Luckily, however, LLVM has already rewritten `ar`
40-
// in the form of `llvm-ar` which is built by default when we build
41-
// LLVM. This tool, unlike `lib.exe`, works just fine with non-object
42-
// files, so we use it instead.
43-
//
44-
// Note that there's a few caveats associated with this:
45-
//
46-
// * This still requires that the *linker* (the consumer of rlibs) will
47-
// ignore non-object files. Thankfully `link.exe` on Windows does
48-
// indeed ignore non-object files in archives.
49-
// * This requires `llvm-ar.exe` to be distributed with the compiler
50-
// itself, but we already make sure of this elsewhere.
51-
//
52-
// Perhaps one day we won't even need this tool at all and we'll just be
53-
// able to make library calls into LLVM!
54-
ar: "llvm-ar.exe".to_string(),
5524
dynamic_linking: true,
5625
executables: true,
5726
dll_prefix: "".to_string(),

src/librustc_back/target/x86_64_rumprun_netbsd.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub fn target() -> TargetResult {
1616
base.cpu = "x86-64".to_string();
1717
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
1818
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
19-
base.ar = "x86_64-rumprun-netbsd-ar".to_string();
2019
base.max_atomic_width = Some(64);
2120

2221
base.dynamic_linking = false;

src/librustc_trans/back/archive.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ pub struct ArchiveConfig<'a> {
3131
pub lib_search_paths: Vec<PathBuf>,
3232
}
3333

34-
/// Helper for adding many files to an archive with a single invocation of
35-
/// `ar`.
34+
/// Helper for adding many files to an archive.
3635
#[must_use = "must call build() to finish building the archive"]
3736
pub struct ArchiveBuilder<'a> {
3837
config: ArchiveConfig<'a>,
@@ -201,8 +200,8 @@ impl<'a> ArchiveBuilder<'a> {
201200
});
202201
}
203202

204-
/// Indicate that the next call to `build` should updates all symbols in
205-
/// the archive (run 'ar s' over it).
203+
/// Indicate that the next call to `build` should update all symbols in
204+
/// the archive (equivalent to running 'ar s' over it).
206205
pub fn update_symbols(&mut self) {
207206
self.should_update_symbols = true;
208207
}

0 commit comments

Comments
 (0)