Skip to content

Commit b385428

Browse files
authored
Merge pull request rust-lang#464 from rust-lang/sync_from_rust_2024_03_04
Sync from rust 2024/03/04
2 parents e4ec64a + 3b4c58d commit b385428

16 files changed

+127
-118
lines changed

build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// TODO: remove this file and deps/libLLVM-18-rust-1.78.0-nightly.so when
2+
// https://github.com/rust-lang/rust/pull/121967 is merged.
3+
fn main() {
4+
println!("cargo:rerun-if-changed=deps/libLLVM-18-rust-1.78.0-nightly.so");
5+
println!("cargo:rustc-link-search=deps");
6+
}

build_system/src/prepare.rs

+26
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,30 @@ fn prepare_libcore(
131131
)?;
132132
}
133133
println!("Successfully prepared libcore for building");
134+
135+
Ok(())
136+
}
137+
138+
// TODO: remove when we can ignore warnings in rustdoc tests.
139+
fn prepare_rand() -> Result<(), String> {
140+
// Apply patch for the rand crate.
141+
let file_path = "patches/crates/0001-Remove-deny-warnings.patch";
142+
let rand_dir = Path::new("build/rand");
143+
println!("[GIT] apply `{}`", file_path);
144+
let path = Path::new("../..").join(file_path);
145+
run_command_with_output(&[&"git", &"apply", &path], Some(rand_dir))?;
146+
run_command_with_output(&[&"git", &"add", &"-A"], Some(rand_dir))?;
147+
run_command_with_output(
148+
&[
149+
&"git",
150+
&"commit",
151+
&"--no-gpg-sign",
152+
&"-m",
153+
&format!("Patch {}", path.display()),
154+
],
155+
Some(rand_dir),
156+
)?;
157+
134158
Ok(())
135159
}
136160

@@ -241,6 +265,8 @@ pub fn run() -> Result<(), String> {
241265
for (repo_url, checkout_commit, cb) in to_clone {
242266
clone_and_setup(repo_url, checkout_commit, *cb)?;
243267
}
268+
269+
prepare_rand()?;
244270
}
245271

246272
println!("Successfully ran `prepare`");

build_system/src/test.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,19 @@ fn extended_rand_tests(env: &Env, args: &TestArg) -> Result<(), String> {
771771
println!("Not using GCC master branch. Skipping `extended_rand_tests`.");
772772
return Ok(());
773773
}
774+
let mut env = env.clone();
775+
// newer aho_corasick versions throw a deprecation warning
776+
let rustflags = format!(
777+
"{} --cap-lints warn",
778+
env.get("RUSTFLAGS").cloned().unwrap_or_default()
779+
);
780+
env.insert("RUSTFLAGS".to_string(), rustflags);
781+
774782
let path = Path::new(crate::BUILD_DIR).join("rand");
775-
run_cargo_command(&[&"clean"], Some(&path), env, args)?;
783+
run_cargo_command(&[&"clean"], Some(&path), &env, args)?;
776784
// FIXME: create a function "display_if_not_quiet" or something along the line.
777785
println!("[TEST] rust-random/rand");
778-
run_cargo_command(&[&"test", &"--workspace"], Some(&path), env, args)?;
786+
run_cargo_command(&[&"test", &"--workspace"], Some(&path), &env, args)?;
779787
Ok(())
780788
}
781789

@@ -911,9 +919,9 @@ fn should_remove_test(file_path: &Path) -> Result<bool, String> {
911919
continue;
912920
}
913921
if [
914-
"// error-pattern:",
915-
"// build-fail",
916-
"// run-fail",
922+
"//@ error-pattern:",
923+
"//@ build-fail",
924+
"//@ run-fail",
917925
"-Cllvm-args",
918926
"//~",
919927
"thread",
@@ -1007,6 +1015,8 @@ where
10071015
// Tests generating errors.
10081016
remove_file(&rust_path.join("tests/ui/consts/issue-94675.rs"))?;
10091017
remove_file(&rust_path.join("tests/ui/mir/mir_heavy_promoted.rs"))?;
1018+
remove_file(&rust_path.join("tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs"))?;
1019+
remove_file(&rust_path.join("tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs"))?;
10101020

10111021
walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?;
10121022

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT(libLLVM.so.18.1-rust-1.78.0-nightly)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
From f4a31d2c57cdbd578b778ab70eb2a0cfb248652c Mon Sep 17 00:00:00 2001
2+
From: Antoni Boucher <[email protected]>
3+
Date: Tue, 5 Mar 2024 12:39:44 -0500
4+
Subject: [PATCH] Remove #[deny(warnings)]
5+
6+
---
7+
src/lib.rs | 1 -
8+
1 file changed, 1 deletion(-)
9+
10+
diff --git a/src/lib.rs b/src/lib.rs
11+
index 8ade2881d5..e26c595e38 100644
12+
--- a/src/lib.rs
13+
+++ b/src/lib.rs
14+
@@ -47,7 +47,6 @@
15+
)]
16+
#![deny(missing_docs)]
17+
#![deny(missing_debug_implementations)]
18+
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
19+
#![no_std]
20+
#![cfg_attr(feature = "simd_support", feature(stdsimd, portable_simd))]
21+
#![cfg_attr(doc_cfg, feature(doc_cfg))]
22+
--
23+
2.44.0
24+

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2024-02-20"
2+
channel = "nightly-2024-03-05"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/archive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_session::cstore::DllImport;
1010
pub(crate) struct ArArchiveBuilderBuilder;
1111

1212
impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
13-
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder<'a> + 'a> {
13+
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
1414
Box::new(ArArchiveBuilder::new(sess, get_native_object_symbols))
1515
}
1616

src/builder.rs

+32-33
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,31 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
862862
result
863863
}
864864

865+
fn fadd_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
866+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
867+
lhs + rhs
868+
}
869+
870+
fn fsub_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
871+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
872+
lhs - rhs
873+
}
874+
875+
fn fmul_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
876+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
877+
lhs * rhs
878+
}
879+
880+
fn fdiv_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
881+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
882+
lhs / rhs
883+
}
884+
885+
fn frem_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
886+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
887+
self.frem(lhs, rhs)
888+
}
889+
865890
fn checked_binop(
866891
&mut self,
867892
oop: OverflowOp,
@@ -983,10 +1008,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
9831008
OperandValue::Immediate(self.to_immediate(load, place.layout))
9841009
} else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
9851010
let b_offset = a.size(self).align_to(b.align(self).abi);
986-
let pair_type = place.layout.gcc_type(self);
9871011

9881012
let mut load = |i, scalar: &abi::Scalar, align| {
989-
let llptr = self.struct_gep(pair_type, place.llval, i as u64);
1013+
let llptr = if i == 0 {
1014+
place.llval
1015+
} else {
1016+
self.inbounds_ptradd(place.llval, self.const_usize(b_offset.bytes()))
1017+
};
9901018
let llty = place.layout.scalar_pair_element_gcc_type(self, i);
9911019
let load = self.load(llty, llptr, align);
9921020
scalar_load_metadata(self, load, scalar);
@@ -1157,35 +1185,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11571185
result.get_address(self.location)
11581186
}
11591187

1160-
fn struct_gep(&mut self, value_type: Type<'gcc>, ptr: RValue<'gcc>, idx: u64) -> RValue<'gcc> {
1161-
// FIXME(antoyo): it would be better if the API only called this on struct, not on arrays.
1162-
assert_eq!(idx as usize as u64, idx);
1163-
let value = ptr.dereference(self.location).to_rvalue();
1164-
1165-
if value_type.dyncast_array().is_some() {
1166-
let index = self
1167-
.context
1168-
.new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from"));
1169-
let element = self.context.new_array_access(self.location, value, index);
1170-
element.get_address(self.location)
1171-
} else if let Some(vector_type) = value_type.dyncast_vector() {
1172-
let array_type = vector_type.get_element_type().make_pointer();
1173-
let array = self.bitcast(ptr, array_type);
1174-
let index = self
1175-
.context
1176-
.new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from"));
1177-
let element = self.context.new_array_access(self.location, array, index);
1178-
element.get_address(self.location)
1179-
} else if let Some(struct_type) = value_type.is_struct() {
1180-
// NOTE: due to opaque pointers now being used, we need to bitcast here.
1181-
let ptr = self.bitcast_if_needed(ptr, value_type.make_pointer());
1182-
ptr.dereference_field(self.location, struct_type.get_field(idx as i32))
1183-
.get_address(self.location)
1184-
} else {
1185-
panic!("Unexpected type {:?}", value_type);
1186-
}
1187-
}
1188-
11891188
/* Casts */
11901189
fn trunc(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {
11911190
// TODO(antoyo): check that it indeed truncate the value.
@@ -2078,7 +2077,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
20782077
self.vector_reduce(src, |a, b, context| context.new_binary_op(loc, op, a.get_type(), a, b))
20792078
}
20802079

2081-
pub fn vector_reduce_fadd_fast(
2080+
pub fn vector_reduce_fadd_reassoc(
20822081
&mut self,
20832082
_acc: RValue<'gcc>,
20842083
_src: RValue<'gcc>,
@@ -2109,7 +2108,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
21092108
unimplemented!();
21102109
}
21112110

2112-
pub fn vector_reduce_fmul_fast(
2111+
pub fn vector_reduce_fmul_reassoc(
21132112
&mut self,
21142113
_acc: RValue<'gcc>,
21152114
_src: RValue<'gcc>,

src/errors.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level};
1+
use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
22
use rustc_macros::{Diagnostic, Subdiagnostic};
33
use rustc_span::Span;
44

@@ -90,12 +90,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
9090
pub(crate) struct MissingFeatures;
9191

9292
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
93-
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> {
94-
let mut diag = DiagnosticBuilder::new(
95-
dcx,
96-
level,
97-
fluent::codegen_gcc_target_feature_disable_or_enable,
98-
);
93+
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
94+
let mut diag = Diag::new(dcx, level, fluent::codegen_gcc_target_feature_disable_or_enable);
9995
if let Some(span) = self.span {
10096
diag.span(span);
10197
};

src/intrinsic/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_middle::ty::layout::LayoutOf;
2323
#[cfg(feature = "master")]
2424
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
2525
use rustc_middle::ty::{self, Instance, Ty};
26-
use rustc_span::{sym, symbol::kw, Span, Symbol};
26+
use rustc_span::{sym, Span, Symbol};
2727
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
2828
use rustc_target::abi::HasDataLayout;
2929
#[cfg(feature = "master")]
@@ -143,7 +143,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
143143
let res = self.context.new_call(None, builtin, &[a]);
144144
self.icmp(IntPredicate::IntEQ, res, self.const_i32(0))
145145
}
146-
kw::Try => {
146+
sym::catch_unwind => {
147147
try_intrinsic(
148148
self,
149149
args[0].immediate(),

src/intrinsic/simd.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1171,14 +1171,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
11711171

11721172
arith_red!(
11731173
simd_reduce_add_unordered: BinaryOp::Plus,
1174-
vector_reduce_fadd_fast,
1174+
vector_reduce_fadd_reassoc,
11751175
false,
11761176
add,
11771177
0.0 // TODO: Use this argument.
11781178
);
11791179
arith_red!(
11801180
simd_reduce_mul_unordered: BinaryOp::Mult,
1181-
vector_reduce_fmul_fast,
1181+
vector_reduce_fmul_reassoc,
11821182
false,
11831183
mul,
11841184
1.0
@@ -1223,9 +1223,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
12231223

12241224
minmax_red!(simd_reduce_min: vector_reduce_min, vector_reduce_fmin);
12251225
minmax_red!(simd_reduce_max: vector_reduce_max, vector_reduce_fmax);
1226-
// TODO(sadlerap): revisit these intrinsics to generate more optimal reductions
1227-
minmax_red!(simd_reduce_min_nanless: vector_reduce_min, vector_reduce_fmin);
1228-
minmax_red!(simd_reduce_max_nanless: vector_reduce_max, vector_reduce_fmax);
12291226

12301227
macro_rules! bitwise_red {
12311228
($name:ident : $op:expr, $boolean:expr) => {

src/type_.rs

+10
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
8383

8484
pub fn type_float_from_ty(&self, t: ty::FloatTy) -> Type<'gcc> {
8585
match t {
86+
ty::FloatTy::F16 => self.type_f16(),
8687
ty::FloatTy::F32 => self.type_f32(),
8788
ty::FloatTy::F64 => self.type_f64(),
89+
ty::FloatTy::F128 => self.type_f128(),
8890
}
8991
}
9092
}
@@ -118,6 +120,10 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
118120
self.isize_type
119121
}
120122

123+
fn type_f16(&self) -> Type<'gcc> {
124+
unimplemented!("f16_f128")
125+
}
126+
121127
fn type_f32(&self) -> Type<'gcc> {
122128
self.float_type
123129
}
@@ -126,6 +132,10 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
126132
self.double_type
127133
}
128134

135+
fn type_f128(&self) -> Type<'gcc> {
136+
unimplemented!("f16_f128")
137+
}
138+
129139
fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> {
130140
self.context.new_function_pointer_type(None, return_type, params, false)
131141
}

src/type_of.rs

+3-24
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::{self, Ty, TypeVisitableExt};
99
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
1010
use rustc_target::abi::{
1111
self, Abi, Align, FieldsShape, Int, Integer, PointeeInfo, Pointer, Size, TyAbiInterface,
12-
Variants, F32, F64,
12+
Variants, F128, F16, F32, F64,
1313
};
1414

1515
use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType};
@@ -171,7 +171,6 @@ pub trait LayoutGccExt<'tcx> {
171171
cx: &CodegenCx<'gcc, 'tcx>,
172172
index: usize,
173173
) -> Type<'gcc>;
174-
fn gcc_field_index(&self, index: usize) -> u64;
175174
fn pointee_info_at<'gcc>(
176175
&self,
177176
cx: &CodegenCx<'gcc, 'tcx>,
@@ -284,8 +283,10 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
284283
match scalar.primitive() {
285284
Int(i, true) => cx.type_from_integer(i),
286285
Int(i, false) => cx.type_from_unsigned_integer(i),
286+
F16 => cx.type_f16(),
287287
F32 => cx.type_f32(),
288288
F64 => cx.type_f64(),
289+
F128 => cx.type_f128(),
289290
Pointer(address_space) => {
290291
// If we know the alignment, pick something better than i8.
291292
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
@@ -327,24 +328,6 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
327328
self.scalar_gcc_type_at(cx, scalar, offset)
328329
}
329330

330-
fn gcc_field_index(&self, index: usize) -> u64 {
331-
match self.abi {
332-
Abi::Scalar(_) | Abi::ScalarPair(..) => {
333-
bug!("TyAndLayout::gcc_field_index({:?}): not applicable", self)
334-
}
335-
_ => {}
336-
}
337-
match self.fields {
338-
FieldsShape::Primitive | FieldsShape::Union(_) => {
339-
bug!("TyAndLayout::gcc_field_index({:?}): not applicable", self)
340-
}
341-
342-
FieldsShape::Array { .. } => index as u64,
343-
344-
FieldsShape::Arbitrary { .. } => 1 + (self.fields.memory_index(index) as u64) * 2,
345-
}
346-
}
347-
348331
fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo> {
349332
if let Some(&pointee) = cx.pointee_infos.borrow().get(&(self.ty, offset)) {
350333
return pointee;
@@ -374,10 +357,6 @@ impl<'gcc, 'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
374357
layout.is_gcc_scalar_pair()
375358
}
376359

377-
fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 {
378-
layout.gcc_field_index(index)
379-
}
380-
381360
fn scalar_pair_element_backend_type(
382361
&self,
383362
layout: TyAndLayout<'tcx>,

0 commit comments

Comments
 (0)