Skip to content

Commit c5445dc

Browse files
committed
Auto merge of #142195 - workingjubilee:rollup-yhkz9am, r=workingjubilee
Rollup of 11 pull requests Successful merges: - #140774 (Affirm `-Cforce-frame-pointers=off` does not override) - #141001 (Make NonZero<char> possible) - #141700 (Atomic intrinsics : use const generic ordering, part 2) - #142008 (const-eval error: always say in which item the error occurred) - #142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`) - #142089 (Replace all uses of sysroot_candidates with get_or_default_sysroot) - #142108 (compiler: Add track_caller to AbiMapping::unwrap) - #142132 (`tests/ui`: A New Order [6/N]) - #142162 (UnsafePinned: update get() docs and signature to allow shared mutation) - #142171 (`tests/ui`: A New Order [7/N]) - #142179 (store `target.min_global_align` as an `Align`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fb644e6 + 9d824b8 commit c5445dc

File tree

283 files changed

+2444
-3226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+2444
-3226
lines changed

Cargo.lock

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ version = "0.4.2"
162162
source = "registry+https://github.com/rust-lang/crates.io-index"
163163
checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4"
164164
dependencies = [
165-
"object",
165+
"object 0.36.7",
166166
]
167167

168168
[[package]]
@@ -235,7 +235,7 @@ dependencies = [
235235
"cfg-if",
236236
"libc",
237237
"miniz_oxide",
238-
"object",
238+
"object 0.36.7",
239239
"rustc-demangle",
240240
"windows-targets 0.52.6",
241241
]
@@ -2509,7 +2509,19 @@ dependencies = [
25092509
"indexmap",
25102510
"memchr",
25112511
"ruzstd",
2512-
"wasmparser 0.222.1",
2512+
]
2513+
2514+
[[package]]
2515+
name = "object"
2516+
version = "0.37.0"
2517+
source = "registry+https://github.com/rust-lang/crates.io-index"
2518+
checksum = "6273adb7096cf9ab4335f258e627d8230e69d40d45567d678f552dcec6245215"
2519+
dependencies = [
2520+
"crc32fast",
2521+
"hashbrown",
2522+
"indexmap",
2523+
"memchr",
2524+
"wasmparser 0.232.0",
25132525
]
25142526

25152527
[[package]]
@@ -3109,7 +3121,7 @@ dependencies = [
31093121
"build_helper",
31103122
"gimli",
31113123
"libc",
3112-
"object",
3124+
"object 0.36.7",
31133125
"regex",
31143126
"serde_json",
31153127
"similar",
@@ -3422,7 +3434,7 @@ dependencies = [
34223434
"itertools",
34233435
"libc",
34243436
"measureme",
3425-
"object",
3437+
"object 0.37.0",
34263438
"rustc-demangle",
34273439
"rustc_abi",
34283440
"rustc_ast",
@@ -3463,7 +3475,7 @@ dependencies = [
34633475
"either",
34643476
"itertools",
34653477
"libc",
3466-
"object",
3478+
"object 0.37.0",
34673479
"pathdiff",
34683480
"regex",
34693481
"rustc_abi",
@@ -3640,6 +3652,7 @@ dependencies = [
36403652
"rustc_macros",
36413653
"rustc_serialize",
36423654
"rustc_span",
3655+
"smallvec",
36433656
"tracing",
36443657
"unic-langid",
36453658
]
@@ -4495,7 +4508,7 @@ name = "rustc_target"
44954508
version = "0.0.0"
44964509
dependencies = [
44974510
"bitflags",
4498-
"object",
4511+
"object 0.37.0",
44994512
"rustc_abi",
45004513
"rustc_data_structures",
45014514
"rustc_fs_util",
@@ -5247,7 +5260,7 @@ checksum = "9e9c1e705f82a260173f3eec93f2ff6d7807f23ad5a8cc2e7316a891733ea7a1"
52475260
dependencies = [
52485261
"gimli",
52495262
"hashbrown",
5250-
"object",
5263+
"object 0.36.7",
52515264
"tracing",
52525265
]
52535266

@@ -5908,15 +5921,6 @@ dependencies = [
59085921
"indexmap",
59095922
]
59105923

5911-
[[package]]
5912-
name = "wasmparser"
5913-
version = "0.222.1"
5914-
source = "registry+https://github.com/rust-lang/crates.io-index"
5915-
checksum = "fa210fd1788e6b37a1d1930f3389c48e1d6ebd1a013d34fa4b7f9e3e3bf03146"
5916-
dependencies = [
5917-
"bitflags",
5918-
]
5919-
59205924
[[package]]
59215925
name = "wasmparser"
59225926
version = "0.229.0"
@@ -5941,6 +5945,15 @@ dependencies = [
59415945
"semver",
59425946
]
59435947

5948+
[[package]]
5949+
name = "wasmparser"
5950+
version = "0.232.0"
5951+
source = "registry+https://github.com/rust-lang/crates.io-index"
5952+
checksum = "917739b33bb1eb0e9a49bcd2637a351931be4578d0cc4d37b908d7a797784fbb"
5953+
dependencies = [
5954+
"bitflags",
5955+
]
5956+
59445957
[[package]]
59455958
name = "wast"
59465959
version = "230.0.0"

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
875875
let ptr = ptr.load_scalar(fx);
876876

877877
let ty = generic_args.type_at(0);
878-
let _ord = generic_args.const_at(1).to_value(); // FIXME: forward this to cranelift once they support that
879878
match ty.kind() {
880879
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
881880
// FIXME implement 128bit atomics
@@ -906,7 +905,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
906905
let val = CValue::by_val(val, fx.layout_of(ty));
907906
ret.write_cvalue(fx, val);
908907
}
909-
_ if intrinsic.as_str().starts_with("atomic_store") => {
908+
sym::atomic_store => {
910909
intrinsic_args!(fx, args => (ptr, val); intrinsic);
911910
let ptr = ptr.load_scalar(fx);
912911

@@ -939,7 +938,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
939938

940939
fx.bcx.ins().atomic_store(MemFlags::trusted(), val, ptr);
941940
}
942-
_ if intrinsic.as_str().starts_with("atomic_xchg") => {
941+
sym::atomic_xchg => {
943942
intrinsic_args!(fx, args => (ptr, new); intrinsic);
944943
let ptr = ptr.load_scalar(fx);
945944

@@ -960,8 +959,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
960959
let old = CValue::by_val(old, layout);
961960
ret.write_cvalue(fx, old);
962961
}
963-
_ if intrinsic.as_str().starts_with("atomic_cxchg") => {
964-
// both atomic_cxchg_* and atomic_cxchgweak_*
962+
sym::atomic_cxchg | sym::atomic_cxchgweak => {
965963
intrinsic_args!(fx, args => (ptr, test_old, new); intrinsic);
966964
let ptr = ptr.load_scalar(fx);
967965

@@ -984,7 +982,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
984982
ret.write_cvalue(fx, ret_val)
985983
}
986984

987-
_ if intrinsic.as_str().starts_with("atomic_xadd") => {
985+
sym::atomic_xadd => {
988986
intrinsic_args!(fx, args => (ptr, amount); intrinsic);
989987
let ptr = ptr.load_scalar(fx);
990988

@@ -1006,7 +1004,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10061004
let old = CValue::by_val(old, layout);
10071005
ret.write_cvalue(fx, old);
10081006
}
1009-
_ if intrinsic.as_str().starts_with("atomic_xsub") => {
1007+
sym::atomic_xsub => {
10101008
intrinsic_args!(fx, args => (ptr, amount); intrinsic);
10111009
let ptr = ptr.load_scalar(fx);
10121010

@@ -1028,7 +1026,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10281026
let old = CValue::by_val(old, layout);
10291027
ret.write_cvalue(fx, old);
10301028
}
1031-
_ if intrinsic.as_str().starts_with("atomic_and") => {
1029+
sym::atomic_and => {
10321030
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10331031
let ptr = ptr.load_scalar(fx);
10341032

@@ -1049,7 +1047,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10491047
let old = CValue::by_val(old, layout);
10501048
ret.write_cvalue(fx, old);
10511049
}
1052-
_ if intrinsic.as_str().starts_with("atomic_or") => {
1050+
sym::atomic_or => {
10531051
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10541052
let ptr = ptr.load_scalar(fx);
10551053

@@ -1070,7 +1068,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10701068
let old = CValue::by_val(old, layout);
10711069
ret.write_cvalue(fx, old);
10721070
}
1073-
_ if intrinsic.as_str().starts_with("atomic_xor") => {
1071+
sym::atomic_xor => {
10741072
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10751073
let ptr = ptr.load_scalar(fx);
10761074

@@ -1091,7 +1089,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10911089
let old = CValue::by_val(old, layout);
10921090
ret.write_cvalue(fx, old);
10931091
}
1094-
_ if intrinsic.as_str().starts_with("atomic_nand") => {
1092+
sym::atomic_nand => {
10951093
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10961094
let ptr = ptr.load_scalar(fx);
10971095

@@ -1112,7 +1110,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11121110
let old = CValue::by_val(old, layout);
11131111
ret.write_cvalue(fx, old);
11141112
}
1115-
_ if intrinsic.as_str().starts_with("atomic_max") => {
1113+
sym::atomic_max => {
11161114
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11171115
let ptr = ptr.load_scalar(fx);
11181116

@@ -1133,7 +1131,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11331131
let old = CValue::by_val(old, layout);
11341132
ret.write_cvalue(fx, old);
11351133
}
1136-
_ if intrinsic.as_str().starts_with("atomic_umax") => {
1134+
sym::atomic_umax => {
11371135
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11381136
let ptr = ptr.load_scalar(fx);
11391137

@@ -1154,7 +1152,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11541152
let old = CValue::by_val(old, layout);
11551153
ret.write_cvalue(fx, old);
11561154
}
1157-
_ if intrinsic.as_str().starts_with("atomic_min") => {
1155+
sym::atomic_min => {
11581156
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11591157
let ptr = ptr.load_scalar(fx);
11601158

@@ -1175,7 +1173,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11751173
let old = CValue::by_val(old, layout);
11761174
ret.write_cvalue(fx, old);
11771175
}
1178-
_ if intrinsic.as_str().starts_with("atomic_umin") => {
1176+
sym::atomic_umin => {
11791177
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11801178
let ptr = ptr.load_scalar(fx);
11811179

compiler/rustc_codegen_gcc/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",

compiler/rustc_codegen_gcc/messages.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +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-
85
codegen_gcc_forbidden_ctarget_feature =
96
target feature `{$feature}` cannot be toggled with `-Ctarget-feature`: {$reason}
107

compiler/rustc_codegen_gcc/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
}

compiler/rustc_codegen_gcc/src/errors.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ pub(crate) struct UnwindingInlineAsm {
4747
pub span: Span,
4848
}
4949

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

compiler/rustc_codegen_llvm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ gimli = "0.31"
1515
itertools = "0.12"
1616
libc = "0.2"
1717
measureme = "12.0.1"
18-
object = { version = "0.36.3", default-features = false, features = ["std", "read"] }
18+
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
1919
rustc-demangle = "0.1.21"
2020
rustc_abi = { path = "../rustc_abi" }
2121
rustc_ast = { path = "../rustc_ast" }

compiler/rustc_codegen_llvm/messages.ftl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ codegen_llvm_from_llvm_diag = {$message}
1919
2020
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}
2121
22-
codegen_llvm_invalid_minimum_alignment_not_power_of_two =
23-
invalid minimum global alignment: {$align} is not power of 2
24-
25-
codegen_llvm_invalid_minimum_alignment_too_large =
26-
invalid minimum global alignment: {$align} is too large
27-
2822
codegen_llvm_load_bitcode = failed to load bitcode of module "{$name}"
2923
codegen_llvm_load_bitcode_with_llvm_err = failed to load bitcode of module "{$name}": {$llvm_err}
3024

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
251251
InlineAsmArch::Nvptx64 => {}
252252
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {}
253253
InlineAsmArch::Hexagon => {}
254-
InlineAsmArch::LoongArch64 => {
254+
InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
255255
constraints.extend_from_slice(&[
256256
"~{$fcc0}".to_string(),
257257
"~{$fcc1}".to_string(),

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::ops::Range;
22

3-
use rustc_abi::{
4-
Align, AlignFromBytesError, HasDataLayout, Primitive, Scalar, Size, WrappingRange,
5-
};
3+
use rustc_abi::{Align, HasDataLayout, Primitive, Scalar, Size, WrappingRange};
64
use rustc_codegen_ssa::common;
75
use rustc_codegen_ssa::traits::*;
86
use rustc_hir::LangItem;
@@ -20,9 +18,7 @@ use rustc_middle::{bug, span_bug};
2018
use tracing::{debug, instrument, trace};
2119

2220
use crate::common::{AsCCharPtr, CodegenCx};
23-
use crate::errors::{
24-
InvalidMinimumAlignmentNotPowerOfTwo, InvalidMinimumAlignmentTooLarge, SymbolAlreadyDefined,
25-
};
21+
use crate::errors::SymbolAlreadyDefined;
2622
use crate::llvm::{self, True};
2723
use crate::type_::Type;
2824
use crate::type_of::LayoutLlvmExt;
@@ -149,22 +145,10 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align:
149145
// The target may require greater alignment for globals than the type does.
150146
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
151147
// which can force it to be smaller. Rust doesn't support this yet.
152-
if let Some(min) = cx.sess().target.min_global_align {
153-
match Align::from_bits(min) {
154-
Ok(min) => align = align.max(min),
155-
Err(err) => match err {
156-
AlignFromBytesError::NotPowerOfTwo(align) => {
157-
cx.sess().dcx().emit_err(InvalidMinimumAlignmentNotPowerOfTwo { align });
158-
}
159-
AlignFromBytesError::TooLarge(align) => {
160-
cx.sess().dcx().emit_err(InvalidMinimumAlignmentTooLarge { align });
161-
}
162-
},
163-
}
164-
}
165-
unsafe {
166-
llvm::LLVMSetAlignment(gv, align.bytes() as u32);
148+
if let Some(min_global) = cx.sess().target.min_global_align {
149+
align = Ord::max(align, min_global);
167150
}
151+
llvm::set_alignment(gv, align);
168152
}
169153

170154
fn check_and_apply_linkage<'ll, 'tcx>(

0 commit comments

Comments
 (0)