cleanup: rustc doesn't use an external archiver
This commit is contained in:
parent
72d65019c7
commit
b434c84bab
@ -250,14 +250,11 @@
|
|||||||
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
|
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
|
||||||
#backtrace = true
|
#backtrace = true
|
||||||
|
|
||||||
# The default linker that will be used by the generated compiler. Note that this
|
# The default linker that will be hard-coded into the generated compiler for
|
||||||
# is not the linker used to link said compiler.
|
# targets that don't specify linker explicitly in their target specifications.
|
||||||
|
# Note that this is not the linker used to link said compiler.
|
||||||
#default-linker = "cc"
|
#default-linker = "cc"
|
||||||
|
|
||||||
# The default ar utility that will be used by the generated compiler if LLVM
|
|
||||||
# cannot be used. Note that this is not used to assemble said compiler.
|
|
||||||
#default-ar = "ar"
|
|
||||||
|
|
||||||
# The "channel" for the Rust build to produce. The stable/beta channels only
|
# The "channel" for the Rust build to produce. The stable/beta channels only
|
||||||
# allow using stable features, whereas the nightly and dev channels allow using
|
# allow using stable features, whereas the nightly and dev channels allow using
|
||||||
# nightly features
|
# nightly features
|
||||||
|
@ -560,9 +560,6 @@ pub fn rustc_cargo(build: &Build,
|
|||||||
if let Some(ref s) = build.config.rustc_default_linker {
|
if let Some(ref s) = build.config.rustc_default_linker {
|
||||||
cargo.env("CFG_DEFAULT_LINKER", s);
|
cargo.env("CFG_DEFAULT_LINKER", s);
|
||||||
}
|
}
|
||||||
if let Some(ref s) = build.config.rustc_default_ar {
|
|
||||||
cargo.env("CFG_DEFAULT_AR", s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -88,7 +88,6 @@ pub struct Config {
|
|||||||
pub rust_debuginfo_only_std: bool,
|
pub rust_debuginfo_only_std: bool,
|
||||||
pub rust_rpath: bool,
|
pub rust_rpath: bool,
|
||||||
pub rustc_default_linker: Option<String>,
|
pub rustc_default_linker: Option<String>,
|
||||||
pub rustc_default_ar: Option<String>,
|
|
||||||
pub rust_optimize_tests: bool,
|
pub rust_optimize_tests: bool,
|
||||||
pub rust_debuginfo_tests: bool,
|
pub rust_debuginfo_tests: bool,
|
||||||
pub rust_dist_src: bool,
|
pub rust_dist_src: bool,
|
||||||
@ -262,7 +261,6 @@ struct Rust {
|
|||||||
use_jemalloc: Option<bool>,
|
use_jemalloc: Option<bool>,
|
||||||
backtrace: Option<bool>,
|
backtrace: Option<bool>,
|
||||||
default_linker: Option<String>,
|
default_linker: Option<String>,
|
||||||
default_ar: Option<String>,
|
|
||||||
channel: Option<String>,
|
channel: Option<String>,
|
||||||
musl_root: Option<String>,
|
musl_root: Option<String>,
|
||||||
rpath: Option<bool>,
|
rpath: Option<bool>,
|
||||||
@ -464,7 +462,6 @@ impl Config {
|
|||||||
set(&mut config.quiet_tests, rust.quiet_tests);
|
set(&mut config.quiet_tests, rust.quiet_tests);
|
||||||
set(&mut config.test_miri, rust.test_miri);
|
set(&mut config.test_miri, rust.test_miri);
|
||||||
config.rustc_default_linker = rust.default_linker.clone();
|
config.rustc_default_linker = rust.default_linker.clone();
|
||||||
config.rustc_default_ar = rust.default_ar.clone();
|
|
||||||
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
||||||
|
|
||||||
match rust.codegen_units {
|
match rust.codegen_units {
|
||||||
|
@ -119,9 +119,8 @@ v("experimental-targets", "llvm.experimental-targets",
|
|||||||
"experimental LLVM targets to build")
|
"experimental LLVM targets to build")
|
||||||
v("release-channel", "rust.channel", "the name of the release channel to build")
|
v("release-channel", "rust.channel", "the name of the release channel to build")
|
||||||
|
|
||||||
# Used on systems where "cc" and "ar" are unavailable
|
# Used on systems where "cc" is unavailable
|
||||||
v("default-linker", "rust.default-linker", "the default linker")
|
v("default-linker", "rust.default-linker", "the default linker")
|
||||||
v("default-ar", "rust.default-ar", "the default ar")
|
|
||||||
|
|
||||||
# Many of these are saved below during the "writing configuration" step
|
# Many of these are saved below during the "writing configuration" step
|
||||||
# (others are conditionally saved).
|
# (others are conditionally saved).
|
||||||
|
@ -176,7 +176,7 @@ fn make_win_dist(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", "libwinpthread-1.dll"];
|
let target_tools = ["gcc.exe", "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
|
||||||
let mut rustc_dlls = vec!["libstdc++-6.dll", "libwinpthread-1.dll"];
|
let mut rustc_dlls = vec!["libstdc++-6.dll", "libwinpthread-1.dll"];
|
||||||
if target_triple.starts_with("i686-") {
|
if target_triple.starts_with("i686-") {
|
||||||
rustc_dlls.push("libgcc_s_dw2-1.dll");
|
rustc_dlls.push("libgcc_s_dw2-1.dll");
|
||||||
|
@ -152,9 +152,6 @@ never colorize output.
|
|||||||
|
|
||||||
.SH CODEGEN OPTIONS
|
.SH CODEGEN OPTIONS
|
||||||
|
|
||||||
.TP
|
|
||||||
\fBar\fR=\fI/path/to/ar\fR
|
|
||||||
Path to the archive utility to use when assembling archives.
|
|
||||||
.TP
|
.TP
|
||||||
\fBlinker\fR=\fI/path/to/cc\fR
|
\fBlinker\fR=\fI/path/to/cc\fR
|
||||||
Path to the linker utility to use when linking libraries, executables, and
|
Path to the linker utility to use when linking libraries, executables, and
|
||||||
|
@ -864,8 +864,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
|||||||
build_codegen_options, "C", "codegen",
|
build_codegen_options, "C", "codegen",
|
||||||
CG_OPTIONS, cg_type_desc, cgsetters,
|
CG_OPTIONS, cg_type_desc, cgsetters,
|
||||||
ar: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
ar: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
||||||
"tool to assemble archives with (has no effect currently, \
|
"this option is deprecated and does nothing"),
|
||||||
rustc doesn't use an external archiver)"),
|
|
||||||
linker: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
linker: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
||||||
"system linker to link outputs with"),
|
"system linker to link outputs with"),
|
||||||
link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
|
link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
|
||||||
|
@ -11,5 +11,4 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
println!("cargo:rerun-if-env-changed=CFG_DEFAULT_LINKER");
|
println!("cargo:rerun-if-env-changed=CFG_DEFAULT_LINKER");
|
||||||
println!("cargo:rerun-if-env-changed=CFG_DEFAULT_AR");
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ pub fn target() -> Result<Target, String> {
|
|||||||
|
|
||||||
let opts = TargetOptions {
|
let opts = TargetOptions {
|
||||||
linker: cmd("emcc"),
|
linker: cmd("emcc"),
|
||||||
ar: cmd("emar"),
|
|
||||||
|
|
||||||
dynamic_linking: false,
|
dynamic_linking: false,
|
||||||
executables: true,
|
executables: true,
|
||||||
|
@ -268,8 +268,6 @@ pub struct TargetOptions {
|
|||||||
|
|
||||||
/// Linker to invoke. Defaults to "cc".
|
/// Linker to invoke. Defaults to "cc".
|
||||||
pub linker: String,
|
pub linker: String,
|
||||||
/// Archive utility to use when managing archives. Defaults to "ar".
|
|
||||||
pub ar: String,
|
|
||||||
|
|
||||||
/// Linker arguments that are unconditionally passed *before* any
|
/// Linker arguments that are unconditionally passed *before* any
|
||||||
/// user-defined libraries.
|
/// user-defined libraries.
|
||||||
@ -439,7 +437,6 @@ impl Default for TargetOptions {
|
|||||||
TargetOptions {
|
TargetOptions {
|
||||||
is_builtin: false,
|
is_builtin: false,
|
||||||
linker: option_env!("CFG_DEFAULT_LINKER").unwrap_or("cc").to_string(),
|
linker: option_env!("CFG_DEFAULT_LINKER").unwrap_or("cc").to_string(),
|
||||||
ar: option_env!("CFG_DEFAULT_AR").unwrap_or("ar").to_string(),
|
|
||||||
pre_link_args: LinkArgs::new(),
|
pre_link_args: LinkArgs::new(),
|
||||||
post_link_args: LinkArgs::new(),
|
post_link_args: LinkArgs::new(),
|
||||||
asm_args: Vec::new(),
|
asm_args: Vec::new(),
|
||||||
@ -680,7 +677,6 @@ impl Target {
|
|||||||
|
|
||||||
key!(is_builtin, bool);
|
key!(is_builtin, bool);
|
||||||
key!(linker);
|
key!(linker);
|
||||||
key!(ar);
|
|
||||||
key!(pre_link_args, link_args);
|
key!(pre_link_args, link_args);
|
||||||
key!(pre_link_objects_exe, list);
|
key!(pre_link_objects_exe, list);
|
||||||
key!(pre_link_objects_dll, list);
|
key!(pre_link_objects_dll, list);
|
||||||
@ -872,7 +868,6 @@ impl ToJson for Target {
|
|||||||
|
|
||||||
target_option_val!(is_builtin);
|
target_option_val!(is_builtin);
|
||||||
target_option_val!(linker);
|
target_option_val!(linker);
|
||||||
target_option_val!(ar);
|
|
||||||
target_option_val!(link_args - pre_link_args);
|
target_option_val!(link_args - pre_link_args);
|
||||||
target_option_val!(pre_link_objects_exe);
|
target_option_val!(pre_link_objects_exe);
|
||||||
target_option_val!(pre_link_objects_dll);
|
target_option_val!(pre_link_objects_dll);
|
||||||
|
@ -25,7 +25,6 @@ pub fn target() -> Result<Target, String> {
|
|||||||
|
|
||||||
let opts = TargetOptions {
|
let opts = TargetOptions {
|
||||||
linker: cmd("emcc"),
|
linker: cmd("emcc"),
|
||||||
ar: cmd("emar"),
|
|
||||||
|
|
||||||
dynamic_linking: false,
|
dynamic_linking: false,
|
||||||
executables: true,
|
executables: true,
|
||||||
|
@ -22,7 +22,6 @@ pub fn target() -> Result<Target, String> {
|
|||||||
|
|
||||||
let opts = TargetOptions {
|
let opts = TargetOptions {
|
||||||
linker: cmd("emcc"),
|
linker: cmd("emcc"),
|
||||||
ar: cmd("emar"),
|
|
||||||
|
|
||||||
dynamic_linking: false,
|
dynamic_linking: false,
|
||||||
executables: true,
|
executables: true,
|
||||||
|
@ -21,37 +21,6 @@ pub fn opts() -> TargetOptions {
|
|||||||
TargetOptions {
|
TargetOptions {
|
||||||
function_sections: true,
|
function_sections: true,
|
||||||
linker: "link.exe".to_string(),
|
linker: "link.exe".to_string(),
|
||||||
// When taking a look at the value of this `ar` field, one might expect
|
|
||||||
// `lib.exe` to be the value here! The `lib.exe` program is the default
|
|
||||||
// tool for managing `.lib` archives on Windows, but unfortunately the
|
|
||||||
// compiler cannot use it.
|
|
||||||
//
|
|
||||||
// To recap, we use `ar` here to manage rlibs (which are just archives).
|
|
||||||
// LLVM does not expose bindings for modifying archives so we have to
|
|
||||||
// invoke this utility for write operations (e.g. deleting files, adding
|
|
||||||
// files, etc). Normally archives only have object files within them,
|
|
||||||
// but the compiler also uses archives for storing metadata and
|
|
||||||
// compressed bytecode, so we don't exactly fall within "normal use
|
|
||||||
// cases".
|
|
||||||
//
|
|
||||||
// MSVC's `lib.exe` tool by default will choke when adding a non-object
|
|
||||||
// file to an archive, which we do on a regular basis, making it
|
|
||||||
// inoperable for us. Luckily, however, LLVM has already rewritten `ar`
|
|
||||||
// in the form of `llvm-ar` which is built by default when we build
|
|
||||||
// LLVM. This tool, unlike `lib.exe`, works just fine with non-object
|
|
||||||
// files, so we use it instead.
|
|
||||||
//
|
|
||||||
// Note that there's a few caveats associated with this:
|
|
||||||
//
|
|
||||||
// * This still requires that the *linker* (the consumer of rlibs) will
|
|
||||||
// ignore non-object files. Thankfully `link.exe` on Windows does
|
|
||||||
// indeed ignore non-object files in archives.
|
|
||||||
// * This requires `llvm-ar.exe` to be distributed with the compiler
|
|
||||||
// itself, but we already make sure of this elsewhere.
|
|
||||||
//
|
|
||||||
// Perhaps one day we won't even need this tool at all and we'll just be
|
|
||||||
// able to make library calls into LLVM!
|
|
||||||
ar: "llvm-ar.exe".to_string(),
|
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
dll_prefix: "".to_string(),
|
dll_prefix: "".to_string(),
|
||||||
|
@ -16,7 +16,6 @@ pub fn target() -> TargetResult {
|
|||||||
base.cpu = "x86-64".to_string();
|
base.cpu = "x86-64".to_string();
|
||||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||||
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
|
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
|
||||||
base.ar = "x86_64-rumprun-netbsd-ar".to_string();
|
|
||||||
base.max_atomic_width = Some(64);
|
base.max_atomic_width = Some(64);
|
||||||
|
|
||||||
base.dynamic_linking = false;
|
base.dynamic_linking = false;
|
||||||
|
@ -31,8 +31,7 @@ pub struct ArchiveConfig<'a> {
|
|||||||
pub lib_search_paths: Vec<PathBuf>,
|
pub lib_search_paths: Vec<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper for adding many files to an archive with a single invocation of
|
/// Helper for adding many files to an archive.
|
||||||
/// `ar`.
|
|
||||||
#[must_use = "must call build() to finish building the archive"]
|
#[must_use = "must call build() to finish building the archive"]
|
||||||
pub struct ArchiveBuilder<'a> {
|
pub struct ArchiveBuilder<'a> {
|
||||||
config: ArchiveConfig<'a>,
|
config: ArchiveConfig<'a>,
|
||||||
@ -201,8 +200,8 @@ impl<'a> ArchiveBuilder<'a> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Indicate that the next call to `build` should updates all symbols in
|
/// Indicate that the next call to `build` should update all symbols in
|
||||||
/// the archive (run 'ar s' over it).
|
/// the archive (equivalent to running 'ar s' over it).
|
||||||
pub fn update_symbols(&mut self) {
|
pub fn update_symbols(&mut self) {
|
||||||
self.should_update_symbols = true;
|
self.should_update_symbols = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user