Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces rustc_target::config::Config with its wrapped Target. On its own, this commit breaks the build. I don't like making build-breaking commits, but in this instance I believe that it makes review easier, as the "real" changes of this PR can be seen much more easily. Result of running: find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \; find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \; find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \; ./x.py fmt
This commit is contained in:
parent
0d1aa1e034
commit
4fa5578774
50 changed files with 224 additions and 240 deletions
|
@ -152,7 +152,7 @@ fn get_linker(
|
|||
_ => match flavor {
|
||||
LinkerFlavor::Lld(f) => Command::lld(linker, f),
|
||||
LinkerFlavor::Msvc
|
||||
if sess.opts.cg.linker.is_none() && sess.target.target.options.linker.is_none() =>
|
||||
if sess.opts.cg.linker.is_none() && sess.target.options.linker.is_none() =>
|
||||
{
|
||||
Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker))
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ fn get_linker(
|
|||
// UWP apps have API restrictions enforced during Store submissions.
|
||||
// To comply with the Windows App Certification Kit,
|
||||
// MSVC needs to link with the Store versions of the runtime libraries (vcruntime, msvcrt, etc).
|
||||
let t = &sess.target.target;
|
||||
let t = &sess.target;
|
||||
if (flavor == LinkerFlavor::Msvc || flavor == LinkerFlavor::Lld(LldFlavor::Link))
|
||||
&& t.target_vendor == "uwp"
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ fn get_linker(
|
|||
// PATH for the child.
|
||||
let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths(self_contained);
|
||||
let mut msvc_changed_path = false;
|
||||
if sess.target.target.options.is_like_msvc {
|
||||
if sess.target.options.is_like_msvc {
|
||||
if let Some(ref tool) = msvc_tool {
|
||||
cmd.args(tool.args());
|
||||
for &(ref k, ref v) in tool.env() {
|
||||
|
@ -365,7 +365,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
|
|||
// After adding all files to the archive, we need to update the
|
||||
// symbol table of the archive. This currently dies on macOS (see
|
||||
// #11162), and isn't necessary there anyway
|
||||
if !sess.target.target.options.is_like_osx {
|
||||
if !sess.target.options.is_like_osx {
|
||||
ab.update_symbols();
|
||||
}
|
||||
}
|
||||
|
@ -476,10 +476,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
|
||||
linker::disable_localization(&mut cmd);
|
||||
|
||||
for &(ref k, ref v) in &sess.target.target.options.link_env {
|
||||
for &(ref k, ref v) in &sess.target.options.link_env {
|
||||
cmd.env(k, v);
|
||||
}
|
||||
for k in &sess.target.target.options.link_env_remove {
|
||||
for k in &sess.target.options.link_env_remove {
|
||||
cmd.env_remove(k);
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
// if the linker doesn't support -no-pie then it should not default to
|
||||
// linking executables as pie. Different versions of gcc seem to use
|
||||
// different quotes in the error message so don't check for them.
|
||||
if sess.target.target.options.linker_is_gnu
|
||||
if sess.target.options.linker_is_gnu
|
||||
&& flavor != LinkerFlavor::Ld
|
||||
&& (out.contains("unrecognized command line option")
|
||||
|| out.contains("unknown argument"))
|
||||
|
@ -535,7 +535,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
|
||||
// Detect '-static-pie' used with an older version of gcc or clang not supporting it.
|
||||
// Fallback from '-static-pie' to '-static' in that case.
|
||||
if sess.target.target.options.linker_is_gnu
|
||||
if sess.target.options.linker_is_gnu
|
||||
&& flavor != LinkerFlavor::Ld
|
||||
&& (out.contains("unrecognized command line option")
|
||||
|| out.contains("unknown argument"))
|
||||
|
@ -548,7 +548,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
);
|
||||
// Mirror `add_(pre,post)_link_objects` to replace CRT objects.
|
||||
let self_contained = crt_objects_fallback(sess, crate_type);
|
||||
let opts = &sess.target.target.options;
|
||||
let opts = &sess.target.options;
|
||||
let pre_objects = if self_contained {
|
||||
&opts.pre_link_objects_fallback
|
||||
} else {
|
||||
|
@ -670,7 +670,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
// is not a Microsoft LNK error then suggest a way to fix or
|
||||
// install the Visual Studio build tools.
|
||||
if let Some(code) = prog.status.code() {
|
||||
if sess.target.target.options.is_like_msvc
|
||||
if sess.target.options.is_like_msvc
|
||||
&& flavor == LinkerFlavor::Msvc
|
||||
// Respect the command line override
|
||||
&& sess.opts.cg.linker.is_none()
|
||||
|
@ -741,7 +741,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
|
||||
linker_error.emit();
|
||||
|
||||
if sess.target.target.options.is_like_msvc && linker_not_found {
|
||||
if sess.target.options.is_like_msvc && linker_not_found {
|
||||
sess.note_without_error(
|
||||
"the msvc targets depend on the msvc linker \
|
||||
but `link.exe` was not found",
|
||||
|
@ -758,7 +758,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
// On macOS, debuggers need this utility to get run to do some munging of
|
||||
// the symbols. Note, though, that if the object files are being preserved
|
||||
// for their debug information there's no need for us to run dsymutil.
|
||||
if sess.target.target.options.is_like_osx
|
||||
if sess.target.options.is_like_osx
|
||||
&& sess.opts.debuginfo != DebugInfo::None
|
||||
&& !preserve_objects_for_their_debuginfo(sess)
|
||||
{
|
||||
|
@ -776,7 +776,7 @@ fn link_sanitizers(sess: &Session, crate_type: CrateType, linker: &mut dyn Linke
|
|||
let needs_runtime = match crate_type {
|
||||
CrateType::Executable => true,
|
||||
CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => {
|
||||
sess.target.target.options.is_like_osx
|
||||
sess.target.options.is_like_osx
|
||||
}
|
||||
CrateType::Rlib | CrateType::Staticlib => false,
|
||||
};
|
||||
|
@ -846,7 +846,7 @@ pub fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool
|
|||
// If our target enables builtin function lowering in LLVM then the
|
||||
// crates providing these functions don't participate in LTO (e.g.
|
||||
// no_builtins or compiler builtins crates).
|
||||
!sess.target.target.options.no_builtins
|
||||
!sess.target.options.no_builtins
|
||||
&& (info.compiler_builtins == Some(cnum) || info.is_no_builtins.contains(&cnum))
|
||||
}
|
||||
|
||||
|
@ -906,10 +906,10 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
|||
} else if stem == "link" || stem == "lld-link" {
|
||||
LinkerFlavor::Msvc
|
||||
} else if stem == "lld" || stem == "rust-lld" {
|
||||
LinkerFlavor::Lld(sess.target.target.options.lld_flavor)
|
||||
LinkerFlavor::Lld(sess.target.options.lld_flavor)
|
||||
} else {
|
||||
// fall back to the value in the target spec
|
||||
sess.target.target.linker_flavor
|
||||
sess.target.linker_flavor
|
||||
};
|
||||
|
||||
Some((linker, flavor))
|
||||
|
@ -926,8 +926,8 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
|||
|
||||
if let Some(ret) = infer_from(
|
||||
sess,
|
||||
sess.target.target.options.linker.clone().map(PathBuf::from),
|
||||
Some(sess.target.target.linker_flavor),
|
||||
sess.target.options.linker.clone().map(PathBuf::from),
|
||||
Some(sess.target.linker_flavor),
|
||||
) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
|
|||
// Basically as a result this just means that if we're on OSX and we're
|
||||
// *not* running dsymutil then the object files are the only source of truth
|
||||
// for debug information, so we must preserve them.
|
||||
if sess.target.target.options.is_like_osx {
|
||||
if sess.target.options.is_like_osx {
|
||||
return !sess.opts.debugging_opts.run_dsymutil;
|
||||
}
|
||||
|
||||
|
@ -988,7 +988,7 @@ fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) {
|
|||
NativeLibKind::StaticNoBundle
|
||||
| NativeLibKind::Dylib
|
||||
| NativeLibKind::Unspecified => {
|
||||
if sess.target.target.options.is_like_msvc {
|
||||
if sess.target.options.is_like_msvc {
|
||||
Some(format!("{}.lib", name))
|
||||
} else {
|
||||
Some(format!("-l{}", name))
|
||||
|
@ -1070,16 +1070,13 @@ fn exec_linker(
|
|||
let mut args = String::new();
|
||||
for arg in cmd2.take_args() {
|
||||
args.push_str(
|
||||
&Escape {
|
||||
arg: arg.to_str().unwrap(),
|
||||
is_like_msvc: sess.target.target.options.is_like_msvc,
|
||||
}
|
||||
.to_string(),
|
||||
&Escape { arg: arg.to_str().unwrap(), is_like_msvc: sess.target.options.is_like_msvc }
|
||||
.to_string(),
|
||||
);
|
||||
args.push('\n');
|
||||
}
|
||||
let file = tmpdir.join("linker-arguments");
|
||||
let bytes = if sess.target.target.options.is_like_msvc {
|
||||
let bytes = if sess.target.options.is_like_msvc {
|
||||
let mut out = Vec::with_capacity((1 + args.len()) * 2);
|
||||
// start the stream with a UTF-16 BOM
|
||||
for c in std::iter::once(0xFEFF).chain(args.encode_utf16()) {
|
||||
|
@ -1195,7 +1192,7 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
|
|||
};
|
||||
|
||||
// Adjust the output kind to target capabilities.
|
||||
let opts = &sess.target.target.options;
|
||||
let opts = &sess.target.options;
|
||||
let pic_exe_supported = opts.position_independent_executables;
|
||||
let static_pic_exe_supported = opts.static_position_independent_executables;
|
||||
let static_dylib_supported = opts.crt_static_allows_dylibs;
|
||||
|
@ -1236,14 +1233,14 @@ fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool {
|
|||
return self_contained;
|
||||
}
|
||||
|
||||
match sess.target.target.options.crt_objects_fallback {
|
||||
match sess.target.options.crt_objects_fallback {
|
||||
// FIXME: Find a better heuristic for "native musl toolchain is available",
|
||||
// based on host and linker path, for example.
|
||||
// (https://github.com/rust-lang/rust/pull/71769#issuecomment-626330237).
|
||||
Some(CrtObjectsFallback::Musl) => sess.crt_static(Some(crate_type)),
|
||||
Some(CrtObjectsFallback::Mingw) => {
|
||||
sess.host == sess.target.target
|
||||
&& sess.target.target.target_vendor != "uwp"
|
||||
sess.host == sess.target
|
||||
&& sess.target.target_vendor != "uwp"
|
||||
&& detect_self_contained_mingw(&sess)
|
||||
}
|
||||
// FIXME: Figure out cases in which WASM needs to link with a native toolchain.
|
||||
|
@ -1259,7 +1256,7 @@ fn add_pre_link_objects(
|
|||
link_output_kind: LinkOutputKind,
|
||||
self_contained: bool,
|
||||
) {
|
||||
let opts = &sess.target.target.options;
|
||||
let opts = &sess.target.options;
|
||||
let objects =
|
||||
if self_contained { &opts.pre_link_objects_fallback } else { &opts.pre_link_objects };
|
||||
for obj in objects.get(&link_output_kind).iter().copied().flatten() {
|
||||
|
@ -1274,7 +1271,7 @@ fn add_post_link_objects(
|
|||
link_output_kind: LinkOutputKind,
|
||||
self_contained: bool,
|
||||
) {
|
||||
let opts = &sess.target.target.options;
|
||||
let opts = &sess.target.options;
|
||||
let objects =
|
||||
if self_contained { &opts.post_link_objects_fallback } else { &opts.post_link_objects };
|
||||
for obj in objects.get(&link_output_kind).iter().copied().flatten() {
|
||||
|
@ -1285,7 +1282,7 @@ fn add_post_link_objects(
|
|||
/// Add arbitrary "pre-link" args defined by the target spec or from command line.
|
||||
/// FIXME: Determine where exactly these args need to be inserted.
|
||||
fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) {
|
||||
if let Some(args) = sess.target.options.pre_link_args.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
cmd.args(&sess.opts.debugging_opts.pre_link_args);
|
||||
|
@ -1293,13 +1290,13 @@ fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor)
|
|||
|
||||
/// Add a link script embedded in the target, if applicable.
|
||||
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
|
||||
match (crate_type, &sess.target.target.options.link_script) {
|
||||
match (crate_type, &sess.target.options.link_script) {
|
||||
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
|
||||
if !sess.target.target.options.linker_is_gnu {
|
||||
if !sess.target.options.linker_is_gnu {
|
||||
sess.fatal("can only use link script when linking with GNU-like linker");
|
||||
}
|
||||
|
||||
let file_name = ["rustc", &sess.target.target.llvm_target, "linkfile.ld"].join("-");
|
||||
let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-");
|
||||
|
||||
let path = tmpdir.join(file_name);
|
||||
if let Err(e) = fs::write(&path, script) {
|
||||
|
@ -1338,15 +1335,15 @@ fn add_late_link_args(
|
|||
*ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
||||
});
|
||||
if any_dynamic_crate {
|
||||
if let Some(args) = sess.target.target.options.late_link_args_dynamic.get(&flavor) {
|
||||
if let Some(args) = sess.target.options.late_link_args_dynamic.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
} else {
|
||||
if let Some(args) = sess.target.target.options.late_link_args_static.get(&flavor) {
|
||||
if let Some(args) = sess.target.options.late_link_args_static.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
}
|
||||
if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
|
||||
if let Some(args) = sess.target.options.late_link_args.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
}
|
||||
|
@ -1354,7 +1351,7 @@ fn add_late_link_args(
|
|||
/// Add arbitrary "post-link" args defined by the target spec.
|
||||
/// FIXME: Determine where exactly these args need to be inserted.
|
||||
fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
if let Some(args) = sess.target.target.options.post_link_args.get(&flavor) {
|
||||
if let Some(args) = sess.target.options.post_link_args.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
}
|
||||
|
@ -1456,7 +1453,7 @@ fn add_library_search_dirs(cmd: &mut dyn Linker, sess: &Session, self_contained:
|
|||
/// Add options making relocation sections in the produced ELF files read-only
|
||||
/// and suppressing lazy binding.
|
||||
fn add_relro_args(cmd: &mut dyn Linker, sess: &Session) {
|
||||
match sess.opts.debugging_opts.relro_level.unwrap_or(sess.target.target.options.relro_level) {
|
||||
match sess.opts.debugging_opts.relro_level.unwrap_or(sess.target.options.relro_level) {
|
||||
RelroLevel::Full => cmd.full_relro(),
|
||||
RelroLevel::Partial => cmd.partial_relro(),
|
||||
RelroLevel::Off => cmd.no_relro(),
|
||||
|
@ -1487,9 +1484,9 @@ fn add_rpath_args(
|
|||
let mut rpath_config = RPathConfig {
|
||||
used_crates: &codegen_results.crate_info.used_crates_dynamic,
|
||||
out_filename: out_filename.to_path_buf(),
|
||||
has_rpath: sess.target.target.options.has_rpath,
|
||||
is_like_osx: sess.target.target.options.is_like_osx,
|
||||
linker_is_gnu: sess.target.target.options.linker_is_gnu,
|
||||
has_rpath: sess.target.options.has_rpath,
|
||||
is_like_osx: sess.target.options.is_like_osx,
|
||||
linker_is_gnu: sess.target.options.linker_is_gnu,
|
||||
get_install_prefix_lib_path: &mut get_install_prefix_lib_path,
|
||||
};
|
||||
cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
|
||||
|
@ -1517,7 +1514,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
let base_cmd = get_linker(sess, path, flavor, crt_objects_fallback);
|
||||
// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
|
||||
// to the linker args construction.
|
||||
assert!(base_cmd.get_args().is_empty() || sess.target.target.target_vendor == "uwp");
|
||||
assert!(base_cmd.get_args().is_empty() || sess.target.target_vendor == "uwp");
|
||||
let cmd = &mut *codegen_results.linker_info.to_linker(base_cmd, &sess, flavor, target_cpu);
|
||||
let link_output_kind = link_output_kind(sess, crate_type);
|
||||
|
||||
|
@ -1531,7 +1528,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
add_link_script(cmd, sess, tmpdir, crate_type);
|
||||
|
||||
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
||||
if sess.target.target.options.is_like_fuchsia && crate_type == CrateType::Executable {
|
||||
if sess.target.options.is_like_fuchsia && crate_type == CrateType::Executable {
|
||||
let prefix = if sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::ADDRESS) {
|
||||
"asan/"
|
||||
} else {
|
||||
|
@ -1541,7 +1538,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
}
|
||||
|
||||
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
||||
if sess.target.target.options.eh_frame_header {
|
||||
if sess.target.options.eh_frame_header {
|
||||
cmd.add_eh_frame_header();
|
||||
}
|
||||
|
||||
|
@ -1554,7 +1551,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
add_pre_link_objects(cmd, sess, link_output_kind, crt_objects_fallback);
|
||||
|
||||
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
||||
if sess.target.target.options.is_like_emscripten {
|
||||
if sess.target.options.is_like_emscripten {
|
||||
cmd.arg("-s");
|
||||
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
|
||||
"DISABLE_EXCEPTION_CATCHING=1"
|
||||
|
@ -1582,7 +1579,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
cmd.output_filename(out_filename);
|
||||
|
||||
// OBJECT-FILES-NO, AUDIT-ORDER
|
||||
if crate_type == CrateType::Executable && sess.target.target.options.is_like_windows {
|
||||
if crate_type == CrateType::Executable && sess.target.options.is_like_windows {
|
||||
if let Some(ref s) = codegen_results.windows_subsystem {
|
||||
cmd.subsystem(s);
|
||||
}
|
||||
|
@ -1626,7 +1623,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
// OBJECT-FILES-NO, AUDIT-ORDER
|
||||
// We want to prevent the compiler from accidentally leaking in any system libraries,
|
||||
// so by default we tell linkers not to link to any default libraries.
|
||||
if !sess.opts.cg.default_linker_libraries && sess.target.target.options.no_default_libraries {
|
||||
if !sess.opts.cg.default_linker_libraries && sess.target.options.no_default_libraries {
|
||||
cmd.no_default_libraries();
|
||||
}
|
||||
|
||||
|
@ -1945,7 +1942,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
|||
// though, so we let that object file slide.
|
||||
let skip_because_lto = are_upstream_rust_objects_already_included(sess)
|
||||
&& is_rust_object
|
||||
&& (sess.target.target.options.no_builtins
|
||||
&& (sess.target.options.no_builtins
|
||||
|| !codegen_results.crate_info.is_no_builtins.contains(&cnum));
|
||||
|
||||
if skip_because_cfg_say_so || skip_because_lto {
|
||||
|
@ -2088,10 +2085,10 @@ fn are_upstream_rust_objects_already_included(sess: &Session) -> bool {
|
|||
}
|
||||
|
||||
fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
let arch = &sess.target.target.arch;
|
||||
let os = &sess.target.target.target_os;
|
||||
let llvm_target = &sess.target.target.llvm_target;
|
||||
if sess.target.target.target_vendor != "apple"
|
||||
let arch = &sess.target.arch;
|
||||
let os = &sess.target.target_os;
|
||||
let llvm_target = &sess.target.llvm_target;
|
||||
if sess.target.target_vendor != "apple"
|
||||
|| !matches!(os.as_str(), "ios" | "tvos")
|
||||
|| flavor != LinkerFlavor::Gcc
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue