Collapse all uses of target.options.foo
into target.foo
with an eye on merging `TargetOptions` into `Target`. `TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
This commit is contained in:
parent
87a0997ef9
commit
bf66988aa1
48 changed files with 235 additions and 260 deletions
|
@ -796,7 +796,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
|
|
||||||
fn visit_expr(&mut self, expr: &'a Expr) {
|
fn visit_expr(&mut self, expr: &'a Expr) {
|
||||||
match &expr.kind {
|
match &expr.kind {
|
||||||
ExprKind::LlvmInlineAsm(..) if !self.session.target.options.allow_asm => {
|
ExprKind::LlvmInlineAsm(..) if !self.session.target.allow_asm => {
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
self.session,
|
self.session,
|
||||||
expr.span,
|
expr.span,
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct TestCtxt<'a> {
|
||||||
pub fn inject(sess: &Session, resolver: &mut dyn ResolverExpand, krate: &mut ast::Crate) {
|
pub fn inject(sess: &Session, resolver: &mut dyn ResolverExpand, krate: &mut ast::Crate) {
|
||||||
let span_diagnostic = sess.diagnostic();
|
let span_diagnostic = sess.diagnostic();
|
||||||
let panic_strategy = sess.panic_strategy();
|
let panic_strategy = sess.panic_strategy();
|
||||||
let platform_panic_strategy = sess.target.options.panic_strategy;
|
let platform_panic_strategy = sess.target.panic_strategy;
|
||||||
|
|
||||||
// Check for #![reexport_test_harness_main = "some_name"] which gives the
|
// Check for #![reexport_test_harness_main = "some_name"] which gives the
|
||||||
// main test function the name `some_name` without hygiene. This needs to be
|
// main test function the name `some_name` without hygiene. This needs to be
|
||||||
|
|
|
@ -63,9 +63,9 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||||
sess,
|
sess,
|
||||||
dst: output.to_path_buf(),
|
dst: output.to_path_buf(),
|
||||||
lib_search_paths: archive_search_paths(sess),
|
lib_search_paths: archive_search_paths(sess),
|
||||||
use_gnu_style_archive: sess.target.options.archive_format == "gnu",
|
use_gnu_style_archive: sess.target.archive_format == "gnu",
|
||||||
// FIXME fix builtin ranlib on macOS
|
// FIXME fix builtin ranlib on macOS
|
||||||
no_builtin_ranlib: sess.target.options.is_like_osx,
|
no_builtin_ranlib: sess.target.is_like_osx,
|
||||||
|
|
||||||
src_archives,
|
src_archives,
|
||||||
entries,
|
entries,
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl<'tcx> DebugContext<'tcx> {
|
||||||
// TODO: this should be configurable
|
// TODO: this should be configurable
|
||||||
// macOS doesn't seem to support DWARF > 3
|
// macOS doesn't seem to support DWARF > 3
|
||||||
// 5 version is required for md5 file hash
|
// 5 version is required for md5 file hash
|
||||||
version: if tcx.sess.target.options.is_like_osx {
|
version: if tcx.sess.target.is_like_osx {
|
||||||
3
|
3
|
||||||
} else {
|
} else {
|
||||||
// FIXME change to version 5 once the gdb and lldb shipping with the latest debian
|
// FIXME change to version 5 once the gdb and lldb shipping with the latest debian
|
||||||
|
|
|
@ -320,8 +320,8 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(not(feature = "inline_asm"))
|
if cfg!(not(feature = "inline_asm"))
|
||||||
|| tcx.sess.target.options.is_like_osx
|
|| tcx.sess.target.is_like_osx
|
||||||
|| tcx.sess.target.options.is_like_windows
|
|| tcx.sess.target.is_like_windows
|
||||||
{
|
{
|
||||||
if global_asm.contains("__rust_probestack") {
|
if global_asm.contains("__rust_probestack") {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -101,7 +101,7 @@ pub(crate) fn write_metadata<P: WriteMetadata>(
|
||||||
product.add_rustc_section(
|
product.add_rustc_section(
|
||||||
rustc_middle::middle::exported_symbols::metadata_symbol_name(tcx),
|
rustc_middle::middle::exported_symbols::metadata_symbol_name(tcx),
|
||||||
compressed,
|
compressed,
|
||||||
tcx.sess.target.options.is_like_osx,
|
tcx.sess.target.is_like_osx,
|
||||||
);
|
);
|
||||||
|
|
||||||
metadata
|
metadata
|
||||||
|
|
|
@ -91,7 +91,7 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
||||||
} else if stem == "link" || stem == "lld-link" {
|
} else if stem == "link" || stem == "lld-link" {
|
||||||
LinkerFlavor::Msvc
|
LinkerFlavor::Msvc
|
||||||
} else if stem == "lld" || stem == "rust-lld" {
|
} else if stem == "lld" || stem == "rust-lld" {
|
||||||
LinkerFlavor::Lld(sess.target.options.lld_flavor)
|
LinkerFlavor::Lld(sess.target.lld_flavor)
|
||||||
} else {
|
} else {
|
||||||
// fall back to the value in the target spec
|
// fall back to the value in the target spec
|
||||||
sess.target.linker_flavor
|
sess.target.linker_flavor
|
||||||
|
@ -115,7 +115,7 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
||||||
|
|
||||||
if let Some(ret) = infer_from(
|
if let Some(ret) = infer_from(
|
||||||
sess,
|
sess,
|
||||||
sess.target.options.linker.clone().map(PathBuf::from),
|
sess.target.linker.clone().map(PathBuf::from),
|
||||||
Some(sess.target.linker_flavor),
|
Some(sess.target.linker_flavor),
|
||||||
) {
|
) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -57,7 +57,7 @@ pub(crate) unsafe fn codegen(
|
||||||
let name = format!("__rust_{}", method.name);
|
let name = format!("__rust_{}", method.name);
|
||||||
let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);
|
let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);
|
||||||
|
|
||||||
if tcx.sess.target.options.default_hidden_visibility {
|
if tcx.sess.target.default_hidden_visibility {
|
||||||
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
|
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
|
||||||
}
|
}
|
||||||
if tcx.sess.must_emit_unwind_tables() {
|
if tcx.sess.must_emit_unwind_tables() {
|
||||||
|
@ -98,7 +98,7 @@ pub(crate) unsafe fn codegen(
|
||||||
// -> ! DIFlagNoReturn
|
// -> ! DIFlagNoReturn
|
||||||
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);
|
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);
|
||||||
|
|
||||||
if tcx.sess.target.options.default_hidden_visibility {
|
if tcx.sess.target.default_hidden_visibility {
|
||||||
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
|
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
|
||||||
}
|
}
|
||||||
if tcx.sess.must_emit_unwind_tables() {
|
if tcx.sess.must_emit_unwind_tables() {
|
||||||
|
|
|
@ -90,8 +90,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
||||||
|
|
||||||
// The function name varies on platforms.
|
// The function name varies on platforms.
|
||||||
// See test/CodeGen/mcount.c in clang.
|
// See test/CodeGen/mcount.c in clang.
|
||||||
let mcount_name =
|
let mcount_name = CString::new(cx.sess().target.target_mcount.as_str().as_bytes()).unwrap();
|
||||||
CString::new(cx.sess().target.options.target_mcount.as_str().as_bytes()).unwrap();
|
|
||||||
|
|
||||||
llvm::AddFunctionAttrStringValue(
|
llvm::AddFunctionAttrStringValue(
|
||||||
llfn,
|
llfn,
|
||||||
|
@ -105,7 +104,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
||||||
fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
||||||
// Only use stack probes if the target specification indicates that we
|
// Only use stack probes if the target specification indicates that we
|
||||||
// should be using stack probes
|
// should be using stack probes
|
||||||
if !cx.sess().target.options.stack_probes {
|
if !cx.sess().target.stack_probes {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +173,6 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
|
||||||
.split(',')
|
.split(',')
|
||||||
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
|
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
|
||||||
sess.target
|
sess.target
|
||||||
.options
|
|
||||||
.features
|
.features
|
||||||
.split(',')
|
.split(',')
|
||||||
.chain(cmdline)
|
.chain(cmdline)
|
||||||
|
|
|
@ -206,7 +206,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn llvm_archive_kind(&self) -> Result<ArchiveKind, &str> {
|
fn llvm_archive_kind(&self) -> Result<ArchiveKind, &str> {
|
||||||
let kind = &*self.config.sess.target.options.archive_format;
|
let kind = &*self.config.sess.target.archive_format;
|
||||||
kind.parse().map_err(|_| kind)
|
kind.parse().map_err(|_| kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,13 +129,13 @@ pub fn target_machine_factory(
|
||||||
let use_softfp = sess.opts.cg.soft_float;
|
let use_softfp = sess.opts.cg.soft_float;
|
||||||
|
|
||||||
let ffunction_sections =
|
let ffunction_sections =
|
||||||
sess.opts.debugging_opts.function_sections.unwrap_or(sess.target.options.function_sections);
|
sess.opts.debugging_opts.function_sections.unwrap_or(sess.target.function_sections);
|
||||||
let fdata_sections = ffunction_sections;
|
let fdata_sections = ffunction_sections;
|
||||||
|
|
||||||
let code_model = to_llvm_code_model(sess.code_model());
|
let code_model = to_llvm_code_model(sess.code_model());
|
||||||
|
|
||||||
let features = attributes::llvm_target_features(sess).collect::<Vec<_>>();
|
let features = attributes::llvm_target_features(sess).collect::<Vec<_>>();
|
||||||
let mut singlethread = sess.target.options.singlethread;
|
let mut singlethread = sess.target.singlethread;
|
||||||
|
|
||||||
// On the wasm target once the `atomics` feature is enabled that means that
|
// On the wasm target once the `atomics` feature is enabled that means that
|
||||||
// we're no longer single-threaded, or otherwise we don't want LLVM to
|
// we're no longer single-threaded, or otherwise we don't want LLVM to
|
||||||
|
@ -151,22 +151,16 @@ pub fn target_machine_factory(
|
||||||
let cpu = SmallCStr::new(llvm_util::target_cpu(sess));
|
let cpu = SmallCStr::new(llvm_util::target_cpu(sess));
|
||||||
let features = features.join(",");
|
let features = features.join(",");
|
||||||
let features = CString::new(features).unwrap();
|
let features = CString::new(features).unwrap();
|
||||||
let abi = SmallCStr::new(&sess.target.options.llvm_abiname);
|
let abi = SmallCStr::new(&sess.target.llvm_abiname);
|
||||||
let trap_unreachable = sess.target.options.trap_unreachable;
|
let trap_unreachable = sess.target.trap_unreachable;
|
||||||
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;
|
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;
|
||||||
|
|
||||||
let asm_comments = sess.asm_comments();
|
let asm_comments = sess.asm_comments();
|
||||||
let relax_elf_relocations = sess
|
let relax_elf_relocations =
|
||||||
.opts
|
sess.opts.debugging_opts.relax_elf_relocations.unwrap_or(sess.target.relax_elf_relocations);
|
||||||
.debugging_opts
|
|
||||||
.relax_elf_relocations
|
|
||||||
.unwrap_or(sess.target.options.relax_elf_relocations);
|
|
||||||
|
|
||||||
let use_init_array = !sess
|
let use_init_array =
|
||||||
.opts
|
!sess.opts.debugging_opts.use_ctors_section.unwrap_or(sess.target.use_ctors_section);
|
||||||
.debugging_opts
|
|
||||||
.use_ctors_section
|
|
||||||
.unwrap_or(sess.target.options.use_ctors_section);
|
|
||||||
|
|
||||||
Arc::new(move || {
|
Arc::new(move || {
|
||||||
let tm = unsafe {
|
let tm = unsafe {
|
||||||
|
|
|
@ -91,7 +91,7 @@ fn set_global_alignment(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: Alig
|
||||||
// The target may require greater alignment for globals than the type does.
|
// The target may require greater alignment for globals than the type does.
|
||||||
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
|
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
|
||||||
// which can force it to be smaller. Rust doesn't support this yet.
|
// which can force it to be smaller. Rust doesn't support this yet.
|
||||||
if let Some(min) = cx.sess().target.options.min_global_align {
|
if let Some(min) = cx.sess().target.min_global_align {
|
||||||
match Align::from_bits(min) {
|
match Align::from_bits(min) {
|
||||||
Ok(min) => align = align.max(min),
|
Ok(min) => align = align.max(min),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -283,7 +283,7 @@ impl CodegenCx<'ll, 'tcx> {
|
||||||
// argument validation.
|
// argument validation.
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
!(self.tcx.sess.opts.cg.linker_plugin_lto.enabled()
|
!(self.tcx.sess.opts.cg.linker_plugin_lto.enabled()
|
||||||
&& self.tcx.sess.target.options.is_like_windows
|
&& self.tcx.sess.target.is_like_windows
|
||||||
&& self.tcx.sess.opts.cg.prefer_dynamic)
|
&& self.tcx.sess.opts.cg.prefer_dynamic)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
|
||||||
// will use load-unaligned instructions instead, and thus avoiding the crash.
|
// will use load-unaligned instructions instead, and thus avoiding the crash.
|
||||||
//
|
//
|
||||||
// We could remove this hack whenever we decide to drop macOS 10.10 support.
|
// We could remove this hack whenever we decide to drop macOS 10.10 support.
|
||||||
if self.tcx.sess.target.options.is_like_osx {
|
if self.tcx.sess.target.is_like_osx {
|
||||||
// The `inspect` method is okay here because we checked relocations, and
|
// The `inspect` method is okay here because we checked relocations, and
|
||||||
// because we are doing this access to inspect the final interpreter state
|
// because we are doing this access to inspect the final interpreter state
|
||||||
// (not as part of the interpreter execution).
|
// (not as part of the interpreter execution).
|
||||||
|
|
|
@ -129,7 +129,7 @@ pub unsafe fn create_module(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the data-layout values hardcoded remain the defaults.
|
// Ensure the data-layout values hardcoded remain the defaults.
|
||||||
if sess.target.options.is_builtin {
|
if sess.target.is_builtin {
|
||||||
let tm = crate::back::write::create_informational_target_machine(tcx.sess);
|
let tm = crate::back::write::create_informational_target_machine(tcx.sess);
|
||||||
llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
|
llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
|
||||||
llvm::LLVMRustDisposeTargetMachine(tm);
|
llvm::LLVMRustDisposeTargetMachine(tm);
|
||||||
|
@ -190,7 +190,7 @@ pub unsafe fn create_module(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
|
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
|
||||||
if sess.target.options.is_like_msvc {
|
if sess.target.is_like_msvc {
|
||||||
match sess.opts.cg.control_flow_guard {
|
match sess.opts.cg.control_flow_guard {
|
||||||
CFGuard::Disabled => {}
|
CFGuard::Disabled => {}
|
||||||
CFGuard::NoChecks => {
|
CFGuard::NoChecks => {
|
||||||
|
@ -265,7 +265,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
||||||
// linker will take care of everything. Fixing this problem will likely
|
// linker will take care of everything. Fixing this problem will likely
|
||||||
// require adding a few attributes to Rust itself (feature gated at the
|
// require adding a few attributes to Rust itself (feature gated at the
|
||||||
// start) and then strongly recommending static linkage on Windows!
|
// start) and then strongly recommending static linkage on Windows!
|
||||||
let use_dll_storage_attrs = tcx.sess.target.options.is_like_windows;
|
let use_dll_storage_attrs = tcx.sess.target.is_like_windows;
|
||||||
|
|
||||||
let check_overflow = tcx.sess.overflow_checks();
|
let check_overflow = tcx.sess.overflow_checks();
|
||||||
|
|
||||||
|
@ -839,7 +839,7 @@ impl CodegenCx<'b, 'tcx> {
|
||||||
return eh_catch_typeinfo;
|
return eh_catch_typeinfo;
|
||||||
}
|
}
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
assert!(self.sess().target.options.is_like_emscripten);
|
assert!(self.sess().target.is_like_emscripten);
|
||||||
let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() {
|
let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() {
|
||||||
Some(def_id) => self.get_static(def_id),
|
Some(def_id) => self.get_static(def_id),
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -67,5 +67,5 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
|
||||||
|
|
||||||
!omit_gdb_pretty_printer_section
|
!omit_gdb_pretty_printer_section
|
||||||
&& cx.sess().opts.debuginfo != DebugInfo::None
|
&& cx.sess().opts.debuginfo != DebugInfo::None
|
||||||
&& cx.sess().target.options.emit_debug_gdb_scripts
|
&& cx.sess().target.emit_debug_gdb_scripts
|
||||||
}
|
}
|
||||||
|
|
|
@ -870,7 +870,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
||||||
|
|
||||||
// When targeting MSVC, emit MSVC style type names for compatibility with
|
// When targeting MSVC, emit MSVC style type names for compatibility with
|
||||||
// .natvis visualizers (and perhaps other existing native debuggers?)
|
// .natvis visualizers (and perhaps other existing native debuggers?)
|
||||||
let msvc_like_names = cx.tcx.sess.target.options.is_like_msvc;
|
let msvc_like_names = cx.tcx.sess.target.is_like_msvc;
|
||||||
|
|
||||||
let (name, encoding) = match t.kind() {
|
let (name, encoding) = match t.kind() {
|
||||||
ty::Never => ("!", DW_ATE_unsigned),
|
ty::Never => ("!", DW_ATE_unsigned),
|
||||||
|
@ -981,7 +981,7 @@ pub fn compile_unit_metadata(
|
||||||
// if multiple object files with the same `DW_AT_name` are linked together.
|
// if multiple object files with the same `DW_AT_name` are linked together.
|
||||||
// As a workaround we generate unique names for each object file. Those do
|
// As a workaround we generate unique names for each object file. Those do
|
||||||
// not correspond to an actual source file but that should be harmless.
|
// not correspond to an actual source file but that should be harmless.
|
||||||
if tcx.sess.target.options.is_like_osx {
|
if tcx.sess.target.is_like_osx {
|
||||||
name_in_debuginfo.push("@");
|
name_in_debuginfo.push("@");
|
||||||
name_in_debuginfo.push(codegen_unit_name);
|
name_in_debuginfo.push(codegen_unit_name);
|
||||||
}
|
}
|
||||||
|
@ -1397,7 +1397,7 @@ fn prepare_union_metadata(
|
||||||
/// on MSVC we have to use the fallback mode, because LLVM doesn't
|
/// on MSVC we have to use the fallback mode, because LLVM doesn't
|
||||||
/// lower variant parts to PDB.
|
/// lower variant parts to PDB.
|
||||||
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
|
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
|
||||||
cx.sess().target.options.is_like_msvc
|
cx.sess().target.is_like_msvc
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(eddyb) maybe precompute this? Right now it's computed once
|
// FIXME(eddyb) maybe precompute this? Right now it's computed once
|
||||||
|
|
|
@ -122,12 +122,12 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
|
||||||
// for macOS to understand. For more info see #11352
|
// for macOS to understand. For more info see #11352
|
||||||
// This can be overridden using --llvm-opts -dwarf-version,N.
|
// This can be overridden using --llvm-opts -dwarf-version,N.
|
||||||
// Android has the same issue (#22398)
|
// Android has the same issue (#22398)
|
||||||
if let Some(version) = cx.sess().target.options.dwarf_version {
|
if let Some(version) = cx.sess().target.dwarf_version {
|
||||||
llvm::LLVMRustAddModuleFlag(cx.llmod, "Dwarf Version\0".as_ptr().cast(), version)
|
llvm::LLVMRustAddModuleFlag(cx.llmod, "Dwarf Version\0".as_ptr().cast(), version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicate that we want CodeView debug information on MSVC
|
// Indicate that we want CodeView debug information on MSVC
|
||||||
if cx.sess().target.options.is_like_msvc {
|
if cx.sess().target.is_like_msvc {
|
||||||
llvm::LLVMRustAddModuleFlag(cx.llmod, "CodeView\0".as_ptr().cast(), 1)
|
llvm::LLVMRustAddModuleFlag(cx.llmod, "CodeView\0".as_ptr().cast(), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ impl CodegenCx<'ll, '_> {
|
||||||
// For MSVC, omit the column number.
|
// For MSVC, omit the column number.
|
||||||
// Otherwise, emit it. This mimics clang behaviour.
|
// Otherwise, emit it. This mimics clang behaviour.
|
||||||
// See discussion in https://github.com/rust-lang/rust/issues/42921
|
// See discussion in https://github.com/rust-lang/rust/issues/42921
|
||||||
if self.sess().target.options.is_like_msvc {
|
if self.sess().target.is_like_msvc {
|
||||||
DebugLoc { file, line, col: None }
|
DebugLoc { file, line, col: None }
|
||||||
} else {
|
} else {
|
||||||
DebugLoc { file, line, col }
|
DebugLoc { file, line, col }
|
||||||
|
@ -387,7 +387,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Arguments types
|
// Arguments types
|
||||||
if cx.sess().target.options.is_like_msvc {
|
if cx.sess().target.is_like_msvc {
|
||||||
// FIXME(#42800):
|
// FIXME(#42800):
|
||||||
// There is a bug in MSDIA that leads to a crash when it encounters
|
// There is a bug in MSDIA that leads to a crash when it encounters
|
||||||
// a fixed-size array of `u8` or something zero-sized in a
|
// a fixed-size array of `u8` or something zero-sized in a
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn declare_raw_fn(
|
||||||
// be merged.
|
// be merged.
|
||||||
llvm::SetUnnamedAddress(llfn, llvm::UnnamedAddr::Global);
|
llvm::SetUnnamedAddress(llfn, llvm::UnnamedAddr::Global);
|
||||||
|
|
||||||
if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.options.disable_redzone) {
|
if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.disable_redzone) {
|
||||||
llvm::Attribute::NoRedZone.apply_llfn(Function, llfn);
|
llvm::Attribute::NoRedZone.apply_llfn(Function, llfn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ fn try_intrinsic(
|
||||||
bx.store(bx.const_i32(0), dest, ret_align);
|
bx.store(bx.const_i32(0), dest, ret_align);
|
||||||
} else if wants_msvc_seh(bx.sess()) {
|
} else if wants_msvc_seh(bx.sess()) {
|
||||||
codegen_msvc_try(bx, try_func, data, catch_func, dest);
|
codegen_msvc_try(bx, try_func, data, catch_func, dest);
|
||||||
} else if bx.sess().target.options.is_like_emscripten {
|
} else if bx.sess().target.is_like_emscripten {
|
||||||
codegen_emcc_try(bx, try_func, data, catch_func, dest);
|
codegen_emcc_try(bx, try_func, data, catch_func, dest);
|
||||||
} else {
|
} else {
|
||||||
codegen_gnu_try(bx, try_func, data, catch_func, dest);
|
codegen_gnu_try(bx, try_func, data, catch_func, dest);
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn require_inited() {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn configure_llvm(sess: &Session) {
|
unsafe fn configure_llvm(sess: &Session) {
|
||||||
let n_args = sess.opts.cg.llvm_args.len() + sess.target.options.llvm_args.len();
|
let n_args = sess.opts.cg.llvm_args.len() + sess.target.llvm_args.len();
|
||||||
let mut llvm_c_strs = Vec::with_capacity(n_args + 1);
|
let mut llvm_c_strs = Vec::with_capacity(n_args + 1);
|
||||||
let mut llvm_args = Vec::with_capacity(n_args + 1);
|
let mut llvm_args = Vec::with_capacity(n_args + 1);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let cg_opts = sess.opts.cg.llvm_args.iter();
|
let cg_opts = sess.opts.cg.llvm_args.iter();
|
||||||
let tg_opts = sess.target.options.llvm_args.iter();
|
let tg_opts = sess.target.llvm_args.iter();
|
||||||
let sess_args = cg_opts.chain(tg_opts);
|
let sess_args = cg_opts.chain(tg_opts);
|
||||||
|
|
||||||
let user_specified_args: FxHashSet<_> =
|
let user_specified_args: FxHashSet<_> =
|
||||||
|
@ -84,12 +84,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||||
if !sess.opts.debugging_opts.no_generate_arange_section {
|
if !sess.opts.debugging_opts.no_generate_arange_section {
|
||||||
add("-generate-arange-section", false);
|
add("-generate-arange-section", false);
|
||||||
}
|
}
|
||||||
match sess
|
match sess.opts.debugging_opts.merge_functions.unwrap_or(sess.target.merge_functions) {
|
||||||
.opts
|
|
||||||
.debugging_opts
|
|
||||||
.merge_functions
|
|
||||||
.unwrap_or(sess.target.options.merge_functions)
|
|
||||||
{
|
|
||||||
MergeFunctions::Disabled | MergeFunctions::Trampolines => {}
|
MergeFunctions::Disabled | MergeFunctions::Trampolines => {}
|
||||||
MergeFunctions::Aliases => {
|
MergeFunctions::Aliases => {
|
||||||
add("-mergefunc-use-aliases", false);
|
add("-mergefunc-use-aliases", false);
|
||||||
|
@ -215,7 +210,7 @@ fn handle_native(name: &str) -> &str {
|
||||||
pub fn target_cpu(sess: &Session) -> &str {
|
pub fn target_cpu(sess: &Session) -> &str {
|
||||||
let name = match sess.opts.cg.target_cpu {
|
let name = match sess.opts.cg.target_cpu {
|
||||||
Some(ref s) => &**s,
|
Some(ref s) => &**s,
|
||||||
None => &*sess.target.options.cpu,
|
None => &*sess.target.cpu,
|
||||||
};
|
};
|
||||||
|
|
||||||
handle_native(name)
|
handle_native(name)
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub fn metadata_section_name(target: &Target) -> &'static str {
|
||||||
// As a result, we choose a slightly shorter name! As to why
|
// As a result, we choose a slightly shorter name! As to why
|
||||||
// `.note.rustc` works on MinGW, that's another good question...
|
// `.note.rustc` works on MinGW, that's another good question...
|
||||||
|
|
||||||
if target.options.is_like_osx { "__DATA,.rustc" } else { ".rustc" }
|
if target.is_like_osx { "__DATA,.rustc" } else { ".rustc" }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_metadata_section_name(_target: &Target) -> &'static str {
|
fn read_metadata_section_name(_target: &Target) -> &'static str {
|
||||||
|
|
|
@ -175,22 +175,22 @@ pub(super) fn emit_va_arg(
|
||||||
let arch = &bx.cx.tcx.sess.target.arch;
|
let arch = &bx.cx.tcx.sess.target.arch;
|
||||||
match &**arch {
|
match &**arch {
|
||||||
// Windows x86
|
// Windows x86
|
||||||
"x86" if target.options.is_like_windows => {
|
"x86" if target.is_like_windows => {
|
||||||
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), false)
|
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), false)
|
||||||
}
|
}
|
||||||
// Generic x86
|
// Generic x86
|
||||||
"x86" => emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), true),
|
"x86" => emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), true),
|
||||||
// Windows AArch64
|
// Windows AArch64
|
||||||
"aarch64" if target.options.is_like_windows => {
|
"aarch64" if target.is_like_windows => {
|
||||||
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
|
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
|
||||||
}
|
}
|
||||||
// macOS / iOS AArch64
|
// macOS / iOS AArch64
|
||||||
"aarch64" if target.options.is_like_osx => {
|
"aarch64" if target.is_like_osx => {
|
||||||
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), true)
|
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), true)
|
||||||
}
|
}
|
||||||
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),
|
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),
|
||||||
// Windows x86_64
|
// Windows x86_64
|
||||||
"x86_64" if target.options.is_like_windows => {
|
"x86_64" if target.is_like_windows => {
|
||||||
let target_ty_size = bx.cx.size_of(target_ty).bytes();
|
let target_ty_size = bx.cx.size_of(target_ty).bytes();
|
||||||
let indirect: bool = target_ty_size > 8 || !target_ty_size.is_power_of_two();
|
let indirect: bool = target_ty_size > 8 || !target_ty_size.is_power_of_two();
|
||||||
emit_ptr_va_arg(bx, addr, target_ty, indirect, Align::from_bytes(8).unwrap(), false)
|
emit_ptr_va_arg(bx, addr, target_ty, indirect, Align::from_bytes(8).unwrap(), false)
|
||||||
|
|
|
@ -7,10 +7,8 @@ use std::path::{Path, PathBuf};
|
||||||
pub fn find_library(name: Symbol, search_paths: &[PathBuf], sess: &Session) -> PathBuf {
|
pub fn find_library(name: Symbol, search_paths: &[PathBuf], sess: &Session) -> PathBuf {
|
||||||
// On Windows, static libraries sometimes show up as libfoo.a and other
|
// On Windows, static libraries sometimes show up as libfoo.a and other
|
||||||
// times show up as foo.lib
|
// times show up as foo.lib
|
||||||
let oslibname = format!(
|
let oslibname =
|
||||||
"{}{}{}",
|
format!("{}{}{}", sess.target.staticlib_prefix, name, sess.target.staticlib_suffix);
|
||||||
sess.target.options.staticlib_prefix, name, sess.target.options.staticlib_suffix
|
|
||||||
);
|
|
||||||
let unixlibname = format!("lib{}.a", name);
|
let unixlibname = format!("lib{}.a", name);
|
||||||
|
|
||||||
for path in search_paths {
|
for path in search_paths {
|
||||||
|
|
|
@ -151,9 +151,7 @@ fn get_linker(
|
||||||
Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker),
|
Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker),
|
||||||
_ => match flavor {
|
_ => match flavor {
|
||||||
LinkerFlavor::Lld(f) => Command::lld(linker, f),
|
LinkerFlavor::Lld(f) => Command::lld(linker, f),
|
||||||
LinkerFlavor::Msvc
|
LinkerFlavor::Msvc if sess.opts.cg.linker.is_none() && sess.target.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))
|
Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker))
|
||||||
}
|
}
|
||||||
_ => Command::new(linker),
|
_ => Command::new(linker),
|
||||||
|
@ -197,7 +195,7 @@ fn get_linker(
|
||||||
// PATH for the child.
|
// PATH for the child.
|
||||||
let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths(self_contained);
|
let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths(self_contained);
|
||||||
let mut msvc_changed_path = false;
|
let mut msvc_changed_path = false;
|
||||||
if sess.target.options.is_like_msvc {
|
if sess.target.is_like_msvc {
|
||||||
if let Some(ref tool) = msvc_tool {
|
if let Some(ref tool) = msvc_tool {
|
||||||
cmd.args(tool.args());
|
cmd.args(tool.args());
|
||||||
for &(ref k, ref v) in tool.env() {
|
for &(ref k, ref v) in tool.env() {
|
||||||
|
@ -365,7 +363,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
|
||||||
// After adding all files to the archive, we need to update the
|
// After adding all files to the archive, we need to update the
|
||||||
// symbol table of the archive. This currently dies on macOS (see
|
// symbol table of the archive. This currently dies on macOS (see
|
||||||
// #11162), and isn't necessary there anyway
|
// #11162), and isn't necessary there anyway
|
||||||
if !sess.target.options.is_like_osx {
|
if !sess.target.is_like_osx {
|
||||||
ab.update_symbols();
|
ab.update_symbols();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,10 +474,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
|
|
||||||
linker::disable_localization(&mut cmd);
|
linker::disable_localization(&mut cmd);
|
||||||
|
|
||||||
for &(ref k, ref v) in &sess.target.options.link_env {
|
for &(ref k, ref v) in &sess.target.link_env {
|
||||||
cmd.env(k, v);
|
cmd.env(k, v);
|
||||||
}
|
}
|
||||||
for k in &sess.target.options.link_env_remove {
|
for k in &sess.target.link_env_remove {
|
||||||
cmd.env_remove(k);
|
cmd.env_remove(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +513,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
// if the linker doesn't support -no-pie then it should not default to
|
// 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
|
// linking executables as pie. Different versions of gcc seem to use
|
||||||
// different quotes in the error message so don't check for them.
|
// different quotes in the error message so don't check for them.
|
||||||
if sess.target.options.linker_is_gnu
|
if sess.target.linker_is_gnu
|
||||||
&& flavor != LinkerFlavor::Ld
|
&& flavor != LinkerFlavor::Ld
|
||||||
&& (out.contains("unrecognized command line option")
|
&& (out.contains("unrecognized command line option")
|
||||||
|| out.contains("unknown argument"))
|
|| out.contains("unknown argument"))
|
||||||
|
@ -535,7 +533,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
|
|
||||||
// Detect '-static-pie' used with an older version of gcc or clang not supporting it.
|
// Detect '-static-pie' used with an older version of gcc or clang not supporting it.
|
||||||
// Fallback from '-static-pie' to '-static' in that case.
|
// Fallback from '-static-pie' to '-static' in that case.
|
||||||
if sess.target.options.linker_is_gnu
|
if sess.target.linker_is_gnu
|
||||||
&& flavor != LinkerFlavor::Ld
|
&& flavor != LinkerFlavor::Ld
|
||||||
&& (out.contains("unrecognized command line option")
|
&& (out.contains("unrecognized command line option")
|
||||||
|| out.contains("unknown argument"))
|
|| out.contains("unknown argument"))
|
||||||
|
@ -548,7 +546,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
);
|
);
|
||||||
// Mirror `add_(pre,post)_link_objects` to replace CRT objects.
|
// Mirror `add_(pre,post)_link_objects` to replace CRT objects.
|
||||||
let self_contained = crt_objects_fallback(sess, crate_type);
|
let self_contained = crt_objects_fallback(sess, crate_type);
|
||||||
let opts = &sess.target.options;
|
let opts = &sess.target;
|
||||||
let pre_objects = if self_contained {
|
let pre_objects = if self_contained {
|
||||||
&opts.pre_link_objects_fallback
|
&opts.pre_link_objects_fallback
|
||||||
} else {
|
} else {
|
||||||
|
@ -670,7 +668,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
// is not a Microsoft LNK error then suggest a way to fix or
|
// is not a Microsoft LNK error then suggest a way to fix or
|
||||||
// install the Visual Studio build tools.
|
// install the Visual Studio build tools.
|
||||||
if let Some(code) = prog.status.code() {
|
if let Some(code) = prog.status.code() {
|
||||||
if sess.target.options.is_like_msvc
|
if sess.target.is_like_msvc
|
||||||
&& flavor == LinkerFlavor::Msvc
|
&& flavor == LinkerFlavor::Msvc
|
||||||
// Respect the command line override
|
// Respect the command line override
|
||||||
&& sess.opts.cg.linker.is_none()
|
&& sess.opts.cg.linker.is_none()
|
||||||
|
@ -741,7 +739,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
|
|
||||||
linker_error.emit();
|
linker_error.emit();
|
||||||
|
|
||||||
if sess.target.options.is_like_msvc && linker_not_found {
|
if sess.target.is_like_msvc && linker_not_found {
|
||||||
sess.note_without_error(
|
sess.note_without_error(
|
||||||
"the msvc targets depend on the msvc linker \
|
"the msvc targets depend on the msvc linker \
|
||||||
but `link.exe` was not found",
|
but `link.exe` was not found",
|
||||||
|
@ -758,7 +756,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
// On macOS, debuggers need this utility to get run to do some munging of
|
// 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
|
// 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.
|
// for their debug information there's no need for us to run dsymutil.
|
||||||
if sess.target.options.is_like_osx
|
if sess.target.is_like_osx
|
||||||
&& sess.opts.debuginfo != DebugInfo::None
|
&& sess.opts.debuginfo != DebugInfo::None
|
||||||
&& !preserve_objects_for_their_debuginfo(sess)
|
&& !preserve_objects_for_their_debuginfo(sess)
|
||||||
{
|
{
|
||||||
|
@ -775,9 +773,7 @@ fn link_sanitizers(sess: &Session, crate_type: CrateType, linker: &mut dyn Linke
|
||||||
// executables only.
|
// executables only.
|
||||||
let needs_runtime = match crate_type {
|
let needs_runtime = match crate_type {
|
||||||
CrateType::Executable => true,
|
CrateType::Executable => true,
|
||||||
CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => {
|
CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => sess.target.is_like_osx,
|
||||||
sess.target.options.is_like_osx
|
|
||||||
}
|
|
||||||
CrateType::Rlib | CrateType::Staticlib => false,
|
CrateType::Rlib | CrateType::Staticlib => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -846,7 +842,7 @@ pub fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool
|
||||||
// If our target enables builtin function lowering in LLVM then the
|
// If our target enables builtin function lowering in LLVM then the
|
||||||
// crates providing these functions don't participate in LTO (e.g.
|
// crates providing these functions don't participate in LTO (e.g.
|
||||||
// no_builtins or compiler builtins crates).
|
// no_builtins or compiler builtins crates).
|
||||||
!sess.target.options.no_builtins
|
!sess.target.no_builtins
|
||||||
&& (info.compiler_builtins == Some(cnum) || info.is_no_builtins.contains(&cnum))
|
&& (info.compiler_builtins == Some(cnum) || info.is_no_builtins.contains(&cnum))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,7 +902,7 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
||||||
} else if stem == "link" || stem == "lld-link" {
|
} else if stem == "link" || stem == "lld-link" {
|
||||||
LinkerFlavor::Msvc
|
LinkerFlavor::Msvc
|
||||||
} else if stem == "lld" || stem == "rust-lld" {
|
} else if stem == "lld" || stem == "rust-lld" {
|
||||||
LinkerFlavor::Lld(sess.target.options.lld_flavor)
|
LinkerFlavor::Lld(sess.target.lld_flavor)
|
||||||
} else {
|
} else {
|
||||||
// fall back to the value in the target spec
|
// fall back to the value in the target spec
|
||||||
sess.target.linker_flavor
|
sess.target.linker_flavor
|
||||||
|
@ -926,7 +922,7 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
||||||
|
|
||||||
if let Some(ret) = infer_from(
|
if let Some(ret) = infer_from(
|
||||||
sess,
|
sess,
|
||||||
sess.target.options.linker.clone().map(PathBuf::from),
|
sess.target.linker.clone().map(PathBuf::from),
|
||||||
Some(sess.target.linker_flavor),
|
Some(sess.target.linker_flavor),
|
||||||
) {
|
) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -962,7 +958,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
|
// 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
|
// *not* running dsymutil then the object files are the only source of truth
|
||||||
// for debug information, so we must preserve them.
|
// for debug information, so we must preserve them.
|
||||||
if sess.target.options.is_like_osx {
|
if sess.target.is_like_osx {
|
||||||
return !sess.opts.debugging_opts.run_dsymutil;
|
return !sess.opts.debugging_opts.run_dsymutil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,7 +984,7 @@ fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) {
|
||||||
NativeLibKind::StaticNoBundle
|
NativeLibKind::StaticNoBundle
|
||||||
| NativeLibKind::Dylib
|
| NativeLibKind::Dylib
|
||||||
| NativeLibKind::Unspecified => {
|
| NativeLibKind::Unspecified => {
|
||||||
if sess.target.options.is_like_msvc {
|
if sess.target.is_like_msvc {
|
||||||
Some(format!("{}.lib", name))
|
Some(format!("{}.lib", name))
|
||||||
} else {
|
} else {
|
||||||
Some(format!("-l{}", name))
|
Some(format!("-l{}", name))
|
||||||
|
@ -1070,13 +1066,13 @@ fn exec_linker(
|
||||||
let mut args = String::new();
|
let mut args = String::new();
|
||||||
for arg in cmd2.take_args() {
|
for arg in cmd2.take_args() {
|
||||||
args.push_str(
|
args.push_str(
|
||||||
&Escape { arg: arg.to_str().unwrap(), is_like_msvc: sess.target.options.is_like_msvc }
|
&Escape { arg: arg.to_str().unwrap(), is_like_msvc: sess.target.is_like_msvc }
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
args.push('\n');
|
args.push('\n');
|
||||||
}
|
}
|
||||||
let file = tmpdir.join("linker-arguments");
|
let file = tmpdir.join("linker-arguments");
|
||||||
let bytes = if sess.target.options.is_like_msvc {
|
let bytes = if sess.target.is_like_msvc {
|
||||||
let mut out = Vec::with_capacity((1 + args.len()) * 2);
|
let mut out = Vec::with_capacity((1 + args.len()) * 2);
|
||||||
// start the stream with a UTF-16 BOM
|
// start the stream with a UTF-16 BOM
|
||||||
for c in std::iter::once(0xFEFF).chain(args.encode_utf16()) {
|
for c in std::iter::once(0xFEFF).chain(args.encode_utf16()) {
|
||||||
|
@ -1192,7 +1188,7 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Adjust the output kind to target capabilities.
|
// Adjust the output kind to target capabilities.
|
||||||
let opts = &sess.target.options;
|
let opts = &sess.target;
|
||||||
let pic_exe_supported = opts.position_independent_executables;
|
let pic_exe_supported = opts.position_independent_executables;
|
||||||
let static_pic_exe_supported = opts.static_position_independent_executables;
|
let static_pic_exe_supported = opts.static_position_independent_executables;
|
||||||
let static_dylib_supported = opts.crt_static_allows_dylibs;
|
let static_dylib_supported = opts.crt_static_allows_dylibs;
|
||||||
|
@ -1233,7 +1229,7 @@ fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool {
|
||||||
return self_contained;
|
return self_contained;
|
||||||
}
|
}
|
||||||
|
|
||||||
match sess.target.options.crt_objects_fallback {
|
match sess.target.crt_objects_fallback {
|
||||||
// FIXME: Find a better heuristic for "native musl toolchain is available",
|
// FIXME: Find a better heuristic for "native musl toolchain is available",
|
||||||
// based on host and linker path, for example.
|
// based on host and linker path, for example.
|
||||||
// (https://github.com/rust-lang/rust/pull/71769#issuecomment-626330237).
|
// (https://github.com/rust-lang/rust/pull/71769#issuecomment-626330237).
|
||||||
|
@ -1256,7 +1252,7 @@ fn add_pre_link_objects(
|
||||||
link_output_kind: LinkOutputKind,
|
link_output_kind: LinkOutputKind,
|
||||||
self_contained: bool,
|
self_contained: bool,
|
||||||
) {
|
) {
|
||||||
let opts = &sess.target.options;
|
let opts = &sess.target;
|
||||||
let objects =
|
let objects =
|
||||||
if self_contained { &opts.pre_link_objects_fallback } else { &opts.pre_link_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() {
|
for obj in objects.get(&link_output_kind).iter().copied().flatten() {
|
||||||
|
@ -1271,7 +1267,7 @@ fn add_post_link_objects(
|
||||||
link_output_kind: LinkOutputKind,
|
link_output_kind: LinkOutputKind,
|
||||||
self_contained: bool,
|
self_contained: bool,
|
||||||
) {
|
) {
|
||||||
let opts = &sess.target.options;
|
let opts = &sess.target;
|
||||||
let objects =
|
let objects =
|
||||||
if self_contained { &opts.post_link_objects_fallback } else { &opts.post_link_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() {
|
for obj in objects.get(&link_output_kind).iter().copied().flatten() {
|
||||||
|
@ -1282,7 +1278,7 @@ fn add_post_link_objects(
|
||||||
/// Add arbitrary "pre-link" args defined by the target spec or from command line.
|
/// Add arbitrary "pre-link" args defined by the target spec or from command line.
|
||||||
/// FIXME: Determine where exactly these args need to be inserted.
|
/// FIXME: Determine where exactly these args need to be inserted.
|
||||||
fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||||
if let Some(args) = sess.target.options.pre_link_args.get(&flavor) {
|
if let Some(args) = sess.target.pre_link_args.get(&flavor) {
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
}
|
}
|
||||||
cmd.args(&sess.opts.debugging_opts.pre_link_args);
|
cmd.args(&sess.opts.debugging_opts.pre_link_args);
|
||||||
|
@ -1290,9 +1286,9 @@ fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor)
|
||||||
|
|
||||||
/// Add a link script embedded in the target, if applicable.
|
/// 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) {
|
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
|
||||||
match (crate_type, &sess.target.options.link_script) {
|
match (crate_type, &sess.target.link_script) {
|
||||||
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
|
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
|
||||||
if !sess.target.options.linker_is_gnu {
|
if !sess.target.linker_is_gnu {
|
||||||
sess.fatal("can only use link script when linking with GNU-like linker");
|
sess.fatal("can only use link script when linking with GNU-like linker");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,15 +1331,15 @@ fn add_late_link_args(
|
||||||
*ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
*ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
||||||
});
|
});
|
||||||
if any_dynamic_crate {
|
if any_dynamic_crate {
|
||||||
if let Some(args) = sess.target.options.late_link_args_dynamic.get(&flavor) {
|
if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) {
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(args) = sess.target.options.late_link_args_static.get(&flavor) {
|
if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(args) = sess.target.options.late_link_args.get(&flavor) {
|
if let Some(args) = sess.target.late_link_args.get(&flavor) {
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1351,7 +1347,7 @@ fn add_late_link_args(
|
||||||
/// Add arbitrary "post-link" args defined by the target spec.
|
/// Add arbitrary "post-link" args defined by the target spec.
|
||||||
/// FIXME: Determine where exactly these args need to be inserted.
|
/// FIXME: Determine where exactly these args need to be inserted.
|
||||||
fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||||
if let Some(args) = sess.target.options.post_link_args.get(&flavor) {
|
if let Some(args) = sess.target.post_link_args.get(&flavor) {
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1453,7 +1449,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
|
/// Add options making relocation sections in the produced ELF files read-only
|
||||||
/// and suppressing lazy binding.
|
/// and suppressing lazy binding.
|
||||||
fn add_relro_args(cmd: &mut dyn Linker, sess: &Session) {
|
fn add_relro_args(cmd: &mut dyn Linker, sess: &Session) {
|
||||||
match sess.opts.debugging_opts.relro_level.unwrap_or(sess.target.options.relro_level) {
|
match sess.opts.debugging_opts.relro_level.unwrap_or(sess.target.relro_level) {
|
||||||
RelroLevel::Full => cmd.full_relro(),
|
RelroLevel::Full => cmd.full_relro(),
|
||||||
RelroLevel::Partial => cmd.partial_relro(),
|
RelroLevel::Partial => cmd.partial_relro(),
|
||||||
RelroLevel::Off => cmd.no_relro(),
|
RelroLevel::Off => cmd.no_relro(),
|
||||||
|
@ -1484,9 +1480,9 @@ fn add_rpath_args(
|
||||||
let mut rpath_config = RPathConfig {
|
let mut rpath_config = RPathConfig {
|
||||||
used_crates: &codegen_results.crate_info.used_crates_dynamic,
|
used_crates: &codegen_results.crate_info.used_crates_dynamic,
|
||||||
out_filename: out_filename.to_path_buf(),
|
out_filename: out_filename.to_path_buf(),
|
||||||
has_rpath: sess.target.options.has_rpath,
|
has_rpath: sess.target.has_rpath,
|
||||||
is_like_osx: sess.target.options.is_like_osx,
|
is_like_osx: sess.target.is_like_osx,
|
||||||
linker_is_gnu: sess.target.options.linker_is_gnu,
|
linker_is_gnu: sess.target.linker_is_gnu,
|
||||||
get_install_prefix_lib_path: &mut get_install_prefix_lib_path,
|
get_install_prefix_lib_path: &mut get_install_prefix_lib_path,
|
||||||
};
|
};
|
||||||
cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
|
cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
|
||||||
|
@ -1528,7 +1524,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
||||||
add_link_script(cmd, sess, tmpdir, crate_type);
|
add_link_script(cmd, sess, tmpdir, crate_type);
|
||||||
|
|
||||||
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
||||||
if sess.target.options.is_like_fuchsia && crate_type == CrateType::Executable {
|
if sess.target.is_like_fuchsia && crate_type == CrateType::Executable {
|
||||||
let prefix = if sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::ADDRESS) {
|
let prefix = if sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::ADDRESS) {
|
||||||
"asan/"
|
"asan/"
|
||||||
} else {
|
} else {
|
||||||
|
@ -1538,7 +1534,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
||||||
if sess.target.options.eh_frame_header {
|
if sess.target.eh_frame_header {
|
||||||
cmd.add_eh_frame_header();
|
cmd.add_eh_frame_header();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1551,7 +1547,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
||||||
add_pre_link_objects(cmd, sess, link_output_kind, crt_objects_fallback);
|
add_pre_link_objects(cmd, sess, link_output_kind, crt_objects_fallback);
|
||||||
|
|
||||||
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
||||||
if sess.target.options.is_like_emscripten {
|
if sess.target.is_like_emscripten {
|
||||||
cmd.arg("-s");
|
cmd.arg("-s");
|
||||||
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
|
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
|
||||||
"DISABLE_EXCEPTION_CATCHING=1"
|
"DISABLE_EXCEPTION_CATCHING=1"
|
||||||
|
@ -1579,7 +1575,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
||||||
cmd.output_filename(out_filename);
|
cmd.output_filename(out_filename);
|
||||||
|
|
||||||
// OBJECT-FILES-NO, AUDIT-ORDER
|
// OBJECT-FILES-NO, AUDIT-ORDER
|
||||||
if crate_type == CrateType::Executable && sess.target.options.is_like_windows {
|
if crate_type == CrateType::Executable && sess.target.is_like_windows {
|
||||||
if let Some(ref s) = codegen_results.windows_subsystem {
|
if let Some(ref s) = codegen_results.windows_subsystem {
|
||||||
cmd.subsystem(s);
|
cmd.subsystem(s);
|
||||||
}
|
}
|
||||||
|
@ -1623,7 +1619,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
||||||
// OBJECT-FILES-NO, AUDIT-ORDER
|
// OBJECT-FILES-NO, AUDIT-ORDER
|
||||||
// We want to prevent the compiler from accidentally leaking in any system libraries,
|
// 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.
|
// so by default we tell linkers not to link to any default libraries.
|
||||||
if !sess.opts.cg.default_linker_libraries && sess.target.options.no_default_libraries {
|
if !sess.opts.cg.default_linker_libraries && sess.target.no_default_libraries {
|
||||||
cmd.no_default_libraries();
|
cmd.no_default_libraries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1843,7 +1839,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
||||||
|
|
||||||
// Converts a library file-stem into a cc -l argument
|
// Converts a library file-stem into a cc -l argument
|
||||||
fn unlib<'a>(target: &Target, stem: &'a str) -> &'a str {
|
fn unlib<'a>(target: &Target, stem: &'a str) -> &'a str {
|
||||||
if stem.starts_with("lib") && !target.options.is_like_windows { &stem[3..] } else { stem }
|
if stem.starts_with("lib") && !target.is_like_windows { &stem[3..] } else { stem }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds the static "rlib" versions of all crates to the command line.
|
// Adds the static "rlib" versions of all crates to the command line.
|
||||||
|
@ -1938,7 +1934,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
||||||
// though, so we let that object file slide.
|
// though, so we let that object file slide.
|
||||||
let skip_because_lto = are_upstream_rust_objects_already_included(sess)
|
let skip_because_lto = are_upstream_rust_objects_already_included(sess)
|
||||||
&& is_rust_object
|
&& is_rust_object
|
||||||
&& (sess.target.options.no_builtins
|
&& (sess.target.no_builtins
|
||||||
|| !codegen_results.crate_info.is_no_builtins.contains(&cnum));
|
|| !codegen_results.crate_info.is_no_builtins.contains(&cnum));
|
||||||
|
|
||||||
if skip_because_cfg_say_so || skip_because_lto {
|
if skip_because_cfg_say_so || skip_because_lto {
|
||||||
|
|
|
@ -184,7 +184,7 @@ impl<'a> GccLinker<'a> {
|
||||||
// * On OSX they have their own linker, not binutils'
|
// * On OSX they have their own linker, not binutils'
|
||||||
// * For WebAssembly the only functional linker is LLD, which doesn't
|
// * For WebAssembly the only functional linker is LLD, which doesn't
|
||||||
// support hint flags
|
// support hint flags
|
||||||
!self.sess.target.options.is_like_osx && self.sess.target.arch != "wasm32"
|
!self.sess.target.is_like_osx && self.sess.target.arch != "wasm32"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some platforms take hints about whether a library is static or dynamic.
|
// 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) {
|
fn build_dylib(&mut self, out_filename: &Path) {
|
||||||
// On mac we need to tell the linker to let this library be rpathed
|
// On mac we need to tell the linker to let this library be rpathed
|
||||||
if self.sess.target.options.is_like_osx {
|
if self.sess.target.is_like_osx {
|
||||||
self.cmd.arg("-dynamiclib");
|
self.cmd.arg("-dynamiclib");
|
||||||
self.linker_arg("-dylib");
|
self.linker_arg("-dylib");
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ impl<'a> GccLinker<'a> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.cmd.arg("-shared");
|
self.cmd.arg("-shared");
|
||||||
if self.sess.target.options.is_like_windows {
|
if self.sess.target.is_like_windows {
|
||||||
// The output filename already contains `dll_suffix` so
|
// The output filename already contains `dll_suffix` so
|
||||||
// the resulting import library will have a name in the
|
// the resulting import library will have a name in the
|
||||||
// form of libfoo.dll.a
|
// 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| {
|
out_filename.file_name().and_then(|file| file.to_str()).map(|file| {
|
||||||
format!(
|
format!(
|
||||||
"{}{}{}",
|
"{}{}{}",
|
||||||
self.sess.target.options.staticlib_prefix,
|
self.sess.target.staticlib_prefix,
|
||||||
file,
|
file,
|
||||||
self.sess.target.options.staticlib_suffix
|
self.sess.target.staticlib_suffix
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
if let Some(implib_name) = implib_name {
|
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) {
|
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
|
||||||
match output_kind {
|
match output_kind {
|
||||||
LinkOutputKind::DynamicNoPicExe => {
|
LinkOutputKind::DynamicNoPicExe => {
|
||||||
if !self.is_ld && self.sess.target.options.linker_is_gnu {
|
if !self.is_ld && self.sess.target.linker_is_gnu {
|
||||||
self.cmd.arg("-no-pie");
|
self.cmd.arg("-no-pie");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
LinkOutputKind::StaticNoPicExe => {
|
LinkOutputKind::StaticNoPicExe => {
|
||||||
// `-static` works for both gcc wrapper and ld.
|
// `-static` works for both gcc wrapper and ld.
|
||||||
self.cmd.arg("-static");
|
self.cmd.arg("-static");
|
||||||
if !self.is_ld && self.sess.target.options.linker_is_gnu {
|
if !self.is_ld && self.sess.target.linker_is_gnu {
|
||||||
self.cmd.arg("-no-pie");
|
self.cmd.arg("-no-pie");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
fn link_whole_staticlib(&mut self, lib: Symbol, search_path: &[PathBuf]) {
|
fn link_whole_staticlib(&mut self, lib: Symbol, search_path: &[PathBuf]) {
|
||||||
self.hint_static();
|
self.hint_static();
|
||||||
let target = &self.sess.target;
|
let target = &self.sess.target;
|
||||||
if !target.options.is_like_osx {
|
if !target.is_like_osx {
|
||||||
self.linker_arg("--whole-archive").cmd.arg(format!("-l{}", lib));
|
self.linker_arg("--whole-archive").cmd.arg(format!("-l{}", lib));
|
||||||
self.linker_arg("--no-whole-archive");
|
self.linker_arg("--no-whole-archive");
|
||||||
} else {
|
} else {
|
||||||
|
@ -400,7 +400,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
|
|
||||||
fn link_whole_rlib(&mut self, lib: &Path) {
|
fn link_whole_rlib(&mut self, lib: &Path) {
|
||||||
self.hint_static();
|
self.hint_static();
|
||||||
if self.sess.target.options.is_like_osx {
|
if self.sess.target.is_like_osx {
|
||||||
self.linker_arg("-force_load");
|
self.linker_arg("-force_load");
|
||||||
self.linker_arg(&lib);
|
self.linker_arg(&lib);
|
||||||
} else {
|
} 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
|
// -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
|
// for partial linking when using multiple codegen units (-r). So we
|
||||||
// insert it here.
|
// insert it here.
|
||||||
if self.sess.target.options.is_like_osx {
|
if self.sess.target.is_like_osx {
|
||||||
self.linker_arg("-dead_strip");
|
self.linker_arg("-dead_strip");
|
||||||
} else if self.sess.target.options.is_like_solaris {
|
} else if self.sess.target.is_like_solaris {
|
||||||
self.linker_arg("-zignore");
|
self.linker_arg("-zignore");
|
||||||
|
|
||||||
// If we're building a dylib, we don't use --gc-sections because LLVM
|
// 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) {
|
fn optimize(&mut self) {
|
||||||
if !self.sess.target.options.linker_is_gnu {
|
if !self.sess.target.linker_is_gnu {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pgo_gen(&mut self) {
|
fn pgo_gen(&mut self) {
|
||||||
if !self.sess.target.options.linker_is_gnu {
|
if !self.sess.target.linker_is_gnu {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,8 +503,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
|
|
||||||
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType) {
|
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType) {
|
||||||
// Symbol visibility in object files typically takes care of this.
|
// Symbol visibility in object files typically takes care of this.
|
||||||
if crate_type == CrateType::Executable
|
if crate_type == CrateType::Executable && self.sess.target.override_export_symbols.is_none()
|
||||||
&& self.sess.target.options.override_export_symbols.is_none()
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -513,7 +512,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
// The object files have far more public symbols than we actually want to export,
|
// The object files have far more public symbols than we actually want to export,
|
||||||
// so we hide them all here.
|
// so we hide them all here.
|
||||||
|
|
||||||
if !self.sess.target.options.limit_rdylib_exports {
|
if !self.sess.target.limit_rdylib_exports {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,13 +520,13 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_windows = self.sess.target.options.is_like_windows;
|
let is_windows = self.sess.target.is_like_windows;
|
||||||
let mut arg = OsString::new();
|
let mut arg = OsString::new();
|
||||||
let path = tmpdir.join(if is_windows { "list.def" } else { "list" });
|
let path = tmpdir.join(if is_windows { "list.def" } else { "list" });
|
||||||
|
|
||||||
debug!("EXPORTED SYMBOLS:");
|
debug!("EXPORTED SYMBOLS:");
|
||||||
|
|
||||||
if self.sess.target.options.is_like_osx {
|
if self.sess.target.is_like_osx {
|
||||||
// Write a plain, newline-separated list of symbols
|
// Write a plain, newline-separated list of symbols
|
||||||
let res: io::Result<()> = try {
|
let res: io::Result<()> = try {
|
||||||
let mut f = BufWriter::new(File::create(&path)?);
|
let mut f = BufWriter::new(File::create(&path)?);
|
||||||
|
@ -573,12 +572,12 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.sess.target.options.is_like_osx {
|
if self.sess.target.is_like_osx {
|
||||||
if !self.is_ld {
|
if !self.is_ld {
|
||||||
arg.push("-Wl,")
|
arg.push("-Wl,")
|
||||||
}
|
}
|
||||||
arg.push("-exported_symbols_list,");
|
arg.push("-exported_symbols_list,");
|
||||||
} else if self.sess.target.options.is_like_solaris {
|
} else if self.sess.target.is_like_solaris {
|
||||||
if !self.is_ld {
|
if !self.is_ld {
|
||||||
arg.push("-Wl,")
|
arg.push("-Wl,")
|
||||||
}
|
}
|
||||||
|
@ -1203,7 +1202,7 @@ impl<'a> Linker for WasmLd<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
|
fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
|
||||||
if let Some(ref exports) = tcx.sess.target.options.override_export_symbols {
|
if let Some(ref exports) = tcx.sess.target.override_export_symbols {
|
||||||
return exports.clone();
|
return exports.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,7 +1292,7 @@ impl<'a> Linker for PtxLinker<'a> {
|
||||||
// Provide the linker with fallback to internal `target-cpu`.
|
// Provide the linker with fallback to internal `target-cpu`.
|
||||||
self.cmd.arg("--fallback-arch").arg(match self.sess.opts.cg.target_cpu {
|
self.cmd.arg("--fallback-arch").arg(match self.sess.opts.cg.target_cpu {
|
||||||
Some(ref s) => s,
|
Some(ref s) => s,
|
||||||
None => &self.sess.target.options.cpu,
|
None => &self.sess.target.cpu,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,8 +229,7 @@ fn exported_symbols_provider_local(
|
||||||
// needs to be exported.
|
// needs to be exported.
|
||||||
// However, on platforms that don't allow for Rust dylibs, having
|
// However, on platforms that don't allow for Rust dylibs, having
|
||||||
// external linkage is enough for monomorphization to be linked to.
|
// external linkage is enough for monomorphization to be linked to.
|
||||||
let need_visibility =
|
let need_visibility = tcx.sess.target.dynamic_linking && !tcx.sess.target.only_cdylib;
|
||||||
tcx.sess.target.options.dynamic_linking && !tcx.sess.target.options.only_cdylib;
|
|
||||||
|
|
||||||
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl ModuleConfig {
|
||||||
|
|
||||||
let emit_obj = if !should_emit_obj {
|
let emit_obj = if !should_emit_obj {
|
||||||
EmitObj::None
|
EmitObj::None
|
||||||
} else if sess.target.options.obj_is_bitcode
|
} else if sess.target.obj_is_bitcode
|
||||||
|| (sess.opts.cg.linker_plugin_lto.enabled() && !no_builtins)
|
|| (sess.opts.cg.linker_plugin_lto.enabled() && !no_builtins)
|
||||||
{
|
{
|
||||||
// This case is selected if the target uses objects as bitcode, or
|
// This case is selected if the target uses objects as bitcode, or
|
||||||
|
@ -221,11 +221,11 @@ impl ModuleConfig {
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
emit_obj,
|
emit_obj,
|
||||||
bc_cmdline: sess.target.options.bitcode_llvm_cmdline.clone(),
|
bc_cmdline: sess.target.bitcode_llvm_cmdline.clone(),
|
||||||
|
|
||||||
verify_llvm_ir: sess.verify_llvm_ir(),
|
verify_llvm_ir: sess.verify_llvm_ir(),
|
||||||
no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes,
|
no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes,
|
||||||
no_builtins: no_builtins || sess.target.options.no_builtins,
|
no_builtins: no_builtins || sess.target.no_builtins,
|
||||||
|
|
||||||
// Exclude metadata and allocator modules from time_passes output,
|
// Exclude metadata and allocator modules from time_passes output,
|
||||||
// since they throw off the "LLVM passes" measurement.
|
// since they throw off the "LLVM passes" measurement.
|
||||||
|
@ -252,7 +252,7 @@ impl ModuleConfig {
|
||||||
.opts
|
.opts
|
||||||
.debugging_opts
|
.debugging_opts
|
||||||
.merge_functions
|
.merge_functions
|
||||||
.unwrap_or(sess.target.options.merge_functions)
|
.unwrap_or(sess.target.merge_functions)
|
||||||
{
|
{
|
||||||
MergeFunctions::Disabled => false,
|
MergeFunctions::Disabled => false,
|
||||||
MergeFunctions::Trampolines | MergeFunctions::Aliases => {
|
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
|
let requested_for_rlib = sess.opts.cg.embed_bitcode
|
||||||
&& sess.crate_types().contains(&CrateType::Rlib)
|
&& sess.crate_types().contains(&CrateType::Rlib)
|
||||||
&& sess.opts.output_types.contains_key(&OutputType::Exe);
|
&& sess.opts.output_types.contains_key(&OutputType::Exe);
|
||||||
let forced_by_target = sess.target.options.forces_embed_bitcode;
|
let forced_by_target = sess.target.forces_embed_bitcode;
|
||||||
requested_for_rlib || forced_by_target
|
requested_for_rlib || forced_by_target
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1865,11 +1865,11 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
|
||||||
// something is wrong with commandline arg validation.
|
// something is wrong with commandline arg validation.
|
||||||
assert!(
|
assert!(
|
||||||
!(tcx.sess.opts.cg.linker_plugin_lto.enabled()
|
!(tcx.sess.opts.cg.linker_plugin_lto.enabled()
|
||||||
&& tcx.sess.target.options.is_like_windows
|
&& tcx.sess.target.is_like_windows
|
||||||
&& tcx.sess.opts.cg.prefer_dynamic)
|
&& tcx.sess.opts.cg.prefer_dynamic)
|
||||||
);
|
);
|
||||||
|
|
||||||
tcx.sess.target.options.is_like_windows &&
|
tcx.sess.target.is_like_windows &&
|
||||||
tcx.sess.crate_types().iter().any(|ct| *ct == CrateType::Rlib) &&
|
tcx.sess.crate_types().iter().any(|ct| *ct == CrateType::Rlib) &&
|
||||||
// ThinLTO can't handle this workaround in all cases, so we don't
|
// ThinLTO can't handle this workaround in all cases, so we don't
|
||||||
// emit the `__imp_` symbols. Instead we make them unnecessary by disallowing
|
// emit the `__imp_` symbols. Instead we make them unnecessary by disallowing
|
||||||
|
|
|
@ -326,7 +326,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
|
/// currently uses SEH-ish unwinding with DWARF info tables to the side (same as
|
||||||
/// 64-bit MinGW) instead of "full SEH".
|
/// 64-bit MinGW) instead of "full SEH".
|
||||||
pub fn wants_msvc_seh(sess: &Session) -> bool {
|
pub fn wants_msvc_seh(sess: &Session) -> bool {
|
||||||
sess.target.options.is_like_msvc
|
sess.target.is_like_msvc
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn memcpy_ty<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub fn memcpy_ty<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
|
@ -387,7 +387,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
) -> Bx::Function {
|
) -> Bx::Function {
|
||||||
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`,
|
// 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.
|
// depending on whether the target needs `argc` and `argv` to be passed in.
|
||||||
let llfty = if cx.sess().target.options.main_needs_argc_argv {
|
let llfty = if cx.sess().target.main_needs_argc_argv {
|
||||||
cx.type_func(&[cx.type_int(), cx.type_ptr_to(cx.type_i8p())], cx.type_int())
|
cx.type_func(&[cx.type_int(), cx.type_ptr_to(cx.type_i8p())], cx.type_int())
|
||||||
} else {
|
} else {
|
||||||
cx.type_func(&[], cx.type_int())
|
cx.type_func(&[], cx.type_int())
|
||||||
|
@ -459,7 +459,7 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
cx: &'a Bx::CodegenCx,
|
cx: &'a Bx::CodegenCx,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
) -> (Bx::Value, Bx::Value) {
|
) -> (Bx::Value, Bx::Value) {
|
||||||
if cx.sess().target.options.main_needs_argc_argv {
|
if cx.sess().target.main_needs_argc_argv {
|
||||||
// Params from native `main()` used as args for rust start function
|
// Params from native `main()` used as args for rust start function
|
||||||
let param_argc = bx.get_param(0);
|
let param_argc = bx.get_param(0);
|
||||||
let param_argv = bx.get_param(1);
|
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
|
// When targeting MSVC, emit C++ style type names for compatibility with
|
||||||
// .natvis visualizers (and perhaps other existing native debuggers?)
|
// .natvis visualizers (and perhaps other existing native debuggers?)
|
||||||
let cpp_like_names = tcx.sess.target.options.is_like_msvc;
|
let cpp_like_names = tcx.sess.target.is_like_msvc;
|
||||||
|
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Bool => output.push_str("bool"),
|
ty::Bool => output.push_str("bool"),
|
||||||
|
|
|
@ -127,7 +127,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||||
if ty == CrateType::Staticlib
|
if ty == CrateType::Staticlib
|
||||||
|| (ty == CrateType::Executable
|
|| (ty == CrateType::Executable
|
||||||
&& sess.crt_static(Some(ty))
|
&& sess.crt_static(Some(ty))
|
||||||
&& !sess.target.options.crt_static_allows_dylibs)
|
&& !sess.target.crt_static_allows_dylibs)
|
||||||
{
|
{
|
||||||
for &cnum in tcx.crates().iter() {
|
for &cnum in tcx.crates().iter() {
|
||||||
if tcx.dep_kind(cnum).macros_only() {
|
if tcx.dep_kind(cnum).macros_only() {
|
||||||
|
|
|
@ -373,11 +373,10 @@ impl<'a> CrateLocator<'a> {
|
||||||
seen_paths: &mut FxHashSet<PathBuf>,
|
seen_paths: &mut FxHashSet<PathBuf>,
|
||||||
) -> Result<Option<Library>, CrateError> {
|
) -> Result<Option<Library>, CrateError> {
|
||||||
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
|
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
|
||||||
let dylib_prefix =
|
let dylib_prefix = format!("{}{}{}", self.target.dll_prefix, self.crate_name, extra_prefix);
|
||||||
format!("{}{}{}", self.target.options.dll_prefix, self.crate_name, extra_prefix);
|
|
||||||
let rlib_prefix = format!("lib{}{}", self.crate_name, extra_prefix);
|
let rlib_prefix = format!("lib{}{}", self.crate_name, extra_prefix);
|
||||||
let staticlib_prefix =
|
let staticlib_prefix =
|
||||||
format!("{}{}{}", self.target.options.staticlib_prefix, self.crate_name, extra_prefix);
|
format!("{}{}{}", self.target.staticlib_prefix, self.crate_name, extra_prefix);
|
||||||
|
|
||||||
let mut candidates: FxHashMap<_, (FxHashMap<_, _>, FxHashMap<_, _>, FxHashMap<_, _>)> =
|
let mut candidates: FxHashMap<_, (FxHashMap<_, _>, FxHashMap<_, _>, FxHashMap<_, _>)> =
|
||||||
Default::default();
|
Default::default();
|
||||||
|
@ -405,17 +404,14 @@ impl<'a> CrateLocator<'a> {
|
||||||
(&file[(rlib_prefix.len())..(file.len() - ".rlib".len())], CrateFlavor::Rlib)
|
(&file[(rlib_prefix.len())..(file.len() - ".rlib".len())], CrateFlavor::Rlib)
|
||||||
} else if file.starts_with(&rlib_prefix) && file.ends_with(".rmeta") {
|
} else if file.starts_with(&rlib_prefix) && file.ends_with(".rmeta") {
|
||||||
(&file[(rlib_prefix.len())..(file.len() - ".rmeta".len())], CrateFlavor::Rmeta)
|
(&file[(rlib_prefix.len())..(file.len() - ".rmeta".len())], CrateFlavor::Rmeta)
|
||||||
} else if file.starts_with(&dylib_prefix)
|
} else if file.starts_with(&dylib_prefix) && file.ends_with(&self.target.dll_suffix) {
|
||||||
&& file.ends_with(&self.target.options.dll_suffix)
|
|
||||||
{
|
|
||||||
(
|
(
|
||||||
&file
|
&file[(dylib_prefix.len())..(file.len() - self.target.dll_suffix.len())],
|
||||||
[(dylib_prefix.len())..(file.len() - self.target.options.dll_suffix.len())],
|
|
||||||
CrateFlavor::Dylib,
|
CrateFlavor::Dylib,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if file.starts_with(&staticlib_prefix)
|
if file.starts_with(&staticlib_prefix)
|
||||||
&& file.ends_with(&self.target.options.staticlib_suffix)
|
&& file.ends_with(&self.target.staticlib_suffix)
|
||||||
{
|
{
|
||||||
staticlibs
|
staticlibs
|
||||||
.push(CrateMismatch { path: spf.path.clone(), got: "static".to_string() });
|
.push(CrateMismatch { path: spf.path.clone(), got: "static".to_string() });
|
||||||
|
@ -679,8 +675,8 @@ impl<'a> CrateLocator<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if file.starts_with("lib") && (file.ends_with(".rlib") || file.ends_with(".rmeta"))
|
if file.starts_with("lib") && (file.ends_with(".rlib") || file.ends_with(".rmeta"))
|
||||||
|| file.starts_with(&self.target.options.dll_prefix)
|
|| file.starts_with(&self.target.dll_prefix)
|
||||||
&& file.ends_with(&self.target.options.dll_suffix)
|
&& file.ends_with(&self.target.dll_suffix)
|
||||||
{
|
{
|
||||||
// Make sure there's at most one rlib and at most one dylib.
|
// Make sure there's at most one rlib and at most one dylib.
|
||||||
// Note to take care and match against the non-canonicalized name:
|
// Note to take care and match against the non-canonicalized name:
|
||||||
|
@ -712,8 +708,8 @@ impl<'a> CrateLocator<'a> {
|
||||||
crate_name: self.crate_name,
|
crate_name: self.crate_name,
|
||||||
root: self.root.cloned(),
|
root: self.root.cloned(),
|
||||||
triple: self.triple,
|
triple: self.triple,
|
||||||
dll_prefix: self.target.options.dll_prefix.clone(),
|
dll_prefix: self.target.dll_prefix.clone(),
|
||||||
dll_suffix: self.target.options.dll_suffix.clone(),
|
dll_suffix: self.target.dll_suffix.clone(),
|
||||||
rejected_via_hash: self.rejected_via_hash,
|
rejected_via_hash: self.rejected_via_hash,
|
||||||
rejected_via_triple: self.rejected_via_triple,
|
rejected_via_triple: self.rejected_via_triple,
|
||||||
rejected_via_kind: self.rejected_via_kind,
|
rejected_via_kind: self.rejected_via_kind,
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl Collector<'tcx> {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let is_osx = self.tcx.sess.target.options.is_like_osx;
|
let is_osx = self.tcx.sess.target.is_like_osx;
|
||||||
if lib.kind == NativeLibKind::Framework && !is_osx {
|
if lib.kind == NativeLibKind::Framework && !is_osx {
|
||||||
let msg = "native frameworks are only available on macOS targets";
|
let msg = "native frameworks are only available on macOS targets";
|
||||||
match span {
|
match span {
|
||||||
|
|
|
@ -2775,7 +2775,7 @@ where
|
||||||
// anyway, we control all calls to it in libstd.
|
// anyway, we control all calls to it in libstd.
|
||||||
Abi::Vector { .. }
|
Abi::Vector { .. }
|
||||||
if abi != SpecAbi::PlatformIntrinsic
|
if abi != SpecAbi::PlatformIntrinsic
|
||||||
&& cx.tcx().sess.target.options.simd_types_indirect =>
|
&& cx.tcx().sess.target.simd_types_indirect =>
|
||||||
{
|
{
|
||||||
arg.make_indirect();
|
arg.make_indirect();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -532,7 +532,7 @@ fn mono_item_visibility(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibility {
|
fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibility {
|
||||||
if !tcx.sess.target.options.default_hidden_visibility {
|
if !tcx.sess.target.default_hidden_visibility {
|
||||||
return Visibility::Default;
|
return Visibility::Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
|
||||||
if items.eh_personality().is_none() {
|
if items.eh_personality().is_none() {
|
||||||
items.missing.push(LangItem::EhPersonality);
|
items.missing.push(LangItem::EhPersonality);
|
||||||
}
|
}
|
||||||
if tcx.sess.target.options.is_like_emscripten && items.eh_catch_typeinfo().is_none() {
|
if tcx.sess.target.is_like_emscripten && items.eh_catch_typeinfo().is_none() {
|
||||||
items.missing.push(LangItem::EhCatchTypeinfo);
|
items.missing.push(LangItem::EhCatchTypeinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -743,7 +743,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
|
||||||
let vendor = &sess.target.target_vendor;
|
let vendor = &sess.target.target_vendor;
|
||||||
let min_atomic_width = sess.target.min_atomic_width();
|
let min_atomic_width = sess.target.min_atomic_width();
|
||||||
let max_atomic_width = sess.target.max_atomic_width();
|
let max_atomic_width = sess.target.max_atomic_width();
|
||||||
let atomic_cas = sess.target.options.atomic_cas;
|
let atomic_cas = sess.target.atomic_cas;
|
||||||
let layout = TargetDataLayout::parse(&sess.target).unwrap_or_else(|err| {
|
let layout = TargetDataLayout::parse(&sess.target).unwrap_or_else(|err| {
|
||||||
sess.fatal(&err);
|
sess.fatal(&err);
|
||||||
});
|
});
|
||||||
|
@ -752,7 +752,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
|
||||||
ret.reserve(6); // the minimum number of insertions
|
ret.reserve(6); // the minimum number of insertions
|
||||||
// Target bindings.
|
// Target bindings.
|
||||||
ret.insert((sym::target_os, Some(Symbol::intern(os))));
|
ret.insert((sym::target_os, Some(Symbol::intern(os))));
|
||||||
if let Some(ref fam) = sess.target.options.target_family {
|
if let Some(ref fam) = sess.target.target_family {
|
||||||
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
|
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
|
||||||
if fam == "windows" {
|
if fam == "windows" {
|
||||||
ret.insert((sym::windows, None));
|
ret.insert((sym::windows, None));
|
||||||
|
@ -765,7 +765,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
|
||||||
ret.insert((sym::target_pointer_width, Some(Symbol::intern(&wordsz))));
|
ret.insert((sym::target_pointer_width, Some(Symbol::intern(&wordsz))));
|
||||||
ret.insert((sym::target_env, Some(Symbol::intern(env))));
|
ret.insert((sym::target_env, Some(Symbol::intern(env))));
|
||||||
ret.insert((sym::target_vendor, Some(Symbol::intern(vendor))));
|
ret.insert((sym::target_vendor, Some(Symbol::intern(vendor))));
|
||||||
if sess.target.options.has_elf_tls {
|
if sess.target.has_elf_tls {
|
||||||
ret.insert((sym::target_thread_local, None));
|
ret.insert((sym::target_thread_local, None));
|
||||||
}
|
}
|
||||||
for &(i, align) in &[
|
for &(i, align) in &[
|
||||||
|
|
|
@ -150,17 +150,15 @@ pub fn filename_for_input(
|
||||||
match crate_type {
|
match crate_type {
|
||||||
CrateType::Rlib => outputs.out_directory.join(&format!("lib{}.rlib", libname)),
|
CrateType::Rlib => outputs.out_directory.join(&format!("lib{}.rlib", libname)),
|
||||||
CrateType::Cdylib | CrateType::ProcMacro | CrateType::Dylib => {
|
CrateType::Cdylib | CrateType::ProcMacro | CrateType::Dylib => {
|
||||||
let (prefix, suffix) =
|
let (prefix, suffix) = (&sess.target.dll_prefix, &sess.target.dll_suffix);
|
||||||
(&sess.target.options.dll_prefix, &sess.target.options.dll_suffix);
|
|
||||||
outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
|
outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
|
||||||
}
|
}
|
||||||
CrateType::Staticlib => {
|
CrateType::Staticlib => {
|
||||||
let (prefix, suffix) =
|
let (prefix, suffix) = (&sess.target.staticlib_prefix, &sess.target.staticlib_suffix);
|
||||||
(&sess.target.options.staticlib_prefix, &sess.target.options.staticlib_suffix);
|
|
||||||
outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
|
outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
|
||||||
}
|
}
|
||||||
CrateType::Executable => {
|
CrateType::Executable => {
|
||||||
let suffix = &sess.target.options.exe_suffix;
|
let suffix = &sess.target.exe_suffix;
|
||||||
let out_filename = outputs.path(OutputType::Exe);
|
let out_filename = outputs.path(OutputType::Exe);
|
||||||
if suffix.is_empty() { out_filename } else { out_filename.with_extension(&suffix[1..]) }
|
if suffix.is_empty() { out_filename } else { out_filename.with_extension(&suffix[1..]) }
|
||||||
}
|
}
|
||||||
|
@ -177,29 +175,29 @@ pub fn filename_for_input(
|
||||||
/// interaction with Rust code through static library is the only
|
/// interaction with Rust code through static library is the only
|
||||||
/// option for now
|
/// option for now
|
||||||
pub fn default_output_for_target(sess: &Session) -> CrateType {
|
pub fn default_output_for_target(sess: &Session) -> CrateType {
|
||||||
if !sess.target.options.executables { CrateType::Staticlib } else { CrateType::Executable }
|
if !sess.target.executables { CrateType::Staticlib } else { CrateType::Executable }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if target supports crate_type as output
|
/// Checks if target supports crate_type as output
|
||||||
pub fn invalid_output_for_target(sess: &Session, crate_type: CrateType) -> bool {
|
pub fn invalid_output_for_target(sess: &Session, crate_type: CrateType) -> bool {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
CrateType::Cdylib | CrateType::Dylib | CrateType::ProcMacro => {
|
CrateType::Cdylib | CrateType::Dylib | CrateType::ProcMacro => {
|
||||||
if !sess.target.options.dynamic_linking {
|
if !sess.target.dynamic_linking {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if sess.crt_static(Some(crate_type)) && !sess.target.options.crt_static_allows_dylibs {
|
if sess.crt_static(Some(crate_type)) && !sess.target.crt_static_allows_dylibs {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
if sess.target.options.only_cdylib {
|
if sess.target.only_cdylib {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
CrateType::ProcMacro | CrateType::Dylib => return true,
|
CrateType::ProcMacro | CrateType::Dylib => return true,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !sess.target.options.executables && crate_type == CrateType::Executable {
|
if !sess.target.executables && crate_type == CrateType::Executable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -663,7 +663,7 @@ impl Session {
|
||||||
/// Calculates the flavor of LTO to use for this compilation.
|
/// Calculates the flavor of LTO to use for this compilation.
|
||||||
pub fn lto(&self) -> config::Lto {
|
pub fn lto(&self) -> config::Lto {
|
||||||
// If our target has codegen requirements ignore the command line
|
// If our target has codegen requirements ignore the command line
|
||||||
if self.target.options.requires_lto {
|
if self.target.requires_lto {
|
||||||
return config::Lto::Fat;
|
return config::Lto::Fat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ impl Session {
|
||||||
/// Returns the panic strategy for this compile session. If the user explicitly selected one
|
/// Returns the panic strategy for this compile session. If the user explicitly selected one
|
||||||
/// using '-C panic', use that, otherwise use the panic strategy defined by the target.
|
/// using '-C panic', use that, otherwise use the panic strategy defined by the target.
|
||||||
pub fn panic_strategy(&self) -> PanicStrategy {
|
pub fn panic_strategy(&self) -> PanicStrategy {
|
||||||
self.opts.cg.panic.unwrap_or(self.target.options.panic_strategy)
|
self.opts.cg.panic.unwrap_or(self.target.panic_strategy)
|
||||||
}
|
}
|
||||||
pub fn fewer_names(&self) -> bool {
|
pub fn fewer_names(&self) -> bool {
|
||||||
let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly)
|
let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly)
|
||||||
|
@ -755,9 +755,9 @@ impl Session {
|
||||||
|
|
||||||
/// Check whether this compile session and crate type use static crt.
|
/// Check whether this compile session and crate type use static crt.
|
||||||
pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool {
|
pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool {
|
||||||
if !self.target.options.crt_static_respected {
|
if !self.target.crt_static_respected {
|
||||||
// If the target does not opt in to crt-static support, use its default.
|
// If the target does not opt in to crt-static support, use its default.
|
||||||
return self.target.options.crt_static_default;
|
return self.target.crt_static_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
let requested_features = self.opts.cg.target_feature.split(',');
|
let requested_features = self.opts.cg.target_feature.split(',');
|
||||||
|
@ -774,20 +774,20 @@ impl Session {
|
||||||
// We can't check `#![crate_type = "proc-macro"]` here.
|
// We can't check `#![crate_type = "proc-macro"]` here.
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
self.target.options.crt_static_default
|
self.target.crt_static_default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn relocation_model(&self) -> RelocModel {
|
pub fn relocation_model(&self) -> RelocModel {
|
||||||
self.opts.cg.relocation_model.unwrap_or(self.target.options.relocation_model)
|
self.opts.cg.relocation_model.unwrap_or(self.target.relocation_model)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn code_model(&self) -> Option<CodeModel> {
|
pub fn code_model(&self) -> Option<CodeModel> {
|
||||||
self.opts.cg.code_model.or(self.target.options.code_model)
|
self.opts.cg.code_model.or(self.target.code_model)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tls_model(&self) -> TlsModel {
|
pub fn tls_model(&self) -> TlsModel {
|
||||||
self.opts.debugging_opts.tls_model.unwrap_or(self.target.options.tls_model)
|
self.opts.debugging_opts.tls_model.unwrap_or(self.target.tls_model)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn must_not_eliminate_frame_pointers(&self) -> bool {
|
pub fn must_not_eliminate_frame_pointers(&self) -> bool {
|
||||||
|
@ -798,7 +798,7 @@ impl Session {
|
||||||
} else if let Some(x) = self.opts.cg.force_frame_pointers {
|
} else if let Some(x) = self.opts.cg.force_frame_pointers {
|
||||||
x
|
x
|
||||||
} else {
|
} else {
|
||||||
!self.target.options.eliminate_frame_pointer
|
!self.target.eliminate_frame_pointer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,7 +822,7 @@ impl Session {
|
||||||
// value, if it is provided, or disable them, if not.
|
// value, if it is provided, or disable them, if not.
|
||||||
if self.panic_strategy() == PanicStrategy::Unwind {
|
if self.panic_strategy() == PanicStrategy::Unwind {
|
||||||
true
|
true
|
||||||
} else if self.target.options.requires_uwtable {
|
} else if self.target.requires_uwtable {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
self.opts.cg.force_unwind_tables.unwrap_or(false)
|
self.opts.cg.force_unwind_tables.unwrap_or(false)
|
||||||
|
@ -993,7 +993,7 @@ impl Session {
|
||||||
if let Some(n) = self.opts.cli_forced_codegen_units {
|
if let Some(n) = self.opts.cli_forced_codegen_units {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
if let Some(n) = self.target.options.default_codegen_units {
|
if let Some(n) = self.target.default_codegen_units {
|
||||||
return n as usize;
|
return n as usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,11 +1078,11 @@ impl Session {
|
||||||
pub fn needs_plt(&self) -> bool {
|
pub fn needs_plt(&self) -> bool {
|
||||||
// Check if the current target usually needs PLT to be enabled.
|
// Check if the current target usually needs PLT to be enabled.
|
||||||
// The user can use the command line flag to override it.
|
// The user can use the command line flag to override it.
|
||||||
let needs_plt = self.target.options.needs_plt;
|
let needs_plt = self.target.needs_plt;
|
||||||
|
|
||||||
let dbg_opts = &self.opts.debugging_opts;
|
let dbg_opts = &self.opts.debugging_opts;
|
||||||
|
|
||||||
let relro_level = dbg_opts.relro_level.unwrap_or(self.target.options.relro_level);
|
let relro_level = dbg_opts.relro_level.unwrap_or(self.target.relro_level);
|
||||||
|
|
||||||
// Only enable this optimization by default if full relro is also enabled.
|
// Only enable this optimization by default if full relro is also enabled.
|
||||||
// In this case, lazy binding was already unavailable, so nothing is lost.
|
// In this case, lazy binding was already unavailable, so nothing is lost.
|
||||||
|
@ -1106,7 +1106,7 @@ impl Session {
|
||||||
match self.opts.cg.link_dead_code {
|
match self.opts.cg.link_dead_code {
|
||||||
Some(explicitly_set) => explicitly_set,
|
Some(explicitly_set) => explicitly_set,
|
||||||
None => {
|
None => {
|
||||||
self.opts.debugging_opts.instrument_coverage && !self.target.options.is_like_msvc
|
self.opts.debugging_opts.instrument_coverage && !self.target.is_like_msvc
|
||||||
// Issue #76038: (rustc `-Clink-dead-code` causes MSVC linker to produce invalid
|
// Issue #76038: (rustc `-Clink-dead-code` causes MSVC linker to produce invalid
|
||||||
// binaries when LLVM InstrProf counters are enabled). As described by this issue,
|
// binaries when LLVM InstrProf counters are enabled). As described by this issue,
|
||||||
// the "link dead code" option produces incorrect binaries when compiled and linked
|
// the "link dead code" option produces incorrect binaries when compiled and linked
|
||||||
|
@ -1307,7 +1307,7 @@ pub fn build_session(
|
||||||
|
|
||||||
let loader = file_loader.unwrap_or(Box::new(RealFileLoader));
|
let loader = file_loader.unwrap_or(Box::new(RealFileLoader));
|
||||||
let hash_kind = sopts.debugging_opts.src_hash_algorithm.unwrap_or_else(|| {
|
let hash_kind = sopts.debugging_opts.src_hash_algorithm.unwrap_or_else(|| {
|
||||||
if target_cfg.options.is_like_msvc {
|
if target_cfg.is_like_msvc {
|
||||||
SourceFileHashAlgorithm::Sha1
|
SourceFileHashAlgorithm::Sha1
|
||||||
} else {
|
} else {
|
||||||
SourceFileHashAlgorithm::Md5
|
SourceFileHashAlgorithm::Md5
|
||||||
|
@ -1417,11 +1417,8 @@ pub fn build_session(
|
||||||
if candidate.join("library/std/src/lib.rs").is_file() { Some(candidate) } else { None }
|
if candidate.join("library/std/src/lib.rs").is_file() { Some(candidate) } else { None }
|
||||||
};
|
};
|
||||||
|
|
||||||
let asm_arch = if target_cfg.options.allow_asm {
|
let asm_arch =
|
||||||
InlineAsmArch::from_str(&target_cfg.arch).ok()
|
if target_cfg.allow_asm { InlineAsmArch::from_str(&target_cfg.arch).ok() } else { None };
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let sess = Session {
|
let sess = Session {
|
||||||
target: target_cfg,
|
target: target_cfg,
|
||||||
|
@ -1487,7 +1484,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
|
||||||
// the `dllimport` attributes and `__imp_` symbols in that case.
|
// the `dllimport` attributes and `__imp_` symbols in that case.
|
||||||
if sess.opts.cg.linker_plugin_lto.enabled()
|
if sess.opts.cg.linker_plugin_lto.enabled()
|
||||||
&& sess.opts.cg.prefer_dynamic
|
&& sess.opts.cg.prefer_dynamic
|
||||||
&& sess.target.options.is_like_windows
|
&& sess.target.is_like_windows
|
||||||
{
|
{
|
||||||
sess.err(
|
sess.err(
|
||||||
"Linker plugin based LTO is not supported together with \
|
"Linker plugin based LTO is not supported together with \
|
||||||
|
@ -1515,7 +1512,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if sess.target.options.requires_uwtable && !include_uwtables {
|
if sess.target.requires_uwtable && !include_uwtables {
|
||||||
sess.err(
|
sess.err(
|
||||||
"target requires unwind tables, they cannot be disabled with \
|
"target requires unwind tables, they cannot be disabled with \
|
||||||
`-C force-unwind-tables=no`.",
|
`-C force-unwind-tables=no`.",
|
||||||
|
@ -1530,7 +1527,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
|
||||||
// We should only display this error if we're actually going to run PGO.
|
// We should only display this error if we're actually going to run PGO.
|
||||||
// If we're just supposed to print out some data, don't show the error (#61002).
|
// If we're just supposed to print out some data, don't show the error (#61002).
|
||||||
if sess.opts.cg.profile_generate.enabled()
|
if sess.opts.cg.profile_generate.enabled()
|
||||||
&& sess.target.options.is_like_msvc
|
&& sess.target.is_like_msvc
|
||||||
&& sess.panic_strategy() == PanicStrategy::Unwind
|
&& sess.panic_strategy() == PanicStrategy::Unwind
|
||||||
&& sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs)
|
&& sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -562,7 +562,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
||||||
"x86_64" => {
|
"x86_64" => {
|
||||||
if abi == spec::abi::Abi::SysV64 {
|
if abi == spec::abi::Abi::SysV64 {
|
||||||
x86_64::compute_abi_info(cx, self);
|
x86_64::compute_abi_info(cx, self);
|
||||||
} else if abi == spec::abi::Abi::Win64 || cx.target_spec().options.is_like_windows {
|
} else if abi == spec::abi::Abi::Win64 || cx.target_spec().is_like_windows {
|
||||||
x86_win64::compute_abi_info(self);
|
x86_win64::compute_abi_info(self);
|
||||||
} else {
|
} else {
|
||||||
x86_64::compute_abi_info(cx, self);
|
x86_64::compute_abi_info(cx, self);
|
||||||
|
|
|
@ -323,7 +323,7 @@ where
|
||||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||||
{
|
{
|
||||||
let flen = match &cx.target_spec().options.llvm_abiname[..] {
|
let flen = match &cx.target_spec().llvm_abiname[..] {
|
||||||
"ilp32f" | "lp64f" => 32,
|
"ilp32f" | "lp64f" => 32,
|
||||||
"ilp32d" | "lp64d" => 64,
|
"ilp32d" | "lp64d" => 64,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
|
|
|
@ -41,10 +41,10 @@ where
|
||||||
// http://www.angelcode.com/dev/callconv/callconv.html
|
// http://www.angelcode.com/dev/callconv/callconv.html
|
||||||
// Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
|
// Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
|
||||||
let t = cx.target_spec();
|
let t = cx.target_spec();
|
||||||
if t.options.abi_return_struct_as_int {
|
if t.abi_return_struct_as_int {
|
||||||
// According to Clang, everyone but MSVC returns single-element
|
// According to Clang, everyone but MSVC returns single-element
|
||||||
// float aggregates directly in a floating-point register.
|
// float aggregates directly in a floating-point register.
|
||||||
if !t.options.is_like_msvc && is_single_fp_element(cx, fn_abi.ret.layout) {
|
if !t.is_like_msvc && is_single_fp_element(cx, fn_abi.ret.layout) {
|
||||||
match fn_abi.ret.layout.size.bytes() {
|
match fn_abi.ret.layout.size.bytes() {
|
||||||
4 => fn_abi.ret.cast_to(Reg::f32()),
|
4 => fn_abi.ret.cast_to(Reg::f32()),
|
||||||
8 => fn_abi.ret.cast_to(Reg::f64()),
|
8 => fn_abi.ret.cast_to(Reg::f64()),
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl ArmInlineAsmRegClass {
|
||||||
|
|
||||||
// This uses the same logic as useR7AsFramePointer in LLVM
|
// This uses the same logic as useR7AsFramePointer in LLVM
|
||||||
fn frame_pointer_is_r7(mut has_feature: impl FnMut(&str) -> bool, target: &Target) -> bool {
|
fn frame_pointer_is_r7(mut has_feature: impl FnMut(&str) -> bool, target: &Target) -> bool {
|
||||||
target.options.is_like_osx || (!target.options.is_like_windows && has_feature("thumb-mode"))
|
target.is_like_osx || (!target.is_like_windows && has_feature("thumb-mode"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame_pointer_r11(
|
fn frame_pointer_r11(
|
||||||
|
|
|
@ -3,7 +3,6 @@ use super::{wasm32_unknown_emscripten, LinkerFlavor, Target};
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut target = wasm32_unknown_emscripten::target();
|
let mut target = wasm32_unknown_emscripten::target();
|
||||||
target
|
target
|
||||||
.options
|
|
||||||
.post_link_args
|
.post_link_args
|
||||||
.entry(LinkerFlavor::Em)
|
.entry(LinkerFlavor::Em)
|
||||||
.or_default()
|
.or_default()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::spec::Target;
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut base = super::i686_pc_windows_msvc::target();
|
let mut base = super::i686_pc_windows_msvc::target();
|
||||||
base.options.cpu = "pentium".to_string();
|
base.cpu = "pentium".to_string();
|
||||||
base.llvm_target = "i586-pc-windows-msvc".to_string();
|
base.llvm_target = "i586-pc-windows-msvc".to_string();
|
||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::spec::Target;
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut base = super::i686_unknown_linux_gnu::target();
|
let mut base = super::i686_unknown_linux_gnu::target();
|
||||||
base.options.cpu = "pentium".to_string();
|
base.cpu = "pentium".to_string();
|
||||||
base.llvm_target = "i586-unknown-linux-gnu".to_string();
|
base.llvm_target = "i586-unknown-linux-gnu".to_string();
|
||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::spec::Target;
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut base = super::i686_unknown_linux_musl::target();
|
let mut base = super::i686_unknown_linux_musl::target();
|
||||||
base.options.cpu = "pentium".to_string();
|
base.cpu = "pentium".to_string();
|
||||||
base.llvm_target = "i586-unknown-linux-musl".to_string();
|
base.llvm_target = "i586-unknown-linux-musl".to_string();
|
||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ use crate::spec::abi::{lookup as lookup_abi, Abi};
|
||||||
use crate::spec::crt_objects::{CrtObjects, CrtObjectsFallback};
|
use crate::spec::crt_objects::{CrtObjects, CrtObjectsFallback};
|
||||||
use rustc_serialize::json::{Json, ToJson};
|
use rustc_serialize::json::{Json, ToJson};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::ops::Deref;
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::{fmt, io};
|
use std::{fmt, io};
|
||||||
|
@ -446,7 +446,7 @@ macro_rules! supported_targets {
|
||||||
$( $($triple)|+ => $module::target(), )+
|
$( $($triple)|+ => $module::target(), )+
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
t.options.is_builtin = true;
|
t.is_builtin = true;
|
||||||
debug!("got builtin target: {:?}", t);
|
debug!("got builtin target: {:?}", t);
|
||||||
Some(t)
|
Some(t)
|
||||||
}
|
}
|
||||||
|
@ -691,6 +691,10 @@ impl HasTargetSpec for Target {
|
||||||
///
|
///
|
||||||
/// This has an implementation of `Default`, see each field for what the default is. In general,
|
/// This has an implementation of `Default`, see each field for what the default is. In general,
|
||||||
/// these try to take "minimal defaults" that don't assume anything about the runtime they run in.
|
/// these try to take "minimal defaults" that don't assume anything about the runtime they run in.
|
||||||
|
///
|
||||||
|
/// `TargetOptions` as a separate structure is mostly an implementation detail of `Target`
|
||||||
|
/// construction, all its fields logically belong to `Target` and available from `Target`
|
||||||
|
/// through `Deref` impls.
|
||||||
#[derive(PartialEq, Clone, Debug)]
|
#[derive(PartialEq, Clone, Debug)]
|
||||||
pub struct TargetOptions {
|
pub struct TargetOptions {
|
||||||
/// Whether the target is built-in or loaded from a custom target specification.
|
/// Whether the target is built-in or loaded from a custom target specification.
|
||||||
|
@ -1094,13 +1098,18 @@ impl Deref for Target {
|
||||||
&self.options
|
&self.options
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl DerefMut for Target {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.options
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Target {
|
impl Target {
|
||||||
/// Given a function ABI, turn it into the correct ABI for this target.
|
/// Given a function ABI, turn it into the correct ABI for this target.
|
||||||
pub fn adjust_abi(&self, abi: Abi) -> Abi {
|
pub fn adjust_abi(&self, abi: Abi) -> Abi {
|
||||||
match abi {
|
match abi {
|
||||||
Abi::System => {
|
Abi::System => {
|
||||||
if self.options.is_like_windows && self.arch == "x86" {
|
if self.is_like_windows && self.arch == "x86" {
|
||||||
Abi::Stdcall
|
Abi::Stdcall
|
||||||
} else {
|
} else {
|
||||||
Abi::C
|
Abi::C
|
||||||
|
@ -1110,7 +1119,7 @@ impl Target {
|
||||||
// See https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions
|
// See https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions
|
||||||
// and the individual pages for __stdcall et al.
|
// and the individual pages for __stdcall et al.
|
||||||
Abi::Stdcall | Abi::Fastcall | Abi::Vectorcall | Abi::Thiscall => {
|
Abi::Stdcall | Abi::Fastcall | Abi::Vectorcall | Abi::Thiscall => {
|
||||||
if self.options.is_like_windows && self.arch != "x86" { Abi::C } else { abi }
|
if self.is_like_windows && self.arch != "x86" { Abi::C } else { abi }
|
||||||
}
|
}
|
||||||
Abi::EfiApi => {
|
Abi::EfiApi => {
|
||||||
if self.arch == "x86_64" {
|
if self.arch == "x86_64" {
|
||||||
|
@ -1126,17 +1135,17 @@ impl Target {
|
||||||
/// Minimum integer size in bits that this target can perform atomic
|
/// Minimum integer size in bits that this target can perform atomic
|
||||||
/// operations on.
|
/// operations on.
|
||||||
pub fn min_atomic_width(&self) -> u64 {
|
pub fn min_atomic_width(&self) -> u64 {
|
||||||
self.options.min_atomic_width.unwrap_or(8)
|
self.min_atomic_width.unwrap_or(8)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maximum integer size in bits that this target can perform atomic
|
/// Maximum integer size in bits that this target can perform atomic
|
||||||
/// operations on.
|
/// operations on.
|
||||||
pub fn max_atomic_width(&self) -> u64 {
|
pub fn max_atomic_width(&self) -> u64 {
|
||||||
self.options.max_atomic_width.unwrap_or_else(|| self.pointer_width.into())
|
self.max_atomic_width.unwrap_or_else(|| self.pointer_width.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_abi_supported(&self, abi: Abi) -> bool {
|
pub fn is_abi_supported(&self, abi: Abi) -> bool {
|
||||||
abi.generic() || !self.options.unsupported_abis.contains(&abi)
|
abi.generic() || !self.unsupported_abis.contains(&abi)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads a target descriptor from a JSON object.
|
/// Loads a target descriptor from a JSON object.
|
||||||
|
@ -1169,19 +1178,19 @@ impl Target {
|
||||||
($key_name:ident) => ( {
|
($key_name:ident) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
if let Some(s) = obj.find(&name).and_then(Json::as_string) {
|
if let Some(s) = obj.find(&name).and_then(Json::as_string) {
|
||||||
base.options.$key_name = s.to_string();
|
base.$key_name = s.to_string();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident = $json_name:expr) => ( {
|
($key_name:ident = $json_name:expr) => ( {
|
||||||
let name = $json_name;
|
let name = $json_name;
|
||||||
if let Some(s) = obj.find(&name).and_then(Json::as_string) {
|
if let Some(s) = obj.find(&name).and_then(Json::as_string) {
|
||||||
base.options.$key_name = s.to_string();
|
base.$key_name = s.to_string();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident, bool) => ( {
|
($key_name:ident, bool) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
if let Some(s) = obj.find(&name).and_then(Json::as_boolean) {
|
if let Some(s) = obj.find(&name).and_then(Json::as_boolean) {
|
||||||
base.options.$key_name = s;
|
base.$key_name = s;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident, Option<u32>) => ( {
|
($key_name:ident, Option<u32>) => ( {
|
||||||
|
@ -1190,20 +1199,20 @@ impl Target {
|
||||||
if s < 1 || s > 5 {
|
if s < 1 || s > 5 {
|
||||||
return Err("Not a valid DWARF version number".to_string());
|
return Err("Not a valid DWARF version number".to_string());
|
||||||
}
|
}
|
||||||
base.options.$key_name = Some(s as u32);
|
base.$key_name = Some(s as u32);
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident, Option<u64>) => ( {
|
($key_name:ident, Option<u64>) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
if let Some(s) = obj.find(&name).and_then(Json::as_u64) {
|
if let Some(s) = obj.find(&name).and_then(Json::as_u64) {
|
||||||
base.options.$key_name = Some(s);
|
base.$key_name = Some(s);
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident, MergeFunctions) => ( {
|
($key_name:ident, MergeFunctions) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match s.parse::<MergeFunctions>() {
|
match s.parse::<MergeFunctions>() {
|
||||||
Ok(mergefunc) => base.options.$key_name = mergefunc,
|
Ok(mergefunc) => base.$key_name = mergefunc,
|
||||||
_ => return Some(Err(format!("'{}' is not a valid value for \
|
_ => return Some(Err(format!("'{}' is not a valid value for \
|
||||||
merge-functions. Use 'disabled', \
|
merge-functions. Use 'disabled', \
|
||||||
'trampolines', or 'aliases'.",
|
'trampolines', or 'aliases'.",
|
||||||
|
@ -1216,7 +1225,7 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match s.parse::<RelocModel>() {
|
match s.parse::<RelocModel>() {
|
||||||
Ok(relocation_model) => base.options.$key_name = relocation_model,
|
Ok(relocation_model) => base.$key_name = relocation_model,
|
||||||
_ => return Some(Err(format!("'{}' is not a valid relocation model. \
|
_ => return Some(Err(format!("'{}' is not a valid relocation model. \
|
||||||
Run `rustc --print relocation-models` to \
|
Run `rustc --print relocation-models` to \
|
||||||
see the list of supported values.", s))),
|
see the list of supported values.", s))),
|
||||||
|
@ -1228,7 +1237,7 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match s.parse::<CodeModel>() {
|
match s.parse::<CodeModel>() {
|
||||||
Ok(code_model) => base.options.$key_name = Some(code_model),
|
Ok(code_model) => base.$key_name = Some(code_model),
|
||||||
_ => return Some(Err(format!("'{}' is not a valid code model. \
|
_ => return Some(Err(format!("'{}' is not a valid code model. \
|
||||||
Run `rustc --print code-models` to \
|
Run `rustc --print code-models` to \
|
||||||
see the list of supported values.", s))),
|
see the list of supported values.", s))),
|
||||||
|
@ -1240,7 +1249,7 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match s.parse::<TlsModel>() {
|
match s.parse::<TlsModel>() {
|
||||||
Ok(tls_model) => base.options.$key_name = tls_model,
|
Ok(tls_model) => base.$key_name = tls_model,
|
||||||
_ => return Some(Err(format!("'{}' is not a valid TLS model. \
|
_ => return Some(Err(format!("'{}' is not a valid TLS model. \
|
||||||
Run `rustc --print tls-models` to \
|
Run `rustc --print tls-models` to \
|
||||||
see the list of supported values.", s))),
|
see the list of supported values.", s))),
|
||||||
|
@ -1252,8 +1261,8 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match s {
|
match s {
|
||||||
"unwind" => base.options.$key_name = PanicStrategy::Unwind,
|
"unwind" => base.$key_name = PanicStrategy::Unwind,
|
||||||
"abort" => base.options.$key_name = PanicStrategy::Abort,
|
"abort" => base.$key_name = PanicStrategy::Abort,
|
||||||
_ => return Some(Err(format!("'{}' is not a valid value for \
|
_ => return Some(Err(format!("'{}' is not a valid value for \
|
||||||
panic-strategy. Use 'unwind' or 'abort'.",
|
panic-strategy. Use 'unwind' or 'abort'.",
|
||||||
s))),
|
s))),
|
||||||
|
@ -1265,7 +1274,7 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match s.parse::<RelroLevel>() {
|
match s.parse::<RelroLevel>() {
|
||||||
Ok(level) => base.options.$key_name = level,
|
Ok(level) => base.$key_name = level,
|
||||||
_ => return Some(Err(format!("'{}' is not a valid value for \
|
_ => return Some(Err(format!("'{}' is not a valid value for \
|
||||||
relro-level. Use 'full', 'partial, or 'off'.",
|
relro-level. Use 'full', 'partial, or 'off'.",
|
||||||
s))),
|
s))),
|
||||||
|
@ -1276,7 +1285,7 @@ impl Target {
|
||||||
($key_name:ident, list) => ( {
|
($key_name:ident, list) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
if let Some(v) = obj.find(&name).and_then(Json::as_array) {
|
if let Some(v) = obj.find(&name).and_then(Json::as_array) {
|
||||||
base.options.$key_name = v.iter()
|
base.$key_name = v.iter()
|
||||||
.map(|a| a.as_string().unwrap().to_string())
|
.map(|a| a.as_string().unwrap().to_string())
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
|
@ -1284,7 +1293,7 @@ impl Target {
|
||||||
($key_name:ident, opt_list) => ( {
|
($key_name:ident, opt_list) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
if let Some(v) = obj.find(&name).and_then(Json::as_array) {
|
if let Some(v) = obj.find(&name).and_then(Json::as_array) {
|
||||||
base.options.$key_name = Some(v.iter()
|
base.$key_name = Some(v.iter()
|
||||||
.map(|a| a.as_string().unwrap().to_string())
|
.map(|a| a.as_string().unwrap().to_string())
|
||||||
.collect());
|
.collect());
|
||||||
}
|
}
|
||||||
|
@ -1292,7 +1301,7 @@ impl Target {
|
||||||
($key_name:ident, optional) => ( {
|
($key_name:ident, optional) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
if let Some(o) = obj.find(&name[..]) {
|
if let Some(o) = obj.find(&name[..]) {
|
||||||
base.options.$key_name = o
|
base.$key_name = o
|
||||||
.as_string()
|
.as_string()
|
||||||
.map(|s| s.to_string() );
|
.map(|s| s.to_string() );
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1310,7 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
if let Some(flavor) = LldFlavor::from_str(&s) {
|
if let Some(flavor) = LldFlavor::from_str(&s) {
|
||||||
base.options.$key_name = flavor;
|
base.$key_name = flavor;
|
||||||
} else {
|
} else {
|
||||||
return Some(Err(format!(
|
return Some(Err(format!(
|
||||||
"'{}' is not a valid value for lld-flavor. \
|
"'{}' is not a valid value for lld-flavor. \
|
||||||
|
@ -1315,7 +1324,7 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match LinkerFlavor::from_str(s) {
|
match LinkerFlavor::from_str(s) {
|
||||||
Some(linker_flavor) => base.options.$key_name = linker_flavor,
|
Some(linker_flavor) => base.$key_name = linker_flavor,
|
||||||
_ => return Some(Err(format!("'{}' is not a valid value for linker-flavor. \
|
_ => return Some(Err(format!("'{}' is not a valid value for linker-flavor. \
|
||||||
Use {}", s, LinkerFlavor::one_of()))),
|
Use {}", s, LinkerFlavor::one_of()))),
|
||||||
}
|
}
|
||||||
|
@ -1326,7 +1335,7 @@ impl Target {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
match s.parse::<CrtObjectsFallback>() {
|
match s.parse::<CrtObjectsFallback>() {
|
||||||
Ok(fallback) => base.options.$key_name = Some(fallback),
|
Ok(fallback) => base.$key_name = Some(fallback),
|
||||||
_ => return Some(Err(format!("'{}' is not a valid CRT objects fallback. \
|
_ => return Some(Err(format!("'{}' is not a valid CRT objects fallback. \
|
||||||
Use 'musl', 'mingw' or 'wasm'", s))),
|
Use 'musl', 'mingw' or 'wasm'", s))),
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1367,7 @@ impl Target {
|
||||||
|
|
||||||
args.insert(kind, v);
|
args.insert(kind, v);
|
||||||
}
|
}
|
||||||
base.options.$key_name = args;
|
base.$key_name = args;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident, link_args) => ( {
|
($key_name:ident, link_args) => ( {
|
||||||
|
@ -1385,7 +1394,7 @@ impl Target {
|
||||||
|
|
||||||
args.insert(flavor, v);
|
args.insert(flavor, v);
|
||||||
}
|
}
|
||||||
base.options.$key_name = args;
|
base.$key_name = args;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident, env) => ( {
|
($key_name:ident, env) => ( {
|
||||||
|
@ -1397,7 +1406,7 @@ impl Target {
|
||||||
if p.len() == 2 {
|
if p.len() == 2 {
|
||||||
let k = p[0].to_string();
|
let k = p[0].to_string();
|
||||||
let v = p[1].to_string();
|
let v = p[1].to_string();
|
||||||
base.options.$key_name.push((k, v));
|
base.$key_name.push((k, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1513,7 +1522,7 @@ impl Target {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
base.options.unsupported_abis.push(abi)
|
base.unsupported_abis.push(abi)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
|
@ -1602,21 +1611,20 @@ impl ToJson for Target {
|
||||||
macro_rules! target_option_val {
|
macro_rules! target_option_val {
|
||||||
($attr:ident) => {{
|
($attr:ident) => {{
|
||||||
let name = (stringify!($attr)).replace("_", "-");
|
let name = (stringify!($attr)).replace("_", "-");
|
||||||
if default.$attr != self.options.$attr {
|
if default.$attr != self.$attr {
|
||||||
d.insert(name, self.options.$attr.to_json());
|
d.insert(name, self.$attr.to_json());
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
($attr:ident, $key_name:expr) => {{
|
($attr:ident, $key_name:expr) => {{
|
||||||
let name = $key_name;
|
let name = $key_name;
|
||||||
if default.$attr != self.options.$attr {
|
if default.$attr != self.$attr {
|
||||||
d.insert(name.to_string(), self.options.$attr.to_json());
|
d.insert(name.to_string(), self.$attr.to_json());
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
(link_args - $attr:ident) => {{
|
(link_args - $attr:ident) => {{
|
||||||
let name = (stringify!($attr)).replace("_", "-");
|
let name = (stringify!($attr)).replace("_", "-");
|
||||||
if default.$attr != self.options.$attr {
|
if default.$attr != self.$attr {
|
||||||
let obj = self
|
let obj = self
|
||||||
.options
|
|
||||||
.$attr
|
.$attr
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(k, v)| (k.desc().to_owned(), v.clone()))
|
.map(|(k, v)| (k.desc().to_owned(), v.clone()))
|
||||||
|
@ -1626,9 +1634,8 @@ impl ToJson for Target {
|
||||||
}};
|
}};
|
||||||
(env - $attr:ident) => {{
|
(env - $attr:ident) => {{
|
||||||
let name = (stringify!($attr)).replace("_", "-");
|
let name = (stringify!($attr)).replace("_", "-");
|
||||||
if default.$attr != self.options.$attr {
|
if default.$attr != self.$attr {
|
||||||
let obj = self
|
let obj = self
|
||||||
.options
|
|
||||||
.$attr
|
.$attr
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(ref k, ref v)| k.clone() + "=" + &v)
|
.map(|&(ref k, ref v)| k.clone() + "=" + &v)
|
||||||
|
@ -1736,11 +1743,10 @@ impl ToJson for Target {
|
||||||
target_option_val!(eh_frame_header);
|
target_option_val!(eh_frame_header);
|
||||||
target_option_val!(has_thumb_interworking);
|
target_option_val!(has_thumb_interworking);
|
||||||
|
|
||||||
if default.unsupported_abis != self.options.unsupported_abis {
|
if default.unsupported_abis != self.unsupported_abis {
|
||||||
d.insert(
|
d.insert(
|
||||||
"unsupported-abis".to_string(),
|
"unsupported-abis".to_string(),
|
||||||
self.options
|
self.unsupported_abis
|
||||||
.unsupported_abis
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&name| Abi::name(name).to_json())
|
.map(|&name| Abi::name(name).to_json())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
|
@ -14,27 +14,27 @@ impl Target {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
self.linker_flavor == LinkerFlavor::Msvc
|
self.linker_flavor == LinkerFlavor::Msvc
|
||||||
|| self.linker_flavor == LinkerFlavor::Lld(LldFlavor::Link),
|
|| self.linker_flavor == LinkerFlavor::Lld(LldFlavor::Link),
|
||||||
self.options.lld_flavor == LldFlavor::Link,
|
self.lld_flavor == LldFlavor::Link,
|
||||||
);
|
);
|
||||||
for args in &[
|
for args in &[
|
||||||
&self.options.pre_link_args,
|
&self.pre_link_args,
|
||||||
&self.options.late_link_args,
|
&self.late_link_args,
|
||||||
&self.options.late_link_args_dynamic,
|
&self.late_link_args_dynamic,
|
||||||
&self.options.late_link_args_static,
|
&self.late_link_args_static,
|
||||||
&self.options.post_link_args,
|
&self.post_link_args,
|
||||||
] {
|
] {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
args.get(&LinkerFlavor::Msvc),
|
args.get(&LinkerFlavor::Msvc),
|
||||||
args.get(&LinkerFlavor::Lld(LldFlavor::Link)),
|
args.get(&LinkerFlavor::Lld(LldFlavor::Link)),
|
||||||
);
|
);
|
||||||
if args.contains_key(&LinkerFlavor::Msvc) {
|
if args.contains_key(&LinkerFlavor::Msvc) {
|
||||||
assert_eq!(self.options.lld_flavor, LldFlavor::Link);
|
assert_eq!(self.lld_flavor, LldFlavor::Link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert!(
|
assert!(
|
||||||
(self.options.pre_link_objects_fallback.is_empty()
|
(self.pre_link_objects_fallback.is_empty()
|
||||||
&& self.options.post_link_objects_fallback.is_empty())
|
&& self.post_link_objects_fallback.is_empty())
|
||||||
|| self.options.crt_objects_fallback.is_some()
|
|| self.crt_objects_fallback.is_some()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2653,7 +2653,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
|
||||||
set.path.segments.iter().map(|x| x.ident.name).collect::<Vec<_>>();
|
set.path.segments.iter().map(|x| x.ident.name).collect::<Vec<_>>();
|
||||||
match segments.as_slice() {
|
match segments.as_slice() {
|
||||||
[sym::arm, sym::a32] | [sym::arm, sym::t32] => {
|
[sym::arm, sym::a32] | [sym::arm, sym::t32] => {
|
||||||
if !tcx.sess.target.options.has_thumb_interworking {
|
if !tcx.sess.target.has_thumb_interworking {
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
tcx.sess.diagnostic(),
|
tcx.sess.diagnostic(),
|
||||||
attr.span,
|
attr.span,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue