Skip to content

Commit db9a97f

Browse files
committed
Auto merge of #3817 - rust-lang:rustup-2024-08-17, r=RalfJung
Automatic Rustup
2 parents 78dfb8a + dc0faec commit db9a97f

File tree

197 files changed

+2751
-1528
lines changed

Some content is hidden

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

197 files changed

+2751
-1528
lines changed

.github/workflows/dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: cargo update rustbook
6868
run: |
6969
echo -e "\nrustbook dependencies:" >> cargo_update.log
70-
cargo update --manifest-path src/tools/rustbook 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
70+
cargo update --manifest-path src/tools/rustbook/Cargo.toml 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
7171
- name: upload Cargo.lock artifact for use in PR
7272
uses: actions/upload-artifact@v4
7373
with:

Cargo.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,9 +1775,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
17751775

17761776
[[package]]
17771777
name = "indexmap"
1778-
version = "2.2.6"
1778+
version = "2.4.0"
17791779
source = "registry+https://github.com/rust-lang/crates.io-index"
1780-
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
1780+
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
17811781
dependencies = [
17821782
"equivalent",
17831783
"hashbrown",
@@ -3149,6 +3149,7 @@ dependencies = [
31493149
"gimli 0.31.0",
31503150
"object 0.36.2",
31513151
"regex",
3152+
"serde_json",
31523153
"similar",
31533154
"wasmparser 0.214.0",
31543155
]

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn parse_asm_args<'a>(
328328
/// Otherwise, the suggestion will be incorrect.
329329
fn err_duplicate_option(p: &Parser<'_>, symbol: Symbol, span: Span) {
330330
// Tool-only output
331-
let full_span = if p.token.kind == token::Comma { span.to(p.token.span) } else { span };
331+
let full_span = if p.token == token::Comma { span.to(p.token.span) } else { span };
332332
p.dcx().emit_err(errors::AsmOptAlreadyprovided { span, symbol, full_span });
333333
}
334334

@@ -338,7 +338,7 @@ fn err_duplicate_option(p: &Parser<'_>, symbol: Symbol, span: Span) {
338338
/// Otherwise, the suggestion will be incorrect.
339339
fn err_unsupported_option(p: &Parser<'_>, symbol: Symbol, span: Span) {
340340
// Tool-only output
341-
let full_span = if p.token.kind == token::Comma { span.to(p.token.span) } else { span };
341+
let full_span = if p.token == token::Comma { span.to(p.token.span) } else { span };
342342
p.dcx().emit_err(errors::GlobalAsmUnsupportedOption { span, symbol, full_span });
343343
}
344344

compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ pub struct LlvmArchiveBuilderBuilder;
106106

107107
impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
108108
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
109-
// FIXME use ArArchiveBuilder on most targets again once reading thin archives is
110-
// implemented
111-
if true {
109+
// Keeping LlvmArchiveBuilder around in case of a regression caused by using
110+
// ArArchiveBuilder.
111+
// FIXME(#128955) remove a couple of months after #128936 gets merged in case
112+
// no regression is found.
113+
if false {
112114
Box::new(LlvmArchiveBuilder { sess, additions: Vec::new() })
113115
} else {
114116
Box::new(ArArchiveBuilder::new(sess, &LLVM_OBJECT_READER))
@@ -198,25 +200,11 @@ static LLVM_OBJECT_READER: ObjectReader = ObjectReader {
198200
get_xcoff_member_alignment: DEFAULT_OBJECT_READER.get_xcoff_member_alignment,
199201
};
200202

201-
fn should_use_llvm_reader(buf: &[u8]) -> bool {
202-
let is_bitcode = unsafe { llvm::LLVMRustIsBitcode(buf.as_ptr(), buf.len()) };
203-
204-
// COFF bigobj file, msvc LTO file or import library. See
205-
// https://github.com/llvm/llvm-project/blob/453f27bc9/llvm/lib/BinaryFormat/Magic.cpp#L38-L51
206-
let is_unsupported_windows_obj_file = buf.get(0..4) == Some(b"\0\0\xFF\xFF");
207-
208-
is_bitcode || is_unsupported_windows_obj_file
209-
}
210-
211203
#[deny(unsafe_op_in_unsafe_fn)]
212204
fn get_llvm_object_symbols(
213205
buf: &[u8],
214206
f: &mut dyn FnMut(&[u8]) -> io::Result<()>,
215207
) -> io::Result<bool> {
216-
if !should_use_llvm_reader(buf) {
217-
return (DEFAULT_OBJECT_READER.get_symbols)(buf, f);
218-
}
219-
220208
let mut state = Box::new(f);
221209

222210
let err = unsafe {
@@ -253,18 +241,10 @@ fn get_llvm_object_symbols(
253241
}
254242

255243
fn llvm_is_64_bit_object_file(buf: &[u8]) -> bool {
256-
if !should_use_llvm_reader(buf) {
257-
return (DEFAULT_OBJECT_READER.is_64_bit_object_file)(buf);
258-
}
259-
260244
unsafe { llvm::LLVMRustIs64BitSymbolicFile(buf.as_ptr(), buf.len()) }
261245
}
262246

263247
fn llvm_is_ec_object_file(buf: &[u8]) -> bool {
264-
if !should_use_llvm_reader(buf) {
265-
return (DEFAULT_OBJECT_READER.is_ec_object_file)(buf);
266-
}
267-
268248
unsafe { llvm::LLVMRustIsECObject(buf.as_ptr(), buf.len()) }
269249
}
270250

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn make_mir_scope<'ll, 'tcx>(
8888
let loc = cx.lookup_debug_loc(scope_data.span.lo());
8989
let file_metadata = file_metadata(cx, &loc.file);
9090

91-
let parent_dbg_scope = match scope_data.inlined {
91+
let dbg_scope = match scope_data.inlined {
9292
Some((callee, _)) => {
9393
// FIXME(eddyb) this would be `self.monomorphize(&callee)`
9494
// if this is moved to `rustc_codegen_ssa::mir::debuginfo`.
@@ -102,17 +102,15 @@ fn make_mir_scope<'ll, 'tcx>(
102102
cx.dbg_scope_fn(callee, callee_fn_abi, None)
103103
})
104104
}
105-
None => parent_scope.dbg_scope,
106-
};
107-
108-
let dbg_scope = unsafe {
109-
llvm::LLVMRustDIBuilderCreateLexicalBlock(
110-
DIB(cx),
111-
parent_dbg_scope,
112-
file_metadata,
113-
loc.line,
114-
loc.col,
115-
)
105+
None => unsafe {
106+
llvm::LLVMRustDIBuilderCreateLexicalBlock(
107+
DIB(cx),
108+
parent_scope.dbg_scope,
109+
file_metadata,
110+
loc.line,
111+
loc.col,
112+
)
113+
},
116114
};
117115

118116
let inlined_at = scope_data.inlined.map(|(_, callsite_span)| {

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::borrow::Cow;
22

33
use libc::c_uint;
44
use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name;
5-
use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo;
5+
use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo};
66
use rustc_codegen_ssa::traits::ConstMethods;
77
use rustc_index::IndexVec;
88
use rustc_middle::bug;
@@ -12,7 +12,7 @@ use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants};
1212
use smallvec::smallvec;
1313

1414
use crate::common::CodegenCx;
15-
use crate::debuginfo::metadata::enums::{tag_base_type, DiscrResult};
15+
use crate::debuginfo::metadata::enums::DiscrResult;
1616
use crate::debuginfo::metadata::type_map::{self, Stub, UniqueTypeId};
1717
use crate::debuginfo::metadata::{
1818
build_field_di_node, file_metadata, size_and_align_of, type_di_node, unknown_file_metadata,
@@ -190,7 +190,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
190190
let enum_type_and_layout = cx.layout_of(enum_type);
191191
let enum_type_name = compute_debuginfo_type_name(cx.tcx, enum_type, false);
192192

193-
assert!(!wants_c_like_enum_debuginfo(enum_type_and_layout));
193+
assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout));
194194

195195
type_map::build_type_with_children(
196196
cx,
@@ -265,7 +265,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
265265
let coroutine_type_and_layout = cx.layout_of(coroutine_type);
266266
let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
267267

268-
assert!(!wants_c_like_enum_debuginfo(coroutine_type_and_layout));
268+
assert!(!wants_c_like_enum_debuginfo(cx.tcx, coroutine_type_and_layout));
269269

270270
type_map::build_type_with_children(
271271
cx,
@@ -381,7 +381,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
381381
tag_field: usize,
382382
untagged_variant_index: Option<VariantIdx>,
383383
) -> SmallVec<&'ll DIType> {
384-
let tag_base_type = super::tag_base_type(cx, enum_type_and_layout);
384+
let tag_base_type = tag_base_type(cx.tcx, enum_type_and_layout);
385385

386386
let variant_names_type_di_node = build_variant_names_type_di_node(
387387
cx,
@@ -676,7 +676,7 @@ fn build_union_fields_for_direct_tag_coroutine<'ll, 'tcx>(
676676
let variant_range = coroutine_args.variant_range(coroutine_def_id, cx.tcx);
677677
let variant_count = (variant_range.start.as_u32()..variant_range.end.as_u32()).len();
678678

679-
let tag_base_type = tag_base_type(cx, coroutine_type_and_layout);
679+
let tag_base_type = tag_base_type(cx.tcx, coroutine_type_and_layout);
680680

681681
let variant_names_type_di_node = build_variant_names_type_di_node(
682682
cx,
@@ -803,7 +803,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
803803

804804
assert_eq!(
805805
cx.size_and_align_of(enum_type_and_layout.field(cx, tag_field).ty),
806-
cx.size_and_align_of(super::tag_base_type(cx, enum_type_and_layout))
806+
cx.size_and_align_of(self::tag_base_type(cx.tcx, enum_type_and_layout))
807807
);
808808

809809
// ... and a field for the tag. If the tag is 128 bits wide, this will actually

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
use std::borrow::Cow;
22

33
use rustc_codegen_ssa::debuginfo::type_names::{compute_debuginfo_type_name, cpp_like_debuginfo};
4-
use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo;
4+
use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo};
55
use rustc_hir::def::CtorKind;
66
use rustc_index::IndexSlice;
77
use rustc_middle::bug;
88
use rustc_middle::mir::CoroutineLayout;
9-
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout};
9+
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1010
use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty, VariantDef};
1111
use rustc_span::Symbol;
12-
use rustc_target::abi::{
13-
FieldIdx, HasDataLayout, Integer, Primitive, TagEncoding, VariantIdx, Variants,
14-
};
12+
use rustc_target::abi::{FieldIdx, TagEncoding, VariantIdx, Variants};
1513

1614
use super::type_map::{DINodeCreationResult, UniqueTypeId};
1715
use super::{size_and_align_of, SmallVec};
@@ -39,7 +37,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
3937

4038
let enum_type_and_layout = cx.layout_of(enum_type);
4139

42-
if wants_c_like_enum_debuginfo(enum_type_and_layout) {
40+
if wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout) {
4341
return build_c_style_enum_di_node(cx, enum_adt_def, enum_type_and_layout);
4442
}
4543

@@ -74,7 +72,7 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
7472
di_node: build_enumeration_type_di_node(
7573
cx,
7674
&compute_debuginfo_type_name(cx.tcx, enum_type_and_layout.ty, false),
77-
tag_base_type(cx, enum_type_and_layout),
75+
tag_base_type(cx.tcx, enum_type_and_layout),
7876
enum_adt_def.discriminants(cx.tcx).map(|(variant_index, discr)| {
7977
let name = Cow::from(enum_adt_def.variant(variant_index).name.as_str());
8078
(name, discr.val)
@@ -85,48 +83,6 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
8583
}
8684
}
8785

88-
/// Extract the type with which we want to describe the tag of the given enum or coroutine.
89-
fn tag_base_type<'ll, 'tcx>(
90-
cx: &CodegenCx<'ll, 'tcx>,
91-
enum_type_and_layout: TyAndLayout<'tcx>,
92-
) -> Ty<'tcx> {
93-
assert!(match enum_type_and_layout.ty.kind() {
94-
ty::Coroutine(..) => true,
95-
ty::Adt(adt_def, _) => adt_def.is_enum(),
96-
_ => false,
97-
});
98-
99-
match enum_type_and_layout.layout.variants() {
100-
// A single-variant enum has no discriminant.
101-
Variants::Single { .. } => {
102-
bug!("tag_base_type() called for enum without tag: {:?}", enum_type_and_layout)
103-
}
104-
105-
Variants::Multiple { tag_encoding: TagEncoding::Niche { .. }, tag, .. } => {
106-
// Niche tags are always normalized to unsized integers of the correct size.
107-
match tag.primitive() {
108-
Primitive::Int(t, _) => t,
109-
Primitive::Float(f) => Integer::from_size(f.size()).unwrap(),
110-
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
111-
Primitive::Pointer(_) => {
112-
// If the niche is the NULL value of a reference, then `discr_enum_ty` will be
113-
// a RawPtr. CodeView doesn't know what to do with enums whose base type is a
114-
// pointer so we fix this up to just be `usize`.
115-
// DWARF might be able to deal with this but with an integer type we are on
116-
// the safe side there too.
117-
cx.data_layout().ptr_sized_integer()
118-
}
119-
}
120-
.to_ty(cx.tcx, false)
121-
}
122-
123-
Variants::Multiple { tag_encoding: TagEncoding::Direct, tag, .. } => {
124-
// Direct tags preserve the sign.
125-
tag.primitive().to_ty(cx.tcx)
126-
}
127-
}
128-
}
129-
13086
/// Build a DW_TAG_enumeration_type debuginfo node, with the given base type and variants.
13187
/// This is a helper function and does not register anything in the type map by itself.
13288
///

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::borrow::Cow;
22

33
use libc::c_uint;
44
use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name;
5-
use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo;
5+
use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo};
66
use rustc_codegen_ssa::traits::ConstMethods;
77
use rustc_middle::bug;
88
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
@@ -11,7 +11,6 @@ use rustc_target::abi::{Size, TagEncoding, VariantIdx, Variants};
1111
use smallvec::smallvec;
1212

1313
use crate::common::CodegenCx;
14-
use crate::debuginfo::metadata::enums::tag_base_type;
1514
use crate::debuginfo::metadata::type_map::{self, Stub, StubInfo, UniqueTypeId};
1615
use crate::debuginfo::metadata::{
1716
file_metadata, size_and_align_of, type_di_node, unknown_file_metadata, visibility_di_flags,
@@ -54,7 +53,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
5453

5554
let visibility_flags = visibility_di_flags(cx, enum_adt_def.did(), enum_adt_def.did());
5655

57-
assert!(!wants_c_like_enum_debuginfo(enum_type_and_layout));
56+
assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout));
5857

5958
type_map::build_type_with_children(
6059
cx,
@@ -131,7 +130,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
131130
let containing_scope = get_namespace_for_item(cx, coroutine_def_id);
132131
let coroutine_type_and_layout = cx.layout_of(coroutine_type);
133132

134-
assert!(!wants_c_like_enum_debuginfo(coroutine_type_and_layout));
133+
assert!(!wants_c_like_enum_debuginfo(cx.tcx, coroutine_type_and_layout));
135134

136135
let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
137136

@@ -321,7 +320,7 @@ fn build_discr_member_di_node<'ll, 'tcx>(
321320
&Variants::Single { .. } => None,
322321

323322
&Variants::Multiple { tag_field, .. } => {
324-
let tag_base_type = tag_base_type(cx, enum_or_coroutine_type_and_layout);
323+
let tag_base_type = tag_base_type(cx.tcx, enum_or_coroutine_type_and_layout);
325324
let (size, align) = cx.size_and_align_of(tag_base_type);
326325

327326
unsafe {

compiler/rustc_codegen_ssa/src/back/archive.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,15 @@ impl<'a> ArchiveBuilder for ArArchiveBuilder<'a> {
307307
let file_name = String::from_utf8(entry.name().to_vec())
308308
.map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;
309309
if !skip(&file_name) {
310-
self.entries.push((
311-
file_name.into_bytes(),
312-
ArchiveEntry::FromArchive { archive_index, file_range: entry.file_range() },
313-
));
310+
if entry.is_thin() {
311+
let member_path = archive_path.parent().unwrap().join(Path::new(&file_name));
312+
self.entries.push((file_name.into_bytes(), ArchiveEntry::File(member_path)));
313+
} else {
314+
self.entries.push((
315+
file_name.into_bytes(),
316+
ArchiveEntry::FromArchive { archive_index, file_range: entry.file_range() },
317+
));
318+
}
314319
}
315320
}
316321

0 commit comments

Comments
 (0)