Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #60636

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies = [
name = "alloc"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -115,7 +115,7 @@ version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]
Expand Down Expand Up @@ -450,7 +450,7 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.10"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -736,7 +736,7 @@ name = "dlmalloc"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]
Expand Down Expand Up @@ -902,7 +902,7 @@ name = "fortanix-sgx-abi"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]

Expand Down Expand Up @@ -1063,7 +1063,7 @@ name = "hashbrown"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-alloc 1.0.0",
"rustc-std-workspace-core 1.0.0",
]
Expand Down Expand Up @@ -1764,7 +1764,7 @@ dependencies = [
name = "panic_abort"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
]
Expand All @@ -1774,7 +1774,7 @@ name = "panic_unwind"
version = "0.0.0"
dependencies = [
"alloc 0.0.0",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
"unwind 0.0.0",
Expand Down Expand Up @@ -1959,7 +1959,7 @@ name = "profiler_builtins"
version = "0.0.0"
dependencies = [
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

Expand Down Expand Up @@ -2484,7 +2484,7 @@ name = "rustc-demangle"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]

Expand Down Expand Up @@ -2612,7 +2612,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

Expand Down Expand Up @@ -2842,7 +2842,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

Expand Down Expand Up @@ -2904,7 +2904,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

Expand Down Expand Up @@ -3021,7 +3021,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

Expand Down Expand Up @@ -3290,7 +3290,7 @@ dependencies = [
"alloc 0.0.0",
"backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3882,7 +3882,7 @@ name = "unwind"
version = "0.0.0"
dependencies = [
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
]
Expand Down Expand Up @@ -4078,7 +4078,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
"checksum compiler_builtins 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4ada53ac629568219809178f988ca2aac9889e9a847379588c097d30ce185145"
"checksum compiler_builtins 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "6549720ae78db799196d4af8f719facb4c7946710b4b64148482553e54b56d15"
"checksum compiletest_rs 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f40ecc9332b68270998995c00f8051ee856121764a0d3230e64c9efd059d27b6"
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
Expand Down
2 changes: 1 addition & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
# linked binaries
#musl-root = "..."

# The root location of the `wasm32-unknown-wasi` sysroot.
# The root location of the `wasm32-wasi` sysroot.
#wasi-root = "..."

# Used in testing for configuring where the QEMU images are located, you
Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ENV TARGETS=x86_64-fuchsia
ENV TARGETS=$TARGETS,aarch64-fuchsia
ENV TARGETS=$TARGETS,sparcv9-sun-solaris
ENV TARGETS=$TARGETS,wasm32-unknown-unknown
ENV TARGETS=$TARGETS,wasm32-unknown-wasi
ENV TARGETS=$TARGETS,wasm32-wasi
ENV TARGETS=$TARGETS,x86_64-sun-solaris
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi
Expand All @@ -79,5 +79,5 @@ ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda
ENV X86_FORTANIX_SGX_LIBS="/x86_64-fortanix-unknown-sgx/lib/"

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
--set target.wasm32-unknown-wasi.wasi-root=/wasm32-unknown-wasi
--set target.wasm32-wasi.wasi-root=/wasm32-wasi
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
2 changes: 1 addition & 1 deletion src/ci/docker/dist-various-2/build-wasi-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone https://github.com/CraneStation/wasi-sysroot

cd wasi-sysroot
git reset --hard e5f14be38362f1ab83302895a6e74b2ffd0e2302
make -j$(nproc) INSTALL_DIR=/wasm32-unknown-wasi install
make -j$(nproc) INSTALL_DIR=/wasm32-wasi install

cd ..
rm -rf reference-sysroot-wasi
Expand Down
97 changes: 60 additions & 37 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Detecting language items.
//
// Language items are items that represent concepts intrinsic to the language
// itself. Examples are:
//
// * Traits that specify "kinds"; e.g., "Sync", "Send".
//
// * Traits that represent operators; e.g., "Add", "Sub", "Index".
//
// * Functions called by the compiler itself.
//! Detecting language items.
//!
//! Language items are items that represent concepts intrinsic to the language
//! itself. Examples are:
//!
//! * Traits that specify "kinds"; e.g., "Sync", "Send".
//!
//! * Traits that represent operators; e.g., "Add", "Sub", "Index".
//!
//! * Functions called by the compiler itself.

pub use self::LangItem::*;

Expand All @@ -32,13 +32,17 @@ macro_rules! language_item_table {
) => {

enum_from_u32! {
/// A representation of all the valid language items in Rust.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub enum LangItem {
$($variant,)*
}
}

impl LangItem {
/// Returns the `name` in `#[lang = "$name"]`.
/// For example, `LangItem::EqTraitLangItem`,
/// that is `#[lang = "eq"]` would result in `"eq"`.
fn name(self) -> &'static str {
match self {
$( $variant => $name, )*
Expand All @@ -48,28 +52,38 @@ impl LangItem {

#[derive(HashStable)]
pub struct LanguageItems {
/// Mappings from lang items to their possibly found `DefId`s.
/// The index corresponds to the order in `LangItem`.
pub items: Vec<Option<DefId>>,
/// Lang items that were not found during collection.
pub missing: Vec<LangItem>,
}

impl LanguageItems {
pub fn new() -> LanguageItems {
fn foo(_: LangItem) -> Option<DefId> { None }
/// Construct an empty collection of lang items and no missing ones.
pub fn new() -> Self {
fn init_none(_: LangItem) -> Option<DefId> { None }

LanguageItems {
items: vec![$(foo($variant)),*],
Self {
items: vec![$(init_none($variant)),*],
missing: Vec::new(),
}
}

/// Returns the mappings to the possibly found `DefId`s for each lang item.
pub fn items(&self) -> &[Option<DefId>] {
&*self.items
}

/// Requires that a given `LangItem` was bound and returns the corresponding `DefId`.
/// If it wasn't bound, e.g. due to a missing `#[lang = "<it.name()>"]`,
/// returns an error message as a string.
pub fn require(&self, it: LangItem) -> Result<DefId, String> {
self.items[it as usize].ok_or_else(|| format!("requires `{}` lang_item", it.name()))
}

/// Returns the kind of closure that `id`, which is one of the `Fn*` traits, corresponds to.
/// If `id` is not one of the `Fn*` traits, `None` is returned.
pub fn fn_trait_kind(&self, id: DefId) -> Option<ty::ClosureKind> {
match Some(id) {
x if x == self.fn_trait() => Some(ty::ClosureKind::Fn),
Expand All @@ -80,6 +94,9 @@ impl LanguageItems {
}

$(
/// Returns the corresponding `DefId` for the lang item
#[doc = $name]
/// if it exists.
#[allow(dead_code)]
pub fn $method(&self) -> Option<DefId> {
self.items[$variant as usize]
Expand All @@ -90,6 +107,7 @@ impl LanguageItems {
struct LanguageItemCollector<'a, 'tcx: 'a> {
items: LanguageItems,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
/// A mapping from the name of the lang item to its order and the form it must be of.
item_refs: FxHashMap<&'static str, (usize, Target)>,
}

Expand All @@ -105,32 +123,28 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
},
// Known lang item with attribute on incorrect target.
Some((_, expected_target)) => {
let mut err = struct_span_err!(
struct_span_err!(
self.tcx.sess, span, E0718,
"`{}` language item must be applied to a {}",
value, expected_target,
);
err.span_label(
).span_label(
span,
format!(
"attribute should be applied to a {}, not a {}",
expected_target, actual_target,
),
);
err.emit();
).emit();
},
// Unknown lang item.
_ => {
let mut err = struct_span_err!(
struct_span_err!(
self.tcx.sess, span, E0522,
"definition of an unknown language item: `{}`",
value
);
err.span_label(
).span_label(
span,
format!("definition of unknown language item `{}`", value)
);
err.emit();
).emit();
},
}
}
Expand Down Expand Up @@ -190,32 +204,39 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
}
}

/// Extract the first `lang = "$name"` out of a list of attributes.
/// The attributes `#[panic_handler]` and `#[alloc_error_handler]`
/// are also extracted out when found.
pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> {
for attribute in attrs {
if attribute.check_name("lang") {
if let Some(value) = attribute.value_str() {
return Some((value, attribute.span));
}
} else if attribute.check_name("panic_handler") {
return Some((Symbol::intern("panic_impl"), attribute.span))
} else if attribute.check_name("alloc_error_handler") {
return Some((Symbol::intern("oom"), attribute.span))
}
}

None
attrs.iter().find_map(|attr| Some(match attr {
_ if attr.check_name("lang") => (attr.value_str()?, attr.span),
_ if attr.check_name("panic_handler") => (Symbol::intern("panic_impl"), attr.span),
_ if attr.check_name("alloc_error_handler") => (Symbol::intern("oom"), attr.span),
_ => return None,
}))
}

/// Traverse and collect all the lang items in all crates.
pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItems {
// Initialize the collector.
let mut collector = LanguageItemCollector::new(tcx);

// Collect lang items in other crates.
for &cnum in tcx.crates().iter() {
for &(def_id, item_index) in tcx.defined_lang_items(cnum).iter() {
collector.collect_item(item_index, def_id);
}
}

// Collect lang items in this crate.
tcx.hir().krate().visit_all_item_likes(&mut collector);

// Extract out the found lang items.
let LanguageItemCollector { mut items, .. } = collector;

// Find all required but not-yet-defined lang items.
weak_lang_items::check_crate(tcx, &mut items);

items
}

Expand Down Expand Up @@ -382,6 +403,8 @@ language_item_table! {
}

impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> {
/// Returns the `DefId` for a given `LangItem`.
/// If not found, fatally abort compilation.
pub fn require_lang_item(&self, lang_item: LangItem) -> DefId {
self.lang_items().require(lang_item).unwrap_or_else(|msg| {
self.sess.fatal(&msg)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ supported_targets! {
("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
("wasm32-unknown-unknown", wasm32_unknown_unknown),
("wasm32-unknown-wasi", wasm32_unknown_wasi),
("wasm32-wasi", wasm32_wasi),
("wasm32-experimental-emscripten", wasm32_experimental_emscripten),

("thumbv6m-none-eabi", thumbv6m_none_eabi),
Expand Down
Loading