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 7 pull requests #125358

Merged
merged 36 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0eb782d
Document all Apple targets in rustc's platform support
madsmtm May 5, 2024
1d1981b
Add opt-for-size core lib feature flag
diondokter May 11, 2024
579266a
Add flag to std and alloc too
diondokter May 11, 2024
9ab0af8
Add flag to sysroot
diondokter May 11, 2024
b8b6898
Forward alloc features to core
diondokter May 13, 2024
b964b00
Run tests with the flag enabled
diondokter May 17, 2024
5c30142
Only test std, alloc and core
diondokter May 17, 2024
f0b8da4
rewrite no-intermediate-extras
Oneirical May 17, 2024
abdaed2
tidy fix
Oneirical May 17, 2024
9d0b75f
missing import
Oneirical May 17, 2024
8c43e54
fix: swap the error codes
Oneirical May 17, 2024
6016bad
Use `_NSGetEnviron` instead of `environ` on iOS/tvOS/watchOS/visionOS
madsmtm May 17, 2024
8f18e4f
Use `_NSGetArgc`/`_NSGetArgv` on iOS/tvOS/watchOS/visionOS
madsmtm May 17, 2024
1914c72
compiler: add simd_ctpop intrinsic
workingjubilee May 19, 2024
abd5d0e
Add NULL check in argument parsing on Apple platforms
madsmtm May 19, 2024
1185a64
miri: support simd_ctpop
workingjubilee May 20, 2024
9557b90
cg_clif: support simd_ctpop
workingjubilee May 20, 2024
213351a
clarify the second arg to llvm.ctlz and cttz
workingjubilee May 20, 2024
38ad851
Make NULL check in argument parsing the same on all unix platforms
madsmtm May 20, 2024
0d23a71
Deduplicate test command
diondokter May 20, 2024
bd71c71
Move tests to more opportune point
diondokter May 20, 2024
f6cf103
Small fixes to `std::path::absolute` docs
tbu- May 20, 2024
95c47d3
simplify
Oneirical May 21, 2024
eb10eb2
Reorder top-level attributes.
nnethercote Apr 24, 2024
d8ea468
Reorder some `use` items.
nnethercote Apr 25, 2024
ce22232
Minor `pub` and whitespace cleanups.
nnethercote Apr 30, 2024
c1d5b6a
Remove erroneous comment.
nnethercote Apr 30, 2024
ac847b2
Remove unused features from `rustc_middle`.
nnethercote Apr 30, 2024
3ac816a
Sort `rustc_middle` attributes.
nnethercote Apr 30, 2024
df59800
Rollup merge of #124570 - nnethercote:misc-cleanups, r=michaelwoerister
matthiaskrgr May 21, 2024
4a4883b
Rollup merge of #124772 - madsmtm:apple-platform-support-docs, r=oli-obk
matthiaskrgr May 21, 2024
4abf179
Rollup merge of #125011 - diondokter:opt-for-size, r=Amanieu,kobzol
matthiaskrgr May 21, 2024
7ef533b
Rollup merge of #125218 - Oneirical:easy-test-the-third, r=jieyouxu
matthiaskrgr May 21, 2024
a8ee8d5
Rollup merge of #125225 - madsmtm:ios-crt_externs.h, r=workingjubilee
matthiaskrgr May 21, 2024
fd975f7
Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJ…
matthiaskrgr May 21, 2024
e6e05d5
Rollup merge of #125348 - tbu-:pr_doc_path_absolute, r=jhpratt
matthiaskrgr May 21, 2024
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
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
| sym::simd_bswap
| sym::simd_bitreverse
| sym::simd_ctlz
| sym::simd_ctpop
| sym::simd_cttz => {
intrinsic_args!(fx, args => (a); intrinsic);

Expand All @@ -367,6 +368,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
(ty::Uint(_) | ty::Int(_), sym::simd_bswap) => fx.bcx.ins().bswap(lane),
(ty::Uint(_) | ty::Int(_), sym::simd_bitreverse) => fx.bcx.ins().bitrev(lane),
(ty::Uint(_) | ty::Int(_), sym::simd_ctlz) => fx.bcx.ins().clz(lane),
(ty::Uint(_) | ty::Int(_), sym::simd_ctpop) => fx.bcx.ins().popcnt(lane),
(ty::Uint(_) | ty::Int(_), sym::simd_cttz) => fx.bcx.ins().ctz(lane),

_ => unreachable!(),
Expand Down
48 changes: 29 additions & 19 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
}

// Unary integer intrinsics
if matches!(name, sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctlz | sym::simd_cttz) {
if matches!(
name,
sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctlz | sym::simd_ctpop | sym::simd_cttz
) {
let vec_ty = bx.cx.type_vector(
match *in_elem.kind() {
ty::Int(i) => bx.cx.type_int_from_ty(i),
Expand All @@ -2354,31 +2357,38 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
sym::simd_bswap => "bswap",
sym::simd_bitreverse => "bitreverse",
sym::simd_ctlz => "ctlz",
sym::simd_ctpop => "ctpop",
sym::simd_cttz => "cttz",
_ => unreachable!(),
};
let int_size = in_elem.int_size_and_signed(bx.tcx()).0.bits();
let llvm_intrinsic = &format!("llvm.{}.v{}i{}", intrinsic_name, in_len, int_size,);

return if name == sym::simd_bswap && int_size == 8 {
return match name {
// byte swap is no-op for i8/u8
Ok(args[0].immediate())
} else if matches!(name, sym::simd_ctlz | sym::simd_cttz) {
let fn_ty = bx.type_func(&[vec_ty, bx.type_i1()], vec_ty);
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
Ok(bx.call(
fn_ty,
None,
None,
f,
&[args[0].immediate(), bx.const_int(bx.type_i1(), 0)],
None,
None,
))
} else {
let fn_ty = bx.type_func(&[vec_ty], vec_ty);
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
Ok(bx.call(fn_ty, None, None, f, &[args[0].immediate()], None, None))
sym::simd_bswap if int_size == 8 => Ok(args[0].immediate()),
sym::simd_ctlz | sym::simd_cttz => {
// for the (int, i1 immediate) pair, the second arg adds `(0, true) => poison`
let fn_ty = bx.type_func(&[vec_ty, bx.type_i1()], vec_ty);
let dont_poison_on_zero = bx.const_int(bx.type_i1(), 0);
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
Ok(bx.call(
fn_ty,
None,
None,
f,
&[args[0].immediate(), dont_poison_on_zero],
None,
None,
))
}
sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctpop => {
// simple unary argument cases
let fn_ty = bx.type_func(&[vec_ty], vec_ty);
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
Ok(bx.call(fn_ty, None, None, f, &[args[0].immediate()], None, None))
}
_ => unreachable!(),
};
}

Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_const_eval/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*!
Rust MIR: a lowered representation of Rust.
*/

#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![feature(rustdoc_internals)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ pub fn check_intrinsic_type(
| sym::simd_bitreverse
| sym::simd_ctlz
| sym::simd_cttz
| sym::simd_ctpop
| sym::simd_fsqrt
| sym::simd_fsin
| sym::simd_fcos
Expand Down
17 changes: 9 additions & 8 deletions compiler/rustc_metadata/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![allow(rustc::potential_query_instability)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![allow(internal_features)]
#![feature(coroutines)]
#![feature(decl_macro)]
#![feature(error_iter)]
#![feature(extract_if)]
#![feature(coroutines)]
#![feature(if_let_guard)]
#![feature(iter_from_coroutine)]
#![feature(let_chains)]
#![feature(if_let_guard)]
#![feature(proc_macro_internals)]
#![feature(macro_metavar_expr)]
#![feature(min_specialization)]
#![feature(trusted_len)]
#![feature(try_blocks)]
#![feature(never_type)]
#![allow(rustc::potential_query_instability)]
#![feature(proc_macro_internals)]
#![feature(rustdoc_internals)]
#![feature(trusted_len)]
// tidy-alphabetical-end

extern crate proc_macro;

Expand Down
25 changes: 10 additions & 15 deletions compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use crate::creader::CrateMetadataRef;
use decoder::Metadata;
pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob};
use decoder::{DecodeContext, Metadata};
use def_path_hash_map::DefPathHashMapRef;
use rustc_data_structures::fx::FxHashMap;
use rustc_macros::{Decodable, Encodable, TyDecodable, TyEncodable};
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::lib_features::FeatureStability;
use table::TableBuilder;

use encoder::EncodeContext;
pub use encoder::{encode_metadata, rendered_const, EncodedMetadata};
use rustc_ast as ast;
use rustc_ast::expand::StrippedCfgItem;
use rustc_attr as attr;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::svh::Svh;
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap};
Expand All @@ -18,10 +16,13 @@ use rustc_hir::definitions::DefKey;
use rustc_hir::lang_items::LangItem;
use rustc_index::bit_set::BitSet;
use rustc_index::IndexVec;
use rustc_macros::{Decodable, Encodable, TyDecodable, TyEncodable};
use rustc_macros::{MetadataDecodable, MetadataEncodable};
use rustc_middle::metadata::ModChild;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
use rustc_middle::middle::lib_features::FeatureStability;
use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault;
use rustc_middle::mir;
use rustc_middle::trivially_parameterized_over_tcx;
Expand All @@ -33,20 +34,14 @@ use rustc_serialize::opaque::FileEncoder;
use rustc_session::config::SymbolManglingVersion;
use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
use rustc_span::edition::Edition;
use rustc_span::hygiene::{ExpnIndex, MacroKind};
use rustc_span::hygiene::{ExpnIndex, MacroKind, SyntaxContextData};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span};
use rustc_target::abi::{FieldIdx, VariantIdx};
use rustc_target::spec::{PanicStrategy, TargetTriple};

use std::marker::PhantomData;
use std::num::NonZero;

use decoder::DecodeContext;
pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob};
use encoder::EncodeContext;
pub use encoder::{encode_metadata, rendered_const, EncodedMetadata};
use rustc_span::hygiene::SyntaxContextData;
use table::TableBuilder;

mod decoder;
mod def_path_hash_map;
Expand Down
44 changes: 22 additions & 22 deletions compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,46 @@
//!
//! This API is completely unstable and subject to change.

// tidy-alphabetical-start
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::potential_query_instability)]
#![allow(rustc::untranslatable_diagnostic)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(min_exhaustive_patterns)]
#![feature(rustdoc_internals)]
#![feature(allocator_api)]
#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(closure_track_caller)]
#![feature(core_intrinsics)]
#![feature(const_option)]
#![feature(const_type_name)]
#![feature(discriminant_kind)]
#![feature(core_intrinsics)]
#![feature(coroutines)]
#![feature(stmt_expr_attributes)]
#![feature(decl_macro)]
#![feature(discriminant_kind)]
#![feature(extern_types)]
#![feature(extract_if)]
#![feature(if_let_guard)]
#![feature(intra_doc_pointers)]
#![feature(iter_from_coroutine)]
#![feature(let_chains)]
#![feature(macro_metavar_expr)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(extern_types)]
#![feature(new_uninit)]
#![feature(let_chains)]
#![feature(min_specialization)]
#![feature(trusted_len)]
#![feature(type_alias_impl_trait)]
#![feature(strict_provenance)]
#![feature(ptr_alignment_type)]
#![feature(rustc_attrs)]
#![feature(control_flow_enum)]
#![feature(rustdoc_internals)]
#![feature(strict_provenance)]
#![feature(trait_upcasting)]
#![feature(trusted_len)]
#![feature(try_blocks)]
#![feature(decl_macro)]
#![feature(extract_if)]
#![feature(intra_doc_pointers)]
#![feature(type_alias_impl_trait)]
#![feature(yeet_expr)]
#![feature(const_option)]
#![feature(ptr_alignment_type)]
#![feature(macro_metavar_expr)]
#![allow(internal_features)]
#![allow(rustc::potential_query_instability)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
// tidy-alphabetical-end

#[macro_use]
extern crate tracing;
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ use std::collections::hash_map::Entry;

#[derive(LintDiagnostic)]
#[diag(passes_diagnostic_diagnostic_on_unimplemented_only_for_traits)]
pub struct DiagnosticOnUnimplementedOnlyForTraits;
struct DiagnosticOnUnimplementedOnlyForTraits;

pub(crate) fn target_from_impl_item<'tcx>(
tcx: TyCtxt<'tcx>,
impl_item: &hir::ImplItem<'_>,
) -> Target {
fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>) -> Target {
match impl_item.kind {
hir::ImplItemKind::Const(..) => Target::AssocConst,
hir::ImplItemKind::Fn(..) => {
Expand Down Expand Up @@ -99,7 +96,7 @@ struct CheckAttrVisitor<'tcx> {
}

impl<'tcx> CheckAttrVisitor<'tcx> {
pub fn dcx(&self) -> &'tcx DiagCtxt {
fn dcx(&self) -> &'tcx DiagCtxt {
self.tcx.dcx()
}

Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_passes/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> {
}
};

// When there's a duplicate lang item, something went very wrong and there's no value in recovering or doing anything.
// Give the user the one message to let them debug the mess they created and then wish them farewell.
// When there's a duplicate lang item, something went very wrong and there's no value
// in recovering or doing anything. Give the user the one message to let them debug the
// mess they created and then wish them farewell.
self.tcx.dcx().emit_fatal(DuplicateLangItem {
local_span: item_span,
lang_item_name,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,7 @@ symbols! {
simd_cast_ptr,
simd_ceil,
simd_ctlz,
simd_ctpop,
simd_cttz,
simd_div,
simd_eq,
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/base/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ fn macos_default_deployment_target(arch: Arch) -> (u32, u32) {

fn macos_deployment_target(arch: Arch) -> (u32, u32) {
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
// Note: If bumping this version, remember to update it in the rustc/platform-support docs.
from_set_deployment_target("MACOSX_DEPLOYMENT_TARGET")
.unwrap_or_else(|| macos_default_deployment_target(arch))
}
Expand Down Expand Up @@ -320,6 +321,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {

fn ios_deployment_target(arch: Arch, abi: &str) -> (u32, u32) {
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
// Note: If bumping this version, remember to update it in the rustc/platform-support docs.
let (major, minor) = match (arch, abi) {
(Arm64e, _) => (14, 0),
// Mac Catalyst defaults to 13.1 in Clang.
Expand Down Expand Up @@ -352,6 +354,7 @@ pub fn ios_sim_llvm_target(arch: Arch) -> String {

fn tvos_deployment_target() -> (u32, u32) {
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
// Note: If bumping this version, remember to update it in the rustc platform-support docs.
from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((10, 0))
}

Expand All @@ -367,6 +370,7 @@ pub fn tvos_sim_llvm_target(arch: Arch) -> String {

fn watchos_deployment_target() -> (u32, u32) {
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
// Note: If bumping this version, remember to update it in the rustc platform-support docs.
from_set_deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0))
}

Expand All @@ -382,6 +386,7 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String {

fn visionos_deployment_target() -> (u32, u32) {
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
// Note: If bumping this version, remember to update it in the rustc platform-support docs.
from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0))
}

Expand Down
4 changes: 3 additions & 1 deletion library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ compiler-builtins-no-asm = ["compiler_builtins/no-asm"]
compiler-builtins-mangled-names = ["compiler_builtins/mangled-names"]
compiler-builtins-weak-intrinsics = ["compiler_builtins/weak-intrinsics"]
# Make panics and failed asserts immediately abort without formatting any message
panic_immediate_abort = []
panic_immediate_abort = ["core/panic_immediate_abort"]
# Choose algorithms that are optimized for binary size instead of runtime performance
optimize_for_size = ["core/optimize_for_size"]
2 changes: 2 additions & 0 deletions library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ rand_xorshift = { version = "0.3.0", default-features = false }
[features]
# Make panics and failed asserts immediately abort without formatting any message
panic_immediate_abort = []
# Choose algorithms that are optimized for binary size instead of runtime performance
optimize_for_size = []
# Make `RefCell` store additional debugging information, which is printed out when
# a borrow error occurs
debug_refcell = []
7 changes: 7 additions & 0 deletions library/core/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ extern "rust-intrinsic" {
#[rustc_nounwind]
pub fn simd_ctlz<T>(x: T) -> T;

/// Count the number of ones in each element.
///
/// `T` must be a vector of integers.
#[rustc_nounwind]
#[cfg(not(bootstrap))]
pub fn simd_ctpop<T>(x: T) -> T;

/// Count the trailing zeros of each element.
///
/// `T` must be a vector of integers.
Expand Down
2 changes: 2 additions & 0 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ system-llvm-libunwind = ["unwind/system-llvm-libunwind"]

# Make panics and failed asserts immediately abort without formatting any message
panic_immediate_abort = ["core/panic_immediate_abort", "alloc/panic_immediate_abort"]
# Choose algorithms that are optimized for binary size instead of runtime performance
optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"]

# Enable std_detect default features for stdarch/crates/std_detect:
# https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml
Expand Down
Loading
Loading