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
|
@ -9,9 +9,7 @@ pub fn find_library(name: Symbol, search_paths: &[PathBuf], sess: &Session) -> P
|
|||
// times show up as foo.lib
|
||||
let oslibname = format!(
|
||||
"{}{}{}",
|
||||
sess.target.target.options.staticlib_prefix,
|
||||
name,
|
||||
sess.target.target.options.staticlib_suffix
|
||||
sess.target.options.staticlib_prefix, name, sess.target.options.staticlib_suffix
|
||||
);
|
||||
let unixlibname = format!("lib{}.a", name);
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -184,7 +184,7 @@ impl<'a> GccLinker<'a> {
|
|||
// * On OSX they have their own linker, not binutils'
|
||||
// * For WebAssembly the only functional linker is LLD, which doesn't
|
||||
// support hint flags
|
||||
!self.sess.target.target.options.is_like_osx && self.sess.target.target.arch != "wasm32"
|
||||
!self.sess.target.options.is_like_osx && self.sess.target.arch != "wasm32"
|
||||
}
|
||||
|
||||
// Some platforms take hints about whether a library is static or dynamic.
|
||||
|
@ -232,7 +232,7 @@ impl<'a> GccLinker<'a> {
|
|||
|
||||
fn build_dylib(&mut self, out_filename: &Path) {
|
||||
// On mac we need to tell the linker to let this library be rpathed
|
||||
if self.sess.target.target.options.is_like_osx {
|
||||
if self.sess.target.options.is_like_osx {
|
||||
self.cmd.arg("-dynamiclib");
|
||||
self.linker_arg("-dylib");
|
||||
|
||||
|
@ -248,7 +248,7 @@ impl<'a> GccLinker<'a> {
|
|||
}
|
||||
} else {
|
||||
self.cmd.arg("-shared");
|
||||
if self.sess.target.target.options.is_like_windows {
|
||||
if self.sess.target.options.is_like_windows {
|
||||
// The output filename already contains `dll_suffix` so
|
||||
// the resulting import library will have a name in the
|
||||
// form of libfoo.dll.a
|
||||
|
@ -256,9 +256,9 @@ impl<'a> GccLinker<'a> {
|
|||
out_filename.file_name().and_then(|file| file.to_str()).map(|file| {
|
||||
format!(
|
||||
"{}{}{}",
|
||||
self.sess.target.target.options.staticlib_prefix,
|
||||
self.sess.target.options.staticlib_prefix,
|
||||
file,
|
||||
self.sess.target.target.options.staticlib_suffix
|
||||
self.sess.target.options.staticlib_suffix
|
||||
)
|
||||
});
|
||||
if let Some(implib_name) = implib_name {
|
||||
|
@ -280,7 +280,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
|
||||
match output_kind {
|
||||
LinkOutputKind::DynamicNoPicExe => {
|
||||
if !self.is_ld && self.sess.target.target.options.linker_is_gnu {
|
||||
if !self.is_ld && self.sess.target.options.linker_is_gnu {
|
||||
self.cmd.arg("-no-pie");
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
LinkOutputKind::StaticNoPicExe => {
|
||||
// `-static` works for both gcc wrapper and ld.
|
||||
self.cmd.arg("-static");
|
||||
if !self.is_ld && self.sess.target.target.options.linker_is_gnu {
|
||||
if !self.is_ld && self.sess.target.options.linker_is_gnu {
|
||||
self.cmd.arg("-no-pie");
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
// any `#[link]` attributes in the `libc` crate, see #72782 for details.
|
||||
// FIXME: Switch to using `#[link]` attributes in the `libc` crate
|
||||
// similarly to other targets.
|
||||
if self.sess.target.target.target_os == "vxworks"
|
||||
if self.sess.target.target_os == "vxworks"
|
||||
&& matches!(
|
||||
output_kind,
|
||||
LinkOutputKind::StaticNoPicExe
|
||||
|
@ -385,7 +385,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
// functions, etc.
|
||||
fn link_whole_staticlib(&mut self, lib: Symbol, search_path: &[PathBuf]) {
|
||||
self.hint_static();
|
||||
let target = &self.sess.target.target;
|
||||
let target = &self.sess.target;
|
||||
if !target.options.is_like_osx {
|
||||
self.linker_arg("--whole-archive").cmd.arg(format!("-l{}", lib));
|
||||
self.linker_arg("--no-whole-archive");
|
||||
|
@ -400,7 +400,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
|
||||
fn link_whole_rlib(&mut self, lib: &Path) {
|
||||
self.hint_static();
|
||||
if self.sess.target.target.options.is_like_osx {
|
||||
if self.sess.target.options.is_like_osx {
|
||||
self.linker_arg("-force_load");
|
||||
self.linker_arg(&lib);
|
||||
} else {
|
||||
|
@ -424,9 +424,9 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
// -dead_strip can't be part of the pre_link_args because it's also used
|
||||
// for partial linking when using multiple codegen units (-r). So we
|
||||
// insert it here.
|
||||
if self.sess.target.target.options.is_like_osx {
|
||||
if self.sess.target.options.is_like_osx {
|
||||
self.linker_arg("-dead_strip");
|
||||
} else if self.sess.target.target.options.is_like_solaris {
|
||||
} else if self.sess.target.options.is_like_solaris {
|
||||
self.linker_arg("-zignore");
|
||||
|
||||
// If we're building a dylib, we don't use --gc-sections because LLVM
|
||||
|
@ -440,7 +440,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
}
|
||||
|
||||
fn optimize(&mut self) {
|
||||
if !self.sess.target.target.options.linker_is_gnu {
|
||||
if !self.sess.target.options.linker_is_gnu {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
}
|
||||
|
||||
fn pgo_gen(&mut self) {
|
||||
if !self.sess.target.target.options.linker_is_gnu {
|
||||
if !self.sess.target.options.linker_is_gnu {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -504,7 +504,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType) {
|
||||
// Symbol visibility in object files typically takes care of this.
|
||||
if crate_type == CrateType::Executable
|
||||
&& self.sess.target.target.options.override_export_symbols.is_none()
|
||||
&& self.sess.target.options.override_export_symbols.is_none()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
// The object files have far more public symbols than we actually want to export,
|
||||
// so we hide them all here.
|
||||
|
||||
if !self.sess.target.target.options.limit_rdylib_exports {
|
||||
if !self.sess.target.options.limit_rdylib_exports {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -521,13 +521,13 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
return;
|
||||
}
|
||||
|
||||
let is_windows = self.sess.target.target.options.is_like_windows;
|
||||
let is_windows = self.sess.target.options.is_like_windows;
|
||||
let mut arg = OsString::new();
|
||||
let path = tmpdir.join(if is_windows { "list.def" } else { "list" });
|
||||
|
||||
debug!("EXPORTED SYMBOLS:");
|
||||
|
||||
if self.sess.target.target.options.is_like_osx {
|
||||
if self.sess.target.options.is_like_osx {
|
||||
// Write a plain, newline-separated list of symbols
|
||||
let res: io::Result<()> = try {
|
||||
let mut f = BufWriter::new(File::create(&path)?);
|
||||
|
@ -573,12 +573,12 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
if self.sess.target.target.options.is_like_osx {
|
||||
if self.sess.target.options.is_like_osx {
|
||||
if !self.is_ld {
|
||||
arg.push("-Wl,")
|
||||
}
|
||||
arg.push("-exported_symbols_list,");
|
||||
} else if self.sess.target.target.options.is_like_solaris {
|
||||
} else if self.sess.target.options.is_like_solaris {
|
||||
if !self.is_ld {
|
||||
arg.push("-Wl,")
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ impl<'a> Linker for WasmLd<'a> {
|
|||
}
|
||||
|
||||
fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
|
||||
if let Some(ref exports) = tcx.sess.target.target.options.override_export_symbols {
|
||||
if let Some(ref exports) = tcx.sess.target.options.override_export_symbols {
|
||||
return exports.clone();
|
||||
}
|
||||
|
||||
|
@ -1293,7 +1293,7 @@ impl<'a> Linker for PtxLinker<'a> {
|
|||
// Provide the linker with fallback to internal `target-cpu`.
|
||||
self.cmd.arg("--fallback-arch").arg(match self.sess.opts.cg.target_cpu {
|
||||
Some(ref s) => s,
|
||||
None => &self.sess.target.target.options.cpu,
|
||||
None => &self.sess.target.options.cpu,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -229,8 +229,8 @@ fn exported_symbols_provider_local(
|
|||
// needs to be exported.
|
||||
// However, on platforms that don't allow for Rust dylibs, having
|
||||
// external linkage is enough for monomorphization to be linked to.
|
||||
let need_visibility = tcx.sess.target.target.options.dynamic_linking
|
||||
&& !tcx.sess.target.target.options.only_cdylib;
|
||||
let need_visibility =
|
||||
tcx.sess.target.options.dynamic_linking && !tcx.sess.target.options.only_cdylib;
|
||||
|
||||
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
||||
|
||||
|
@ -391,7 +391,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
|
|||
codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
|
||||
|
||||
if is_extern && !std_internal {
|
||||
let target = &tcx.sess.target.target.llvm_target;
|
||||
let target = &tcx.sess.target.llvm_target;
|
||||
// WebAssembly cannot export data symbols, so reduce their export level
|
||||
if target.contains("emscripten") {
|
||||
if let Some(Node::Item(&hir::Item { kind: hir::ItemKind::Static(..), .. })) =
|
||||
|
|
|
@ -139,7 +139,7 @@ impl ModuleConfig {
|
|||
|
||||
let emit_obj = if !should_emit_obj {
|
||||
EmitObj::None
|
||||
} else if sess.target.target.options.obj_is_bitcode
|
||||
} else if sess.target.options.obj_is_bitcode
|
||||
|| (sess.opts.cg.linker_plugin_lto.enabled() && !no_builtins)
|
||||
{
|
||||
// This case is selected if the target uses objects as bitcode, or
|
||||
|
@ -221,11 +221,11 @@ impl ModuleConfig {
|
|||
false
|
||||
),
|
||||
emit_obj,
|
||||
bc_cmdline: sess.target.target.options.bitcode_llvm_cmdline.clone(),
|
||||
bc_cmdline: sess.target.options.bitcode_llvm_cmdline.clone(),
|
||||
|
||||
verify_llvm_ir: sess.verify_llvm_ir(),
|
||||
no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes,
|
||||
no_builtins: no_builtins || sess.target.target.options.no_builtins,
|
||||
no_builtins: no_builtins || sess.target.options.no_builtins,
|
||||
|
||||
// Exclude metadata and allocator modules from time_passes output,
|
||||
// since they throw off the "LLVM passes" measurement.
|
||||
|
@ -252,7 +252,7 @@ impl ModuleConfig {
|
|||
.opts
|
||||
.debugging_opts
|
||||
.merge_functions
|
||||
.unwrap_or(sess.target.target.options.merge_functions)
|
||||
.unwrap_or(sess.target.options.merge_functions)
|
||||
{
|
||||
MergeFunctions::Disabled => false,
|
||||
MergeFunctions::Trampolines | MergeFunctions::Aliases => {
|
||||
|
@ -388,7 +388,7 @@ fn need_bitcode_in_object(sess: &Session) -> bool {
|
|||
let requested_for_rlib = sess.opts.cg.embed_bitcode
|
||||
&& sess.crate_types().contains(&CrateType::Rlib)
|
||||
&& sess.opts.output_types.contains_key(&OutputType::Exe);
|
||||
let forced_by_target = sess.target.target.options.forces_embed_bitcode;
|
||||
let forced_by_target = sess.target.options.forces_embed_bitcode;
|
||||
requested_for_rlib || forced_by_target
|
||||
}
|
||||
|
||||
|
@ -1022,8 +1022,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
tm_factory: TargetMachineFactory(backend.target_machine_factory(tcx.sess, ol)),
|
||||
total_cgus,
|
||||
msvc_imps_needed: msvc_imps_needed(tcx),
|
||||
target_pointer_width: tcx.sess.target.target.pointer_width,
|
||||
target_arch: tcx.sess.target.target.arch.clone(),
|
||||
target_pointer_width: tcx.sess.target.pointer_width,
|
||||
target_arch: tcx.sess.target.arch.clone(),
|
||||
debuginfo: tcx.sess.opts.debuginfo,
|
||||
};
|
||||
|
||||
|
@ -1865,11 +1865,11 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
|
|||
// something is wrong with commandline arg validation.
|
||||
assert!(
|
||||
!(tcx.sess.opts.cg.linker_plugin_lto.enabled()
|
||||
&& tcx.sess.target.target.options.is_like_windows
|
||||
&& tcx.sess.target.options.is_like_windows
|
||||
&& tcx.sess.opts.cg.prefer_dynamic)
|
||||
);
|
||||
|
||||
tcx.sess.target.target.options.is_like_windows &&
|
||||
tcx.sess.target.options.is_like_windows &&
|
||||
tcx.sess.crate_types().iter().any(|ct| *ct == CrateType::Rlib) &&
|
||||
// ThinLTO can't handle this workaround in all cases, so we don't
|
||||
// emit the `__imp_` symbols. Instead we make them unnecessary by disallowing
|
||||
|
|
|
@ -327,7 +327,7 @@ fn cast_shift_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
/// currently uses SEH-ish unwinding with DWARF info tables to the side (same as
|
||||
/// 64-bit MinGW) instead of "full SEH".
|
||||
pub fn wants_msvc_seh(sess: &Session) -> bool {
|
||||
sess.target.target.options.is_like_msvc
|
||||
sess.target.options.is_like_msvc
|
||||
}
|
||||
|
||||
pub fn memcpy_ty<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
|
@ -393,7 +393,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
) -> Bx::Function {
|
||||
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`,
|
||||
// depending on whether the target needs `argc` and `argv` to be passed in.
|
||||
let llfty = if cx.sess().target.target.options.main_needs_argc_argv {
|
||||
let llfty = if cx.sess().target.options.main_needs_argc_argv {
|
||||
cx.type_func(&[cx.type_int(), cx.type_ptr_to(cx.type_i8p())], cx.type_int())
|
||||
} else {
|
||||
cx.type_func(&[], cx.type_int())
|
||||
|
@ -464,7 +464,7 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
cx: &'a Bx::CodegenCx,
|
||||
bx: &mut Bx,
|
||||
) -> (Bx::Value, Bx::Value) {
|
||||
if cx.sess().target.target.options.main_needs_argc_argv {
|
||||
if cx.sess().target.options.main_needs_argc_argv {
|
||||
// Params from native `main()` used as args for rust start function
|
||||
let param_argc = bx.get_param(0);
|
||||
let param_argv = bx.get_param(1);
|
||||
|
|
|
@ -33,7 +33,7 @@ pub fn push_debuginfo_type_name<'tcx>(
|
|||
) {
|
||||
// When targeting MSVC, emit C++ style type names for compatibility with
|
||||
// .natvis visualizers (and perhaps other existing native debuggers?)
|
||||
let cpp_like_names = tcx.sess.target.target.options.is_like_msvc;
|
||||
let cpp_like_names = tcx.sess.target.options.is_like_msvc;
|
||||
|
||||
match *t.kind() {
|
||||
ty::Bool => output.push_str("bool"),
|
||||
|
|
|
@ -872,7 +872,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
let string = match ty.kind() {
|
||||
ty::Uint(_) => value.to_string(),
|
||||
ty::Int(int_ty) => {
|
||||
match int_ty.normalize(bx.tcx().sess.target.ptr_width) {
|
||||
match int_ty.normalize(bx.tcx().sess.target.pointer_width) {
|
||||
ast::IntTy::I8 => (value as i8).to_string(),
|
||||
ast::IntTy::I16 => (value as i16).to_string(),
|
||||
ast::IntTy::I32 => (value as i32).to_string(),
|
||||
|
|
|
@ -580,8 +580,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
// stuffs.
|
||||
fn int_type_width_signed(ty: Ty<'_>, tcx: TyCtxt<'_>) -> Option<(u64, bool)> {
|
||||
match ty.kind() {
|
||||
ty::Int(t) => Some((t.bit_width().unwrap_or(u64::from(tcx.sess.target.ptr_width)), true)),
|
||||
ty::Uint(t) => Some((t.bit_width().unwrap_or(u64::from(tcx.sess.target.ptr_width)), false)),
|
||||
ty::Int(t) => {
|
||||
Some((t.bit_width().unwrap_or(u64::from(tcx.sess.target.pointer_width)), true))
|
||||
}
|
||||
ty::Uint(t) => {
|
||||
Some((t.bit_width().unwrap_or(u64::from(tcx.sess.target.pointer_width)), false))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,8 +346,8 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
..
|
||||
} => {
|
||||
if variant_index != dataful_variant {
|
||||
if bx.cx().sess().target.target.arch == "arm"
|
||||
|| bx.cx().sess().target.target.arch == "aarch64"
|
||||
if bx.cx().sess().target.arch == "arm"
|
||||
|| bx.cx().sess().target.arch == "aarch64"
|
||||
{
|
||||
// FIXME(#34427): as workaround for LLVM bug on ARM,
|
||||
// use memset of 0 before assigning niche value.
|
||||
|
|
|
@ -138,7 +138,7 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol
|
|||
}
|
||||
|
||||
pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Option<Symbol>)] {
|
||||
match &*sess.target.target.arch {
|
||||
match &*sess.target.arch {
|
||||
"arm" => ARM_ALLOWED_FEATURES,
|
||||
"aarch64" => AARCH64_ALLOWED_FEATURES,
|
||||
"x86" | "x86_64" => X86_ALLOWED_FEATURES,
|
||||
|
|
|
@ -51,7 +51,7 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
|
|||
}
|
||||
|
||||
fn type_int(&self) -> Self::Type {
|
||||
match &self.sess().target.target.target_c_int_width[..] {
|
||||
match &self.sess().target.target_c_int_width[..] {
|
||||
"16" => self.type_i16(),
|
||||
"32" => self.type_i32(),
|
||||
"64" => self.type_i64(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue