Skip to content

Commit 12c0f09

Browse files
committed
Auto merge of rust-lang#3265 - rust-lang:rustup-2024-01-13, r=saethlin
Automatic Rustup
2 parents 67659fb + 9b46f3b commit 12c0f09

File tree

401 files changed

+7535
-2395
lines changed

Some content is hidden

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

401 files changed

+7535
-2395
lines changed

Cargo.lock

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ dependencies = [
119119
"yansi-term",
120120
]
121121

122+
[[package]]
123+
name = "annotate-snippets"
124+
version = "0.10.1"
125+
source = "registry+https://github.com/rust-lang/crates.io-index"
126+
checksum = "0a433302f833baa830c0092100c481c7ea768c5981a3c36f549517a502f246dd"
127+
dependencies = [
128+
"anstyle",
129+
"unicode-width",
130+
]
131+
122132
[[package]]
123133
name = "ansi_term"
124134
version = "0.12.1"
@@ -3771,7 +3781,7 @@ dependencies = [
37713781
name = "rustc_errors"
37723782
version = "0.0.0"
37733783
dependencies = [
3774-
"annotate-snippets",
3784+
"annotate-snippets 0.10.1",
37753785
"derive_setters",
37763786
"rustc_ast",
37773787
"rustc_ast_pretty",
@@ -3831,7 +3841,7 @@ dependencies = [
38313841
name = "rustc_fluent_macro"
38323842
version = "0.0.0"
38333843
dependencies = [
3834-
"annotate-snippets",
3844+
"annotate-snippets 0.10.1",
38353845
"fluent-bundle",
38363846
"fluent-syntax",
38373847
"proc-macro2",
@@ -4564,6 +4574,7 @@ checksum = "8ba09476327c4b70ccefb6180f046ef588c26a24cf5d269a9feba316eb4f029f"
45644574
name = "rustc_trait_selection"
45654575
version = "0.0.0"
45664576
dependencies = [
4577+
"bitflags 2.4.1",
45674578
"itertools",
45684579
"rustc_ast",
45694580
"rustc_attr",
@@ -4738,7 +4749,7 @@ dependencies = [
47384749
name = "rustfmt-nightly"
47394750
version = "1.7.0"
47404751
dependencies = [
4741-
"annotate-snippets",
4752+
"annotate-snippets 0.9.1",
47424753
"anyhow",
47434754
"bytecount",
47444755
"cargo_metadata 0.15.4",
@@ -5728,7 +5739,7 @@ version = "0.21.2"
57285739
source = "registry+https://github.com/rust-lang/crates.io-index"
57295740
checksum = "aaf4bf7c184b8dfc7a4d3b90df789b1eb992ee42811cd115f32a7a1eb781058d"
57305741
dependencies = [
5731-
"annotate-snippets",
5742+
"annotate-snippets 0.9.1",
57325743
"anyhow",
57335744
"bstr",
57345745
"cargo-platform",
@@ -5859,9 +5870,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
58595870

58605871
[[package]]
58615872
name = "unicode-width"
5862-
version = "0.1.10"
5873+
version = "0.1.11"
58635874
source = "registry+https://github.com/rust-lang/crates.io-index"
5864-
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
5875+
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
58655876
dependencies = [
58665877
"compiler_builtins",
58675878
"rustc-std-workspace-core",

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ exclude = [
6464
]
6565

6666
[profile.release.package.compiler_builtins]
67-
# The compiler-builtins crate cannot reference libcore, and it's own CI will
67+
# The compiler-builtins crate cannot reference libcore, and its own CI will
6868
# verify that this is the case. This requires, however, that the crate is built
6969
# without overflow checks and debug assertions. Forcefully disable debug
7070
# assertions and overflow checks here which should ensure that even if these

compiler/rustc_borrowck/src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,18 +2399,19 @@ mod error {
23992399
/// and we want only the best of those errors.
24002400
///
24012401
/// The `report_use_of_moved_or_uninitialized` function checks this map and replaces the
2402-
/// diagnostic (if there is one) if the `Place` of the error being reported is a prefix of the
2403-
/// `Place` of the previous most diagnostic. This happens instead of buffering the error. Once
2404-
/// all move errors have been reported, any diagnostics in this map are added to the buffer
2405-
/// to be emitted.
2402+
/// diagnostic (if there is one) if the `Place` of the error being reported is a prefix of
2403+
/// the `Place` of the previous most diagnostic. This happens instead of buffering the
2404+
/// error. Once all move errors have been reported, any diagnostics in this map are added
2405+
/// to the buffer to be emitted.
24062406
///
24072407
/// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary
24082408
/// when errors in the map are being re-added to the error buffer so that errors with the
24092409
/// same primary span come out in a consistent order.
24102410
buffered_move_errors:
24112411
BTreeMap<Vec<MoveOutIndex>, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx>)>,
24122412
buffered_mut_errors: FxIndexMap<Span, (DiagnosticBuilder<'tcx>, usize)>,
2413-
/// Diagnostics to be reported buffer.
2413+
/// Buffer of diagnostics to be reported. Uses `Diagnostic` rather than `DiagnosticBuilder`
2414+
/// because it has a mixture of error diagnostics and non-error diagnostics.
24142415
buffered: Vec<Diagnostic>,
24152416
/// Set to Some if we emit an error during borrowck
24162417
tainted_by_errors: Option<ErrorGuaranteed>,
@@ -2434,11 +2435,11 @@ mod error {
24342435
"diagnostic buffered but not emitted",
24352436
))
24362437
}
2437-
t.buffer(&mut self.buffered);
2438+
self.buffered.push(t.into_diagnostic());
24382439
}
24392440

24402441
pub fn buffer_non_error_diag(&mut self, t: DiagnosticBuilder<'_, ()>) {
2441-
t.buffer(&mut self.buffered);
2442+
self.buffered.push(t.into_diagnostic());
24422443
}
24432444

24442445
pub fn set_tainted_by_errors(&mut self, e: ErrorGuaranteed) {
@@ -2486,13 +2487,13 @@ mod error {
24862487
// Buffer any move errors that we collected and de-duplicated.
24872488
for (_, (_, diag)) in std::mem::take(&mut self.errors.buffered_move_errors) {
24882489
// We have already set tainted for this error, so just buffer it.
2489-
diag.buffer(&mut self.errors.buffered);
2490+
self.errors.buffered.push(diag.into_diagnostic());
24902491
}
24912492
for (_, (mut diag, count)) in std::mem::take(&mut self.errors.buffered_mut_errors) {
24922493
if count > 10 {
24932494
diag.note(format!("...and {} other attempted mutable borrows", count - 10));
24942495
}
2495-
diag.buffer(&mut self.errors.buffered);
2496+
self.errors.buffered.push(diag.into_diagnostic());
24962497
}
24972498

24982499
if !self.errors.buffered.is_empty() {

compiler/rustc_builtin_macros/src/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Option<Symbol> {
1818
if let Some(value) = cx.sess.opts.logical_env.get(var) {
1919
return Some(Symbol::intern(value));
2020
}
21-
// If the environment variable was not defined with the `--env` option, we try to retrieve it
21+
// If the environment variable was not defined with the `--env-set` option, we try to retrieve it
2222
// from rustc's environment.
2323
env::var(var).ok().as_deref().map(Symbol::intern)
2424
}

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn prepare_lto(
6060
};
6161

6262
let symbol_filter = &|&(ref name, info): &(String, SymbolExportInfo)| {
63-
if info.level.is_below_threshold(export_threshold) || info.used || info.used_compiler {
63+
if info.level.is_below_threshold(export_threshold) || info.used {
6464
Some(CString::new(name.as_str()).unwrap())
6565
} else {
6666
None

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ pub(crate) unsafe fn llvm_optimize(
569569
unroll_loops,
570570
config.vectorize_slp,
571571
config.vectorize_loop,
572+
config.no_builtins,
572573
config.emit_lifetime_markers,
573574
sanitizer_options.as_ref(),
574575
pgo_gen_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
@@ -677,14 +678,15 @@ pub(crate) unsafe fn codegen(
677678
unsafe fn with_codegen<'ll, F, R>(
678679
tm: &'ll llvm::TargetMachine,
679680
llmod: &'ll llvm::Module,
681+
no_builtins: bool,
680682
f: F,
681683
) -> R
682684
where
683685
F: FnOnce(&'ll mut PassManager<'ll>) -> R,
684686
{
685687
let cpm = llvm::LLVMCreatePassManager();
686688
llvm::LLVMAddAnalysisPasses(tm, cpm);
687-
llvm::LLVMRustAddLibraryInfo(cpm, llmod);
689+
llvm::LLVMRustAddLibraryInfo(cpm, llmod, no_builtins);
688690
f(cpm)
689691
}
690692

@@ -785,7 +787,7 @@ pub(crate) unsafe fn codegen(
785787
} else {
786788
llmod
787789
};
788-
with_codegen(tm, llmod, |cpm| {
790+
with_codegen(tm, llmod, config.no_builtins, |cpm| {
789791
write_output_file(
790792
dcx,
791793
tm,
@@ -820,7 +822,7 @@ pub(crate) unsafe fn codegen(
820822
(_, SplitDwarfKind::Split) => Some(dwo_out.as_path()),
821823
};
822824

823-
with_codegen(tm, llmod, |cpm| {
825+
with_codegen(tm, llmod, config.no_builtins, |cpm| {
824826
write_output_file(
825827
dcx,
826828
tm,

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,8 +2173,13 @@ extern "C" {
21732173
ArgsCstrBuff: *const c_char,
21742174
ArgsCstrBuffLen: usize,
21752175
) -> *mut TargetMachine;
2176+
21762177
pub fn LLVMRustDisposeTargetMachine(T: *mut TargetMachine);
2177-
pub fn LLVMRustAddLibraryInfo<'a>(PM: &PassManager<'a>, M: &'a Module);
2178+
pub fn LLVMRustAddLibraryInfo<'a>(
2179+
PM: &PassManager<'a>,
2180+
M: &'a Module,
2181+
DisableSimplifyLibCalls: bool,
2182+
);
21782183
pub fn LLVMRustWriteOutputFile<'a>(
21792184
T: &'a TargetMachine,
21802185
PM: &PassManager<'a>,
@@ -2196,6 +2201,7 @@ extern "C" {
21962201
UnrollLoops: bool,
21972202
SLPVectorize: bool,
21982203
LoopVectorize: bool,
2204+
DisableSimplifyLibCalls: bool,
21992205
EmitLifetimeMarkers: bool,
22002206
SanitizerOptions: Option<&SanitizerOptions>,
22012207
PGOGenPath: *const c_char,

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,8 @@ pub fn each_linked_rlib(
270270

271271
for &cnum in crates {
272272
match fmts.get(cnum.as_usize() - 1) {
273-
Some(&Linkage::NotLinked | &Linkage::Dynamic) => continue,
274-
Some(&Linkage::IncludedFromDylib) => {
275-
// We always link crate `compiler_builtins` statically. When enabling LTO, we include it as well.
276-
if info.compiler_builtins != Some(cnum) {
277-
continue;
278-
}
279-
}
280-
Some(&Linkage::Static) => {}
273+
Some(&Linkage::NotLinked | &Linkage::Dynamic | &Linkage::IncludedFromDylib) => continue,
274+
Some(_) => {}
281275
None => return Err(errors::LinkRlibError::MissingFormat),
282276
}
283277
let crate_name = info.crate_name[&cnum];
@@ -526,7 +520,8 @@ fn link_staticlib<'a>(
526520
&codegen_results.crate_info,
527521
Some(CrateType::Staticlib),
528522
&mut |cnum, path| {
529-
let lto = are_upstream_rust_objects_already_included(sess);
523+
let lto = are_upstream_rust_objects_already_included(sess)
524+
&& !ignored_for_lto(sess, &codegen_results.crate_info, cnum);
530525

531526
let native_libs = codegen_results.crate_info.native_libraries[&cnum].iter();
532527
let relevant = native_libs.clone().filter(|lib| relevant_lib(sess, lib));
@@ -1277,6 +1272,24 @@ fn link_sanitizer_runtime(
12771272
}
12781273
}
12791274

1275+
/// Returns a boolean indicating whether the specified crate should be ignored
1276+
/// during LTO.
1277+
///
1278+
/// Crates ignored during LTO are not lumped together in the "massive object
1279+
/// file" that we create and are linked in their normal rlib states. See
1280+
/// comments below for what crates do not participate in LTO.
1281+
///
1282+
/// It's unusual for a crate to not participate in LTO. Typically only
1283+
/// compiler-specific and unstable crates have a reason to not participate in
1284+
/// LTO.
1285+
pub fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool {
1286+
// If our target enables builtin function lowering in LLVM then the
1287+
// crates providing these functions don't participate in LTO (e.g.
1288+
// no_builtins or compiler builtins crates).
1289+
!sess.target.no_builtins
1290+
&& (info.compiler_builtins == Some(cnum) || info.is_no_builtins.contains(&cnum))
1291+
}
1292+
12801293
/// This functions tries to determine the appropriate linker (and corresponding LinkerFlavor) to use
12811294
pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
12821295
fn infer_from(
@@ -2742,6 +2755,10 @@ fn rehome_sysroot_lib_dir<'a>(sess: &'a Session, lib_dir: &Path) -> PathBuf {
27422755
// symbols). We must continue to include the rest of the rlib, however, as
27432756
// it may contain static native libraries which must be linked in.
27442757
//
2758+
// (*) Crates marked with `#![no_builtins]` don't participate in LTO and
2759+
// their bytecode wasn't included. The object files in those libraries must
2760+
// still be passed to the linker.
2761+
//
27452762
// Note, however, that if we're not doing LTO we can just pass the rlib
27462763
// blindly to the linker (fast) because it's fine if it's not actually
27472764
// included as we're at the end of the dependency chain.
@@ -2767,7 +2784,9 @@ fn add_static_crate<'a>(
27672784
cmd.link_rlib(&rlib_path);
27682785
};
27692786

2770-
if !are_upstream_rust_objects_already_included(sess) {
2787+
if !are_upstream_rust_objects_already_included(sess)
2788+
|| ignored_for_lto(sess, &codegen_results.crate_info, cnum)
2789+
{
27712790
link_upstream(cratepath);
27722791
return;
27732792
}
@@ -2781,6 +2800,8 @@ fn add_static_crate<'a>(
27812800
let canonical_name = name.replace('-', "_");
27822801
let upstream_rust_objects_already_included =
27832802
are_upstream_rust_objects_already_included(sess);
2803+
let is_builtins =
2804+
sess.target.no_builtins || !codegen_results.crate_info.is_no_builtins.contains(&cnum);
27842805

27852806
let mut archive = archive_builder_builder.new_archive_builder(sess);
27862807
if let Err(error) = archive.add_archive(
@@ -2797,8 +2818,9 @@ fn add_static_crate<'a>(
27972818

27982819
// If we're performing LTO and this is a rust-generated object
27992820
// file, then we don't need the object file as it's part of the
2800-
// LTO module.
2801-
if upstream_rust_objects_already_included && is_rust_object {
2821+
// LTO module. Note that `#![no_builtins]` is excluded from LTO,
2822+
// though, so we let that object file slide.
2823+
if upstream_rust_objects_already_included && is_rust_object && is_builtins {
28022824
return true;
28032825
}
28042826

0 commit comments

Comments
 (0)