Skip to content

Commit 0950848

Browse files
committed
Auto merge of #103978 - matthiaskrgr:rollup-iym9kmg, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #103367 (Remove std's transitive dependency on cfg-if 0.1) - #103397 (Port `dead_code` lints to be translatable.) - #103681 (libtest: run all tests in their own thread, if supported by the host) - #103792 (Migrate `codegen_ssa` to diagnostics structs - [Part 2]) - #103897 (asm: Work around LLVM bug on AArch64) - #103937 (minor changes to make method lookup diagnostic code easier to read) - #103958 (Test tidy should not count untracked paths towards entries limit) - #103964 (Give a specific lint for unsafety not being inherited) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c2a5c3a + 347c478 commit 0950848

39 files changed

+811
-407
lines changed

Cargo.lock

+9-8
Original file line numberDiff line numberDiff line change
@@ -1526,11 +1526,11 @@ dependencies = [
15261526

15271527
[[package]]
15281528
name = "getrandom"
1529-
version = "0.1.14"
1529+
version = "0.1.16"
15301530
source = "registry+https://github.com/rust-lang/crates.io-index"
1531-
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
1531+
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
15321532
dependencies = [
1533-
"cfg-if 0.1.10",
1533+
"cfg-if 1.0.0",
15341534
"libc",
15351535
"wasi 0.9.0+wasi-snapshot-preview1",
15361536
]
@@ -2478,7 +2478,7 @@ name = "panic_abort"
24782478
version = "0.0.0"
24792479
dependencies = [
24802480
"alloc",
2481-
"cfg-if 0.1.10",
2481+
"cfg-if 1.0.0",
24822482
"compiler_builtins",
24832483
"core",
24842484
"libc",
@@ -2489,7 +2489,7 @@ name = "panic_unwind"
24892489
version = "0.0.0"
24902490
dependencies = [
24912491
"alloc",
2492-
"cfg-if 0.1.10",
2492+
"cfg-if 1.0.0",
24932493
"compiler_builtins",
24942494
"core",
24952495
"libc",
@@ -2817,7 +2817,7 @@ version = "0.7.3"
28172817
source = "registry+https://github.com/rust-lang/crates.io-index"
28182818
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
28192819
dependencies = [
2820-
"getrandom 0.1.14",
2820+
"getrandom 0.1.16",
28212821
"libc",
28222822
"rand_chacha 0.2.2",
28232823
"rand_core 0.5.1",
@@ -2861,7 +2861,7 @@ version = "0.5.1"
28612861
source = "registry+https://github.com/rust-lang/crates.io-index"
28622862
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
28632863
dependencies = [
2864-
"getrandom 0.1.14",
2864+
"getrandom 0.1.16",
28652865
]
28662866

28672867
[[package]]
@@ -4937,6 +4937,7 @@ name = "tidy"
49374937
version = "0.1.0"
49384938
dependencies = [
49394939
"cargo_metadata 0.14.0",
4940+
"ignore",
49404941
"lazy_static",
49414942
"miropt-test-tools",
49424943
"regex",
@@ -5357,7 +5358,7 @@ name = "unwind"
53575358
version = "0.0.0"
53585359
dependencies = [
53595360
"cc",
5360-
"cfg-if 0.1.10",
5361+
"cfg-if 1.0.0",
53615362
"compiler_builtins",
53625363
"core",
53635364
"libc",

compiler/rustc_codegen_llvm/src/asm.rs

+54-3
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,44 @@ fn xmm_reg_index(reg: InlineAsmReg) -> Option<u32> {
505505
}
506506
}
507507

508+
/// If the register is an AArch64 integer register then return its index.
509+
fn a64_reg_index(reg: InlineAsmReg) -> Option<u32> {
510+
match reg {
511+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x0) => Some(0),
512+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x1) => Some(1),
513+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x2) => Some(2),
514+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x3) => Some(3),
515+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x4) => Some(4),
516+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x5) => Some(5),
517+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x6) => Some(6),
518+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x7) => Some(7),
519+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x8) => Some(8),
520+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x9) => Some(9),
521+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x10) => Some(10),
522+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x11) => Some(11),
523+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x12) => Some(12),
524+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x13) => Some(13),
525+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x14) => Some(14),
526+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x15) => Some(15),
527+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x16) => Some(16),
528+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x17) => Some(17),
529+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x18) => Some(18),
530+
// x19 is reserved
531+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x20) => Some(20),
532+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x21) => Some(21),
533+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x22) => Some(22),
534+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x23) => Some(23),
535+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x24) => Some(24),
536+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x25) => Some(25),
537+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x26) => Some(26),
538+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x27) => Some(27),
539+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x28) => Some(28),
540+
// x29 is reserved
541+
InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) => Some(30),
542+
_ => None,
543+
}
544+
}
545+
508546
/// If the register is an AArch64 vector register then return its index.
509547
fn a64_vreg_index(reg: InlineAsmReg) -> Option<u32> {
510548
match reg {
@@ -535,6 +573,22 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
535573
'x'
536574
};
537575
format!("{{{}mm{}}}", class, idx)
576+
} else if let Some(idx) = a64_reg_index(reg) {
577+
let class = if let Some(layout) = layout {
578+
match layout.size.bytes() {
579+
8 => 'x',
580+
_ => 'w',
581+
}
582+
} else {
583+
// We use i32 as the type for discarded outputs
584+
'w'
585+
};
586+
if class == 'x' && reg == InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) {
587+
// LLVM doesn't recognize x30. use lr instead.
588+
"{lr}".to_string()
589+
} else {
590+
format!("{{{}{}}}", class, idx)
591+
}
538592
} else if let Some(idx) = a64_vreg_index(reg) {
539593
let class = if let Some(layout) = layout {
540594
match layout.size.bytes() {
@@ -550,9 +604,6 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
550604
'q'
551605
};
552606
format!("{{{}{}}}", class, idx)
553-
} else if reg == InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) {
554-
// LLVM doesn't recognize x30
555-
"{lr}".to_string()
556607
} else if reg == InlineAsmReg::Arm(ArmInlineAsmReg::r14) {
557608
// LLVM doesn't recognize r14
558609
"{lr}".to_string()

compiler/rustc_codegen_ssa/src/back/archive.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use rustc_span::symbol::Symbol;
66

77
use object::read::archive::ArchiveFile;
88

9-
use std::fmt::Display;
109
use std::fs::File;
1110
use std::io;
1211
use std::path::{Path, PathBuf};
1312

13+
use crate::errors::ExtractBundledLibsError;
14+
1415
pub trait ArchiveBuilderBuilder {
1516
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder<'a> + 'a>;
1617

@@ -28,32 +29,35 @@ pub trait ArchiveBuilderBuilder {
2829
is_direct_dependency: bool,
2930
) -> PathBuf;
3031

31-
fn extract_bundled_libs(
32-
&self,
33-
rlib: &Path,
32+
fn extract_bundled_libs<'a>(
33+
&'a self,
34+
rlib: &'a Path,
3435
outdir: &Path,
3536
bundled_lib_file_names: &FxHashSet<Symbol>,
36-
) -> Result<(), String> {
37-
let message = |msg: &str, e: &dyn Display| format!("{} '{}': {}", msg, &rlib.display(), e);
37+
) -> Result<(), ExtractBundledLibsError<'_>> {
3838
let archive_map = unsafe {
39-
Mmap::map(File::open(rlib).map_err(|e| message("failed to open file", &e))?)
40-
.map_err(|e| message("failed to mmap file", &e))?
39+
Mmap::map(
40+
File::open(rlib)
41+
.map_err(|e| ExtractBundledLibsError::OpenFile { rlib, error: Box::new(e) })?,
42+
)
43+
.map_err(|e| ExtractBundledLibsError::MmapFile { rlib, error: Box::new(e) })?
4144
};
4245
let archive = ArchiveFile::parse(&*archive_map)
43-
.map_err(|e| message("failed to parse archive", &e))?;
46+
.map_err(|e| ExtractBundledLibsError::ParseArchive { rlib, error: Box::new(e) })?;
4447

4548
for entry in archive.members() {
46-
let entry = entry.map_err(|e| message("failed to read entry", &e))?;
49+
let entry = entry
50+
.map_err(|e| ExtractBundledLibsError::ReadEntry { rlib, error: Box::new(e) })?;
4751
let data = entry
4852
.data(&*archive_map)
49-
.map_err(|e| message("failed to get data from archive member", &e))?;
53+
.map_err(|e| ExtractBundledLibsError::ArchiveMember { rlib, error: Box::new(e) })?;
5054
let name = std::str::from_utf8(entry.name())
51-
.map_err(|e| message("failed to convert name", &e))?;
55+
.map_err(|e| ExtractBundledLibsError::ConvertName { rlib, error: Box::new(e) })?;
5256
if !bundled_lib_file_names.contains(&Symbol::intern(name)) {
5357
continue; // We need to extract only native libraries.
5458
}
5559
std::fs::write(&outdir.join(&name), data)
56-
.map_err(|e| message("failed to write file", &e))?;
60+
.map_err(|e| ExtractBundledLibsError::WriteFile { rlib, error: Box::new(e) })?;
5761
}
5862
Ok(())
5963
}

0 commit comments

Comments
 (0)