summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_ssa/src/back
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /compiler/rustc_codegen_ssa/src/back
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/archive.rs1
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs169
-rw-r--r--compiler/rustc_codegen_ssa/src/back/linker.rs26
-rw-r--r--compiler/rustc_codegen_ssa/src/back/metadata.rs91
-rw-r--r--compiler/rustc_codegen_ssa/src/back/symbol_export.rs17
-rw-r--r--compiler/rustc_codegen_ssa/src/back/write.rs16
6 files changed, 281 insertions, 39 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs
index 66ec8f5f5..1c464b3ec 100644
--- a/compiler/rustc_codegen_ssa/src/back/archive.rs
+++ b/compiler/rustc_codegen_ssa/src/back/archive.rs
@@ -233,6 +233,7 @@ impl<'a> ArArchiveBuilder<'a> {
"bsd" => ArchiveKind::Bsd,
"darwin" => ArchiveKind::Darwin,
"coff" => ArchiveKind::Coff,
+ "aix_big" => ArchiveKind::AixBig,
kind => {
self.sess.emit_fatal(UnknownArchiveKind { kind });
}
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index eecfe13bb..8a00c42a0 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -9,6 +9,7 @@ use rustc_fs_util::fix_windows_verbatim_for_gcc;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_metadata::find_native_static_library;
use rustc_metadata::fs::{emit_wrapper_file, METADATA_FILENAME};
+use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
use rustc_session::config::{self, CFGuard, CrateType, DebugInfo, LdImpl, Strip};
@@ -21,7 +22,6 @@ use rustc_session::utils::NativeLibKind;
/// need out of the shared crate context before we get rid of it.
use rustc_session::{filesearch, Session};
use rustc_span::symbol::Symbol;
-use rustc_span::DebuggerVisualizerFile;
use rustc_target::spec::crt_objects::{CrtObjects, LinkSelfContainedDefault};
use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, LinkerFlavorCli, Lld, PanicStrategy};
use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo};
@@ -40,7 +40,6 @@ use regex::Regex;
use tempfile::Builder as TempFileBuilder;
use itertools::Itertools;
-use std::borrow::Borrow;
use std::cell::OnceCell;
use std::collections::BTreeSet;
use std::ffi::OsString;
@@ -54,7 +53,7 @@ use std::{env, fmt, fs, io, mem, str};
pub fn ensure_removed(diag_handler: &Handler, path: &Path) {
if let Err(e) = fs::remove_file(path) {
if e.kind() != io::ErrorKind::NotFound {
- diag_handler.err(&format!("failed to remove {}: {}", path.display(), e));
+ diag_handler.err(format!("failed to remove {}: {}", path.display(), e));
}
}
}
@@ -547,12 +546,40 @@ fn link_staticlib<'a>(
ab.build(out_filename);
- if !all_native_libs.is_empty() {
- if sess.opts.prints.contains(&PrintRequest::NativeStaticLibs) {
- print_native_static_libs(sess, &all_native_libs);
+ let crates = codegen_results.crate_info.used_crates.iter();
+
+ let fmts = codegen_results
+ .crate_info
+ .dependency_formats
+ .iter()
+ .find_map(|&(ty, ref list)| if ty == CrateType::Staticlib { Some(list) } else { None })
+ .expect("no dependency formats for staticlib");
+
+ let mut all_rust_dylibs = vec![];
+ for &cnum in crates {
+ match fmts.get(cnum.as_usize() - 1) {
+ Some(&Linkage::Dynamic) => {}
+ _ => continue,
+ }
+ let crate_name = codegen_results.crate_info.crate_name[&cnum];
+ let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum];
+ if let Some((path, _)) = &used_crate_source.dylib {
+ all_rust_dylibs.push(&**path);
+ } else {
+ if used_crate_source.rmeta.is_some() {
+ sess.emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
+ } else {
+ sess.emit_fatal(errors::LinkRlibError::NotFound { crate_name });
+ }
}
}
+ all_native_libs.extend_from_slice(&codegen_results.crate_info.used_libraries);
+
+ if sess.opts.prints.contains(&PrintRequest::NativeStaticLibs) {
+ print_native_static_libs(sess, &all_native_libs, &all_rust_dylibs);
+ }
+
Ok(())
}
@@ -576,17 +603,17 @@ fn link_dwarf_object<'a>(
impl<Relocations> ThorinSession<Relocations> {
fn alloc_mmap(&self, data: Mmap) -> &Mmap {
- (*self.arena_mmap.alloc(data)).borrow()
+ &*self.arena_mmap.alloc(data)
}
}
impl<Relocations> thorin::Session<Relocations> for ThorinSession<Relocations> {
fn alloc_data(&self, data: Vec<u8>) -> &[u8] {
- (*self.arena_data.alloc(data)).borrow()
+ &*self.arena_data.alloc(data)
}
fn alloc_relocation(&self, data: Relocations) -> &Relocations {
- (*self.arena_relocations.alloc(data)).borrow()
+ &*self.arena_relocations.alloc(data)
}
fn read_input(&self, path: &Path) -> std::io::Result<&[u8]> {
@@ -860,7 +887,7 @@ fn link_natively<'a>(
if !prog.status.success() {
let mut output = prog.stderr.clone();
output.extend_from_slice(&prog.stdout);
- let escaped_output = escape_string(&output);
+ let escaped_output = escape_linker_output(&output, flavor);
// FIXME: Add UI tests for this error.
let err = errors::LinkingFailed {
linker_path: &linker_path,
@@ -1052,6 +1079,83 @@ fn escape_string(s: &[u8]) -> String {
}
}
+#[cfg(not(windows))]
+fn escape_linker_output(s: &[u8], _flavour: LinkerFlavor) -> String {
+ escape_string(s)
+}
+
+/// If the output of the msvc linker is not UTF-8 and the host is Windows,
+/// then try to convert the string from the OEM encoding.
+#[cfg(windows)]
+fn escape_linker_output(s: &[u8], flavour: LinkerFlavor) -> String {
+ // This only applies to the actual MSVC linker.
+ if flavour != LinkerFlavor::Msvc(Lld::No) {
+ return escape_string(s);
+ }
+ match str::from_utf8(s) {
+ Ok(s) => return s.to_owned(),
+ Err(_) => match win::locale_byte_str_to_string(s, win::oem_code_page()) {
+ Some(s) => s,
+ // The string is not UTF-8 and isn't valid for the OEM code page
+ None => format!("Non-UTF-8 output: {}", s.escape_ascii()),
+ },
+ }
+}
+
+/// Wrappers around the Windows API.
+#[cfg(windows)]
+mod win {
+ use windows::Win32::Globalization::{
+ GetLocaleInfoEx, MultiByteToWideChar, CP_OEMCP, LOCALE_IUSEUTF8LEGACYOEMCP,
+ LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_RETURN_NUMBER, MB_ERR_INVALID_CHARS,
+ };
+
+ /// Get the Windows system OEM code page. This is most notably the code page
+ /// used for link.exe's output.
+ pub fn oem_code_page() -> u32 {
+ unsafe {
+ let mut cp: u32 = 0;
+ // We're using the `LOCALE_RETURN_NUMBER` flag to return a u32.
+ // But the API requires us to pass the data as though it's a [u16] string.
+ let len = std::mem::size_of::<u32>() / std::mem::size_of::<u16>();
+ let data = std::slice::from_raw_parts_mut(&mut cp as *mut u32 as *mut u16, len);
+ let len_written = GetLocaleInfoEx(
+ LOCALE_NAME_SYSTEM_DEFAULT,
+ LOCALE_IUSEUTF8LEGACYOEMCP | LOCALE_RETURN_NUMBER,
+ Some(data),
+ );
+ if len_written as usize == len { cp } else { CP_OEMCP }
+ }
+ }
+ /// Try to convert a multi-byte string to a UTF-8 string using the given code page
+ /// The string does not need to be null terminated.
+ ///
+ /// This is implemented as a wrapper around `MultiByteToWideChar`.
+ /// See <https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar>
+ ///
+ /// It will fail if the multi-byte string is longer than `i32::MAX` or if it contains
+ /// any invalid bytes for the expected encoding.
+ pub fn locale_byte_str_to_string(s: &[u8], code_page: u32) -> Option<String> {
+ // `MultiByteToWideChar` requires a length to be a "positive integer".
+ if s.len() > isize::MAX as usize {
+ return None;
+ }
+ // Error if the string is not valid for the expected code page.
+ let flags = MB_ERR_INVALID_CHARS;
+ // Call MultiByteToWideChar twice.
+ // First to calculate the length then to convert the string.
+ let mut len = unsafe { MultiByteToWideChar(code_page, flags, s, None) };
+ if len > 0 {
+ let mut utf16 = vec![0; len as usize];
+ len = unsafe { MultiByteToWideChar(code_page, flags, s, Some(&mut utf16)) };
+ if len > 0 {
+ return utf16.get(..len as usize).map(String::from_utf16_lossy);
+ }
+ }
+ None
+ }
+}
+
fn add_sanitizer_libraries(sess: &Session, crate_type: CrateType, linker: &mut dyn Linker) {
// On macOS the runtimes are distributed as dylibs which should be linked to
// both executables and dynamic shared objects. Everywhere else the runtimes
@@ -1294,8 +1398,12 @@ enum RlibFlavor {
StaticlibBase,
}
-fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) {
- let lib_args: Vec<_> = all_native_libs
+fn print_native_static_libs(
+ sess: &Session,
+ all_native_libs: &[NativeLib],
+ all_rust_dylibs: &[&Path],
+) {
+ let mut lib_args: Vec<_> = all_native_libs
.iter()
.filter(|l| relevant_lib(sess, l))
.filter_map(|lib| {
@@ -1325,11 +1433,46 @@ fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) {
}
})
.collect();
+ for path in all_rust_dylibs {
+ // FIXME deduplicate with add_dynamic_crate
+
+ // Just need to tell the linker about where the library lives and
+ // what its name is
+ let parent = path.parent();
+ if let Some(dir) = parent {
+ let dir = fix_windows_verbatim_for_gcc(dir);
+ if sess.target.is_like_msvc {
+ let mut arg = String::from("/LIBPATH:");
+ arg.push_str(&dir.display().to_string());
+ lib_args.push(arg);
+ } else {
+ lib_args.push("-L".to_owned());
+ lib_args.push(dir.display().to_string());
+ }
+ }
+ let stem = path.file_stem().unwrap().to_str().unwrap();
+ // Convert library file-stem into a cc -l argument.
+ let prefix = if stem.starts_with("lib") && !sess.target.is_like_windows { 3 } else { 0 };
+ let lib = &stem[prefix..];
+ let path = parent.unwrap_or_else(|| Path::new(""));
+ if sess.target.is_like_msvc {
+ // When producing a dll, the MSVC linker may not actually emit a
+ // `foo.lib` file if the dll doesn't actually export any symbols, so we
+ // check to see if the file is there and just omit linking to it if it's
+ // not present.
+ let name = format!("{}.dll.lib", lib);
+ if path.join(&name).exists() {
+ lib_args.push(name);
+ }
+ } else {
+ lib_args.push(format!("-l{}", lib));
+ }
+ }
if !lib_args.is_empty() {
sess.emit_note(errors::StaticLibraryNativeArtifacts);
// Prefix for greppability
// Note: This must not be translated as tools are allowed to depend on this exact string.
- sess.note_without_error(&format!("native-static-libs: {}", &lib_args.join(" ")));
+ sess.note_without_error(format!("native-static-libs: {}", &lib_args.join(" ")));
}
}
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs
index 65dfc325a..cd56f85cc 100644
--- a/compiler/rustc_codegen_ssa/src/back/linker.rs
+++ b/compiler/rustc_codegen_ssa/src/back/linker.rs
@@ -144,7 +144,7 @@ pub fn get_linker<'a>(
cmd,
sess,
target_cpu,
- hinted_static: false,
+ hinted_static: None,
is_ld: cc == Cc::No,
is_gnu: flavor.is_gnu(),
}) as Box<dyn Linker>,
@@ -214,7 +214,7 @@ pub struct GccLinker<'a> {
cmd: Command,
sess: &'a Session,
target_cpu: &'a str,
- hinted_static: bool, // Keeps track of the current hinting mode.
+ hinted_static: Option<bool>, // Keeps track of the current hinting mode.
// Link as ld
is_ld: bool,
is_gnu: bool,
@@ -275,9 +275,9 @@ impl<'a> GccLinker<'a> {
if !self.takes_hints() {
return;
}
- if !self.hinted_static {
+ if self.hinted_static != Some(true) {
self.linker_arg("-Bstatic");
- self.hinted_static = true;
+ self.hinted_static = Some(true);
}
}
@@ -285,9 +285,9 @@ impl<'a> GccLinker<'a> {
if !self.takes_hints() {
return;
}
- if self.hinted_static {
+ if self.hinted_static != Some(false) {
self.linker_arg("-Bdynamic");
- self.hinted_static = false;
+ self.hinted_static = Some(false);
}
}
@@ -1484,25 +1484,25 @@ impl<'a> L4Bender<'a> {
pub struct AixLinker<'a> {
cmd: Command,
sess: &'a Session,
- hinted_static: bool,
+ hinted_static: Option<bool>,
}
impl<'a> AixLinker<'a> {
pub fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
- AixLinker { cmd: cmd, sess: sess, hinted_static: false }
+ AixLinker { cmd: cmd, sess: sess, hinted_static: None }
}
fn hint_static(&mut self) {
- if !self.hinted_static {
+ if self.hinted_static != Some(true) {
self.cmd.arg("-bstatic");
- self.hinted_static = true;
+ self.hinted_static = Some(true);
}
}
fn hint_dynamic(&mut self) {
- if self.hinted_static {
+ if self.hinted_static != Some(false) {
self.cmd.arg("-bdynamic");
- self.hinted_static = false;
+ self.hinted_static = Some(false);
}
}
@@ -1631,7 +1631,7 @@ impl<'a> Linker for AixLinker<'a> {
}
};
if let Err(e) = res {
- self.sess.fatal(&format!("failed to write export file: {}", e));
+ self.sess.fatal(format!("failed to write export file: {}", e));
}
self.cmd.arg(format!("-bE:{}", path.to_str().unwrap()));
}
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
index d5d843702..ad27b854d 100644
--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs
+++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs
@@ -12,9 +12,9 @@ use object::{
use snap::write::FrameEncoder;
+use object::elf::NT_GNU_PROPERTY_TYPE_0;
use rustc_data_structures::memmap::Mmap;
-use rustc_data_structures::owned_slice::try_slice_owned;
-use rustc_data_structures::sync::MetadataRef;
+use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice};
use rustc_metadata::fs::METADATA_FILENAME;
use rustc_metadata::EncodedMetadata;
use rustc_session::cstore::MetadataLoader;
@@ -38,7 +38,7 @@ pub struct DefaultMetadataLoader;
fn load_metadata_with(
path: &Path,
f: impl for<'a> FnOnce(&'a [u8]) -> Result<&'a [u8], String>,
-) -> Result<MetadataRef, String> {
+) -> Result<OwnedSlice, String> {
let file =
File::open(path).map_err(|e| format!("failed to open file '{}': {}", path.display(), e))?;
@@ -48,7 +48,7 @@ fn load_metadata_with(
}
impl MetadataLoader for DefaultMetadataLoader {
- fn get_rlib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
+ fn get_rlib_metadata(&self, _target: &Target, path: &Path) -> Result<OwnedSlice, String> {
load_metadata_with(path, |data| {
let archive = object::read::archive::ArchiveFile::parse(&*data)
.map_err(|e| format!("failed to parse rlib '{}': {}", path.display(), e))?;
@@ -68,7 +68,7 @@ impl MetadataLoader for DefaultMetadataLoader {
})
}
- fn get_dylib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
+ fn get_dylib_metadata(&self, _target: &Target, path: &Path) -> Result<OwnedSlice, String> {
load_metadata_with(path, |data| search_for_section(path, data, ".rustc"))
}
}
@@ -93,6 +93,54 @@ pub(super) fn search_for_section<'a>(
.map_err(|e| format!("failed to read {} section in '{}': {}", section, path.display(), e))
}
+fn add_gnu_property_note(
+ file: &mut write::Object<'static>,
+ architecture: Architecture,
+ binary_format: BinaryFormat,
+ endianness: Endianness,
+) {
+ // check bti protection
+ if binary_format != BinaryFormat::Elf
+ || !matches!(architecture, Architecture::X86_64 | Architecture::Aarch64)
+ {
+ return;
+ }
+
+ let section = file.add_section(
+ file.segment_name(StandardSegment::Data).to_vec(),
+ b".note.gnu.property".to_vec(),
+ SectionKind::Note,
+ );
+ let mut data: Vec<u8> = Vec::new();
+ let n_namsz: u32 = 4; // Size of the n_name field
+ let n_descsz: u32 = 16; // Size of the n_desc field
+ let n_type: u32 = NT_GNU_PROPERTY_TYPE_0; // Type of note descriptor
+ let header_values = [n_namsz, n_descsz, n_type];
+ header_values.iter().for_each(|v| {
+ data.extend_from_slice(&match endianness {
+ Endianness::Little => v.to_le_bytes(),
+ Endianness::Big => v.to_be_bytes(),
+ })
+ });
+ data.extend_from_slice(b"GNU\0"); // Owner of the program property note
+ let pr_type: u32 = match architecture {
+ Architecture::X86_64 => 0xc0000002,
+ Architecture::Aarch64 => 0xc0000000,
+ _ => unreachable!(),
+ };
+ let pr_datasz: u32 = 4; //size of the pr_data field
+ let pr_data: u32 = 3; //program property descriptor
+ let pr_padding: u32 = 0;
+ let property_values = [pr_type, pr_datasz, pr_data, pr_padding];
+ property_values.iter().for_each(|v| {
+ data.extend_from_slice(&match endianness {
+ Endianness::Little => v.to_le_bytes(),
+ Endianness::Big => v.to_be_bytes(),
+ })
+ });
+ file.append_section_data(section, &data, 8);
+}
+
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
let endianness = match sess.target.options.endian {
Endian::Little => Endianness::Little,
@@ -140,6 +188,11 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
};
let mut file = write::Object::new(binary_format, architecture, endianness);
+ if sess.target.is_like_osx {
+ if let Some(build_version) = macho_object_build_version_for_target(&sess.target) {
+ file.set_macho_build_version(build_version)
+ }
+ }
let e_flags = match architecture {
Architecture::Mips => {
let arch = match sess.target.options.cpu.as_ref() {
@@ -205,10 +258,38 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
_ => elf::ELFOSABI_NONE,
};
let abi_version = 0;
+ add_gnu_property_note(&mut file, architecture, binary_format, endianness);
file.flags = FileFlags::Elf { os_abi, abi_version, e_flags };
Some(file)
}
+/// Apple's LD, when linking for Mac Catalyst, requires object files to
+/// contain information about what they were built for (LC_BUILD_VERSION):
+/// the platform (macOS/watchOS etc), minimum OS version, and SDK version.
+/// This returns a `MachOBuildVersion` if necessary for the target.
+fn macho_object_build_version_for_target(
+ target: &Target,
+) -> Option<object::write::MachOBuildVersion> {
+ if !target.llvm_target.ends_with("-macabi") {
+ return None;
+ }
+ /// The `object` crate demands "X.Y.Z encoded in nibbles as xxxx.yy.zz"
+ /// e.g. minOS 14.0 = 0x000E0000, or SDK 16.2 = 0x00100200
+ fn pack_version((major, minor): (u32, u32)) -> u32 {
+ (major << 16) | (minor << 8)
+ }
+
+ let platform = object::macho::PLATFORM_MACCATALYST;
+ let min_os = (14, 0);
+ let sdk = (16, 2);
+
+ let mut build_version = object::write::MachOBuildVersion::default();
+ build_version.platform = platform;
+ build_version.minos = pack_version(min_os);
+ build_version.sdk = pack_version(sdk);
+ Some(build_version)
+}
+
pub enum MetadataPosition {
First,
Last,
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
index d0fd3cd76..a8b6030ac 100644
--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
+++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
@@ -2,7 +2,7 @@ use crate::base::allocator_kind_for_codegen;
use std::collections::hash_map::Entry::*;
-use rustc_ast::expand::allocator::ALLOCATOR_METHODS;
+use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
@@ -11,7 +11,7 @@ use rustc_middle::middle::exported_symbols::{
metadata_symbol_name, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
};
use rustc_middle::query::LocalCrate;
-use rustc_middle::ty::query::{ExternProviders, Providers};
+use rustc_middle::query::{ExternProviders, Providers};
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
use rustc_middle::ty::Instance;
use rustc_middle::ty::{self, SymbolName, TyCtxt};
@@ -241,6 +241,17 @@ fn exported_symbols_provider_local(
used: false,
},
));
+
+ let exported_symbol =
+ ExportedSymbol::NoDefId(SymbolName::new(tcx, NO_ALLOC_SHIM_IS_UNSTABLE));
+ symbols.push((
+ exported_symbol,
+ SymbolExportInfo {
+ level: SymbolExportLevel::Rust,
+ kind: SymbolExportKind::Data,
+ used: false,
+ },
+ ))
}
if tcx.sess.instrument_coverage() || tcx.sess.opts.cg.profile_generate.enabled() {
@@ -333,7 +344,7 @@ fn exported_symbols_provider_local(
match *mono_item {
MonoItem::Fn(Instance { def: InstanceDef::Item(def), substs }) => {
if substs.non_erasable_generics().next().is_some() {
- let symbol = ExportedSymbol::Generic(def.did, substs);
+ let symbol = ExportedSymbol::Generic(def, substs);
symbols.push((
symbol,
SymbolExportInfo {
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs
index 2dda4cd16..c323372bd 100644
--- a/compiler/rustc_codegen_ssa/src/back/write.rs
+++ b/compiler/rustc_codegen_ssa/src/back/write.rs
@@ -872,7 +872,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
let load_from_incr_comp_dir = |output_path: PathBuf, saved_path: &str| {
let source_file = in_incr_comp_dir(&incr_comp_session_dir, saved_path);
debug!(
- "copying pre-existing module `{}` from {:?} to {}",
+ "copying preexisting module `{}` from {:?} to {}",
module.name,
source_file,
output_path.display()
@@ -1821,9 +1821,15 @@ impl SharedEmitterMain {
let source = sess
.source_map()
.new_source_file(FileName::inline_asm_source_code(&buffer), buffer);
- let source_span = Span::with_root_ctxt(source.start_pos, source.end_pos);
- let spans: Vec<_> =
- spans.iter().map(|sp| source_span.from_inner(*sp)).collect();
+ let spans: Vec<_> = spans
+ .iter()
+ .map(|sp| {
+ Span::with_root_ctxt(
+ source.normalized_byte_pos(sp.start as u32),
+ source.normalized_byte_pos(sp.end as u32),
+ )
+ })
+ .collect();
err.span_note(spans, "instantiated into assembly here");
}
@@ -1833,7 +1839,7 @@ impl SharedEmitterMain {
sess.abort_if_errors();
}
Ok(SharedEmitterMessage::Fatal(msg)) => {
- sess.fatal(&msg);
+ sess.fatal(msg);
}
Err(_) => {
break;