Skip to content

Commit 94cac95

Browse files
committed
Merge ref 'd087f112b7d1:/library/compiler-builtins' from https://github.com/rust-lang/rust
Pull recent changes from rust-lang/rust via Josh. Upstream ref: d087f112b7d1323446c7b39a8b616aee7fa56b3d Filtered ref: 2d43ce8ac022170e5383f7e5a188b55564b6566a
2 parents 3fffc88 + 77367f8 commit 94cac95

10 files changed

Lines changed: 25 additions & 64 deletions

File tree

build_system/build_sysroot/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ resolver = "2"
66

77
[dependencies]
88
core = { path = "./sysroot_src/library/core" }
9-
compiler_builtins = "0.1"
109
alloc = { path = "./sysroot_src/library/alloc" }
1110
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
1211
test = { path = "./sysroot_src/library/test" }
@@ -16,6 +15,7 @@ proc_macro = { path = "./sysroot_src/library/proc_macro" }
1615
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
1716
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
1817
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }
18+
compiler_builtins = { path = "./sysroot_src/library/compiler-builtins/compiler-builtins" }
1919

2020
# For compiler-builtins we always use a high number of codegen units.
2121
# The goal here is to place every single intrinsic into its own object

example/alloc_system.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// add fast paths for low alignment values.
99
#[cfg(any(target_arch = "x86",
1010
target_arch = "arm",
11+
target_arch = "loongarch32",
1112
target_arch = "m68k",
1213
target_arch = "mips",
1314
target_arch = "mips32r6",

example/mini_core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,9 @@ pub mod intrinsics {
655655
#[rustc_intrinsic]
656656
pub unsafe fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
657657
#[rustc_intrinsic]
658-
pub fn min_align_of<T>() -> usize;
658+
pub fn align_of<T>() -> usize;
659659
#[rustc_intrinsic]
660-
pub unsafe fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
660+
pub unsafe fn align_of_val<T: ?::Sized>(val: *const T) -> usize;
661661
#[rustc_intrinsic]
662662
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize);
663663
#[rustc_intrinsic]

example/mini_core_hello_world.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn main() {
153153
let slice = &[0, 1] as &[i32];
154154
let slice_ptr = slice as *const [i32] as *const i32;
155155

156-
let align = intrinsics::min_align_of::<*const i32>();
156+
let align = intrinsics::align_of::<*const i32>();
157157
assert_eq!(slice_ptr as usize % align, 0);
158158

159159
//return;
@@ -194,8 +194,8 @@ fn main() {
194194
assert_eq!(intrinsics::size_of_val(a) as u8, 8);
195195
assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4);
196196

197-
assert_eq!(intrinsics::min_align_of::<u16>() as u8, 2);
198-
assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8);
197+
assert_eq!(intrinsics::align_of::<u16>() as u8, 2);
198+
assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8);
199199

200200
assert!(!intrinsics::needs_drop::<u8>());
201201
assert!(!intrinsics::needs_drop::<[u8]>());

messages.ftl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ codegen_gcc_unknown_ctarget_feature_prefix =
22
unknown feature specified for `-Ctarget-feature`: `{$feature}`
33
.note = features must begin with a `+` to enable or `-` to disable it
44
5-
codegen_gcc_invalid_minimum_alignment =
6-
invalid minimum global alignment: {$err}
7-
8-
codegen_gcc_forbidden_ctarget_feature =
9-
target feature `{$feature}` cannot be toggled with `-Ctarget-feature`: {$reason}
10-
115
codegen_gcc_unwinding_inline_asm =
126
GCC backend does not support unwinding from inline asm
137
@@ -29,10 +23,6 @@ codegen_gcc_unknown_ctarget_feature =
2923
.possible_feature = you might have meant: `{$rust_feature}`
3024
.consider_filing_feature_request = consider filing a feature request
3125
32-
codegen_gcc_unstable_ctarget_feature =
33-
unstable feature specified for `-Ctarget-feature`: `{$feature}`
34-
.note = this feature is not stably supported; its behavior can change in the future
35-
3626
codegen_gcc_missing_features =
3727
add the missing features in a `target_feature` attribute
3828

src/abi.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,16 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
239239
pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option<FnAttribute<'gcc>> {
240240
let attribute = match conv {
241241
CanonAbi::C | CanonAbi::Rust => return None,
242+
CanonAbi::RustCold => FnAttribute::Cold,
243+
// Functions with this calling convention can only be called from assembly, but it is
244+
// possible to declare an `extern "custom"` block, so the backend still needs a calling
245+
// convention for declaring foreign functions.
246+
CanonAbi::Custom => return None,
242247
CanonAbi::Arm(arm_call) => match arm_call {
243248
ArmCall::CCmseNonSecureCall => FnAttribute::ArmCmseNonsecureCall,
244249
ArmCall::CCmseNonSecureEntry => FnAttribute::ArmCmseNonsecureEntry,
245250
ArmCall::Aapcs => FnAttribute::ArmPcs("aapcs"),
246251
},
247-
CanonAbi::RustCold => FnAttribute::Cold,
248252
CanonAbi::GpuKernel => {
249253
if arch == "amdgpu" {
250254
FnAttribute::GcnAmdGpuHsaKernel

src/consts.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use rustc_span::def_id::DefId;
1818

1919
use crate::base;
2020
use crate::context::CodegenCx;
21-
use crate::errors::InvalidMinimumAlignment;
2221
use crate::type_of::LayoutGccExt;
2322

2423
fn set_global_alignment<'gcc, 'tcx>(
@@ -29,13 +28,8 @@ fn set_global_alignment<'gcc, 'tcx>(
2928
// The target may require greater alignment for globals than the type does.
3029
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
3130
// which can force it to be smaller. Rust doesn't support this yet.
32-
if let Some(min) = cx.sess().target.min_global_align {
33-
match Align::from_bits(min) {
34-
Ok(min) => align = align.max(min),
35-
Err(err) => {
36-
cx.sess().dcx().emit_err(InvalidMinimumAlignment { err: err.to_string() });
37-
}
38-
}
31+
if let Some(min_global) = cx.sess().target.min_global_align {
32+
align = Ord::max(align, min_global);
3933
}
4034
gv.set_alignment(align.bytes() as i32);
4135
}

src/errors.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,6 @@ pub(crate) struct UnknownCTargetFeature<'a> {
1717
pub rust_feature: PossibleFeature<'a>,
1818
}
1919

20-
#[derive(Diagnostic)]
21-
#[diag(codegen_gcc_unstable_ctarget_feature)]
22-
#[note]
23-
pub(crate) struct UnstableCTargetFeature<'a> {
24-
pub feature: &'a str,
25-
}
26-
27-
#[derive(Diagnostic)]
28-
#[diag(codegen_gcc_forbidden_ctarget_feature)]
29-
pub(crate) struct ForbiddenCTargetFeature<'a> {
30-
pub feature: &'a str,
31-
pub enabled: &'a str,
32-
pub reason: &'a str,
33-
}
34-
3520
#[derive(Subdiagnostic)]
3621
pub(crate) enum PossibleFeature<'a> {
3722
#[help(codegen_gcc_possible_feature)]
@@ -47,12 +32,6 @@ pub(crate) struct UnwindingInlineAsm {
4732
pub span: Span,
4833
}
4934

50-
#[derive(Diagnostic)]
51-
#[diag(codegen_gcc_invalid_minimum_alignment)]
52-
pub(crate) struct InvalidMinimumAlignment {
53-
pub err: String,
54-
}
55-
5635
#[derive(Diagnostic)]
5736
#[diag(codegen_gcc_copy_bitcode)]
5837
pub(crate) struct CopyBitcode {

src/gcc_util.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable;
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_data_structures::unord::UnordSet;
77
use rustc_session::Session;
8+
use rustc_session::features::{StabilityExt, retpoline_features_by_flags};
89
use rustc_target::target_features::RUSTC_SPECIFIC_FEATURES;
910
use smallvec::{SmallVec, smallvec};
1011

11-
use crate::errors::{
12-
ForbiddenCTargetFeature, PossibleFeature, UnknownCTargetFeature, UnknownCTargetFeaturePrefix,
13-
UnstableCTargetFeature,
14-
};
12+
use crate::errors::{PossibleFeature, UnknownCTargetFeature, UnknownCTargetFeaturePrefix};
13+
14+
fn gcc_features_by_flags(sess: &Session) -> Vec<&str> {
15+
let mut features: Vec<&str> = Vec::new();
16+
retpoline_features_by_flags(sess, &mut features);
17+
features
18+
}
1519

1620
/// The list of GCC features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
1721
/// `--target` and similar).
@@ -45,7 +49,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
4549

4650
// Compute implied features
4751
let mut all_rust_features = vec![];
48-
for feature in sess.opts.cg.target_feature.split(',') {
52+
for feature in sess.opts.cg.target_feature.split(',').chain(gcc_features_by_flags(sess)) {
4953
if let Some(feature) = feature.strip_prefix('+') {
5054
all_rust_features.extend(
5155
UnordSet::from(sess.target.implied_target_features(feature))
@@ -94,18 +98,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
9498
sess.dcx().emit_warn(unknown_feature);
9599
}
96100
Some(&(_, stability, _)) => {
97-
if let Err(reason) = stability.toggle_allowed() {
98-
sess.dcx().emit_warn(ForbiddenCTargetFeature {
99-
feature,
100-
enabled: if enable { "enabled" } else { "disabled" },
101-
reason,
102-
});
103-
} else if stability.requires_nightly().is_some() {
104-
// An unstable feature. Warn about using it. (It makes little sense
105-
// to hard-error here since we just warn about fully unknown
106-
// features above).
107-
sess.dcx().emit_warn(UnstableCTargetFeature { feature });
108-
}
101+
stability.verify_feature_enabled_by_flag(sess, enable, feature);
109102
}
110103
}
111104

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![allow(internal_features)]
1717
#![doc(rust_logo)]
1818
#![feature(rustdoc_internals)]
19-
#![feature(rustc_private, decl_macro, never_type, trusted_len)]
19+
#![feature(rustc_private)]
2020
#![allow(broken_intra_doc_links)]
2121
#![recursion_limit = "256"]
2222
#![warn(rust_2018_idioms)]

0 commit comments

Comments
 (0)