Skip to content

Commit

Permalink
Auto merge of rust-lang#2712 - RalfJung:rustup, r=RalfJung
Browse files Browse the repository at this point in the history
Rustup
  • Loading branch information
bors committed Dec 3, 2022
2 parents 7d75cc4 + 29814f2 commit 840f227
Show file tree
Hide file tree
Showing 728 changed files with 10,507 additions and 7,117 deletions.
13 changes: 12 additions & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Björn Steinbrink <[email protected]> <[email protected]>
blake2-ppc <[email protected]> <blake2-ppc>
boolean_coercion <[email protected]>
Boris Egorov <[email protected]> <[email protected]>
bors <[email protected]> bors[bot] <26634292+bors[bot]@users.noreply.github.com>
bors <[email protected]> bors[bot] <bors[bot]@users.noreply.github.com>
Braden Nelson <[email protected]>
Brandon Sanderson <[email protected]> Brandon Sanderson <[email protected]>
Brett Cannon <[email protected]> Brett Cannon <[email protected]>
Expand Down Expand Up @@ -139,6 +141,10 @@ David Ross <[email protected]>
David Wood <[email protected]> <[email protected]>
Deadbeef <[email protected]>
Deadbeef <[email protected]> <[email protected]>
dependabot[bot] <dependabot[bot]@users.noreply.github.com> <27856297+dependabot-preview[bot]@users.noreply.github.com>
dependabot[bot] <dependabot[bot]@users.noreply.github.com> <49699333+dependabot[bot]@users.noreply.github.com>
dependabot[bot] <dependabot[bot]@users.noreply.github.com> <dependabot-preview[bot]@users.noreply.github.com>
dependabot[bot] <dependabot[bot]@users.noreply.github.com> <[email protected]>
Derek Chiang <[email protected]> Derek Chiang (Enchi Jiang) <[email protected]>
DeveloperC <[email protected]>
Devin Ragotzy <[email protected]>
Expand Down Expand Up @@ -229,7 +235,7 @@ Jacob <[email protected]>
Jacob Greenfield <[email protected]>
Jacob Pratt <[email protected]> <[email protected]>
Jake Vossen <[email protected]>
Jakob Degen <[email protected]>
Jakob Degen <jakob[email protected]> <jakob@degen.com>
Jakob Lautrup Nysom <[email protected]>
Jakub Adam Wieczorek <[email protected]>
Jakub Adam Wieczorek <[email protected]> <[email protected]>
Expand Down Expand Up @@ -396,6 +402,10 @@ Nathaniel Herman <[email protected]> Nathaniel Herman <[email protected]
Neil Pankey <[email protected]> <[email protected]>
Ngo Iok Ui (Wu Yu Wei) <[email protected]>
Nicholas Baron <[email protected]>
Nicholas Bishop <[email protected]> <[email protected]>
Nicholas Bishop <[email protected]> <[email protected]>
Nicholas Nethercote <[email protected]> <[email protected]>
Nicholas Nethercote <[email protected]> <[email protected]>
Nick Platt <[email protected]>
Niclas Schwarzlose <[email protected]>
Nicolas Abram <[email protected]>
Expand Down Expand Up @@ -522,6 +532,7 @@ Tomas Koutsky <[email protected]>
Torsten Weber <[email protected]>
Torsten Weber <[email protected]> <[email protected]>
Trevor Spiteri <[email protected]> <[email protected]>
Tshepang Mbambo <[email protected]>
Ty Overby <[email protected]>
Tyler Mandry <[email protected]> <[email protected]>
Tyler Ruckinger <[email protected]>
Expand Down
101 changes: 99 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ name = "cargo"
version = "0.68.0"
dependencies = [
"anyhow",
"atty",
"bytesize",
"cargo-platform 0.1.2",
"cargo-test-macro",
Expand All @@ -298,7 +297,7 @@ dependencies = [
"crates-io",
"curl",
"curl-sys",
"env_logger 0.9.0",
"env_logger 0.10.0",
"filetime",
"flate2",
"fwdansi",
Expand All @@ -312,6 +311,7 @@ dependencies = [
"ignore",
"im-rc",
"indexmap",
"is-terminal",
"itertools",
"jobserver",
"lazy_static",
Expand Down Expand Up @@ -870,6 +870,12 @@ dependencies = [
"memchr",
]

[[package]]
name = "convert_case"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"

[[package]]
name = "core"
version = "0.0.0"
Expand Down Expand Up @@ -1060,6 +1066,19 @@ dependencies = [
"syn",
]

[[package]]
name = "derive_more"
version = "0.99.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"rustc_version",
"syn",
]

[[package]]
name = "diff"
version = "0.1.13"
Expand Down Expand Up @@ -1213,6 +1232,40 @@ dependencies = [
"termcolor",
]

[[package]]
name = "env_logger"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
dependencies = [
"humantime 2.0.1",
"is-terminal",
"log",
"regex",
"termcolor",
]

[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
"errno-dragonfly",
"libc",
"winapi",
]

[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]

[[package]]
name = "error_index_generator"
version = "0.0.0"
Expand Down Expand Up @@ -1907,6 +1960,28 @@ dependencies = [
"unic-langid",
]

[[package]]
name = "io-lifetimes"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e394faa0efb47f9f227f1cd89978f854542b318a6f64fa695489c9c993056656"
dependencies = [
"libc",
"windows-sys",
]

[[package]]
name = "is-terminal"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d"
dependencies = [
"hermit-abi 0.2.6",
"io-lifetimes",
"rustix",
"windows-sys",
]

[[package]]
name = "itertools"
version = "0.10.5"
Expand Down Expand Up @@ -2116,6 +2191,12 @@ dependencies = [
"walkdir",
]

[[package]]
name = "linux-raw-sys"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f"

[[package]]
name = "litemap"
version = "0.6.0"
Expand Down Expand Up @@ -3193,6 +3274,7 @@ version = "1.0.0"
dependencies = [
"bstr 0.2.17",
"clap 3.2.20",
"libc",
"libz-sys",
"rand 0.8.5",
"regex",
Expand Down Expand Up @@ -3916,6 +3998,7 @@ version = "0.0.0"
dependencies = [
"bitflags",
"chalk-ir",
"derive_more",
"either",
"gsgdt",
"polonius-engine",
Expand Down Expand Up @@ -4508,6 +4591,20 @@ dependencies = [
"unicode_categories",
]

[[package]]
name = "rustix"
version = "0.36.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e"
dependencies = [
"bitflags",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys",
]

[[package]]
name = "rustversion"
version = "1.0.5"
Expand Down
96 changes: 96 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,102 @@ pub enum TargetDataLayoutErrors<'a> {
}

impl TargetDataLayout {
/// Parse data layout from an [llvm data layout string](https://llvm.org/docs/LangRef.html#data-layout)
///
/// This function doesn't fill `c_enum_min_size` and it will always be `I32` since it can not be
/// determined from llvm string.
pub fn parse_from_llvm_datalayout_string<'a>(
input: &'a str,
) -> Result<TargetDataLayout, TargetDataLayoutErrors<'a>> {
// Parse an address space index from a string.
let parse_address_space = |s: &'a str, cause: &'a str| {
s.parse::<u32>().map(AddressSpace).map_err(|err| {
TargetDataLayoutErrors::InvalidAddressSpace { addr_space: s, cause, err }
})
};

// Parse a bit count from a string.
let parse_bits = |s: &'a str, kind: &'a str, cause: &'a str| {
s.parse::<u64>().map_err(|err| TargetDataLayoutErrors::InvalidBits {
kind,
bit: s,
cause,
err,
})
};

// Parse a size string.
let size = |s: &'a str, cause: &'a str| parse_bits(s, "size", cause).map(Size::from_bits);

// Parse an alignment string.
let align = |s: &[&'a str], cause: &'a str| {
if s.is_empty() {
return Err(TargetDataLayoutErrors::MissingAlignment { cause });
}
let align_from_bits = |bits| {
Align::from_bits(bits)
.map_err(|err| TargetDataLayoutErrors::InvalidAlignment { cause, err })
};
let abi = parse_bits(s[0], "alignment", cause)?;
let pref = s.get(1).map_or(Ok(abi), |pref| parse_bits(pref, "alignment", cause))?;
Ok(AbiAndPrefAlign { abi: align_from_bits(abi)?, pref: align_from_bits(pref)? })
};

let mut dl = TargetDataLayout::default();
let mut i128_align_src = 64;
for spec in input.split('-') {
let spec_parts = spec.split(':').collect::<Vec<_>>();

match &*spec_parts {
["e"] => dl.endian = Endian::Little,
["E"] => dl.endian = Endian::Big,
[p] if p.starts_with('P') => {
dl.instruction_address_space = parse_address_space(&p[1..], "P")?
}
["a", ref a @ ..] => dl.aggregate_align = align(a, "a")?,
["f32", ref a @ ..] => dl.f32_align = align(a, "f32")?,
["f64", ref a @ ..] => dl.f64_align = align(a, "f64")?,
[p @ "p", s, ref a @ ..] | [p @ "p0", s, ref a @ ..] => {
dl.pointer_size = size(s, p)?;
dl.pointer_align = align(a, p)?;
}
[s, ref a @ ..] if s.starts_with('i') => {
let Ok(bits) = s[1..].parse::<u64>() else {
size(&s[1..], "i")?; // For the user error.
continue;
};
let a = align(a, s)?;
match bits {
1 => dl.i1_align = a,
8 => dl.i8_align = a,
16 => dl.i16_align = a,
32 => dl.i32_align = a,
64 => dl.i64_align = a,
_ => {}
}
if bits >= i128_align_src && bits <= 128 {
// Default alignment for i128 is decided by taking the alignment of
// largest-sized i{64..=128}.
i128_align_src = bits;
dl.i128_align = a;
}
}
[s, ref a @ ..] if s.starts_with('v') => {
let v_size = size(&s[1..], "v")?;
let a = align(a, s)?;
if let Some(v) = dl.vector_align.iter_mut().find(|v| v.0 == v_size) {
v.1 = a;
continue;
}
// No existing entry, add a new one.
dl.vector_align.push((v_size, a));
}
_ => {} // Ignore everything else.
}
}
Ok(dl)
}

/// Returns exclusive upper bound on object size.
///
/// The theoretical maximum object size is defined as the maximum positive `isize` value.
Expand Down
Loading

0 comments on commit 840f227

Please sign in to comment.