Skip to content

Commit b7091ec

Browse files
authored
Merge pull request #694 from rust-lang/sync_from_rust_2025_06_02
Sync from rust 2025/06/02
2 parents 98d65f2 + 8385f3c commit b7091ec

File tree

14 files changed

+124
-218
lines changed

14 files changed

+124
-218
lines changed

build_system/src/test.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -738,14 +738,7 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
738738
let path = get_sysroot_dir().join("sysroot_src/library/coretests");
739739
let _ = remove_dir_all(path.join("target"));
740740
// TODO(antoyo): run in release mode when we fix the failures.
741-
// TODO(antoyo): remove the --skip f16::test_total_cmp when this issue is fixed:
742-
// https://github.com/rust-lang/rust/issues/141503
743-
run_cargo_command(
744-
&[&"test", &"--", &"--skip", &"f16::test_total_cmp"],
745-
Some(&path),
746-
env,
747-
args,
748-
)?;
741+
run_cargo_command(&[&"test"], Some(&path), env, args)?;
749742
Ok(())
750743
}
751744

patches/0001-Pin-compiler_builtins-to-0.1.160.patch

Lines changed: 0 additions & 39 deletions
This file was deleted.

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-05-21"
2+
channel = "nightly-2025-06-02"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/abi.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_target::callconv::{Conv, RiscvInterruptKind};
1515

1616
use crate::builder::Builder;
1717
use crate::context::CodegenCx;
18-
use crate::intrinsic::ArgAbiExt;
1918
use crate::type_of::LayoutGccExt;
2019

2120
impl AbiBuilderMethods for Builder<'_, '_, '_> {
@@ -125,7 +124,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
125124
PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx),
126125
PassMode::Cast { ref cast, .. } => cast.gcc_type(cx),
127126
PassMode::Indirect { .. } => {
128-
argument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx)));
127+
argument_tys.push(cx.type_ptr_to(self.ret.layout.gcc_type(cx)));
129128
cx.type_void()
130129
}
131130
};
@@ -176,13 +175,13 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
176175
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: true } => {
177176
// This is a "byval" argument, so we don't apply the `restrict` attribute on it.
178177
on_stack_param_indices.insert(argument_tys.len());
179-
arg.memory_ty(cx)
178+
arg.layout.gcc_type(cx)
180179
}
181180
PassMode::Direct(attrs) => {
182181
apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs, argument_tys.len())
183182
}
184183
PassMode::Indirect { attrs, meta_attrs: None, on_stack: false } => {
185-
apply_attrs(cx.type_ptr_to(arg.memory_ty(cx)), &attrs, argument_tys.len())
184+
apply_attrs(cx.type_ptr_to(arg.layout.gcc_type(cx)), &attrs, argument_tys.len())
186185
}
187186
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => {
188187
assert!(!on_stack);

src/base.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,22 @@ pub fn compile_codegen_unit(
219219

220220
let mono_items = cgu.items_in_deterministic_order(tcx);
221221
for &(mono_item, data) in &mono_items {
222-
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
222+
mono_item.predefine::<Builder<'_, '_, '_>>(
223+
&mut cx,
224+
cgu_name.as_str(),
225+
data.linkage,
226+
data.visibility,
227+
);
223228
}
224229

225230
// ... and now that we have everything pre-defined, fill out those definitions.
226231
for &(mono_item, item_data) in &mono_items {
227-
mono_item.define::<Builder<'_, '_, '_>>(&mut cx, item_data);
232+
mono_item.define::<Builder<'_, '_, '_>>(&mut cx, cgu_name.as_str(), item_data);
228233
}
229234

230235
// If this codegen unit contains the main function, also create the
231236
// wrapper here
232-
maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&cx);
237+
maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&cx, cx.codegen_unit);
233238

234239
// Finalize debuginfo
235240
if cx.sess().opts.debuginfo != DebugInfo::None {

src/builder.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
1212
use rustc_apfloat::{Float, Round, Status, ieee};
1313
use rustc_codegen_ssa::MemFlags;
1414
use rustc_codegen_ssa::common::{
15-
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
15+
AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
1616
};
1717
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
1818
use rustc_codegen_ssa::mir::place::PlaceRef;
@@ -26,7 +26,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2626
use rustc_middle::ty::layout::{
2727
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers,
2828
};
29-
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
29+
use rustc_middle::ty::{self, AtomicOrdering, Instance, Ty, TyCtxt};
3030
use rustc_span::Span;
3131
use rustc_span::def_id::DefId;
3232
use rustc_target::callconv::FnAbi;
@@ -75,7 +75,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
7575

7676
let load_ordering = match order {
7777
// TODO(antoyo): does this make sense?
78-
AtomicOrdering::AcquireRelease | AtomicOrdering::Release => AtomicOrdering::Acquire,
78+
AtomicOrdering::AcqRel | AtomicOrdering::Release => AtomicOrdering::Acquire,
7979
_ => order,
8080
};
8181
let previous_value =
@@ -781,6 +781,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
781781
return self.context.new_call(self.location, fmod, &[a, b]);
782782
}
783783
TypeKind::FP128 => {
784+
// TODO(antoyo): use get_simple_function_f128_2args.
784785
let f128_type = self.type_f128();
785786
let fmodf128 = self.context.new_function(
786787
None,
@@ -1118,7 +1119,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11181119
// TODO(antoyo)
11191120
}
11201121

1121-
fn store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> {
1122+
fn store(&mut self, mut val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> {
1123+
if self.structs_as_pointer.borrow().contains(&val) {
1124+
// NOTE: hack to workaround a limitation of the rustc API: see comment on
1125+
// CodegenCx.structs_as_pointer
1126+
val = val.dereference(self.location).to_rvalue();
1127+
}
1128+
11221129
self.store_with_flags(val, ptr, align, MemFlags::empty())
11231130
}
11241131

@@ -1564,16 +1571,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
15641571
aggregate_value
15651572
}
15661573

1567-
fn set_personality_fn(&mut self, _personality: RValue<'gcc>) {
1574+
fn set_personality_fn(&mut self, _personality: Function<'gcc>) {
15681575
#[cfg(feature = "master")]
1569-
{
1570-
let personality = self.rvalue_as_function(_personality);
1571-
self.current_func().set_personality_function(personality);
1572-
}
1576+
self.current_func().set_personality_function(_personality);
15731577
}
15741578

15751579
#[cfg(feature = "master")]
1576-
fn cleanup_landing_pad(&mut self, pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
1580+
fn cleanup_landing_pad(&mut self, pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
15771581
self.set_personality_fn(pers_fn);
15781582

15791583
// NOTE: insert the current block in a variable so that a later call to invoke knows to
@@ -1594,7 +1598,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
15941598
}
15951599

15961600
#[cfg(not(feature = "master"))]
1597-
fn cleanup_landing_pad(&mut self, _pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
1601+
fn cleanup_landing_pad(&mut self, _pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
15981602
let value1 = self
15991603
.current_func()
16001604
.new_local(self.location, self.u8_type.make_pointer(), "landing_pad0")
@@ -1604,7 +1608,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
16041608
(value1, value2)
16051609
}
16061610

1607-
fn filter_landing_pad(&mut self, pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
1611+
fn filter_landing_pad(&mut self, pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
16081612
// TODO(antoyo): generate the correct landing pad
16091613
self.cleanup_landing_pad(pers_fn)
16101614
}
@@ -2511,8 +2515,8 @@ impl ToGccOrdering for AtomicOrdering {
25112515
AtomicOrdering::Relaxed => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
25122516
AtomicOrdering::Acquire => __ATOMIC_ACQUIRE,
25132517
AtomicOrdering::Release => __ATOMIC_RELEASE,
2514-
AtomicOrdering::AcquireRelease => __ATOMIC_ACQ_REL,
2515-
AtomicOrdering::SequentiallyConsistent => __ATOMIC_SEQ_CST,
2518+
AtomicOrdering::AcqRel => __ATOMIC_ACQ_REL,
2519+
AtomicOrdering::SeqCst => __ATOMIC_SEQ_CST,
25162520
};
25172521
ordering as i32
25182522
}

src/common.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,6 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
234234
match cv {
235235
Scalar::Int(int) => {
236236
let data = int.to_bits(layout.size(self));
237-
238-
// FIXME(antoyo): there's some issues with using the u128 code that follows, so hard-code
239-
// the paths for floating-point values.
240-
// TODO: Remove this code?
241-
/*if ty == self.float_type {
242-
return self
243-
.context
244-
.new_rvalue_from_double(ty, f32::from_bits(data as u32) as f64);
245-
}
246-
if ty == self.double_type {
247-
return self.context.new_rvalue_from_double(ty, f64::from_bits(data as u64));
248-
}*/
249-
250237
let value = self.const_uint_big(self.type_ix(bitsize), data);
251238
let bytesize = layout.size(self).bytes();
252239
if bitsize > 1 && ty.is_integral() && bytesize as u32 == ty.get_size() {

src/consts.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
6363
}
6464

6565
#[cfg_attr(not(feature = "master"), allow(unused_mut))]
66-
fn codegen_static(&self, def_id: DefId) {
66+
fn codegen_static(&mut self, def_id: DefId) {
6767
let attrs = self.tcx.codegen_fn_attrs(def_id);
6868

6969
let Ok((value, alloc)) = codegen_static_initializer(self, def_id) else {
@@ -150,25 +150,20 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
150150
// TODO(antoyo): set link section.
151151
}
152152

153-
if attrs.flags.contains(CodegenFnAttrFlags::USED)
153+
if attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
154154
|| attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
155155
{
156156
self.add_used_global(global.to_rvalue());
157157
}
158158
}
159+
}
159160

161+
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
160162
/// Add a global value to a list to be stored in the `llvm.used` variable, an array of i8*.
161-
fn add_used_global(&self, _global: RValue<'gcc>) {
163+
pub fn add_used_global(&mut self, _global: RValue<'gcc>) {
162164
// TODO(antoyo)
163165
}
164166

165-
fn add_compiler_used_global(&self, global: RValue<'gcc>) {
166-
// NOTE: seems like GCC does not make the distinction between compiler.used and used.
167-
self.add_used_global(global);
168-
}
169-
}
170-
171-
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
172167
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
173168
pub fn add_used_function(&self, function: Function<'gcc>) {
174169
#[cfg(feature = "master")]

src/context.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,15 @@ pub struct CodegenCx<'gcc, 'tcx> {
120120
/// A counter that is used for generating local symbol names
121121
local_gen_sym_counter: Cell<usize>,
122122

123-
eh_personality: Cell<Option<RValue<'gcc>>>,
123+
eh_personality: Cell<Option<Function<'gcc>>>,
124124
#[cfg(feature = "master")]
125125
pub rust_try_fn: Cell<Option<(Type<'gcc>, Function<'gcc>)>>,
126126

127127
pub pointee_infos: RefCell<FxHashMap<(Ty<'tcx>, Size), Option<PointeeInfo>>>,
128128

129129
/// NOTE: a hack is used because the rustc API is not suitable to libgccjit and as such,
130-
/// `const_undef()` returns struct as pointer so that they can later be assigned a value.
130+
/// `const_undef()` returns struct as pointer so that they can later be assigned a value (in
131+
/// e.g. Builder::insert_value).
131132
/// As such, this set remembers which of these pointers were returned by this function so that
132133
/// they can be dereferenced later.
133134
/// FIXME(antoyo): fix the rustc API to avoid having this hack.
@@ -427,7 +428,7 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
427428
ptr
428429
}
429430

430-
fn eh_personality(&self) -> RValue<'gcc> {
431+
fn eh_personality(&self) -> Function<'gcc> {
431432
// The exception handling personality function.
432433
//
433434
// If our compilation unit has the `eh_personality` lang item somewhere
@@ -465,18 +466,15 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
465466
let symbol_name = tcx.symbol_name(instance).name;
466467
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
467468
self.linkage.set(FunctionType::Extern);
468-
let func = self.declare_fn(symbol_name, fn_abi);
469-
let func: RValue<'gcc> = unsafe { std::mem::transmute(func) };
470-
func
469+
self.declare_fn(symbol_name, fn_abi)
471470
}
472471
_ => {
473472
let name = if wants_msvc_seh(self.sess()) {
474473
"__CxxFrameHandler3"
475474
} else {
476475
"rust_eh_personality"
477476
};
478-
let func = self.declare_func(name, self.type_i32(), &[], true);
479-
unsafe { std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(func) }
477+
self.declare_func(name, self.type_i32(), &[], true)
480478
}
481479
};
482480
// TODO(antoyo): apply target cpu attributes.
@@ -488,10 +486,6 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
488486
self.tcx.sess
489487
}
490488

491-
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
492-
self.codegen_unit
493-
}
494-
495489
fn set_frame_pointer_type(&self, _llfn: Function<'gcc>) {
496490
// TODO(antoyo)
497491
}

0 commit comments

Comments
 (0)