From 7804d949dfcc32003dfd5412b44066d3546e4299 Mon Sep 17 00:00:00 2001 From: Jayden Qi Date: Sat, 22 Feb 2025 13:03:50 -0800 Subject: fix: wasm-bare targets compiling x86 builtins Added sanity check to bootstrap to hard error on wasm builds without clang, and changed distribution image `dist-various-2` to use clang to build for official targets. --- src/bootstrap/src/core/sanity.rs | 11 +++++++++++ src/ci/docker/host-x86_64/dist-various-2/Dockerfile | 4 ++++ src/ci/docker/host-x86_64/test-various/Dockerfile | 7 ++++--- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 958058d982b..fa6987d4bf5 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -328,6 +328,17 @@ than building it. .entry(*target) .or_insert_with(|| Target::from_triple(&target.triple)); + // compiler-rt c fallbacks for wasm cannot be built with gcc + if target.contains("wasm") // bare metal targets without wasi sdk + && (build.config.optimized_compiler_builtins(*target) + || build.config.rust_std_features.contains("compiler-builtins-c")) + { + let is_clang = build.cc_tool(*target).is_like_clang(); + if !is_clang { + panic!("only clang supports building c code for wasm targets"); + } + } + if (target.contains("-none-") || target.contains("nvptx")) && build.no_std(*target) == Some(false) { diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index e1d83d36087..931cc688402 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -59,6 +59,10 @@ ENV \ CXX_i686_unknown_uefi=clang++-11 \ CC_x86_64_unknown_uefi=clang-11 \ CXX_x86_64_unknown_uefi=clang++-11 \ + CC_wasm32_unknown_unknown=clang-11 \ + CXX_wasm32_unknown_unknown=clang++-11 \ + CC_wasm32v1_none=clang-11 \ + CXX_wasm32v1_none=clang++-11 \ CC=gcc-9 \ CXX=g++-9 diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index 8d2e45ae497..6c3e62267e1 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -4,6 +4,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ clang-11 \ llvm-11 \ + gcc-multilib \ g++ \ make \ ninja-build \ @@ -59,8 +60,8 @@ RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v19.0 tar -xJ ENV PATH "$PATH:/wasmtime-v19.0.0-x86_64-linux" -ENV WASM_TARGETS=wasm32-wasip1 -ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_TARGETS \ +ENV WASM_WASIP_TARGET=wasm32-wasip1 +ENV WASM_WASIP_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_WASIP_TARGET \ tests/run-make \ tests/ui \ tests/mir-opt \ @@ -90,4 +91,4 @@ ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \ ENV UEFI_SCRIPT python3 /checkout/x.py --stage 2 build --host='' --target $UEFI_TARGETS && \ python3 -u /uefi_qemu_test/run.py -ENV SCRIPT $WASM_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT +ENV SCRIPT $WASM_WASIP_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT -- cgit 1.4.1-3-g733a5 From e2d2926e6840294fe2e0b1a72d162e8d9facf8ea Mon Sep 17 00:00:00 2001 From: Jayden Qi Date: Fri, 14 Mar 2025 18:40:11 -0700 Subject: fix: install correct cc for wasm32-unknown-emscripten Also fixed a typo in the sanity check for bootstrap, as we are checking for clang-likeness in every wasm target. --- src/bootstrap/src/core/sanity.rs | 2 +- src/ci/docker/host-x86_64/dist-various-1/Dockerfile | 9 +++++++++ .../docker/host-x86_64/dist-various-1/install-emscripten.sh | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 src/ci/docker/host-x86_64/dist-various-1/install-emscripten.sh (limited to 'src') diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index fa6987d4bf5..37b2d782931 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -329,7 +329,7 @@ than building it. .or_insert_with(|| Target::from_triple(&target.triple)); // compiler-rt c fallbacks for wasm cannot be built with gcc - if target.contains("wasm") // bare metal targets without wasi sdk + if target.contains("wasm") && (build.config.optimized_compiler_builtins(*target) || build.config.rust_std_features.contains("compiler-builtins-c")) { diff --git a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile index 5c459e5cd18..1e45ef45c9b 100644 --- a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile @@ -55,6 +55,15 @@ RUN ./install-riscv64-none-elf.sh COPY host-x86_64/dist-various-1/install-riscv32-none-elf.sh /build RUN ./install-riscv32-none-elf.sh +COPY host-x86_64/dist-various-1/install-llvm-mingw.sh /build +RUN ./install-llvm-mingw.sh + +COPY host-x86_64/dist-various-1/install-emscripten.sh /build +RUN ./install-emscripten.sh + +# Add Emscripten to PATH +ENV PATH="/build/emsdk:/build/emsdk/upstream/emscripten:/build/emsdk/node/current/bin:${PATH}" + # Suppress some warnings in the openwrt toolchains we downloaded ENV STAGING_DIR=/tmp diff --git a/src/ci/docker/host-x86_64/dist-various-1/install-emscripten.sh b/src/ci/docker/host-x86_64/dist-various-1/install-emscripten.sh new file mode 100755 index 00000000000..eeb54ca67f7 --- /dev/null +++ b/src/ci/docker/host-x86_64/dist-various-1/install-emscripten.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -ex + +apt-get update +apt-get install -y --no-install-recommends \ + nodejs \ + default-jre + +git clone https://github.com/emscripten-core/emsdk.git +cd emsdk +./emsdk install latest +./emsdk activate latest -- cgit 1.4.1-3-g733a5 From 2a0fdef9260a72ded605ae1d980cad70644f25cb Mon Sep 17 00:00:00 2001 From: Jayden Qi Date: Tue, 1 Jul 2025 14:12:01 -0700 Subject: fix: error message --- src/bootstrap/src/core/sanity.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 37b2d782931..295faa25e1c 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -333,9 +333,14 @@ than building it. && (build.config.optimized_compiler_builtins(*target) || build.config.rust_std_features.contains("compiler-builtins-c")) { - let is_clang = build.cc_tool(*target).is_like_clang(); - if !is_clang { - panic!("only clang supports building c code for wasm targets"); + let cc_tool = build.cc_tool(*target); + if !cc_tool.is_like_clang() { + panic!( + "Clang is required to build C code for Wasm targets, got `{}` instead\n\ + this is because compiler-builtins is configured to build C source. Either \ + ensure Clang is used, or adjust this configuration.", + cc_tool.path().display() + ); } } -- cgit 1.4.1-3-g733a5 From 8b1dbac4e508c4b27f0461ad2631b6df07f1af73 Mon Sep 17 00:00:00 2001 From: Jayden Qi Date: Tue, 1 Jul 2025 14:12:21 -0700 Subject: fix: remove unneeded(?) install script --- src/ci/docker/host-x86_64/dist-various-1/Dockerfile | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile index 1e45ef45c9b..4d5980027ca 100644 --- a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile @@ -55,9 +55,6 @@ RUN ./install-riscv64-none-elf.sh COPY host-x86_64/dist-various-1/install-riscv32-none-elf.sh /build RUN ./install-riscv32-none-elf.sh -COPY host-x86_64/dist-various-1/install-llvm-mingw.sh /build -RUN ./install-llvm-mingw.sh - COPY host-x86_64/dist-various-1/install-emscripten.sh /build RUN ./install-emscripten.sh -- cgit 1.4.1-3-g733a5 From dee1b192cb4343cbe228dcf1e553b6f380595b53 Mon Sep 17 00:00:00 2001 From: Jayden Qi Date: Thu, 3 Jul 2025 15:17:36 -0700 Subject: fix: allow emcc --- src/bootstrap/src/core/sanity.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 295faa25e1c..d26d4ce1ba8 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -334,7 +334,8 @@ than building it. || build.config.rust_std_features.contains("compiler-builtins-c")) { let cc_tool = build.cc_tool(*target); - if !cc_tool.is_like_clang() { + if !cc_tool.is_like_clang() && !cc_tool.path().ends_with("emcc") { + // emcc works as well panic!( "Clang is required to build C code for Wasm targets, got `{}` instead\n\ this is because compiler-builtins is configured to build C source. Either \ -- cgit 1.4.1-3-g733a5 From 6e002317cec5fa0c55a88307f839f2b5fb31922c Mon Sep 17 00:00:00 2001 From: Maksim Bondarenkov Date: Sat, 19 Jul 2025 14:19:54 +0300 Subject: opt-dist: rebuild rustc when doing static LLVM builds when building LLVM it's obvious that in case of shared build rustc doesn't need to be recompiled, but with static builds it would be better to compile rustc again to ensure we linked proper library. maybe I didn't understand the pipeline correctly, but it was strange for me to see that in Stage 5 LLVM is built while rustc is not --- src/tools/opt-dist/src/exec.rs | 6 ++++++ src/tools/opt-dist/src/main.rs | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/opt-dist/src/exec.rs b/src/tools/opt-dist/src/exec.rs index 56eff2ca2a7..e5a037dc4e9 100644 --- a/src/tools/opt-dist/src/exec.rs +++ b/src/tools/opt-dist/src/exec.rs @@ -189,6 +189,12 @@ impl Bootstrap { self } + /// Rebuild rustc in case of statically linked LLVM + pub fn rustc_rebuild(mut self) -> Self { + self.cmd = self.cmd.arg("--keep-stage").arg("0"); + self + } + pub fn run(self, timer: &mut TimerSection) -> anyhow::Result<()> { self.cmd.run()?; let metrics = load_metrics(&self.metrics_path)?; diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 7857f196626..8dc77883612 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -363,8 +363,14 @@ fn execute_pipeline( let mut dist = Bootstrap::dist(env, &dist_args) .llvm_pgo_optimize(llvm_pgo_profile.as_ref()) - .rustc_pgo_optimize(&rustc_pgo_profile) - .avoid_rustc_rebuild(); + .rustc_pgo_optimize(&rustc_pgo_profile); + + // if LLVM is not built we'll have PGO optimized rustc + dist = if env.supports_shared_llvm() || !env.build_llvm() { + dist.avoid_rustc_rebuild() + } else { + dist.rustc_rebuild() + }; for bolt_profile in bolt_profiles { dist = dist.with_bolt_profile(bolt_profile); -- cgit 1.4.1-3-g733a5 From 12eb1a0bce83b569f0500f0a78972a1102906264 Mon Sep 17 00:00:00 2001 From: nilptr Date: Sun, 10 Aug 2025 22:16:17 +0800 Subject: feat(lldb debug info): improve enum value formatting in lldb --- src/etc/lldb_providers.py | 35 +++++++++++++++++------------------ tests/debuginfo/borrowed-enum.rs | 6 +++--- 2 files changed, 20 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 98426e42423..46f483de388 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -1,4 +1,5 @@ from __future__ import annotations +import re import sys from typing import List, TYPE_CHECKING @@ -409,6 +410,14 @@ class MSVCStrSyntheticProvider: else: return "&str" +def _getVariantName(variant) -> str: + """ + Since the enum variant's type name is in the form `TheEnumName::TheVariantName$Variant`, + we can extract `TheVariantName` from it for display purpose. + """ + s = variant.GetType().GetName() + match = re.search(r'::([^:]+)\$Variant$', s) + return match.group(1) if match else "" class ClangEncodedEnumProvider: """Pretty-printer for 'clang-encoded' enums support implemented in LLDB""" @@ -424,37 +433,27 @@ class ClangEncodedEnumProvider: return True def num_children(self) -> int: - if self.is_default: - return 1 - return 2 + return 1 - def get_child_index(self, name: str) -> int: - if name == ClangEncodedEnumProvider.VALUE_MEMBER_NAME: - return 0 - if name == ClangEncodedEnumProvider.DISCRIMINANT_MEMBER_NAME: - return 1 + def get_child_index(self, _name: str) -> int: return -1 def get_child_at_index(self, index: int) -> SBValue: if index == 0: - return self.variant.GetChildMemberWithName( + value = self.variant.GetChildMemberWithName( ClangEncodedEnumProvider.VALUE_MEMBER_NAME ) - if index == 1: - return self.variant.GetChildMemberWithName( - ClangEncodedEnumProvider.DISCRIMINANT_MEMBER_NAME + return value.CreateChildAtOffset( + _getVariantName(self.variant), + 0, + value.GetType() ) + return None def update(self): all_variants = self.valobj.GetChildAtIndex(0) index = self._getCurrentVariantIndex(all_variants) self.variant = all_variants.GetChildAtIndex(index) - self.is_default = ( - self.variant.GetIndexOfChildWithName( - ClangEncodedEnumProvider.DISCRIMINANT_MEMBER_NAME - ) - == -1 - ) def _getCurrentVariantIndex(self, all_variants: SBValue) -> int: default_index = 0 diff --git a/tests/debuginfo/borrowed-enum.rs b/tests/debuginfo/borrowed-enum.rs index 517b439ff15..893dd777bcd 100644 --- a/tests/debuginfo/borrowed-enum.rs +++ b/tests/debuginfo/borrowed-enum.rs @@ -22,11 +22,11 @@ // lldb-command:run // lldb-command:v *the_a_ref -// lldb-check:(borrowed_enum::ABC) *the_a_ref = { value = { x = 0 y = 8970181431921507452 } $discr$ = 0 } +// lldb-check:(borrowed_enum::ABC) *the_a_ref = { TheA = { x = 0 y = 8970181431921507452 } } // lldb-command:v *the_b_ref -// lldb-check:(borrowed_enum::ABC) *the_b_ref = { value = { 0 = 0 1 = 286331153 2 = 286331153 } $discr$ = 1 } +// lldb-check:(borrowed_enum::ABC) *the_b_ref = { TheB = { 0 = 0 1 = 286331153 2 = 286331153 } } // lldb-command:v *univariant_ref -// lldb-check:(borrowed_enum::Univariant) *univariant_ref = { value = { 0 = 4820353753753434 } } +// lldb-check:(borrowed_enum::Univariant) *univariant_ref = { TheOnlyCase = { 0 = 4820353753753434 } } #![allow(unused_variables)] -- cgit 1.4.1-3-g733a5 From c39ebeaa0b780afbeb40c8a42cc20bea861ca458 Mon Sep 17 00:00:00 2001 From: nilptr Date: Sun, 10 Aug 2025 22:43:08 +0800 Subject: feat(lldb debug info): deref pointer types for more accurate rust type classification --- src/etc/lldb_lookup.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/etc/lldb_lookup.py b/src/etc/lldb_lookup.py index f4ea904b7f5..f43d2c6a725 100644 --- a/src/etc/lldb_lookup.py +++ b/src/etc/lldb_lookup.py @@ -10,6 +10,9 @@ def is_hashbrown_hashmap(hash_map: lldb.SBValue) -> bool: def classify_rust_type(type: lldb.SBType) -> str: + if type.IsPointerType(): + type = type.GetPointeeType() + type_class = type.GetTypeClass() if type_class == lldb.eTypeClassStruct: return classify_struct(type.name, type.fields) -- cgit 1.4.1-3-g733a5 From 6be749b619e5c74133a27ffa9f2485179b64068f Mon Sep 17 00:00:00 2001 From: nilptr Date: Mon, 11 Aug 2025 00:18:36 +0800 Subject: fix: python formatting error --- src/etc/lldb_providers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 46f483de388..65f18baa937 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -410,15 +410,17 @@ class MSVCStrSyntheticProvider: else: return "&str" + def _getVariantName(variant) -> str: """ Since the enum variant's type name is in the form `TheEnumName::TheVariantName$Variant`, we can extract `TheVariantName` from it for display purpose. """ s = variant.GetType().GetName() - match = re.search(r'::([^:]+)\$Variant$', s) + match = re.search(r"::([^:]+)\$Variant$", s) return match.group(1) if match else "" + class ClangEncodedEnumProvider: """Pretty-printer for 'clang-encoded' enums support implemented in LLDB""" @@ -444,9 +446,7 @@ class ClangEncodedEnumProvider: ClangEncodedEnumProvider.VALUE_MEMBER_NAME ) return value.CreateChildAtOffset( - _getVariantName(self.variant), - 0, - value.GetType() + _getVariantName(self.variant), 0, value.GetType() ) return None -- cgit 1.4.1-3-g733a5 From 77c3d6edfa30cf4c9dc010d96324f6f72579f36b Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Mon, 18 Aug 2025 09:37:50 +0530 Subject: remove default config --- src/bootstrap/src/core/config/config.rs | 1068 +++++++++++++++---------------- src/bootstrap/src/core/config/mod.rs | 6 - src/bootstrap/src/core/download.rs | 71 +- 3 files changed, 563 insertions(+), 582 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 5eea5436023..692c05456f6 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -13,7 +13,6 @@ //! and the `bootstrap.toml` file—merging them, applying defaults, and performing //! cross-component validation. The main `parse_inner` function and its supporting //! helpers reside here, transforming raw `Toml` data into the structured `Config` type. - use std::cell::Cell; use std::collections::{BTreeSet, HashMap, HashSet}; use std::io::IsTerminal; @@ -48,7 +47,7 @@ use crate::core::config::toml::rust::{ use crate::core::config::toml::target::Target; use crate::core::config::{ DebuginfoLevel, DryRun, GccCiMode, LlvmLibunwind, Merge, ReplaceOpt, RustcLto, SplitDebuginfo, - StringOrBool, set, threads_from_config, + StringOrBool, threads_from_config, }; use crate::core::download::{ DownloadContext, download_beta_toolchain, is_download_ci_available, maybe_download_rustfmt, @@ -463,35 +462,32 @@ impl Config { "flags.exclude" = ?flags_exclude ); - // First initialize the bare minimum that we need for further operation - source directory - // and execution context. - let mut config = Config::default_opts(); - let exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast()); + // Set config values based on flags. - config.exec_ctx = exec_ctx; + let mut exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast()); + exec_ctx.set_dry_run(if flags_dry_run { DryRun::UserSelected } else { DryRun::Disabled }); + let mut src = { + let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + // Undo `src/bootstrap` + manifest_dir.parent().unwrap().parent().unwrap().to_owned() + }; - if let Some(src) = compute_src_directory(flags_src, &config.exec_ctx) { - config.src = src; + if let Some(src_) = compute_src_directory(flags_src, &exec_ctx) { + src = src_; } // Now load the TOML config, as soon as possible - let (mut toml, toml_path) = load_toml_config(&config.src, flags_config, &get_toml); - config.config = toml_path.clone(); - - postprocess_toml( - &mut toml, - &config.src, - toml_path, - config.exec_ctx(), - &flags_set, - &get_toml, - ); + let (mut toml, toml_path) = load_toml_config(&src, flags_config, &get_toml); + + let is_running_on_ci = flags_ci.unwrap_or(CiEnv::is_ci()); + + postprocess_toml(&mut toml, &src, toml_path.clone(), &exec_ctx, &flags_set, &get_toml); // Now override TOML values with flags, to make sure that we won't later override flags with // TOML values by accident instead, because flags have higher priority. let Build { description: build_description, - build: mut build_build, + build: build_build, host: build_host, target: build_target, build_dir: build_build_dir, @@ -538,7 +534,7 @@ impl Config { metrics: _, android_ndk: build_android_ndk, optimized_compiler_builtins: build_optimized_compiler_builtins, - jobs: mut build_jobs, + jobs: build_jobs, compiletest_diff_tool: build_compiletest_diff_tool, compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest, tidy_extra_checks: build_tidy_extra_checks, @@ -558,226 +554,179 @@ impl Config { } = toml.install.unwrap_or_default(); let Rust { - optimize: rust_optimize, + optimize: rust_optimize_, debug: rust_debug, - codegen_units: rust_codegen_units, - codegen_units_std: rust_codegen_units_std, + codegen_units: rust_codegen_units_, + codegen_units_std: rust_codegen_units_std_, rustc_debug_assertions: rust_rustc_debug_assertions, std_debug_assertions: rust_std_debug_assertions, tools_debug_assertions: rust_tools_debug_assertions, - overflow_checks: rust_overflow_checks, - overflow_checks_std: rust_overflow_checks_std, - debug_logging: rust_debug_logging, + overflow_checks: rust_overflow_checks_, + overflow_checks_std: rust_overflow_checks_std_, + debug_logging: rust_debug_logging_, debuginfo_level: rust_debuginfo_level, - debuginfo_level_rustc: rust_debuginfo_level_rustc, - debuginfo_level_std: rust_debuginfo_level_std, - debuginfo_level_tools: rust_debuginfo_level_tools, - debuginfo_level_tests: rust_debuginfo_level_tests, + debuginfo_level_rustc: rust_debuginfo_level_rustc_, + debuginfo_level_std: rust_debuginfo_level_std_, + debuginfo_level_tools: rust_debuginfo_level_tools_, + debuginfo_level_tests: rust_debuginfo_level_tests_, backtrace: rust_backtrace, incremental: rust_incremental, - randomize_layout: rust_randomize_layout, + randomize_layout: rust_randomize_layout_, default_linker: rust_default_linker, channel: rust_channel, musl_root: rust_musl_root, - rpath: rust_rpath, + rpath: rust_rpath_, verbose_tests: rust_verbose_tests, - optimize_tests: rust_optimize_tests, + optimize_tests: rust_optimize_tests_, codegen_tests: rust_codegen_tests, omit_git_hash: rust_omit_git_hash, - dist_src: rust_dist_src, + dist_src: rust_dist_src_, save_toolstates: rust_save_toolstates, - codegen_backends: rust_codegen_backends, + codegen_backends: rust_codegen_backends_, lld: rust_lld_enabled, llvm_tools: rust_llvm_tools, llvm_bitcode_linker: rust_llvm_bitcode_linker, deny_warnings: rust_deny_warnings, backtrace_on_ice: rust_backtrace_on_ice, - verify_llvm_ir: rust_verify_llvm_ir, - thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit, - remap_debuginfo: rust_remap_debuginfo, + verify_llvm_ir: rust_verify_llvm_ir_, + thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_, + remap_debuginfo: rust_remap_debuginfo_, jemalloc: rust_jemalloc, test_compare_mode: rust_test_compare_mode, llvm_libunwind: rust_llvm_libunwind, control_flow_guard: rust_control_flow_guard, ehcont_guard: rust_ehcont_guard, - new_symbol_mangling: rust_new_symbol_mangling, - profile_generate: rust_profile_generate, - profile_use: rust_profile_use, + new_symbol_mangling: rust_new_symbol_mangling_, + profile_generate: rust_profile_generate_, + profile_use: rust_profile_use_, download_rustc: rust_download_rustc, - lto: rust_lto, - validate_mir_opts: rust_validate_mir_opts, - frame_pointers: rust_frame_pointers, - stack_protector: rust_stack_protector, - strip: rust_strip, + lto: rust_lto_, + validate_mir_opts: rust_validate_mir_opts_, + frame_pointers: rust_frame_pointers_, + stack_protector: rust_stack_protector_, + strip: rust_strip_, lld_mode: rust_lld_mode, - std_features: rust_std_features, + std_features: rust_std_features_, } = toml.rust.unwrap_or_default(); let Llvm { - optimize: llvm_optimize, - thin_lto: llvm_thin_lto, - release_debuginfo: llvm_release_debuginfo, - assertions: llvm_assertions, - tests: llvm_tests, - enzyme: llvm_enzyme, + optimize: llvm_optimize_, + thin_lto: llvm_thin_lto_, + release_debuginfo: llvm_release_debuginfo_, + assertions: llvm_assertions_, + tests: llvm_tests_, + enzyme: llvm_enzyme_, plugins: llvm_plugin, static_libstdcpp: llvm_static_libstdcpp, - libzstd: llvm_libzstd, + libzstd: llvm_libzstd_, ninja: llvm_ninja, - targets: llvm_targets, - experimental_targets: llvm_experimental_targets, - link_jobs: llvm_link_jobs, - link_shared: llvm_link_shared, - version_suffix: llvm_version_suffix, - clang_cl: llvm_clang_cl, - cflags: llvm_cflags, - cxxflags: llvm_cxxflags, - ldflags: llvm_ldflags, - use_libcxx: llvm_use_libcxx, - use_linker: llvm_use_linker, - allow_old_toolchain: llvm_allow_old_toolchain, - offload: llvm_offload, - polly: llvm_polly, - clang: llvm_clang, - enable_warnings: llvm_enable_warnings, + targets: llvm_targets_, + experimental_targets: llvm_experimental_targets_, + link_jobs: llvm_link_jobs_, + link_shared: llvm_link_shared_, + version_suffix: llvm_version_suffix_, + clang_cl: llvm_clang_cl_, + cflags: llvm_cflags_, + cxxflags: llvm_cxxflags_, + ldflags: llvm_ldflags_, + use_libcxx: llvm_use_libcxx_, + use_linker: llvm_use_linker_, + allow_old_toolchain: llvm_allow_old_toolchain_, + offload: llvm_offload_, + polly: llvm_polly_, + clang: llvm_clang_, + enable_warnings: llvm_enable_warnings_, download_ci_llvm: llvm_download_ci_llvm, - build_config: llvm_build_config, + build_config: llvm_build_config_, } = toml.llvm.unwrap_or_default(); let Dist { - sign_folder: dist_sign_folder, - upload_addr: dist_upload_addr, - src_tarball: dist_src_tarball, - compression_formats: dist_compression_formats, - compression_profile: dist_compression_profile, - include_mingw_linker: dist_include_mingw_linker, - vendor: dist_vendor, + sign_folder: dist_sign_folder_, + upload_addr: dist_upload_addr_, + src_tarball: dist_src_tarball_, + compression_formats: dist_compression_formats_, + compression_profile: dist_compression_profile_, + include_mingw_linker: dist_include_mingw_linker_, + vendor: dist_vendor_, } = toml.dist.unwrap_or_default(); let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default(); - if cfg!(test) { - // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the - // same ones used to call the tests (if custom ones are not defined in the toml). If we - // don't do that, bootstrap will use its own detection logic to find a suitable rustc - // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or - // Cargo in their bootstrap.toml. - build_rustc = build_rustc.take().or(std::env::var_os("RUSTC").map(|p| p.into())); - build_cargo = build_cargo.take().or(std::env::var_os("CARGO").map(|p| p.into())); - } - - build_jobs = flags_jobs.or(build_jobs); - build_build = flags_build.or(build_build); - - let build_dir = flags_build_dir.or(build_build_dir.map(PathBuf::from)); - let host = if let Some(TargetSelectionList(hosts)) = flags_host { - Some(hosts) - } else { - build_host - .map(|file_host| file_host.iter().map(|h| TargetSelection::from_user(h)).collect()) - }; - let target = if let Some(TargetSelectionList(targets)) = flags_target { - Some(targets) - } else { - build_target.map(|file_target| { - file_target.iter().map(|h| TargetSelection::from_user(h)).collect() - }) - }; - - if let Some(rustc) = &build_rustc - && !flags_skip_stage0_validation - { - check_stage0_version(rustc, "rustc", &config.src, config.exec_ctx()); - } - if let Some(cargo) = &build_cargo - && !flags_skip_stage0_validation - { - check_stage0_version(cargo, "cargo", &config.src, config.exec_ctx()); + if rust_optimize_.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { + eprintln!( + "WARNING: setting `optimize` to `false` is known to cause errors and \ + should be considered unsupported. Refer to `bootstrap.example.toml` \ + for more details." + ); } // Prefer CLI verbosity flags if set (`flags_verbose` > 0), otherwise take the value from // TOML. - config - .exec_ctx - .set_verbosity(cmp::max(build_verbose.unwrap_or_default() as u8, flags_verbose)); + exec_ctx.set_verbosity(cmp::max(build_verbose.unwrap_or_default() as u8, flags_verbose)); + + let stage0_metadata = build_helper::stage0_parser::parse_stage0_file(); + let bootstrap_cache_path = build_bootstrap_cache_path; + let patch_binaries_for_nix = build_patch_binaries_for_nix; + + let path_modification_cache = Arc::new(Mutex::new(HashMap::new())); + + let host_target = flags_build + .or(build_build) + .map(|build| TargetSelection::from_user(&build)) + .unwrap_or_else(get_host_target); + let hosts = flags_host + .map(|TargetSelectionList(hosts)| hosts) + .or_else(|| { + build_host.map(|h| h.iter().map(|t| TargetSelection::from_user(t)).collect()) + }) + .unwrap_or_else(|| vec![host_target]); - let mut paths: Vec = flags_skip.into_iter().chain(flags_exclude).collect(); - if let Some(exclude) = build_exclude { - paths.extend(exclude); - } + let submodules = build_submodules; + let llvm_assertions = llvm_assertions_.unwrap_or(false); - // Set config values based on flags. - config.paths = flags_paths; - config.include_default_paths = flags_include_default_paths; - config.rustc_error_format = flags_rustc_error_format; - config.json_output = flags_json_output; - config.compile_time_deps = flags_compile_time_deps; - config.on_fail = flags_on_fail; - config.cmd = flags_cmd; - config.incremental = flags_incremental; - config.set_dry_run(if flags_dry_run { DryRun::UserSelected } else { DryRun::Disabled }); - config.dump_bootstrap_shims = flags_dump_bootstrap_shims; - config.keep_stage = flags_keep_stage; - config.keep_stage_std = flags_keep_stage_std; - config.color = flags_color; - config.free_args = flags_free_args; - config.llvm_profile_use = flags_llvm_profile_use; - config.llvm_profile_generate = flags_llvm_profile_generate; - config.enable_bolt_settings = flags_enable_bolt_settings; - config.bypass_bootstrap_lock = flags_bypass_bootstrap_lock; - config.is_running_on_ci = flags_ci.unwrap_or(CiEnv::is_ci()); - config.skip_std_check_if_no_download_rustc = flags_skip_std_check_if_no_download_rustc; - - // Infer the rest of the configuration. + let mut target_config = HashMap::new(); + let mut download_rustc_commit = None; + let llvm_link_shared = Cell::default(); + let mut llvm_from_ci = false; + let mut channel = "dev".to_string(); + let mut out = flags_build_dir + .or(build_build_dir.map(PathBuf::from)) + .unwrap_or_else(|| PathBuf::from("build")); + let mut rust_info = GitInfo::Absent; if cfg!(test) { // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. - config.out = Path::new( - &env::var_os("CARGO_TARGET_DIR").expect("cargo test directly is not supported"), - ) - .parent() - .unwrap() - .to_path_buf(); - } - - config.compiletest_allow_stage0 = build_compiletest_allow_stage0.unwrap_or(false); - config.stage0_metadata = build_helper::stage0_parser::parse_stage0_file(); - - config.change_id = toml.change_id.inner; - - config.skip = paths - .into_iter() - .map(|p| { - // Never return top-level path here as it would break `--skip` - // logic on rustc's internal test framework which is utilized - // by compiletest. - if cfg!(windows) { - PathBuf::from(p.to_str().unwrap().replace('/', "\\")) - } else { - p - } - }) - .collect(); - - #[cfg(feature = "tracing")] - span!( - target: "CONFIG_HANDLING", - tracing::Level::TRACE, - "normalizing and combining `flag.skip`/`flag.exclude` paths", - "config.skip" = ?config.skip, - ); - - config.jobs = Some(threads_from_config(build_jobs.unwrap_or(0))); - if let Some(build) = build_build { - config.host_target = TargetSelection::from_user(&build); + if out == PathBuf::from("build") { + out = Path::new( + &env::var_os("CARGO_TARGET_DIR").expect("cargo test directly is not supported"), + ) + .parent() + .unwrap() + .to_path_buf(); + } + // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the + // same ones used to call the tests (if custom ones are not defined in the toml). If we + // don't do that, bootstrap will use its own detection logic to find a suitable rustc + // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or + // Cargo in their bootstrap.toml. + build_rustc = build_rustc.take().or(std::env::var_os("RUSTC").map(|p| p.into())); + build_cargo = build_cargo.take().or(std::env::var_os("CARGO").map(|p| p.into())); } - set(&mut config.out, build_dir); // NOTE: Bootstrap spawns various commands with different working directories. // To avoid writing to random places on the file system, `config.out` needs to be an absolute path. - if !config.out.is_absolute() { + if !out.is_absolute() { // `canonicalize` requires the path to already exist. Use our vendored copy of `absolute` instead. - config.out = absolute(&config.out).expect("can't make empty path absolute"); + out = absolute(&out).expect("can't make empty path absolute"); + } + + if !flags_skip_stage0_validation { + if let Some(rustc) = &build_rustc { + check_stage0_version(rustc, "rustc", &src, &exec_ctx); + } + if let Some(cargo) = &build_cargo { + check_stage0_version(cargo, "cargo", &src, &exec_ctx); + } } if build_cargo_clippy.is_some() && build_rustc.is_none() { @@ -786,146 +735,74 @@ impl Config { ); } - config.initial_rustc = if let Some(rustc) = build_rustc { - rustc - } else { - let dwn_ctx = DownloadContext::from(&config); - download_beta_toolchain(dwn_ctx); - config - .out - .join(config.host_target) - .join("stage0") - .join("bin") - .join(exe("rustc", config.host_target)) - }; + let mut dwn_ctx = DownloadContext::new( + path_modification_cache.clone(), + &src, + rust_info.clone(), + &submodules, + download_rustc_commit.clone(), + host_target, + llvm_from_ci, + target_config.clone(), + out.clone(), + patch_binaries_for_nix, + &exec_ctx, + &stage0_metadata, + llvm_assertions, + &bootstrap_cache_path, + is_running_on_ci, + ); + + let initial_rustc = build_rustc.unwrap_or_else(|| { + download_beta_toolchain(&dwn_ctx); + out.join(host_target).join("stage0").join("bin").join(exe("rustc", host_target)) + }); - config.initial_sysroot = t!(PathBuf::from_str( - command(&config.initial_rustc) + let initial_sysroot = t!(PathBuf::from_str( + command(&initial_rustc) .args(["--print", "sysroot"]) .run_in_dry_run() - .run_capture_stdout(&config) + .run_capture_stdout(&exec_ctx) .stdout() .trim() )); - config.initial_cargo_clippy = build_cargo_clippy; - - config.initial_cargo = if let Some(cargo) = build_cargo { - cargo - } else { - let dwn_ctx = DownloadContext::from(&config); - download_beta_toolchain(dwn_ctx); - config.initial_sysroot.join("bin").join(exe("cargo", config.host_target)) - }; + let initial_cargo = build_cargo.unwrap_or_else(|| { + download_beta_toolchain(&mut dwn_ctx); + initial_sysroot.join("bin").join(exe("cargo", host_target)) + }); // NOTE: it's important this comes *after* we set `initial_rustc` just above. - if config.dry_run() { - let dir = config.out.join("tmp-dry-run"); - t!(fs::create_dir_all(&dir)); - config.out = dir; + if exec_ctx.dry_run() { + out = out.join("tmp-dry-run"); + fs::create_dir_all(&out).expect("Failed to create dry-run directory"); + dwn_ctx.out = out.clone(); } - config.hosts = if let Some(hosts) = host { hosts } else { vec![config.host_target] }; - config.targets = if let Some(targets) = target { - targets - } else { - // If target is *not* configured, then default to the host - // toolchains. - config.hosts.clone() - }; - - config.nodejs = build_nodejs.map(PathBuf::from); - config.npm = build_npm.map(PathBuf::from); - config.gdb = build_gdb.map(PathBuf::from); - config.lldb = build_lldb.map(PathBuf::from); - config.python = build_python.map(PathBuf::from); - config.reuse = build_reuse.map(PathBuf::from); - config.submodules = build_submodules; - config.android_ndk = build_android_ndk; - config.bootstrap_cache_path = build_bootstrap_cache_path; - set(&mut config.low_priority, build_low_priority); - set(&mut config.compiler_docs, build_compiler_docs); - set(&mut config.library_docs_private_items, build_library_docs_private_items); - set(&mut config.docs_minification, build_docs_minification); - set(&mut config.docs, build_docs); - set(&mut config.locked_deps, build_locked_deps); - set(&mut config.full_bootstrap, build_full_bootstrap); - set(&mut config.extended, build_extended); - config.tools = build_tools; - set(&mut config.tool, build_tool); - set(&mut config.sanitizers, build_sanitizers); - set(&mut config.profiler, build_profiler); - set(&mut config.cargo_native_static, build_cargo_native_static); - set(&mut config.configure_args, build_configure_args); - set(&mut config.local_rebuild, build_local_rebuild); - set(&mut config.print_step_timings, build_print_step_timings); - set(&mut config.print_step_rusage, build_print_step_rusage); - config.patch_binaries_for_nix = build_patch_binaries_for_nix; - - // Verbose flag is a good default for `rust.verbose-tests`. - config.verbose_tests = config.is_verbose(); - - config.prefix = install_prefix.map(PathBuf::from); - config.sysconfdir = install_sysconfdir.map(PathBuf::from); - config.datadir = install_datadir.map(PathBuf::from); - config.docdir = install_docdir.map(PathBuf::from); - set(&mut config.bindir, install_bindir.map(PathBuf::from)); - config.libdir = install_libdir.map(PathBuf::from); - config.mandir = install_mandir.map(PathBuf::from); - - config.llvm_assertions = llvm_assertions.unwrap_or(false); - - let file_content = t!(fs::read_to_string(config.src.join("src/ci/channel"))); + let file_content = t!(fs::read_to_string(src.join("src/ci/channel"))); let ci_channel = file_content.trim_end(); let is_user_configured_rust_channel = match rust_channel { - Some(channel) if channel == "auto-detect" => { - config.channel = ci_channel.into(); + Some(channel_) if channel_ == "auto-detect" => { + channel = ci_channel.into(); true } - Some(channel) => { - config.channel = channel; + Some(channel_) => { + channel = channel_; true } None => false, }; - let default = config.channel == "dev"; - config.omit_git_hash = rust_omit_git_hash.unwrap_or(default); + let omit_git_hash = rust_omit_git_hash.unwrap_or(channel == "dev"); - config.rust_info = git_info(&config.exec_ctx, config.omit_git_hash, &config.src); - config.cargo_info = - git_info(&config.exec_ctx, config.omit_git_hash, &config.src.join("src/tools/cargo")); - config.rust_analyzer_info = git_info( - &config.exec_ctx, - config.omit_git_hash, - &config.src.join("src/tools/rust-analyzer"), - ); - config.clippy_info = - git_info(&config.exec_ctx, config.omit_git_hash, &config.src.join("src/tools/clippy")); - config.miri_info = - git_info(&config.exec_ctx, config.omit_git_hash, &config.src.join("src/tools/miri")); - config.rustfmt_info = - git_info(&config.exec_ctx, config.omit_git_hash, &config.src.join("src/tools/rustfmt")); - config.enzyme_info = - git_info(&config.exec_ctx, config.omit_git_hash, &config.src.join("src/tools/enzyme")); - config.in_tree_llvm_info = - git_info(&config.exec_ctx, false, &config.src.join("src/llvm-project")); - config.in_tree_gcc_info = git_info(&config.exec_ctx, false, &config.src.join("src/gcc")); - - config.vendor = build_vendor.unwrap_or( - config.rust_info.is_from_tarball() - && config.src.join("vendor").exists() - && config.src.join(".cargo/config.toml").exists(), - ); + rust_info = git_info(&exec_ctx, omit_git_hash, &src); + dwn_ctx.rust_info = rust_info.clone(); - if !is_user_configured_rust_channel && config.rust_info.is_from_tarball() { - config.channel = ci_channel.into(); + if !is_user_configured_rust_channel && rust_info.is_from_tarball() { + channel = ci_channel.into(); } - config.rust_profile_use = flags_rust_profile_use; - config.rust_profile_generate = flags_rust_profile_generate; - // FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions // enabled. We should not download a CI alt rustc if we need rustc to have debug // assertions (e.g. for crashes test suite). This can be changed once something like @@ -951,17 +828,35 @@ impl Config { ); } - let dwn_ctx = DownloadContext::from(&config); - config.download_rustc_commit = - download_ci_rustc_commit(dwn_ctx, rust_download_rustc, config.llvm_assertions); + download_rustc_commit = + download_ci_rustc_commit(&dwn_ctx, rust_download_rustc, llvm_assertions); + dwn_ctx.download_rustc_commit = download_rustc_commit.clone(); - if debug_assertions_requested && config.download_rustc_commit.is_some() { + if debug_assertions_requested && download_rustc_commit.is_some() { eprintln!( "WARN: `rust.debug-assertions = true` will prevent downloading CI rustc as alt CI \ rustc is not currently built with debug assertions." ); // We need to put this later down_ci_rustc_commit. - config.download_rustc_commit = None; + download_rustc_commit = None; + dwn_ctx.download_rustc_commit = None; + } + + // We need to override `rust.channel` if it's manually specified when using the CI rustc. + // This is because if the compiler uses a different channel than the one specified in bootstrap.toml, + // tests may fail due to using a different channel than the one used by the compiler during tests. + if let Some(commit) = &download_rustc_commit + && is_user_configured_rust_channel + { + println!( + "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." + ); + + let channel_ = read_file_by_commit(&dwn_ctx, Path::new("src/ci/channel"), commit) + .trim() + .to_owned(); + + channel = channel_; } if let Some(t) = toml.target { @@ -969,24 +864,22 @@ impl Config { let mut target = Target::from_triple(&triple); if let Some(ref s) = cfg.llvm_config { - if config.download_rustc_commit.is_some() - && triple == *config.host_target.triple - { + if download_rustc_commit.is_some() && triple == *host_target.triple { panic!( "setting llvm_config for the host is incompatible with download-rustc" ); } - target.llvm_config = Some(config.src.join(s)); + target.llvm_config = Some(src.join(s)); } if let Some(patches) = cfg.llvm_has_rust_patches { assert!( - config.submodules == Some(false) || cfg.llvm_config.is_some(), + submodules == Some(false) || cfg.llvm_config.is_some(), "use of `llvm-has-rust-patches` is restricted to cases where either submodules are disabled or llvm-config been provided" ); target.llvm_has_rust_patches = Some(patches); } if let Some(ref s) = cfg.llvm_filecheck { - target.llvm_filecheck = Some(config.src.join(s)); + target.llvm_filecheck = Some(src.join(s)); } target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| { v.parse().unwrap_or_else(|_| { @@ -1023,82 +916,11 @@ impl Config { }) }); - config.target_config.insert(TargetSelection::from_user(&triple), target); + target_config.insert(TargetSelection::from_user(&triple), target); } + dwn_ctx.target_config = target_config.clone(); } - if rust_optimize.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { - eprintln!( - "WARNING: setting `optimize` to `false` is known to cause errors and \ - should be considered unsupported. Refer to `bootstrap.example.toml` \ - for more details." - ); - } - - config.rust_new_symbol_mangling = rust_new_symbol_mangling; - set(&mut config.rust_optimize_tests, rust_optimize_tests); - set(&mut config.codegen_tests, rust_codegen_tests); - set(&mut config.rust_rpath, rust_rpath); - set(&mut config.rust_strip, rust_strip); - set(&mut config.rust_frame_pointers, rust_frame_pointers); - config.rust_stack_protector = rust_stack_protector; - set(&mut config.jemalloc, rust_jemalloc); - set(&mut config.test_compare_mode, rust_test_compare_mode); - set(&mut config.backtrace, rust_backtrace); - set(&mut config.rust_dist_src, rust_dist_src); - set(&mut config.verbose_tests, rust_verbose_tests); - // in the case "false" is set explicitly, do not overwrite the command line args - if let Some(true) = rust_incremental { - config.incremental = true; - } - set(&mut config.lld_mode, rust_lld_mode); - set(&mut config.llvm_bitcode_linker_enabled, rust_llvm_bitcode_linker); - - config.rust_randomize_layout = rust_randomize_layout.unwrap_or_default(); - config.llvm_tools_enabled = rust_llvm_tools.unwrap_or(true); - - config.llvm_enzyme = config.channel == "dev" || config.channel == "nightly"; - config.rustc_default_linker = rust_default_linker; - config.musl_root = rust_musl_root.map(PathBuf::from); - config.save_toolstates = rust_save_toolstates.map(PathBuf::from); - set( - &mut config.deny_warnings, - match flags_warnings { - Warnings::Deny => Some(true), - Warnings::Warn => Some(false), - Warnings::Default => rust_deny_warnings, - }, - ); - set(&mut config.backtrace_on_ice, rust_backtrace_on_ice); - set(&mut config.rust_verify_llvm_ir, rust_verify_llvm_ir); - config.rust_thin_lto_import_instr_limit = rust_thin_lto_import_instr_limit; - set(&mut config.rust_remap_debuginfo, rust_remap_debuginfo); - set(&mut config.control_flow_guard, rust_control_flow_guard); - set(&mut config.ehcont_guard, rust_ehcont_guard); - config.llvm_libunwind_default = - rust_llvm_libunwind.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); - set( - &mut config.rust_codegen_backends, - rust_codegen_backends.map(|backends| parse_codegen_backends(backends, "rust")), - ); - - config.rust_codegen_units = rust_codegen_units.map(threads_from_config); - config.rust_codegen_units_std = rust_codegen_units_std.map(threads_from_config); - - if config.rust_profile_use.is_none() { - config.rust_profile_use = rust_profile_use; - } - - if config.rust_profile_generate.is_none() { - config.rust_profile_generate = rust_profile_generate; - } - - config.rust_lto = - rust_lto.as_deref().map(|value| RustcLto::from_str(value).unwrap()).unwrap_or_default(); - config.rust_validate_mir_opts = rust_validate_mir_opts; - - config.rust_optimize = rust_optimize.unwrap_or(RustOptimize::Bool(true)); - // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will // build our internal lld and use it as the default linker, by setting the `rust.lld` config // to true by default: @@ -1111,105 +933,24 @@ impl Config { // thus, disabled // - similarly, lld will not be built nor used by default when explicitly asked not to, e.g. // when the config sets `rust.lld = false` - if default_lld_opt_in_targets().contains(&config.host_target.triple.to_string()) - && config.hosts == [config.host_target] + let lld_enabled = if default_lld_opt_in_targets().contains(&host_target.triple.to_string()) + && hosts == [host_target] { - let no_llvm_config = config - .target_config - .get(&config.host_target) - .is_none_or(|target_config| target_config.llvm_config.is_none()); - let enable_lld = config.llvm_from_ci || no_llvm_config; - // Prefer the config setting in case an explicit opt-out is needed. - config.lld_enabled = rust_lld_enabled.unwrap_or(enable_lld); + let no_llvm_config = + target_config.get(&host_target).map_or(true, |config| config.llvm_config.is_none()); + rust_lld_enabled.unwrap_or(llvm_from_ci || no_llvm_config) } else { - set(&mut config.lld_enabled, rust_lld_enabled); - } - - let default_std_features = BTreeSet::from([String::from("panic-unwind")]); - config.rust_std_features = rust_std_features.unwrap_or(default_std_features); - - let default = rust_debug == Some(true); - config.rustc_debug_assertions = rust_rustc_debug_assertions.unwrap_or(default); - config.std_debug_assertions = - rust_std_debug_assertions.unwrap_or(config.rustc_debug_assertions); - config.tools_debug_assertions = - rust_tools_debug_assertions.unwrap_or(config.rustc_debug_assertions); - config.rust_overflow_checks = rust_overflow_checks.unwrap_or(default); - config.rust_overflow_checks_std = - rust_overflow_checks_std.unwrap_or(config.rust_overflow_checks); - - config.rust_debug_logging = rust_debug_logging.unwrap_or(config.rustc_debug_assertions); - - let with_defaults = |debuginfo_level_specific: Option<_>| { - debuginfo_level_specific.or(rust_debuginfo_level).unwrap_or( - if rust_debug == Some(true) { - DebuginfoLevel::Limited - } else { - DebuginfoLevel::None - }, - ) + rust_lld_enabled.unwrap_or(false) }; - config.rust_debuginfo_level_rustc = with_defaults(rust_debuginfo_level_rustc); - config.rust_debuginfo_level_std = with_defaults(rust_debuginfo_level_std); - config.rust_debuginfo_level_tools = with_defaults(rust_debuginfo_level_tools); - config.rust_debuginfo_level_tests = - rust_debuginfo_level_tests.unwrap_or(DebuginfoLevel::None); - - config.reproducible_artifacts = flags_reproducible_artifact; - config.description = build_description; - - // We need to override `rust.channel` if it's manually specified when using the CI rustc. - // This is because if the compiler uses a different channel than the one specified in bootstrap.toml, - // tests may fail due to using a different channel than the one used by the compiler during tests. - if let Some(commit) = &config.download_rustc_commit - && is_user_configured_rust_channel - { - println!( - "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." - ); - let dwn_ctx = DownloadContext::from(&config); - let channel = - read_file_by_commit(dwn_ctx, Path::new("src/ci/channel"), commit).trim().to_owned(); - - config.channel = channel; + if let Some(v) = llvm_link_shared_ { + llvm_link_shared.set(Some(v)); } - set(&mut config.ninja_in_file, llvm_ninja); - set(&mut config.llvm_optimize, llvm_optimize); - set(&mut config.llvm_thin_lto, llvm_thin_lto); - set(&mut config.llvm_release_debuginfo, llvm_release_debuginfo); - set(&mut config.llvm_static_stdcpp, llvm_static_libstdcpp); - set(&mut config.llvm_libzstd, llvm_libzstd); - if let Some(v) = llvm_link_shared { - config.llvm_link_shared.set(Some(v)); - } - config.llvm_targets.clone_from(&llvm_targets); - config.llvm_experimental_targets.clone_from(&llvm_experimental_targets); - config.llvm_link_jobs = llvm_link_jobs; - config.llvm_version_suffix.clone_from(&llvm_version_suffix); - config.llvm_clang_cl.clone_from(&llvm_clang_cl); - config.llvm_tests = llvm_tests.unwrap_or_default(); - config.llvm_enzyme = llvm_enzyme.unwrap_or_default(); - config.llvm_plugins = llvm_plugin.unwrap_or_default(); - - config.llvm_cflags.clone_from(&llvm_cflags); - config.llvm_cxxflags.clone_from(&llvm_cxxflags); - config.llvm_ldflags.clone_from(&llvm_ldflags); - set(&mut config.llvm_use_libcxx, llvm_use_libcxx); - config.llvm_use_linker.clone_from(&llvm_use_linker); - config.llvm_allow_old_toolchain = llvm_allow_old_toolchain.unwrap_or(false); - config.llvm_offload = llvm_offload.unwrap_or(false); - config.llvm_polly = llvm_polly.unwrap_or(false); - config.llvm_clang = llvm_clang.unwrap_or(false); - config.llvm_enable_warnings = llvm_enable_warnings.unwrap_or(false); - config.llvm_build_config = llvm_build_config.clone().unwrap_or(Default::default()); - - let dwn_ctx = DownloadContext::from(&config); - config.llvm_from_ci = - parse_download_ci_llvm(dwn_ctx, llvm_download_ci_llvm, config.llvm_assertions); - - if config.llvm_from_ci { + llvm_from_ci = parse_download_ci_llvm(&dwn_ctx, llvm_download_ci_llvm, llvm_assertions); + dwn_ctx.llvm_from_ci = llvm_from_ci; + + if llvm_from_ci { let warn = |option: &str| { println!( "WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build." @@ -1223,7 +964,7 @@ impl Config { warn("static-libstdcpp"); } - if llvm_link_shared.is_some() { + if llvm_link_shared_.is_some() { warn("link-shared"); } @@ -1232,7 +973,7 @@ impl Config { // config to the ones used to build the LLVM artifacts on CI, and only notify users // if they've chosen a different value. - if llvm_libzstd.is_some() { + if llvm_libzstd_.is_some() { println!( "WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \ like almost all `llvm.*` options, will be ignored and set by the LLVM CI \ @@ -1244,66 +985,30 @@ impl Config { } } - if !config.llvm_from_ci && config.llvm_thin_lto && llvm_link_shared.is_none() { + if !llvm_from_ci && llvm_thin_lto_.unwrap_or(false) && llvm_link_shared_.is_none() { // If we're building with ThinLTO on, by default we want to link // to LLVM shared, to avoid re-doing ThinLTO (which happens in // the link step) with each stage. - config.llvm_link_shared.set(Some(true)); - } - - config.gcc_ci_mode = match gcc_download_ci_gcc { - Some(value) => match value { - true => GccCiMode::DownloadFromCi, - false => GccCiMode::BuildLocally, - }, - None => GccCiMode::default(), - }; - - match build_ccache { - Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()), - Some(StringOrBool::Bool(true)) => { - config.ccache = Some("ccache".to_string()); - } - Some(StringOrBool::Bool(false)) | None => {} + llvm_link_shared.set(Some(true)); } - if config.llvm_from_ci { - let triple = &config.host_target.triple; - let dwn_ctx = DownloadContext::from(&config); - let ci_llvm_bin = ci_llvm_root(dwn_ctx).join("bin"); - let build_target = config - .target_config - .entry(config.host_target) - .or_insert_with(|| Target::from_triple(triple)); + if llvm_from_ci { + let triple = &host_target.triple; + let ci_llvm_bin = ci_llvm_root(&dwn_ctx).join("bin"); + let build_target = + target_config.entry(host_target).or_insert_with(|| Target::from_triple(triple)); + dwn_ctx.target_config.entry(host_target).or_insert_with(|| Target::from_triple(triple)); check_ci_llvm!(build_target.llvm_config); check_ci_llvm!(build_target.llvm_filecheck); - build_target.llvm_config = - Some(ci_llvm_bin.join(exe("llvm-config", config.host_target))); - build_target.llvm_filecheck = - Some(ci_llvm_bin.join(exe("FileCheck", config.host_target))); + build_target.llvm_config = Some(ci_llvm_bin.join(exe("llvm-config", host_target))); + build_target.llvm_filecheck = Some(ci_llvm_bin.join(exe("FileCheck", host_target))); } - config.dist_sign_folder = dist_sign_folder.map(PathBuf::from); - config.dist_upload_addr = dist_upload_addr; - config.dist_compression_formats = dist_compression_formats; - set(&mut config.dist_compression_profile, dist_compression_profile); - set(&mut config.rust_dist_src, dist_src_tarball); - set(&mut config.dist_include_mingw_linker, dist_include_mingw_linker); - config.dist_vendor = dist_vendor.unwrap_or_else(|| { - // If we're building from git or tarball sources, enable it by default. - config.rust_info.is_managed_git_subrepository() || config.rust_info.is_from_tarball() - }); - - config.initial_rustfmt = if let Some(r) = build_rustfmt { - Some(r) - } else { - let dwn_ctx = DownloadContext::from(&config); - maybe_download_rustfmt(dwn_ctx) - }; + let initial_rustfmt = build_rustfmt.or_else(|| maybe_download_rustfmt(&dwn_ctx)); - if matches!(config.lld_mode, LldMode::SelfContained) - && !config.lld_enabled + if matches!(rust_lld_mode.unwrap_or_default(), LldMode::SelfContained) + && !lld_enabled && flags_stage.unwrap_or(0) > 0 { panic!( @@ -1311,29 +1016,13 @@ impl Config { ); } - let dwn_ctx = DownloadContext::from(&config); - if config.lld_enabled && is_system_llvm(dwn_ctx, config.host_target) { + if lld_enabled && is_system_llvm(&dwn_ctx, host_target) { panic!("Cannot enable LLD with `rust.lld = true` when using external llvm-config."); } - config.optimized_compiler_builtins = - build_optimized_compiler_builtins.unwrap_or(config.channel != "dev"); - config.compiletest_diff_tool = build_compiletest_diff_tool; - config.compiletest_use_stage0_libtest = - build_compiletest_use_stage0_libtest.unwrap_or(true); - config.tidy_extra_checks = build_tidy_extra_checks; - - let download_rustc = config.download_rustc_commit.is_some(); - config.explicit_stage_from_cli = flags_stage.is_some(); - config.explicit_stage_from_config = build_test_stage.is_some() - || build_build_stage.is_some() - || build_doc_stage.is_some() - || build_dist_stage.is_some() - || build_install_stage.is_some() - || build_check_stage.is_some() - || build_bench_stage.is_some(); - - config.stage = match config.cmd { + let download_rustc = download_rustc_commit.is_some(); + + let stage = match flags_cmd { Subcommand::Check { .. } => flags_stage.or(build_check_stage).unwrap_or(1), Subcommand::Clippy { .. } | Subcommand::Fix => { flags_stage.or(build_check_stage).unwrap_or(1) @@ -1362,7 +1051,7 @@ impl Config { }; // Now check that the selected stage makes sense, and if not, print a warning and end - match (config.stage, &config.cmd) { + match (stage, &flags_cmd) { (0, Subcommand::Build { .. }) => { eprintln!("ERROR: cannot build anything on stage 0. Use at least stage 1."); exit!(1); @@ -1382,7 +1071,7 @@ impl Config { _ => {} } - if config.compile_time_deps && !matches!(config.cmd, Subcommand::Check { .. }) { + if flags_compile_time_deps && !matches!(flags_cmd, Subcommand::Check { .. }) { eprintln!( "WARNING: Can't use --compile-time-deps with any subcommand other than check." ); @@ -1391,8 +1080,8 @@ impl Config { // CI should always run stage 2 builds, unless it specifically states otherwise #[cfg(not(test))] - if flags_stage.is_none() && config.is_running_on_ci { - match config.cmd { + if flags_stage.is_none() && is_running_on_ci { + match flags_cmd { Subcommand::Test { .. } | Subcommand::Miri { .. } | Subcommand::Doc { .. } @@ -1401,9 +1090,8 @@ impl Config { | Subcommand::Dist | Subcommand::Install => { assert_eq!( - config.stage, 2, - "x.py should be run with `--stage 2` on CI, but was run with `--stage {}`", - config.stage, + stage, 2, + "x.py should be run with `--stage 2` on CI, but was run with `--stage {stage}`", ); } Subcommand::Clean { .. } @@ -1418,7 +1106,267 @@ impl Config { } } - config + let with_defaults = |debuginfo_level_specific: Option<_>| { + debuginfo_level_specific.or(rust_debuginfo_level).unwrap_or( + if rust_debug == Some(true) { + DebuginfoLevel::Limited + } else { + DebuginfoLevel::None + }, + ) + }; + + Config { + change_id: toml.change_id.inner, + bypass_bootstrap_lock: flags_bypass_bootstrap_lock, + ccache: match build_ccache { + Some(StringOrBool::String(s)) => Some(s), + Some(StringOrBool::Bool(true)) => Some("ccache".to_string()), + _ => None, + }, + ninja_in_file: llvm_ninja.unwrap_or(true), + compiler_docs: build_compiler_docs.unwrap_or(false), + library_docs_private_items: build_library_docs_private_items.unwrap_or(false), + docs_minification: build_docs_minification.unwrap_or(true), + docs: build_docs.unwrap_or(true), + locked_deps: build_locked_deps.unwrap_or(false), + full_bootstrap: build_full_bootstrap.unwrap_or(false), + bootstrap_cache_path, + extended: build_extended.unwrap_or(false), + tools: build_tools, + tool: build_tool.unwrap_or_default(), + sanitizers: build_sanitizers.unwrap_or(false), + profiler: build_profiler.unwrap_or(false), + include_default_paths: flags_include_default_paths, + rustc_error_format: flags_rustc_error_format, + json_output: flags_json_output, + compile_time_deps: flags_compile_time_deps, + test_compare_mode: rust_test_compare_mode.unwrap_or(false), + color: flags_color, + android_ndk: build_android_ndk, + optimized_compiler_builtins: build_optimized_compiler_builtins + .unwrap_or(channel != "dev"), + stdout_is_tty: std::io::stdout().is_terminal(), + stderr_is_tty: std::io::stderr().is_terminal(), + on_fail: flags_on_fail, + explicit_stage_from_cli: flags_stage.is_some(), + explicit_stage_from_config: build_test_stage.is_some() + || build_build_stage.is_some() + || build_doc_stage.is_some() + || build_dist_stage.is_some() + || build_install_stage.is_some() + || build_check_stage.is_some() + || build_bench_stage.is_some(), + + keep_stage: flags_keep_stage, + keep_stage_std: flags_keep_stage_std, + jobs: Some(threads_from_config(flags_jobs.or(build_jobs).unwrap_or(0))), + incremental: flags_incremental || rust_incremental == Some(true), + dump_bootstrap_shims: flags_dump_bootstrap_shims, + free_args: flags_free_args, + deny_warnings: match flags_warnings { + Warnings::Deny => true, + Warnings::Warn => false, + Warnings::Default => rust_deny_warnings.unwrap_or(true), + }, + backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), + llvm_tests: llvm_tests_.unwrap_or_default(), + llvm_enzyme: llvm_enzyme_.unwrap_or_default(), + llvm_offload: llvm_offload_.unwrap_or(false), + llvm_plugins: llvm_plugin.unwrap_or_default(), + llvm_optimize: llvm_optimize_.unwrap_or(true), + llvm_release_debuginfo: llvm_release_debuginfo_.unwrap_or(false), + llvm_static_stdcpp: llvm_static_libstdcpp.unwrap_or(false), + llvm_libzstd: llvm_libzstd_.unwrap_or(false), + llvm_clang_cl: llvm_clang_cl_, + llvm_targets: llvm_targets_, + llvm_experimental_targets: llvm_experimental_targets_, + llvm_link_jobs: llvm_link_jobs_, + llvm_version_suffix: llvm_version_suffix_, + llvm_use_linker: llvm_use_linker_, + llvm_allow_old_toolchain: llvm_allow_old_toolchain_.unwrap_or(false), + llvm_polly: llvm_polly_.unwrap_or(false), + llvm_clang: llvm_clang_.unwrap_or(false), + llvm_enable_warnings: llvm_enable_warnings_.unwrap_or(false), + llvm_build_config: llvm_build_config_.clone().unwrap_or(Default::default()), + llvm_tools_enabled: rust_llvm_tools.unwrap_or(true), + llvm_bitcode_linker_enabled: rust_llvm_bitcode_linker.unwrap_or(false), + llvm_cflags: llvm_cflags_, + llvm_cxxflags: llvm_cxxflags_, + llvm_ldflags: llvm_ldflags_, + llvm_use_libcxx: llvm_use_libcxx_.unwrap_or(false), + gcc_ci_mode: match gcc_download_ci_gcc { + Some(value) => match value { + true => GccCiMode::DownloadFromCi, + false => GccCiMode::BuildLocally, + }, + None => GccCiMode::default(), + }, + rust_optimize: rust_optimize_.unwrap_or(RustOptimize::Bool(true)), + rust_codegen_units: rust_codegen_units_.map(threads_from_config), + rust_codegen_units_std: rust_codegen_units_std_.map(threads_from_config), + std_debug_assertions: rust_std_debug_assertions + .or(rust_rustc_debug_assertions) + .unwrap_or(rust_debug == Some(true)), + tools_debug_assertions: rust_tools_debug_assertions + .or(rust_rustc_debug_assertions) + .unwrap_or(rust_debug == Some(true)), + rust_overflow_checks_std: rust_overflow_checks_std_ + .or(rust_overflow_checks_) + .unwrap_or(rust_debug == Some(true)), + rust_overflow_checks: rust_overflow_checks_.unwrap_or(rust_debug == Some(true)), + rust_debug_logging: rust_debug_logging_ + .or(rust_rustc_debug_assertions) + .unwrap_or(rust_debug == Some(true)), + rust_debuginfo_level_rustc: with_defaults(rust_debuginfo_level_rustc_), + rust_debuginfo_level_std: with_defaults(rust_debuginfo_level_std_), + rust_debuginfo_level_tools: with_defaults(rust_debuginfo_level_tools_), + rust_debuginfo_level_tests: rust_debuginfo_level_tests_.unwrap_or(DebuginfoLevel::None), + rust_rpath: rust_rpath_.unwrap_or(true), + rust_strip: rust_strip_.unwrap_or(false), + rust_frame_pointers: rust_frame_pointers_.unwrap_or(false), + rust_stack_protector: rust_stack_protector_, + rustc_default_linker: rust_default_linker, + rust_optimize_tests: rust_optimize_tests_.unwrap_or(true), + rust_dist_src: dist_src_tarball_.unwrap_or_else(|| rust_dist_src_.unwrap_or(true)), + rust_codegen_backends: rust_codegen_backends_ + .map(|backends| parse_codegen_backends(backends, "rust")) + .unwrap_or(vec![CodegenBackendKind::Llvm]), + rust_verify_llvm_ir: rust_verify_llvm_ir_.unwrap_or(false), + rust_thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_, + rust_randomize_layout: rust_randomize_layout_.unwrap_or_default(), + rust_remap_debuginfo: rust_remap_debuginfo_.unwrap_or(false), + rust_new_symbol_mangling: rust_new_symbol_mangling_, + rust_profile_use: flags_rust_profile_use.or(rust_profile_use_), + rust_profile_generate: flags_rust_profile_generate.or(rust_profile_generate_), + rust_lto: rust_lto_ + .as_deref() + .map(|value| RustcLto::from_str(value).unwrap()) + .unwrap_or_default(), + rust_validate_mir_opts: rust_validate_mir_opts_, + rust_std_features: rust_std_features_ + .unwrap_or(BTreeSet::from([String::from("panic-unwind")])), + llvm_profile_use: flags_llvm_profile_use, + llvm_profile_generate: flags_llvm_profile_generate, + llvm_libunwind_default: rust_llvm_libunwind + .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")), + enable_bolt_settings: flags_enable_bolt_settings, + reproducible_artifacts: flags_reproducible_artifact, + local_rebuild: build_local_rebuild.unwrap_or(false), + jemalloc: rust_jemalloc.unwrap_or(false), + control_flow_guard: rust_control_flow_guard.unwrap_or(false), + ehcont_guard: rust_ehcont_guard.unwrap_or(false), + dist_sign_folder: dist_sign_folder_.map(PathBuf::from), + dist_upload_addr: dist_upload_addr_, + dist_compression_formats: dist_compression_formats_, + dist_compression_profile: dist_compression_profile_.unwrap_or("fast".into()), + dist_include_mingw_linker: dist_include_mingw_linker_.unwrap_or(true), + backtrace: rust_backtrace.unwrap_or(true), + low_priority: build_low_priority.unwrap_or(false), + description: build_description, + verbose_tests: rust_verbose_tests.unwrap_or(exec_ctx.is_verbose()), + save_toolstates: rust_save_toolstates.map(PathBuf::from), + print_step_timings: build_print_step_timings.unwrap_or(false), + print_step_rusage: build_print_step_rusage.unwrap_or(false), + musl_root: rust_musl_root.map(PathBuf::from), + prefix: install_prefix.map(PathBuf::from), + sysconfdir: install_sysconfdir.map(PathBuf::from), + datadir: install_datadir.map(PathBuf::from), + docdir: install_docdir.map(PathBuf::from), + bindir: install_bindir.map(PathBuf::from).unwrap_or("bin".into()), + libdir: install_libdir.map(PathBuf::from), + mandir: install_mandir.map(PathBuf::from), + codegen_tests: rust_codegen_tests.unwrap_or(true), + nodejs: build_nodejs.map(PathBuf::from), + npm: build_npm.map(PathBuf::from), + gdb: build_gdb.map(PathBuf::from), + lldb: build_lldb.map(PathBuf::from), + python: build_python.map(PathBuf::from), + reuse: build_reuse.map(PathBuf::from), + cargo_native_static: build_cargo_native_static.unwrap_or(false), + configure_args: build_configure_args.unwrap_or_default(), + compiletest_diff_tool: build_compiletest_diff_tool, + compiletest_allow_stage0: build_compiletest_allow_stage0.unwrap_or(false), + compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest.unwrap_or(true), + tidy_extra_checks: build_tidy_extra_checks, + skip_std_check_if_no_download_rustc: flags_skip_std_check_if_no_download_rustc, + cargo_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/cargo")), + rust_analyzer_info: git_info( + &exec_ctx, + omit_git_hash, + &src.join("src/tools/rust-analyzer"), + ), + clippy_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/clippy")), + miri_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/miri")), + rustfmt_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/rustfmt")), + enzyme_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/enzyme")), + in_tree_llvm_info: git_info(&exec_ctx, false, &src.join("src/llvm-project")), + in_tree_gcc_info: git_info(&exec_ctx, false, &src.join("src/gcc")), + dist_vendor: dist_vendor_.unwrap_or_else(|| { + // If we're building from git or tarball sources, enable it by default. + rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball() + }), + targets: flags_target + .map(|TargetSelectionList(targets)| targets) + .or_else(|| { + build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect()) + }) + .unwrap_or_else(|| hosts.clone()), + #[allow(clippy::map_identity)] + skip: flags_skip + .into_iter() + .chain(flags_exclude) + .chain(build_exclude.unwrap_or_default()) + .map(|p| { + // Never return top-level path here as it would break `--skip` + // logic on rustc's internal test framework which is utilized by compiletest. + #[cfg(windows)] + { + PathBuf::from(p.to_string_lossy().replace('/', "\\")) + } + #[cfg(not(windows))] + { + p + } + }) + .collect(), + paths: flags_paths, + config: toml_path, + llvm_thin_lto: llvm_thin_lto_.unwrap_or(false), + rustc_debug_assertions: rust_rustc_debug_assertions.unwrap_or(rust_debug == Some(true)), + lld_mode: rust_lld_mode.unwrap_or_default(), + initial_cargo_clippy: build_cargo_clippy, + vendor: build_vendor.unwrap_or( + rust_info.is_from_tarball() + && src.join("vendor").exists() + && src.join(".cargo/config.toml").exists(), + ), + cmd: flags_cmd, + exec_ctx, + out, + rust_info, + initial_cargo, + initial_rustc, + initial_sysroot, + initial_rustfmt, + submodules, + target_config, + omit_git_hash, + stage, + src, + llvm_from_ci, + llvm_assertions, + lld_enabled, + host_target, + hosts, + channel, + is_running_on_ci, + path_modification_cache, + patch_binaries_for_nix, + stage0_metadata, + download_rustc_commit, + llvm_link_shared, + } } pub fn dry_run(&self) -> bool { @@ -2292,7 +2240,7 @@ pub fn has_changes_from_upstream<'a>( )] pub(crate) fn update_submodule<'a>(dwn_ctx: impl AsRef>, relative_path: &str) { let dwn_ctx = dwn_ctx.as_ref(); - if dwn_ctx.rust_info.is_from_tarball() || !submodules_(dwn_ctx.submodules, dwn_ctx.rust_info) { + if dwn_ctx.rust_info.is_from_tarball() || !submodules_(dwn_ctx.submodules, &dwn_ctx.rust_info) { return; } diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs index 285d20917e7..02f44d41e9e 100644 --- a/src/bootstrap/src/core/config/mod.rs +++ b/src/bootstrap/src/core/config/mod.rs @@ -402,12 +402,6 @@ pub enum GccCiMode { DownloadFromCi, } -pub fn set(field: &mut T, val: Option) { - if let Some(v) = val { - *field = v; - } -} - pub fn threads_from_config(v: u32) -> u32 { match v { 0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32, diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 5ded44cef14..29a244a6c40 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -403,13 +403,13 @@ impl Config { pub(crate) struct DownloadContext<'a> { pub path_modification_cache: Arc, PathFreshness>>>, pub src: &'a Path, - pub rust_info: &'a channel::GitInfo, + pub rust_info: channel::GitInfo, pub submodules: &'a Option, - pub download_rustc_commit: &'a Option, + pub download_rustc_commit: Option, pub host_target: TargetSelection, pub llvm_from_ci: bool, - pub target_config: &'a HashMap, - pub out: &'a Path, + pub target_config: HashMap, + pub out: PathBuf, pub patch_binaries_for_nix: Option, pub exec_ctx: &'a ExecutionContext, pub stage0_metadata: &'a build_helper::stage0_parser::Stage0, @@ -418,6 +418,45 @@ pub(crate) struct DownloadContext<'a> { pub is_running_on_ci: bool, } +impl<'a> DownloadContext<'a> { + #[allow(clippy::too_many_arguments)] + pub fn new( + path_modification_cache: Arc, PathFreshness>>>, + src: &'a Path, + rust_info: channel::GitInfo, + submodules: &'a Option, + download_rustc_commit: Option, + host_target: TargetSelection, + llvm_from_ci: bool, + target_config: HashMap, + out: PathBuf, + patch_binaries_for_nix: Option, + exec_ctx: &'a ExecutionContext, + stage0_metadata: &'a build_helper::stage0_parser::Stage0, + llvm_assertions: bool, + bootstrap_cache_path: &'a Option, + is_running_on_ci: bool, + ) -> Self { + Self { + path_modification_cache, + src, + rust_info, + submodules, + download_rustc_commit, + host_target, + llvm_from_ci, + target_config, + out, + patch_binaries_for_nix, + exec_ctx, + stage0_metadata, + llvm_assertions, + bootstrap_cache_path, + is_running_on_ci, + } + } +} + impl<'a> AsRef> for DownloadContext<'a> { fn as_ref(&self) -> &DownloadContext<'a> { self @@ -430,12 +469,12 @@ impl<'a> From<&'a Config> for DownloadContext<'a> { path_modification_cache: value.path_modification_cache.clone(), src: &value.src, host_target: value.host_target, - rust_info: &value.rust_info, - download_rustc_commit: &value.download_rustc_commit, + rust_info: value.rust_info.clone(), + download_rustc_commit: value.download_rustc_commit.clone(), submodules: &value.submodules, llvm_from_ci: value.llvm_from_ci, - target_config: &value.target_config, - out: &value.out, + target_config: value.target_config.clone(), + out: value.out.clone(), patch_binaries_for_nix: value.patch_binaries_for_nix, exec_ctx: &value.exec_ctx, stage0_metadata: &value.stage0_metadata, @@ -543,13 +582,13 @@ pub(crate) fn maybe_download_rustfmt<'a>( ); if should_fix_bins_and_dylibs(dwn_ctx.patch_binaries_for_nix, dwn_ctx.exec_ctx) { - fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("rustfmt"), dwn_ctx.exec_ctx); - fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("cargo-fmt"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustfmt"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("cargo-fmt"), dwn_ctx.exec_ctx); let lib_dir = bin_root.join("lib"); for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) { let lib = t!(lib); if path_is_dylib(&lib.path()) { - fix_bin_or_dylib(dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx); + fix_bin_or_dylib(&dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx); } } } @@ -615,10 +654,10 @@ fn download_toolchain<'a>( } if should_fix_bins_and_dylibs(dwn_ctx.patch_binaries_for_nix, dwn_ctx.exec_ctx) { - fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("rustc"), dwn_ctx.exec_ctx); - fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("rustdoc"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustc"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustdoc"), dwn_ctx.exec_ctx); fix_bin_or_dylib( - dwn_ctx.out, + &dwn_ctx.out, &bin_root.join("libexec").join("rust-analyzer-proc-macro-srv"), dwn_ctx.exec_ctx, ); @@ -626,7 +665,7 @@ fn download_toolchain<'a>( for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) { let lib = t!(lib); if path_is_dylib(&lib.path()) { - fix_bin_or_dylib(dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx); + fix_bin_or_dylib(&dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx); } } } @@ -963,7 +1002,7 @@ fn download_file<'a>( println!("download {url}"); }); // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/. - let tempfile = tempdir(dwn_ctx.out).join(dest_path.file_name().unwrap()); + let tempfile = tempdir(&dwn_ctx.out).join(dest_path.file_name().unwrap()); // While bootstrap itself only supports http and https downloads, downstream forks might // need to download components from other protocols. The match allows them adding more // protocols without worrying about merge conflicts if we change the HTTP implementation. -- cgit 1.4.1-3-g733a5 From a0aaa1275a83b51089442127571f1eb62e993a23 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Mon, 18 Aug 2025 10:56:58 +0530 Subject: clippy'ed --- src/bootstrap/src/core/config/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 692c05456f6..e6d5171eaf9 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -937,7 +937,7 @@ impl Config { && hosts == [host_target] { let no_llvm_config = - target_config.get(&host_target).map_or(true, |config| config.llvm_config.is_none()); + target_config.get(&host_target).is_none_or(|config| config.llvm_config.is_none()); rust_lld_enabled.unwrap_or(llvm_from_ci || no_llvm_config) } else { rust_lld_enabled.unwrap_or(false) -- cgit 1.4.1-3-g733a5 From 21e9889306e221f3ba85d4ae17b4ab56d6ddb17e Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 17 Aug 2025 00:26:31 +0000 Subject: cargo update compiler & tools dependencies: Locking 28 packages to latest compatible versions Updating anyhow v1.0.98 -> v1.0.99 Updating bitflags v2.9.1 -> v2.9.2 Updating clap v4.5.43 -> v4.5.45 Updating clap_builder v4.5.43 -> v4.5.44 Updating clap_derive v4.5.41 -> v4.5.45 Updating curl v0.4.48 -> v0.4.49 Updating curl-sys v0.4.82+curl-8.14.1 -> v0.4.83+curl-8.15.0 Updating cxx v1.0.166 -> v1.0.168 Updating cxx-build v1.0.166 -> v1.0.168 Updating cxxbridge-cmd v1.0.166 -> v1.0.168 Updating cxxbridge-flags v1.0.166 -> v1.0.168 Updating cxxbridge-macro v1.0.166 -> v1.0.168 Updating glob v0.3.2 -> v0.3.3 Updating object v0.37.2 -> v0.37.3 Updating proc-macro2 v1.0.95 -> v1.0.101 Updating rayon v1.10.0 -> v1.11.0 Updating rayon-core v1.12.1 -> v1.13.0 Updating serde-untagged v0.1.7 -> v0.1.8 Updating socket2 v0.5.10 -> v0.6.0 Updating syn v2.0.104 -> v2.0.106 Updating thiserror v2.0.12 -> v2.0.15 Updating thiserror-impl v2.0.12 -> v2.0.15 Updating uuid v1.17.0 -> v1.18.0 Updating wasm-encoder v0.236.0 -> v0.236.1 Updating wasmparser v0.236.0 -> v0.236.1 Updating wast v236.0.0 -> v236.0.1 Updating wat v1.236.0 -> v1.236.1 note: pass `--verbose` to see 35 unchanged dependencies behind latest library dependencies: Locking 2 packages to latest compatible versions Updating libc v0.2.174 -> v0.2.175 Updating object v0.37.2 -> v0.37.3 note: pass `--verbose` to see 2 unchanged dependencies behind latest rustbook dependencies: Locking 13 packages to latest compatible versions Updating anyhow v1.0.98 -> v1.0.99 Updating bitflags v2.9.1 -> v2.9.2 Updating cc v1.2.32 -> v1.2.33 Updating clap v4.5.43 -> v4.5.45 Updating clap_builder v4.5.43 -> v4.5.44 Updating clap_complete v4.5.56 -> v4.5.57 Updating clap_derive v4.5.41 -> v4.5.45 Updating proc-macro2 v1.0.95 -> v1.0.101 Updating syn v2.0.104 -> v2.0.106 Updating terminal_size v0.4.2 -> v0.4.3 Updating thiserror v2.0.12 -> v2.0.15 Updating thiserror-impl v2.0.12 -> v2.0.15 --- Cargo.lock | 220 +++++++++++++++++++------------------- compiler/rustc_session/Cargo.toml | 4 +- library/Cargo.lock | 8 +- src/tools/rustbook/Cargo.lock | 69 ++++++------ src/tools/rustbook/Cargo.toml | 3 + 5 files changed, 155 insertions(+), 149 deletions(-) (limited to 'src') diff --git a/Cargo.lock b/Cargo.lock index 85df0dda818..e16b30ee278 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,9 +152,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "ar_archive_writer" @@ -204,7 +204,7 @@ dependencies = [ "rustc-hash 2.1.1", "serde", "serde_derive", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -266,9 +266,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29" [[package]] name = "blake3" @@ -421,7 +421,7 @@ dependencies = [ "serde", "serde-untagged", "serde-value", - "thiserror 2.0.12", + "thiserror 2.0.15", "toml 0.8.23", "unicode-xid", "url", @@ -453,7 +453,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror 2.0.12", + "thiserror 2.0.15", ] [[package]] @@ -518,9 +518,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.43" +version = "4.5.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50fd97c9dc2399518aa331917ac6f274280ec5eb34e555dd291899745c48ec6f" +checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" dependencies = [ "clap_builder", "clap_derive", @@ -538,9 +538,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.43" +version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35b5830294e1fa0462034af85cc95225a4cb07092c088c55bda3147cfcd8f65" +checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" dependencies = [ "anstream", "anstyle", @@ -550,14 +550,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.41" +version = "4.5.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" +checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -720,7 +720,7 @@ dependencies = [ "nom", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -907,9 +907,9 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.48" +version = "0.4.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d5c8f48d9c0c23250e52b55e82a6ab4fdba6650c931f5a0a57a43abda812b" +checksum = "79fc3b6dd0b87ba36e565715bf9a2ced221311db47bd18011676f24a6066edbc" dependencies = [ "curl-sys", "libc", @@ -922,9 +922,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.82+curl-8.14.1" +version = "0.4.83+curl-8.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4d63638b5ec65f1a4ae945287b3fd035be4554bbaf211901159c9a2a74fb5be" +checksum = "5830daf304027db10c82632a464879d46a3f7c4ba17a31592657ad16c719b483" dependencies = [ "cc", "libc", @@ -937,9 +937,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.166" +version = "1.0.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5287274dfdf7e7eaa3d97d460eb2a94922539e6af214bda423f292105011ee2" +checksum = "7aa144b12f11741f0dab5b4182896afad46faa0598b6a061f7b9d17a21837ba7" dependencies = [ "cc", "cxxbridge-cmd", @@ -951,9 +951,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.166" +version = "1.0.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65f3ce027a744135db10a1ebffa0863dab685aeef48f40a02c201f5e70c667d3" +checksum = "12d3cbb84fb003242941c231b45ca9417e786e66e94baa39584bd99df3a270b6" dependencies = [ "cc", "codespan-reporting", @@ -961,40 +961,40 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] name = "cxxbridge-cmd" -version = "1.0.166" +version = "1.0.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a07dc23f2eea4774297f4c9a17ae4065fecb63127da556e6c9fadb0216d93595" +checksum = "3fa36b7b249d43f67a3f54bd65788e35e7afe64bbc671396387a48b3e8aaea94" dependencies = [ "clap", "codespan-reporting", "indexmap", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] name = "cxxbridge-flags" -version = "1.0.166" +version = "1.0.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7a4dbad6171f763c4066c83dcd27546b6e93c5c5ae2229f9813bda7233f571d" +checksum = "77707c70f6563edc5429618ca34a07241b75ebab35bd01d46697c75d58f8ddfe" [[package]] name = "cxxbridge-macro" -version = "1.0.166" +version = "1.0.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9be4b527950fc42db06163705e78e73eedc8fd723708e942afe3572a9a2c366" +checksum = "ede6c0fb7e318f0a11799b86ee29dcf17b9be2960bd379a6c38e1a96a6010fff" dependencies = [ "indexmap", "proc-macro2", "quote", "rustversion", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1018,7 +1018,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1029,7 +1029,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1061,7 +1061,7 @@ checksum = "ef941ded77d15ca19b40374869ac6000af1c9f2a4c0f3d4c70926287e6364a8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1082,7 +1082,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1092,7 +1092,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1104,7 +1104,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1194,7 +1194,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -1379,7 +1379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198" dependencies = [ "memchr", - "thiserror 2.0.12", + "thiserror 2.0.15", ] [[package]] @@ -1539,9 +1539,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "globset" @@ -1855,7 +1855,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -2044,7 +2044,7 @@ checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -2102,7 +2102,7 @@ dependencies = [ "pest_derive", "regex", "serde_json", - "thiserror 2.0.12", + "thiserror 2.0.15", ] [[package]] @@ -2337,7 +2337,7 @@ checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -2643,9 +2643,9 @@ dependencies = [ [[package]] name = "object" -version = "0.37.2" +version = "0.37.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e3d0a7419f081f4a808147e845310313a39f322d7ae1f996b7f001d6cbed04" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" dependencies = [ "crc32fast", "flate2", @@ -2653,7 +2653,7 @@ dependencies = [ "indexmap", "memchr", "ruzstd 0.8.1", - "wasmparser 0.236.0", + "wasmparser 0.236.1", ] [[package]] @@ -2834,7 +2834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" dependencies = [ "memchr", - "thiserror 2.0.12", + "thiserror 2.0.15", "ucd-trie", ] @@ -2858,7 +2858,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -3007,9 +3007,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] @@ -3147,9 +3147,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" dependencies = [ "either", "rayon-core", @@ -3157,9 +3157,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -3193,7 +3193,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror 2.0.12", + "thiserror 2.0.15", ] [[package]] @@ -3279,11 +3279,11 @@ dependencies = [ "build_helper", "gimli 0.32.0", "libc", - "object 0.37.2", + "object 0.37.3", "regex", "serde_json", "similar", - "wasmparser 0.236.0", + "wasmparser 0.236.1", ] [[package]] @@ -3570,7 +3570,7 @@ dependencies = [ "itertools", "libc", "measureme", - "object 0.37.2", + "object 0.37.3", "rustc-demangle", "rustc_abi", "rustc_ast", @@ -3608,7 +3608,7 @@ dependencies = [ "cc", "itertools", "libc", - "object 0.37.2", + "object 0.37.3", "pathdiff", "regex", "rustc_abi", @@ -3865,7 +3865,7 @@ dependencies = [ "fluent-syntax", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "unic-langid", ] @@ -4012,7 +4012,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -4158,7 +4158,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "synstructure", ] @@ -4644,7 +4644,7 @@ name = "rustc_target" version = "0.0.0" dependencies = [ "bitflags", - "object 0.37.2", + "object 0.37.3", "rustc_abi", "rustc_data_structures", "rustc_fs_util", @@ -4781,7 +4781,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "synstructure", ] @@ -4872,7 +4872,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -5009,9 +5009,9 @@ dependencies = [ [[package]] name = "serde-untagged" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299d9c19d7d466db4ab10addd5703e4c615dec2a5a16dbbafe191045e87ee66e" +checksum = "34836a629bcbc6f1afdf0907a744870039b1e14c0561cb26094fa683b158eff3" dependencies = [ "erased-serde", "serde", @@ -5036,7 +5036,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -5127,12 +5127,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.5.10" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5263,9 +5263,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.104" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -5280,7 +5280,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -5398,11 +5398,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850" dependencies = [ - "thiserror-impl 2.0.12", + "thiserror-impl 2.0.15", ] [[package]] @@ -5413,18 +5413,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -5621,7 +5621,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -5804,7 +5804,7 @@ checksum = "a1249a628de3ad34b821ecb1001355bca3940bcb2f88558f1a8bd82e977f75b5" dependencies = [ "proc-macro-hack", "quote", - "syn 2.0.104", + "syn 2.0.106", "unic-langid-impl", ] @@ -5936,9 +5936,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" dependencies = [ "getrandom 0.3.3", "js-sys", @@ -6016,7 +6016,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "wasm-bindgen-shared", ] @@ -6038,7 +6038,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6101,12 +6101,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.236.0" +version = "0.236.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3108979166ab0d3c7262d2e16a2190ffe784b2a5beb963edef154b5e8e07680b" +checksum = "724fccfd4f3c24b7e589d333fc0429c68042897a7e8a5f8694f31792471841e7" dependencies = [ "leb128fmt", - "wasmparser 0.236.0", + "wasmparser 0.236.1", ] [[package]] @@ -6146,9 +6146,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.236.0" +version = "0.236.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d1eee846a705f6f3cb9d7b9f79b54583810f1fb57a1e3aea76d1742db2e3d2" +checksum = "a9b1e81f3eb254cf7404a82cee6926a4a3ccc5aad80cc3d43608a070c67aa1d7" dependencies = [ "bitflags", "indexmap", @@ -6157,22 +6157,22 @@ dependencies = [ [[package]] name = "wast" -version = "236.0.0" +version = "236.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d6b6faeab519ba6fbf9b26add41617ca6f5553f99ebc33d876e591d2f4f3c6" +checksum = "d3bec4b4db9c6808d394632fd4b0cd4654c32c540bd3237f55ee6a40fff6e51f" dependencies = [ "bumpalo", "leb128fmt", "memchr", "unicode-width 0.2.1", - "wasm-encoder 0.236.0", + "wasm-encoder 0.236.1", ] [[package]] name = "wat" -version = "1.236.0" +version = "1.236.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc31704322400f461f7f31a5f9190d5488aaeafb63ae69ad2b5888d2704dcb08" +checksum = "64475e2f77d6071ce90624098fc236285ddafa8c3ea1fb386f2c4154b6c2bbdb" dependencies = [ "wast", ] @@ -6306,7 +6306,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -6317,7 +6317,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -6328,7 +6328,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -6339,7 +6339,7 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -6772,7 +6772,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "synstructure", ] @@ -6784,7 +6784,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "synstructure", ] @@ -6805,7 +6805,7 @@ checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -6825,7 +6825,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", "synstructure", ] @@ -6870,7 +6870,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] [[package]] @@ -6881,5 +6881,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn 2.0.106", ] diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index 0516982aeab..60d56b1b808 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -27,8 +27,10 @@ tracing = "0.1" # tidy-alphabetical-end [target.'cfg(unix)'.dependencies] +# FIXME: Remove this pin once this rustix issue is resolved +# https://github.com/bytecodealliance/rustix/issues/1496 # tidy-alphabetical-start -libc = "0.2" +libc = "=0.2.174" # tidy-alphabetical-end [target.'cfg(windows)'.dependencies.windows] diff --git a/library/Cargo.lock b/library/Cargo.lock index 4b06f14c7ee..e3441be045d 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.174" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" dependencies = [ "rustc-std-workspace-core", ] @@ -169,9 +169,9 @@ dependencies = [ [[package]] name = "object" -version = "0.37.2" +version = "0.37.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e3d0a7419f081f4a808147e845310313a39f322d7ae1f996b7f001d6cbed04" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" dependencies = [ "memchr", "rustc-std-workspace-alloc", diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock index e42f266391e..cd7ee6fb4fe 100644 --- a/src/tools/rustbook/Cargo.lock +++ b/src/tools/rustbook/Cargo.lock @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "autocfg" @@ -124,9 +124,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29" [[package]] name = "block-buffer" @@ -156,9 +156,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "cc" -version = "1.2.32" +version = "1.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" +checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f" dependencies = [ "shlex", ] @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.43" +version = "4.5.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50fd97c9dc2399518aa331917ac6f274280ec5eb34e555dd291899745c48ec6f" +checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" dependencies = [ "clap_builder", "clap_derive", @@ -195,9 +195,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.43" +version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35b5830294e1fa0462034af85cc95225a4cb07092c088c55bda3147cfcd8f65" +checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" dependencies = [ "anstream", "anstyle", @@ -208,18 +208,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.56" +version = "4.5.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e4efcbb5da11a92e8a609233aa1e8a7d91e38de0be865f016d14700d45a7fd" +checksum = "4d9501bd3f5f09f7bbee01da9a511073ed30a80cd7a509f1214bb74eadea71ad" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.5.41" +version = "4.5.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" +checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" dependencies = [ "heck", "proc-macro2", @@ -559,7 +559,7 @@ dependencies = [ "pest_derive", "serde", "serde_json", - "thiserror 2.0.12", + "thiserror 2.0.15", ] [[package]] @@ -1035,7 +1035,7 @@ version = "6.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "336b9c63443aceef14bea841b899035ae3abe89b7c486aaf4c5bd8aafedac3f0" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "libc", "once_cell", "onig_sys", @@ -1104,7 +1104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" dependencies = [ "memchr", - "thiserror 2.0.12", + "thiserror 2.0.15", "ucd-trie", ] @@ -1240,9 +1240,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] @@ -1253,7 +1253,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "memchr", "pulldown-cmark-escape 0.10.1", "unicase", @@ -1265,7 +1265,7 @@ version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f86ba2052aebccc42cbbb3ed234b8b13ce76f75c3551a303cb2bcffcff12bb14" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "getopts", "memchr", "pulldown-cmark-escape 0.11.0", @@ -1347,7 +1347,7 @@ version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", ] [[package]] @@ -1385,6 +1385,7 @@ version = "0.1.0" dependencies = [ "clap", "env_logger", + "libc", "mdbook", "mdbook-i18n-helpers", "mdbook-spec", @@ -1397,7 +1398,7 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "errno", "libc", "linux-raw-sys", @@ -1546,9 +1547,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -1612,12 +1613,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c6481c4829e4cc63825e62c49186a34538b7b2750b73b266581ffb612fb5ed" +checksum = "60b8cb979cb11c32ce1603f8137b22262a9d131aaa5c37b5678025f22b8becd0" dependencies = [ "rustix", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -1637,11 +1638,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850" dependencies = [ - "thiserror-impl 2.0.12", + "thiserror-impl 2.0.15", ] [[package]] @@ -1657,9 +1658,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0" dependencies = [ "proc-macro2", "quote", @@ -2116,7 +2117,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", ] [[package]] diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index c7c6e39f157..b34c39c225d 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -10,6 +10,9 @@ edition = "2021" [dependencies] clap = "4.0.32" env_logger = "0.11" +# FIXME: Remove this pin once this rustix issue is resolved +# https://github.com/bytecodealliance/rustix/issues/1496 +libc = "=0.2.174" mdbook-trpl = { path = "../../doc/book/packages/mdbook-trpl" } mdbook-i18n-helpers = "0.3.3" mdbook-spec = { path = "../../doc/reference/mdbook-spec" } -- cgit 1.4.1-3-g733a5 From f960e368a91714d38e3bd3c72c0eb530ee4784c8 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Mon, 18 Aug 2025 23:49:01 +0530 Subject: remove downstream new method --- src/bootstrap/src/core/config/config.rs | 24 ++++++++++---------- src/bootstrap/src/core/download.rs | 39 --------------------------------- 2 files changed, 12 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index e6d5171eaf9..9028c7aec36 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -735,23 +735,23 @@ impl Config { ); } - let mut dwn_ctx = DownloadContext::new( - path_modification_cache.clone(), - &src, - rust_info.clone(), - &submodules, - download_rustc_commit.clone(), + let mut dwn_ctx = DownloadContext { + path_modification_cache: path_modification_cache.clone(), + src: &src, + rust_info: rust_info.clone(), + submodules: &submodules, + download_rustc_commit: download_rustc_commit.clone(), host_target, llvm_from_ci, - target_config.clone(), - out.clone(), + target_config: target_config.clone(), + out: out.clone(), patch_binaries_for_nix, - &exec_ctx, - &stage0_metadata, + exec_ctx: &exec_ctx, + stage0_metadata: &stage0_metadata, llvm_assertions, - &bootstrap_cache_path, + bootstrap_cache_path: &bootstrap_cache_path, is_running_on_ci, - ); + }; let initial_rustc = build_rustc.unwrap_or_else(|| { download_beta_toolchain(&dwn_ctx); diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 29a244a6c40..402d6019dab 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -418,45 +418,6 @@ pub(crate) struct DownloadContext<'a> { pub is_running_on_ci: bool, } -impl<'a> DownloadContext<'a> { - #[allow(clippy::too_many_arguments)] - pub fn new( - path_modification_cache: Arc, PathFreshness>>>, - src: &'a Path, - rust_info: channel::GitInfo, - submodules: &'a Option, - download_rustc_commit: Option, - host_target: TargetSelection, - llvm_from_ci: bool, - target_config: HashMap, - out: PathBuf, - patch_binaries_for_nix: Option, - exec_ctx: &'a ExecutionContext, - stage0_metadata: &'a build_helper::stage0_parser::Stage0, - llvm_assertions: bool, - bootstrap_cache_path: &'a Option, - is_running_on_ci: bool, - ) -> Self { - Self { - path_modification_cache, - src, - rust_info, - submodules, - download_rustc_commit, - host_target, - llvm_from_ci, - target_config, - out, - patch_binaries_for_nix, - exec_ctx, - stage0_metadata, - llvm_assertions, - bootstrap_cache_path, - is_running_on_ci, - } - } -} - impl<'a> AsRef> for DownloadContext<'a> { fn as_ref(&self) -> &DownloadContext<'a> { self -- cgit 1.4.1-3-g733a5 From 46c4d5cf15dbe2955f0ad102ae89ec54a8e0a15e Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 20 Aug 2025 17:42:04 +0530 Subject: remove now not required _ --- src/bootstrap/src/core/config/config.rs | 230 ++++++++++++++++---------------- 1 file changed, 115 insertions(+), 115 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 9028c7aec36..b3fca61709e 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -554,105 +554,105 @@ impl Config { } = toml.install.unwrap_or_default(); let Rust { - optimize: rust_optimize_, + optimize: rust_optimize, debug: rust_debug, - codegen_units: rust_codegen_units_, - codegen_units_std: rust_codegen_units_std_, + codegen_units: rust_codegen_units, + codegen_units_std: rust_codegen_units_std, rustc_debug_assertions: rust_rustc_debug_assertions, std_debug_assertions: rust_std_debug_assertions, tools_debug_assertions: rust_tools_debug_assertions, - overflow_checks: rust_overflow_checks_, - overflow_checks_std: rust_overflow_checks_std_, - debug_logging: rust_debug_logging_, + overflow_checks: rust_overflow_checks, + overflow_checks_std: rust_overflow_checks_std, + debug_logging: rust_debug_logging, debuginfo_level: rust_debuginfo_level, - debuginfo_level_rustc: rust_debuginfo_level_rustc_, - debuginfo_level_std: rust_debuginfo_level_std_, - debuginfo_level_tools: rust_debuginfo_level_tools_, - debuginfo_level_tests: rust_debuginfo_level_tests_, + debuginfo_level_rustc: rust_debuginfo_level_rustc, + debuginfo_level_std: rust_debuginfo_level_std, + debuginfo_level_tools: rust_debuginfo_level_tools, + debuginfo_level_tests: rust_debuginfo_level_tests, backtrace: rust_backtrace, incremental: rust_incremental, - randomize_layout: rust_randomize_layout_, + randomize_layout: rust_randomize_layout, default_linker: rust_default_linker, channel: rust_channel, musl_root: rust_musl_root, - rpath: rust_rpath_, + rpath: rust_rpath, verbose_tests: rust_verbose_tests, - optimize_tests: rust_optimize_tests_, + optimize_tests: rust_optimize_tests, codegen_tests: rust_codegen_tests, omit_git_hash: rust_omit_git_hash, - dist_src: rust_dist_src_, + dist_src: rust_dist_src, save_toolstates: rust_save_toolstates, - codegen_backends: rust_codegen_backends_, + codegen_backends: rust_codegen_backends, lld: rust_lld_enabled, llvm_tools: rust_llvm_tools, llvm_bitcode_linker: rust_llvm_bitcode_linker, deny_warnings: rust_deny_warnings, backtrace_on_ice: rust_backtrace_on_ice, - verify_llvm_ir: rust_verify_llvm_ir_, - thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_, - remap_debuginfo: rust_remap_debuginfo_, + verify_llvm_ir: rust_verify_llvm_ir, + thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit, + remap_debuginfo: rust_remap_debuginfo, jemalloc: rust_jemalloc, test_compare_mode: rust_test_compare_mode, llvm_libunwind: rust_llvm_libunwind, control_flow_guard: rust_control_flow_guard, ehcont_guard: rust_ehcont_guard, - new_symbol_mangling: rust_new_symbol_mangling_, - profile_generate: rust_profile_generate_, - profile_use: rust_profile_use_, + new_symbol_mangling: rust_new_symbol_mangling, + profile_generate: rust_profile_generate, + profile_use: rust_profile_use, download_rustc: rust_download_rustc, - lto: rust_lto_, - validate_mir_opts: rust_validate_mir_opts_, - frame_pointers: rust_frame_pointers_, - stack_protector: rust_stack_protector_, - strip: rust_strip_, + lto: rust_lto, + validate_mir_opts: rust_validate_mir_opts, + frame_pointers: rust_frame_pointers, + stack_protector: rust_stack_protector, + strip: rust_strip, lld_mode: rust_lld_mode, - std_features: rust_std_features_, + std_features: rust_std_features, } = toml.rust.unwrap_or_default(); let Llvm { - optimize: llvm_optimize_, - thin_lto: llvm_thin_lto_, - release_debuginfo: llvm_release_debuginfo_, + optimize: llvm_optimize, + thin_lto: llvm_thin_lto, + release_debuginfo: llvm_release_debuginfo, assertions: llvm_assertions_, - tests: llvm_tests_, - enzyme: llvm_enzyme_, + tests: llvm_tests, + enzyme: llvm_enzyme, plugins: llvm_plugin, static_libstdcpp: llvm_static_libstdcpp, - libzstd: llvm_libzstd_, + libzstd: llvm_libzstd, ninja: llvm_ninja, - targets: llvm_targets_, - experimental_targets: llvm_experimental_targets_, - link_jobs: llvm_link_jobs_, + targets: llvm_targets, + experimental_targets: llvm_experimental_targets, + link_jobs: llvm_link_jobs, link_shared: llvm_link_shared_, - version_suffix: llvm_version_suffix_, - clang_cl: llvm_clang_cl_, - cflags: llvm_cflags_, - cxxflags: llvm_cxxflags_, - ldflags: llvm_ldflags_, - use_libcxx: llvm_use_libcxx_, - use_linker: llvm_use_linker_, - allow_old_toolchain: llvm_allow_old_toolchain_, - offload: llvm_offload_, - polly: llvm_polly_, - clang: llvm_clang_, - enable_warnings: llvm_enable_warnings_, + version_suffix: llvm_version_suffix, + clang_cl: llvm_clang_cl, + cflags: llvm_cflags, + cxxflags: llvm_cxxflags, + ldflags: llvm_ldflags, + use_libcxx: llvm_use_libcxx, + use_linker: llvm_use_linker, + allow_old_toolchain: llvm_allow_old_toolchain, + offload: llvm_offload, + polly: llvm_polly, + clang: llvm_clang, + enable_warnings: llvm_enable_warnings, download_ci_llvm: llvm_download_ci_llvm, - build_config: llvm_build_config_, + build_config: llvm_build_config, } = toml.llvm.unwrap_or_default(); let Dist { - sign_folder: dist_sign_folder_, - upload_addr: dist_upload_addr_, - src_tarball: dist_src_tarball_, - compression_formats: dist_compression_formats_, - compression_profile: dist_compression_profile_, - include_mingw_linker: dist_include_mingw_linker_, - vendor: dist_vendor_, + sign_folder: dist_sign_folder, + upload_addr: dist_upload_addr, + src_tarball: dist_src_tarball, + compression_formats: dist_compression_formats, + compression_profile: dist_compression_profile, + include_mingw_linker: dist_include_mingw_linker, + vendor: dist_vendor, } = toml.dist.unwrap_or_default(); let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default(); - if rust_optimize_.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { + if rust_optimize.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { eprintln!( "WARNING: setting `optimize` to `false` is known to cause errors and \ should be considered unsupported. Refer to `bootstrap.example.toml` \ @@ -973,7 +973,7 @@ impl Config { // config to the ones used to build the LLVM artifacts on CI, and only notify users // if they've chosen a different value. - if llvm_libzstd_.is_some() { + if llvm_libzstd.is_some() { println!( "WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \ like almost all `llvm.*` options, will be ignored and set by the LLVM CI \ @@ -985,7 +985,7 @@ impl Config { } } - if !llvm_from_ci && llvm_thin_lto_.unwrap_or(false) && llvm_link_shared_.is_none() { + if !llvm_from_ci && llvm_thin_lto.unwrap_or(false) && llvm_link_shared_.is_none() { // If we're building with ThinLTO on, by default we want to link // to LLVM shared, to avoid re-doing ThinLTO (which happens in // the link step) with each stage. @@ -1170,31 +1170,31 @@ impl Config { Warnings::Default => rust_deny_warnings.unwrap_or(true), }, backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), - llvm_tests: llvm_tests_.unwrap_or_default(), - llvm_enzyme: llvm_enzyme_.unwrap_or_default(), - llvm_offload: llvm_offload_.unwrap_or(false), + llvm_tests: llvm_tests.unwrap_or_default(), + llvm_enzyme: llvm_enzyme.unwrap_or_default(), + llvm_offload: llvm_offload.unwrap_or(false), llvm_plugins: llvm_plugin.unwrap_or_default(), - llvm_optimize: llvm_optimize_.unwrap_or(true), - llvm_release_debuginfo: llvm_release_debuginfo_.unwrap_or(false), + llvm_optimize: llvm_optimize.unwrap_or(true), + llvm_release_debuginfo: llvm_release_debuginfo.unwrap_or(false), llvm_static_stdcpp: llvm_static_libstdcpp.unwrap_or(false), - llvm_libzstd: llvm_libzstd_.unwrap_or(false), - llvm_clang_cl: llvm_clang_cl_, - llvm_targets: llvm_targets_, - llvm_experimental_targets: llvm_experimental_targets_, - llvm_link_jobs: llvm_link_jobs_, - llvm_version_suffix: llvm_version_suffix_, - llvm_use_linker: llvm_use_linker_, - llvm_allow_old_toolchain: llvm_allow_old_toolchain_.unwrap_or(false), - llvm_polly: llvm_polly_.unwrap_or(false), - llvm_clang: llvm_clang_.unwrap_or(false), - llvm_enable_warnings: llvm_enable_warnings_.unwrap_or(false), - llvm_build_config: llvm_build_config_.clone().unwrap_or(Default::default()), + llvm_libzstd: llvm_libzstd.unwrap_or(false), + llvm_clang_cl, + llvm_targets, + llvm_experimental_targets, + llvm_link_jobs, + llvm_version_suffix, + llvm_use_linker, + llvm_allow_old_toolchain: llvm_allow_old_toolchain.unwrap_or(false), + llvm_polly: llvm_polly.unwrap_or(false), + llvm_clang: llvm_clang.unwrap_or(false), + llvm_enable_warnings: llvm_enable_warnings.unwrap_or(false), + llvm_build_config: llvm_build_config.clone().unwrap_or(Default::default()), llvm_tools_enabled: rust_llvm_tools.unwrap_or(true), llvm_bitcode_linker_enabled: rust_llvm_bitcode_linker.unwrap_or(false), - llvm_cflags: llvm_cflags_, - llvm_cxxflags: llvm_cxxflags_, - llvm_ldflags: llvm_ldflags_, - llvm_use_libcxx: llvm_use_libcxx_.unwrap_or(false), + llvm_cflags, + llvm_cxxflags, + llvm_ldflags, + llvm_use_libcxx: llvm_use_libcxx.unwrap_or(false), gcc_ci_mode: match gcc_download_ci_gcc { Some(value) => match value { true => GccCiMode::DownloadFromCi, @@ -1202,49 +1202,49 @@ impl Config { }, None => GccCiMode::default(), }, - rust_optimize: rust_optimize_.unwrap_or(RustOptimize::Bool(true)), - rust_codegen_units: rust_codegen_units_.map(threads_from_config), - rust_codegen_units_std: rust_codegen_units_std_.map(threads_from_config), + rust_optimize: rust_optimize.unwrap_or(RustOptimize::Bool(true)), + rust_codegen_units: rust_codegen_units.map(threads_from_config), + rust_codegen_units_std: rust_codegen_units_std.map(threads_from_config), std_debug_assertions: rust_std_debug_assertions .or(rust_rustc_debug_assertions) .unwrap_or(rust_debug == Some(true)), tools_debug_assertions: rust_tools_debug_assertions .or(rust_rustc_debug_assertions) .unwrap_or(rust_debug == Some(true)), - rust_overflow_checks_std: rust_overflow_checks_std_ - .or(rust_overflow_checks_) + rust_overflow_checks_std: rust_overflow_checks_std + .or(rust_overflow_checks) .unwrap_or(rust_debug == Some(true)), - rust_overflow_checks: rust_overflow_checks_.unwrap_or(rust_debug == Some(true)), - rust_debug_logging: rust_debug_logging_ + rust_overflow_checks: rust_overflow_checks.unwrap_or(rust_debug == Some(true)), + rust_debug_logging: rust_debug_logging .or(rust_rustc_debug_assertions) .unwrap_or(rust_debug == Some(true)), - rust_debuginfo_level_rustc: with_defaults(rust_debuginfo_level_rustc_), - rust_debuginfo_level_std: with_defaults(rust_debuginfo_level_std_), - rust_debuginfo_level_tools: with_defaults(rust_debuginfo_level_tools_), - rust_debuginfo_level_tests: rust_debuginfo_level_tests_.unwrap_or(DebuginfoLevel::None), - rust_rpath: rust_rpath_.unwrap_or(true), - rust_strip: rust_strip_.unwrap_or(false), - rust_frame_pointers: rust_frame_pointers_.unwrap_or(false), - rust_stack_protector: rust_stack_protector_, + rust_debuginfo_level_rustc: with_defaults(rust_debuginfo_level_rustc), + rust_debuginfo_level_std: with_defaults(rust_debuginfo_level_std), + rust_debuginfo_level_tools: with_defaults(rust_debuginfo_level_tools), + rust_debuginfo_level_tests: rust_debuginfo_level_tests.unwrap_or(DebuginfoLevel::None), + rust_rpath: rust_rpath.unwrap_or(true), + rust_strip: rust_strip.unwrap_or(false), + rust_frame_pointers: rust_frame_pointers.unwrap_or(false), + rust_stack_protector, rustc_default_linker: rust_default_linker, - rust_optimize_tests: rust_optimize_tests_.unwrap_or(true), - rust_dist_src: dist_src_tarball_.unwrap_or_else(|| rust_dist_src_.unwrap_or(true)), - rust_codegen_backends: rust_codegen_backends_ + rust_optimize_tests: rust_optimize_tests.unwrap_or(true), + rust_dist_src: dist_src_tarball.unwrap_or_else(|| rust_dist_src.unwrap_or(true)), + rust_codegen_backends: rust_codegen_backends .map(|backends| parse_codegen_backends(backends, "rust")) .unwrap_or(vec![CodegenBackendKind::Llvm]), - rust_verify_llvm_ir: rust_verify_llvm_ir_.unwrap_or(false), - rust_thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_, - rust_randomize_layout: rust_randomize_layout_.unwrap_or_default(), - rust_remap_debuginfo: rust_remap_debuginfo_.unwrap_or(false), - rust_new_symbol_mangling: rust_new_symbol_mangling_, - rust_profile_use: flags_rust_profile_use.or(rust_profile_use_), - rust_profile_generate: flags_rust_profile_generate.or(rust_profile_generate_), - rust_lto: rust_lto_ + rust_verify_llvm_ir: rust_verify_llvm_ir.unwrap_or(false), + rust_thin_lto_import_instr_limit, + rust_randomize_layout: rust_randomize_layout.unwrap_or_default(), + rust_remap_debuginfo: rust_remap_debuginfo.unwrap_or(false), + rust_new_symbol_mangling, + rust_profile_use: flags_rust_profile_use.or(rust_profile_use), + rust_profile_generate: flags_rust_profile_generate.or(rust_profile_generate), + rust_lto: rust_lto .as_deref() .map(|value| RustcLto::from_str(value).unwrap()) .unwrap_or_default(), - rust_validate_mir_opts: rust_validate_mir_opts_, - rust_std_features: rust_std_features_ + rust_validate_mir_opts, + rust_std_features: rust_std_features .unwrap_or(BTreeSet::from([String::from("panic-unwind")])), llvm_profile_use: flags_llvm_profile_use, llvm_profile_generate: flags_llvm_profile_generate, @@ -1256,11 +1256,11 @@ impl Config { jemalloc: rust_jemalloc.unwrap_or(false), control_flow_guard: rust_control_flow_guard.unwrap_or(false), ehcont_guard: rust_ehcont_guard.unwrap_or(false), - dist_sign_folder: dist_sign_folder_.map(PathBuf::from), - dist_upload_addr: dist_upload_addr_, - dist_compression_formats: dist_compression_formats_, - dist_compression_profile: dist_compression_profile_.unwrap_or("fast".into()), - dist_include_mingw_linker: dist_include_mingw_linker_.unwrap_or(true), + dist_sign_folder: dist_sign_folder.map(PathBuf::from), + dist_upload_addr, + dist_compression_formats, + dist_compression_profile: dist_compression_profile.unwrap_or("fast".into()), + dist_include_mingw_linker: dist_include_mingw_linker.unwrap_or(true), backtrace: rust_backtrace.unwrap_or(true), low_priority: build_low_priority.unwrap_or(false), description: build_description, @@ -1302,7 +1302,7 @@ impl Config { enzyme_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/enzyme")), in_tree_llvm_info: git_info(&exec_ctx, false, &src.join("src/llvm-project")), in_tree_gcc_info: git_info(&exec_ctx, false, &src.join("src/gcc")), - dist_vendor: dist_vendor_.unwrap_or_else(|| { + dist_vendor: dist_vendor.unwrap_or_else(|| { // If we're building from git or tarball sources, enable it by default. rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball() }), @@ -1332,7 +1332,7 @@ impl Config { .collect(), paths: flags_paths, config: toml_path, - llvm_thin_lto: llvm_thin_lto_.unwrap_or(false), + llvm_thin_lto: llvm_thin_lto.unwrap_or(false), rustc_debug_assertions: rust_rustc_debug_assertions.unwrap_or(rust_debug == Some(true)), lld_mode: rust_lld_mode.unwrap_or_default(), initial_cargo_clippy: build_cargo_clippy, -- cgit 1.4.1-3-g733a5 From fce2464c8d4de263910e1360f1b2dc6f17663632 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 20 Aug 2025 17:47:23 +0530 Subject: use local variables coming from toml, directly from toml --- src/bootstrap/src/core/config/config.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index b3fca61709e..0be2e339669 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -665,9 +665,6 @@ impl Config { exec_ctx.set_verbosity(cmp::max(build_verbose.unwrap_or_default() as u8, flags_verbose)); let stage0_metadata = build_helper::stage0_parser::parse_stage0_file(); - let bootstrap_cache_path = build_bootstrap_cache_path; - let patch_binaries_for_nix = build_patch_binaries_for_nix; - let path_modification_cache = Arc::new(Mutex::new(HashMap::new())); let host_target = flags_build @@ -681,7 +678,6 @@ impl Config { }) .unwrap_or_else(|| vec![host_target]); - let submodules = build_submodules; let llvm_assertions = llvm_assertions_.unwrap_or(false); let mut target_config = HashMap::new(); @@ -739,17 +735,17 @@ impl Config { path_modification_cache: path_modification_cache.clone(), src: &src, rust_info: rust_info.clone(), - submodules: &submodules, + submodules: &build_submodules, download_rustc_commit: download_rustc_commit.clone(), host_target, llvm_from_ci, target_config: target_config.clone(), out: out.clone(), - patch_binaries_for_nix, + patch_binaries_for_nix: build_patch_binaries_for_nix, exec_ctx: &exec_ctx, stage0_metadata: &stage0_metadata, llvm_assertions, - bootstrap_cache_path: &bootstrap_cache_path, + bootstrap_cache_path: &build_bootstrap_cache_path, is_running_on_ci, }; @@ -873,7 +869,7 @@ impl Config { } if let Some(patches) = cfg.llvm_has_rust_patches { assert!( - submodules == Some(false) || cfg.llvm_config.is_some(), + build_submodules == Some(false) || cfg.llvm_config.is_some(), "use of `llvm-has-rust-patches` is restricted to cases where either submodules are disabled or llvm-config been provided" ); target.llvm_has_rust_patches = Some(patches); @@ -1131,7 +1127,7 @@ impl Config { docs: build_docs.unwrap_or(true), locked_deps: build_locked_deps.unwrap_or(false), full_bootstrap: build_full_bootstrap.unwrap_or(false), - bootstrap_cache_path, + bootstrap_cache_path: build_bootstrap_cache_path, extended: build_extended.unwrap_or(false), tools: build_tools, tool: build_tool.unwrap_or_default(), @@ -1341,7 +1337,9 @@ impl Config { && src.join("vendor").exists() && src.join(".cargo/config.toml").exists(), ), + patch_binaries_for_nix: build_patch_binaries_for_nix, cmd: flags_cmd, + submodules: build_submodules, exec_ctx, out, rust_info, @@ -1349,7 +1347,6 @@ impl Config { initial_rustc, initial_sysroot, initial_rustfmt, - submodules, target_config, omit_git_hash, stage, @@ -1362,7 +1359,6 @@ impl Config { channel, is_running_on_ci, path_modification_cache, - patch_binaries_for_nix, stage0_metadata, download_rustc_commit, llvm_link_shared, -- cgit 1.4.1-3-g733a5 From b91b31061cdd228a8685f8bfeb0aeac9c9d29265 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 20 Aug 2025 18:07:01 +0530 Subject: add explicit defaults --- src/bootstrap/src/core/config/config.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 0be2e339669..11373e3e411 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1166,10 +1166,10 @@ impl Config { Warnings::Default => rust_deny_warnings.unwrap_or(true), }, backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), - llvm_tests: llvm_tests.unwrap_or_default(), - llvm_enzyme: llvm_enzyme.unwrap_or_default(), + llvm_tests: llvm_tests.unwrap_or(false), + llvm_enzyme: llvm_enzyme.unwrap_or(false), llvm_offload: llvm_offload.unwrap_or(false), - llvm_plugins: llvm_plugin.unwrap_or_default(), + llvm_plugins: llvm_plugin.unwrap_or(false), llvm_optimize: llvm_optimize.unwrap_or(true), llvm_release_debuginfo: llvm_release_debuginfo.unwrap_or(false), llvm_static_stdcpp: llvm_static_libstdcpp.unwrap_or(false), @@ -1230,7 +1230,7 @@ impl Config { .unwrap_or(vec![CodegenBackendKind::Llvm]), rust_verify_llvm_ir: rust_verify_llvm_ir.unwrap_or(false), rust_thin_lto_import_instr_limit, - rust_randomize_layout: rust_randomize_layout.unwrap_or_default(), + rust_randomize_layout: rust_randomize_layout.unwrap_or(false), rust_remap_debuginfo: rust_remap_debuginfo.unwrap_or(false), rust_new_symbol_mangling, rust_profile_use: flags_rust_profile_use.or(rust_profile_use), -- cgit 1.4.1-3-g733a5 From 5ae81c984f35ed0e4334c57287ac1fbf2467dd5f Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 20 Aug 2025 18:59:34 +0530 Subject: remove unwanted references, and make more initialization inline --- src/bootstrap/src/core/config/config.rs | 36 +++++++++++++-------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 11373e3e411..9d8f97196b6 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -623,7 +623,7 @@ impl Config { targets: llvm_targets, experimental_targets: llvm_experimental_targets, link_jobs: llvm_link_jobs, - link_shared: llvm_link_shared_, + link_shared: llvm_link_shared, version_suffix: llvm_version_suffix, clang_cl: llvm_clang_cl, cflags: llvm_cflags, @@ -682,7 +682,6 @@ impl Config { let mut target_config = HashMap::new(); let mut download_rustc_commit = None; - let llvm_link_shared = Cell::default(); let mut llvm_from_ci = false; let mut channel = "dev".to_string(); let mut out = flags_build_dir @@ -764,7 +763,7 @@ impl Config { )); let initial_cargo = build_cargo.unwrap_or_else(|| { - download_beta_toolchain(&mut dwn_ctx); + download_beta_toolchain(&dwn_ctx); initial_sysroot.join("bin").join(exe("cargo", host_target)) }); @@ -848,11 +847,9 @@ impl Config { "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." ); - let channel_ = read_file_by_commit(&dwn_ctx, Path::new("src/ci/channel"), commit) + channel = read_file_by_commit(&dwn_ctx, Path::new("src/ci/channel"), commit) .trim() .to_owned(); - - channel = channel_; } if let Some(t) = toml.target { @@ -917,6 +914,9 @@ impl Config { dwn_ctx.target_config = target_config.clone(); } + llvm_from_ci = parse_download_ci_llvm(&dwn_ctx, llvm_download_ci_llvm, llvm_assertions); + dwn_ctx.llvm_from_ci = llvm_from_ci; + // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will // build our internal lld and use it as the default linker, by setting the `rust.lld` config // to true by default: @@ -939,13 +939,6 @@ impl Config { rust_lld_enabled.unwrap_or(false) }; - if let Some(v) = llvm_link_shared_ { - llvm_link_shared.set(Some(v)); - } - - llvm_from_ci = parse_download_ci_llvm(&dwn_ctx, llvm_download_ci_llvm, llvm_assertions); - dwn_ctx.llvm_from_ci = llvm_from_ci; - if llvm_from_ci { let warn = |option: &str| { println!( @@ -960,7 +953,7 @@ impl Config { warn("static-libstdcpp"); } - if llvm_link_shared_.is_some() { + if llvm_link_shared.is_some() { warn("link-shared"); } @@ -981,13 +974,6 @@ impl Config { } } - if !llvm_from_ci && llvm_thin_lto.unwrap_or(false) && llvm_link_shared_.is_none() { - // If we're building with ThinLTO on, by default we want to link - // to LLVM shared, to avoid re-doing ThinLTO (which happens in - // the link step) with each stage. - llvm_link_shared.set(Some(true)); - } - if llvm_from_ci { let triple = &host_target.triple; let ci_llvm_bin = ci_llvm_root(&dwn_ctx).join("bin"); @@ -1340,6 +1326,13 @@ impl Config { patch_binaries_for_nix: build_patch_binaries_for_nix, cmd: flags_cmd, submodules: build_submodules, + // If we're building with ThinLTO on, by default we want to link + // to LLVM shared, to avoid re-doing ThinLTO (which happens in + // the link step) with each stage. + llvm_link_shared: Cell::new( + llvm_link_shared + .or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)), + ), exec_ctx, out, rust_info, @@ -1361,7 +1354,6 @@ impl Config { path_modification_cache, stage0_metadata, download_rustc_commit, - llvm_link_shared, } } -- cgit 1.4.1-3-g733a5 From 433dc2be446c1532f764f410e868a7d7d3b0b07c Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 20 Aug 2025 23:24:53 +0530 Subject: make download context lean and remove mutable types --- src/bootstrap/src/core/config/config.rs | 98 +++++++++++++++++---------------- src/bootstrap/src/core/download.rs | 70 ++++++++++++----------- 2 files changed, 89 insertions(+), 79 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 9d8f97196b6..5913c871d83 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -679,15 +679,11 @@ impl Config { .unwrap_or_else(|| vec![host_target]); let llvm_assertions = llvm_assertions_.unwrap_or(false); - let mut target_config = HashMap::new(); - let mut download_rustc_commit = None; - let mut llvm_from_ci = false; let mut channel = "dev".to_string(); let mut out = flags_build_dir .or(build_build_dir.map(PathBuf::from)) .unwrap_or_else(|| PathBuf::from("build")); - let mut rust_info = GitInfo::Absent; if cfg!(test) { // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. @@ -730,16 +726,11 @@ impl Config { ); } - let mut dwn_ctx = DownloadContext { + let dwn_ctx = DownloadContext { path_modification_cache: path_modification_cache.clone(), src: &src, - rust_info: rust_info.clone(), submodules: &build_submodules, - download_rustc_commit: download_rustc_commit.clone(), host_target, - llvm_from_ci, - target_config: target_config.clone(), - out: out.clone(), patch_binaries_for_nix: build_patch_binaries_for_nix, exec_ctx: &exec_ctx, stage0_metadata: &stage0_metadata, @@ -749,7 +740,7 @@ impl Config { }; let initial_rustc = build_rustc.unwrap_or_else(|| { - download_beta_toolchain(&dwn_ctx); + download_beta_toolchain(&dwn_ctx, &out); out.join(host_target).join("stage0").join("bin").join(exe("rustc", host_target)) }); @@ -763,7 +754,7 @@ impl Config { )); let initial_cargo = build_cargo.unwrap_or_else(|| { - download_beta_toolchain(&dwn_ctx); + download_beta_toolchain(&dwn_ctx, &out); initial_sysroot.join("bin").join(exe("cargo", host_target)) }); @@ -771,7 +762,6 @@ impl Config { if exec_ctx.dry_run() { out = out.join("tmp-dry-run"); fs::create_dir_all(&out).expect("Failed to create dry-run directory"); - dwn_ctx.out = out.clone(); } let file_content = t!(fs::read_to_string(src.join("src/ci/channel"))); @@ -791,8 +781,7 @@ impl Config { let omit_git_hash = rust_omit_git_hash.unwrap_or(channel == "dev"); - rust_info = git_info(&exec_ctx, omit_git_hash, &src); - dwn_ctx.rust_info = rust_info.clone(); + let rust_info = git_info(&exec_ctx, omit_git_hash, &src); if !is_user_configured_rust_channel && rust_info.is_from_tarball() { channel = ci_channel.into(); @@ -823,9 +812,8 @@ impl Config { ); } - download_rustc_commit = - download_ci_rustc_commit(&dwn_ctx, rust_download_rustc, llvm_assertions); - dwn_ctx.download_rustc_commit = download_rustc_commit.clone(); + let mut download_rustc_commit = + download_ci_rustc_commit(&dwn_ctx, &rust_info, rust_download_rustc, llvm_assertions); if debug_assertions_requested && download_rustc_commit.is_some() { eprintln!( @@ -834,7 +822,6 @@ impl Config { ); // We need to put this later down_ci_rustc_commit. download_rustc_commit = None; - dwn_ctx.download_rustc_commit = None; } // We need to override `rust.channel` if it's manually specified when using the CI rustc. @@ -847,9 +834,10 @@ impl Config { "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." ); - channel = read_file_by_commit(&dwn_ctx, Path::new("src/ci/channel"), commit) - .trim() - .to_owned(); + channel = + read_file_by_commit(&dwn_ctx, &rust_info, Path::new("src/ci/channel"), commit) + .trim() + .to_owned(); } if let Some(t) = toml.target { @@ -911,11 +899,15 @@ impl Config { target_config.insert(TargetSelection::from_user(&triple), target); } - dwn_ctx.target_config = target_config.clone(); } - llvm_from_ci = parse_download_ci_llvm(&dwn_ctx, llvm_download_ci_llvm, llvm_assertions); - dwn_ctx.llvm_from_ci = llvm_from_ci; + let llvm_from_ci = parse_download_ci_llvm( + &dwn_ctx, + &rust_info, + &download_rustc_commit, + llvm_download_ci_llvm, + llvm_assertions, + ); // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will // build our internal lld and use it as the default linker, by setting the `rust.lld` config @@ -976,18 +968,16 @@ impl Config { if llvm_from_ci { let triple = &host_target.triple; - let ci_llvm_bin = ci_llvm_root(&dwn_ctx).join("bin"); + let ci_llvm_bin = ci_llvm_root(&dwn_ctx, llvm_from_ci, &out).join("bin"); let build_target = target_config.entry(host_target).or_insert_with(|| Target::from_triple(triple)); - dwn_ctx.target_config.entry(host_target).or_insert_with(|| Target::from_triple(triple)); - check_ci_llvm!(build_target.llvm_config); check_ci_llvm!(build_target.llvm_filecheck); build_target.llvm_config = Some(ci_llvm_bin.join(exe("llvm-config", host_target))); build_target.llvm_filecheck = Some(ci_llvm_bin.join(exe("FileCheck", host_target))); } - let initial_rustfmt = build_rustfmt.or_else(|| maybe_download_rustfmt(&dwn_ctx)); + let initial_rustfmt = build_rustfmt.or_else(|| maybe_download_rustfmt(&dwn_ctx, &out)); if matches!(rust_lld_mode.unwrap_or_default(), LldMode::SelfContained) && !lld_enabled @@ -998,7 +988,7 @@ impl Config { ); } - if lld_enabled && is_system_llvm(&dwn_ctx, host_target) { + if lld_enabled && is_system_llvm(&dwn_ctx, &target_config, llvm_from_ci, host_target) { panic!("Cannot enable LLD with `rust.lld = true` when using external llvm-config."); } @@ -1392,7 +1382,7 @@ impl Config { /// Returns the content of the given file at a specific commit. pub(crate) fn read_file_by_commit(&self, file: &Path, commit: &str) -> String { let dwn_ctx = DownloadContext::from(self); - read_file_by_commit(dwn_ctx, file, commit) + read_file_by_commit(dwn_ctx, &self.rust_info, file, commit) } /// Bootstrap embeds a version number into the name of shared libraries it uploads in CI. @@ -1464,7 +1454,7 @@ impl Config { /// The absolute path to the downloaded LLVM artifacts. pub(crate) fn ci_llvm_root(&self) -> PathBuf { let dwn_ctx = DownloadContext::from(self); - ci_llvm_root(dwn_ctx) + ci_llvm_root(dwn_ctx, self.llvm_from_ci, &self.out) } /// Directory where the extracted `rustc-dev` component is stored. @@ -1628,7 +1618,7 @@ impl Config { )] pub(crate) fn update_submodule(&self, relative_path: &str) { let dwn_ctx = DownloadContext::from(self); - update_submodule(dwn_ctx, relative_path); + update_submodule(dwn_ctx, &self.rust_info, relative_path); } /// Returns true if any of the `paths` have been modified locally. @@ -1744,7 +1734,7 @@ impl Config { /// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set. pub fn is_system_llvm(&self, target: TargetSelection) -> bool { let dwn_ctx = DownloadContext::from(self); - is_system_llvm(dwn_ctx, target) + is_system_llvm(dwn_ctx, &self.target_config, self.llvm_from_ci, target) } /// Returns `true` if this is our custom, patched, version of LLVM. @@ -2038,6 +2028,7 @@ pub fn check_stage0_version( pub fn download_ci_rustc_commit<'a>( dwn_ctx: impl AsRef>, + rust_info: &channel::GitInfo, download_rustc: Option, llvm_assertions: bool, ) -> Option { @@ -2057,7 +2048,7 @@ pub fn download_ci_rustc_commit<'a>( None | Some(StringOrBool::Bool(false)) => return None, Some(StringOrBool::Bool(true)) => false, Some(StringOrBool::String(s)) if s == "if-unchanged" => { - if !dwn_ctx.rust_info.is_managed_git_subrepository() { + if !rust_info.is_managed_git_subrepository() { println!( "ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources." ); @@ -2071,7 +2062,7 @@ pub fn download_ci_rustc_commit<'a>( } }; - let commit = if dwn_ctx.rust_info.is_managed_git_subrepository() { + let commit = if rust_info.is_managed_git_subrepository() { // Look for a version to compare to based on the current commit. // Only commits merged by bors will have CI artifacts. let freshness = check_path_modifications_(dwn_ctx, RUSTC_IF_UNCHANGED_ALLOWED_PATHS); @@ -2145,6 +2136,8 @@ pub fn git_config(stage0_metadata: &build_helper::stage0_parser::Stage0) -> GitC pub fn parse_download_ci_llvm<'a>( dwn_ctx: impl AsRef>, + rust_info: &channel::GitInfo, + download_rustc_commit: &Option, download_ci_llvm: Option, asserts: bool, ) -> bool { @@ -2160,7 +2153,7 @@ pub fn parse_download_ci_llvm<'a>( let download_ci_llvm = download_ci_llvm.unwrap_or(default); let if_unchanged = || { - if dwn_ctx.rust_info.is_from_tarball() { + if rust_info.is_from_tarball() { // Git is needed for running "if-unchanged" logic. println!("ERROR: 'if-unchanged' is only compatible with Git managed sources."); crate::exit!(1); @@ -2168,7 +2161,7 @@ pub fn parse_download_ci_llvm<'a>( // Fetching the LLVM submodule is unnecessary for self-tests. #[cfg(not(test))] - update_submodule(dwn_ctx, "src/llvm-project"); + update_submodule(dwn_ctx, rust_info, "src/llvm-project"); // Check for untracked changes in `src/llvm-project` and other important places. let has_changes = has_changes_from_upstream(dwn_ctx, LLVM_INVALIDATION_PATHS); @@ -2183,7 +2176,7 @@ pub fn parse_download_ci_llvm<'a>( match download_ci_llvm { StringOrBool::Bool(b) => { - if !b && dwn_ctx.download_rustc_commit.is_some() { + if !b && download_rustc_commit.is_some() { panic!( "`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`." ); @@ -2226,9 +2219,13 @@ pub fn has_changes_from_upstream<'a>( fields(relative_path = ?relative_path), ), )] -pub(crate) fn update_submodule<'a>(dwn_ctx: impl AsRef>, relative_path: &str) { +pub(crate) fn update_submodule<'a>( + dwn_ctx: impl AsRef>, + rust_info: &channel::GitInfo, + relative_path: &str, +) { let dwn_ctx = dwn_ctx.as_ref(); - if dwn_ctx.rust_info.is_from_tarball() || !submodules_(dwn_ctx.submodules, &dwn_ctx.rust_info) { + if rust_info.is_from_tarball() || !submodules_(dwn_ctx.submodules, rust_info) { return; } @@ -2357,12 +2354,14 @@ pub fn submodules_(submodules: &Option, rust_info: &channel::GitInfo) -> b /// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set. pub fn is_system_llvm<'a>( dwn_ctx: impl AsRef>, + target_config: &HashMap, + llvm_from_ci: bool, target: TargetSelection, ) -> bool { let dwn_ctx = dwn_ctx.as_ref(); - match dwn_ctx.target_config.get(&target) { + match target_config.get(&target) { Some(Target { llvm_config: Some(_), .. }) => { - let ci_llvm = dwn_ctx.llvm_from_ci && is_host_target(&dwn_ctx.host_target, &target); + let ci_llvm = llvm_from_ci && is_host_target(&dwn_ctx.host_target, &target); !ci_llvm } // We're building from the in-tree src/llvm-project sources. @@ -2375,21 +2374,26 @@ pub fn is_host_target(host_target: &TargetSelection, target: &TargetSelection) - host_target == target } -pub(crate) fn ci_llvm_root<'a>(dwn_ctx: impl AsRef>) -> PathBuf { +pub(crate) fn ci_llvm_root<'a>( + dwn_ctx: impl AsRef>, + llvm_from_ci: bool, + out: &Path, +) -> PathBuf { let dwn_ctx = dwn_ctx.as_ref(); - assert!(dwn_ctx.llvm_from_ci); - dwn_ctx.out.join(dwn_ctx.host_target).join("ci-llvm") + assert!(llvm_from_ci); + out.join(dwn_ctx.host_target).join("ci-llvm") } /// Returns the content of the given file at a specific commit. pub(crate) fn read_file_by_commit<'a>( dwn_ctx: impl AsRef>, + rust_info: &channel::GitInfo, file: &Path, commit: &str, ) -> String { let dwn_ctx = dwn_ctx.as_ref(); assert!( - dwn_ctx.rust_info.is_managed_git_subrepository(), + rust_info.is_managed_git_subrepository(), "`Config::read_file_by_commit` is not supported in non-git sources." ); diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 402d6019dab..2f3c80559c0 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -9,9 +9,8 @@ use std::sync::{Arc, Mutex, OnceLock}; use build_helper::git::PathFreshness; use xz2::bufread::XzDecoder; -use crate::core::config::{BUILDER_CONFIG_FILENAME, Target, TargetSelection}; +use crate::core::config::{BUILDER_CONFIG_FILENAME, TargetSelection}; use crate::utils::build_stamp::BuildStamp; -use crate::utils::channel; use crate::utils::exec::{ExecutionContext, command}; use crate::utils::helpers::{exe, hex_encode, move_file}; use crate::{Config, t}; @@ -73,7 +72,7 @@ impl Config { fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) { let dwn_ctx: DownloadContext<'_> = self.into(); - download_file(dwn_ctx, url, dest_path, help_on_error); + download_file(dwn_ctx, &self.out, url, dest_path, help_on_error); } fn unpack(&self, tarball: &Path, dst: &Path, pattern: &str) { @@ -238,7 +237,7 @@ impl Config { destination: &str, ) { let dwn_ctx: DownloadContext<'_> = self.into(); - download_component(dwn_ctx, mode, filename, prefix, key, destination); + download_component(dwn_ctx, &self.out, mode, filename, prefix, key, destination); } #[cfg(test)] @@ -403,13 +402,8 @@ impl Config { pub(crate) struct DownloadContext<'a> { pub path_modification_cache: Arc, PathFreshness>>>, pub src: &'a Path, - pub rust_info: channel::GitInfo, pub submodules: &'a Option, - pub download_rustc_commit: Option, pub host_target: TargetSelection, - pub llvm_from_ci: bool, - pub target_config: HashMap, - pub out: PathBuf, pub patch_binaries_for_nix: Option, pub exec_ctx: &'a ExecutionContext, pub stage0_metadata: &'a build_helper::stage0_parser::Stage0, @@ -430,12 +424,7 @@ impl<'a> From<&'a Config> for DownloadContext<'a> { path_modification_cache: value.path_modification_cache.clone(), src: &value.src, host_target: value.host_target, - rust_info: value.rust_info.clone(), - download_rustc_commit: value.download_rustc_commit.clone(), submodules: &value.submodules, - llvm_from_ci: value.llvm_from_ci, - target_config: value.target_config.clone(), - out: value.out.clone(), patch_binaries_for_nix: value.patch_binaries_for_nix, exec_ctx: &value.exec_ctx, stage0_metadata: &value.stage0_metadata, @@ -495,6 +484,7 @@ pub(crate) fn is_download_ci_available(target_triple: &str, llvm_assertions: boo #[cfg(test)] pub(crate) fn maybe_download_rustfmt<'a>( dwn_ctx: impl AsRef>, + out: &Path, ) -> Option { Some(PathBuf::new()) } @@ -504,6 +494,7 @@ pub(crate) fn maybe_download_rustfmt<'a>( #[cfg(not(test))] pub(crate) fn maybe_download_rustfmt<'a>( dwn_ctx: impl AsRef>, + out: &Path, ) -> Option { use build_helper::stage0_parser::VersionMetadata; @@ -517,7 +508,7 @@ pub(crate) fn maybe_download_rustfmt<'a>( let channel = format!("{version}-{date}"); let host = dwn_ctx.host_target; - let bin_root = dwn_ctx.out.join(host).join("rustfmt"); + let bin_root = out.join(host).join("rustfmt"); let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host)); let rustfmt_stamp = BuildStamp::new(&bin_root).with_prefix("rustfmt").add_stamp(channel); if rustfmt_path.exists() && rustfmt_stamp.is_up_to_date() { @@ -526,6 +517,7 @@ pub(crate) fn maybe_download_rustfmt<'a>( download_component( dwn_ctx, + out, DownloadSource::Dist, format!("rustfmt-{version}-{build}.tar.xz", build = host.triple), "rustfmt-preview", @@ -535,6 +527,7 @@ pub(crate) fn maybe_download_rustfmt<'a>( download_component( dwn_ctx, + out, DownloadSource::Dist, format!("rustc-{version}-{build}.tar.xz", build = host.triple), "rustc", @@ -543,13 +536,13 @@ pub(crate) fn maybe_download_rustfmt<'a>( ); if should_fix_bins_and_dylibs(dwn_ctx.patch_binaries_for_nix, dwn_ctx.exec_ctx) { - fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustfmt"), dwn_ctx.exec_ctx); - fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("cargo-fmt"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(out, &bin_root.join("bin").join("rustfmt"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(out, &bin_root.join("bin").join("cargo-fmt"), dwn_ctx.exec_ctx); let lib_dir = bin_root.join("lib"); for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) { let lib = t!(lib); if path_is_dylib(&lib.path()) { - fix_bin_or_dylib(&dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx); + fix_bin_or_dylib(out, &lib.path(), dwn_ctx.exec_ctx); } } } @@ -559,10 +552,10 @@ pub(crate) fn maybe_download_rustfmt<'a>( } #[cfg(test)] -pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef>) {} +pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef>, out: &Path) {} #[cfg(not(test))] -pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef>) { +pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef>, out: &Path) { let dwn_ctx = dwn_ctx.as_ref(); dwn_ctx.exec_ctx.verbose(|| { println!("downloading stage0 beta artifacts"); @@ -574,6 +567,7 @@ pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef(dwn_ctx: impl AsRef( dwn_ctx: impl AsRef>, + out: &Path, version: &str, sysroot: &str, stamp_key: &str, @@ -594,7 +590,7 @@ fn download_toolchain<'a>( ) { let dwn_ctx = dwn_ctx.as_ref(); let host = dwn_ctx.host_target.triple; - let bin_root = dwn_ctx.out.join(host).join(sysroot); + let bin_root = out.join(host).join(sysroot); let rustc_stamp = BuildStamp::new(&bin_root).with_prefix("rustc").add_stamp(stamp_key); if !bin_root.join("bin").join(exe("rustc", dwn_ctx.host_target)).exists() @@ -605,20 +601,28 @@ fn download_toolchain<'a>( } let filename = format!("rust-std-{version}-{host}.tar.xz"); let pattern = format!("rust-std-{host}"); - download_component(dwn_ctx, mode.clone(), filename, &pattern, stamp_key, destination); + download_component(dwn_ctx, out, mode.clone(), filename, &pattern, stamp_key, destination); let filename = format!("rustc-{version}-{host}.tar.xz"); - download_component(dwn_ctx, mode.clone(), filename, "rustc", stamp_key, destination); + download_component(dwn_ctx, out, mode.clone(), filename, "rustc", stamp_key, destination); for component in extra_components { let filename = format!("{component}-{version}-{host}.tar.xz"); - download_component(dwn_ctx, mode.clone(), filename, component, stamp_key, destination); + download_component( + dwn_ctx, + out, + mode.clone(), + filename, + component, + stamp_key, + destination, + ); } if should_fix_bins_and_dylibs(dwn_ctx.patch_binaries_for_nix, dwn_ctx.exec_ctx) { - fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustc"), dwn_ctx.exec_ctx); - fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustdoc"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(out, &bin_root.join("bin").join("rustc"), dwn_ctx.exec_ctx); + fix_bin_or_dylib(out, &bin_root.join("bin").join("rustdoc"), dwn_ctx.exec_ctx); fix_bin_or_dylib( - &dwn_ctx.out, + out, &bin_root.join("libexec").join("rust-analyzer-proc-macro-srv"), dwn_ctx.exec_ctx, ); @@ -626,7 +630,7 @@ fn download_toolchain<'a>( for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) { let lib = t!(lib); if path_is_dylib(&lib.path()) { - fix_bin_or_dylib(&dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx); + fix_bin_or_dylib(out, &lib.path(), dwn_ctx.exec_ctx); } } } @@ -750,6 +754,7 @@ fn should_fix_bins_and_dylibs( fn download_component<'a>( dwn_ctx: impl AsRef>, + out: &Path, mode: DownloadSource, filename: String, prefix: &str, @@ -763,14 +768,14 @@ fn download_component<'a>( } let cache_dst = - dwn_ctx.bootstrap_cache_path.as_ref().cloned().unwrap_or_else(|| dwn_ctx.out.join("cache")); + dwn_ctx.bootstrap_cache_path.as_ref().cloned().unwrap_or_else(|| out.join("cache")); let cache_dir = cache_dst.join(key); if !cache_dir.exists() { t!(fs::create_dir_all(&cache_dir)); } - let bin_root = dwn_ctx.out.join(dwn_ctx.host_target).join(destination); + let bin_root = out.join(dwn_ctx.host_target).join(destination); let tarball = cache_dir.join(&filename); let (base_url, url, should_verify) = match mode { DownloadSource::CI => { @@ -835,7 +840,7 @@ HELP: if trying to compile an old commit of rustc, disable `download-rustc` in b download-rustc = false "; } - download_file(dwn_ctx, &format!("{base_url}/{url}"), &tarball, help_on_error); + download_file(dwn_ctx, out, &format!("{base_url}/{url}"), &tarball, help_on_error); if let Some(sha256) = checksum && !verify(dwn_ctx.exec_ctx, &tarball, sha256) { @@ -953,6 +958,7 @@ fn unpack(exec_ctx: &ExecutionContext, tarball: &Path, dst: &Path, pattern: &str fn download_file<'a>( dwn_ctx: impl AsRef>, + out: &Path, url: &str, dest_path: &Path, help_on_error: &str, @@ -963,7 +969,7 @@ fn download_file<'a>( println!("download {url}"); }); // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/. - let tempfile = tempdir(&dwn_ctx.out).join(dest_path.file_name().unwrap()); + let tempfile = tempdir(out).join(dest_path.file_name().unwrap()); // While bootstrap itself only supports http and https downloads, downstream forks might // need to download components from other protocols. The match allows them adding more // protocols without worrying about merge conflicts if we change the HTTP implementation. -- cgit 1.4.1-3-g733a5 From e261e25c9973a71f9d6cf5ee32640de9e28c6369 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 20 Aug 2025 23:40:59 +0530 Subject: move few complex initialization from config to parse-inner --- src/bootstrap/src/core/config/config.rs | 110 ++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 5913c871d83..efc76a0df64 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -687,7 +687,7 @@ impl Config { if cfg!(test) { // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. - if out == PathBuf::from("build") { + if out == Path::new("build") { out = Path::new( &env::var_os("CARGO_TARGET_DIR").expect("cargo test directly is not supported"), ) @@ -1088,14 +1088,64 @@ impl Config { ) }; + let ccache = match build_ccache { + Some(StringOrBool::String(s)) => Some(s), + Some(StringOrBool::Bool(true)) => Some("ccache".to_string()), + _ => None, + }; + + let explicit_stage_from_config = build_test_stage.is_some() + || build_build_stage.is_some() + || build_doc_stage.is_some() + || build_dist_stage.is_some() + || build_install_stage.is_some() + || build_check_stage.is_some() + || build_bench_stage.is_some(); + + let deny_warnings = match flags_warnings { + Warnings::Deny => true, + Warnings::Warn => false, + Warnings::Default => rust_deny_warnings.unwrap_or(true), + }; + + let gcc_ci_mode = match gcc_download_ci_gcc { + Some(value) => match value { + true => GccCiMode::DownloadFromCi, + false => GccCiMode::BuildLocally, + }, + None => GccCiMode::default(), + }; + + let targets = flags_target + .map(|TargetSelectionList(targets)| targets) + .or_else(|| { + build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect()) + }) + .unwrap_or_else(|| hosts.clone()); + + #[allow(clippy::map_identity)] + let skip = flags_skip + .into_iter() + .chain(flags_exclude) + .chain(build_exclude.unwrap_or_default()) + .map(|p| { + // Never return top-level path here as it would break `--skip` + // logic on rustc's internal test framework which is utilized by compiletest. + #[cfg(windows)] + { + PathBuf::from(p.to_string_lossy().replace('/', "\\")) + } + #[cfg(not(windows))] + { + p + } + }) + .collect(); + Config { change_id: toml.change_id.inner, bypass_bootstrap_lock: flags_bypass_bootstrap_lock, - ccache: match build_ccache { - Some(StringOrBool::String(s)) => Some(s), - Some(StringOrBool::Bool(true)) => Some("ccache".to_string()), - _ => None, - }, + ccache, ninja_in_file: llvm_ninja.unwrap_or(true), compiler_docs: build_compiler_docs.unwrap_or(false), library_docs_private_items: build_library_docs_private_items.unwrap_or(false), @@ -1122,13 +1172,7 @@ impl Config { stderr_is_tty: std::io::stderr().is_terminal(), on_fail: flags_on_fail, explicit_stage_from_cli: flags_stage.is_some(), - explicit_stage_from_config: build_test_stage.is_some() - || build_build_stage.is_some() - || build_doc_stage.is_some() - || build_dist_stage.is_some() - || build_install_stage.is_some() - || build_check_stage.is_some() - || build_bench_stage.is_some(), + explicit_stage_from_config, keep_stage: flags_keep_stage, keep_stage_std: flags_keep_stage_std, @@ -1136,11 +1180,7 @@ impl Config { incremental: flags_incremental || rust_incremental == Some(true), dump_bootstrap_shims: flags_dump_bootstrap_shims, free_args: flags_free_args, - deny_warnings: match flags_warnings { - Warnings::Deny => true, - Warnings::Warn => false, - Warnings::Default => rust_deny_warnings.unwrap_or(true), - }, + deny_warnings, backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), llvm_tests: llvm_tests.unwrap_or(false), llvm_enzyme: llvm_enzyme.unwrap_or(false), @@ -1167,13 +1207,7 @@ impl Config { llvm_cxxflags, llvm_ldflags, llvm_use_libcxx: llvm_use_libcxx.unwrap_or(false), - gcc_ci_mode: match gcc_download_ci_gcc { - Some(value) => match value { - true => GccCiMode::DownloadFromCi, - false => GccCiMode::BuildLocally, - }, - None => GccCiMode::default(), - }, + gcc_ci_mode, rust_optimize: rust_optimize.unwrap_or(RustOptimize::Bool(true)), rust_codegen_units: rust_codegen_units.map(threads_from_config), rust_codegen_units_std: rust_codegen_units_std.map(threads_from_config), @@ -1278,30 +1312,8 @@ impl Config { // If we're building from git or tarball sources, enable it by default. rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball() }), - targets: flags_target - .map(|TargetSelectionList(targets)| targets) - .or_else(|| { - build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect()) - }) - .unwrap_or_else(|| hosts.clone()), - #[allow(clippy::map_identity)] - skip: flags_skip - .into_iter() - .chain(flags_exclude) - .chain(build_exclude.unwrap_or_default()) - .map(|p| { - // Never return top-level path here as it would break `--skip` - // logic on rustc's internal test framework which is utilized by compiletest. - #[cfg(windows)] - { - PathBuf::from(p.to_string_lossy().replace('/', "\\")) - } - #[cfg(not(windows))] - { - p - } - }) - .collect(), + targets, + skip, paths: flags_paths, config: toml_path, llvm_thin_lto: llvm_thin_lto.unwrap_or(false), -- cgit 1.4.1-3-g733a5 From ead9f5825184cff3509da36be20bb9ff87e3135d Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 15:48:29 -0500 Subject: make primitive:pointer work in type-based search. --- src/librustdoc/html/render/search_index.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 41657e290ea..1ccffef15bb 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -1855,7 +1855,7 @@ fn get_index_type_id( } clean::Primitive(p) => Some(RenderTypeId::Primitive(p)), clean::BorrowedRef { .. } => Some(RenderTypeId::Primitive(clean::PrimitiveType::Reference)), - clean::RawPointer(_, ref type_) => get_index_type_id(type_, rgen), + clean::RawPointer{ .. } => Some(RenderTypeId::Primitive(clean::PrimitiveType::RawPointer)), // The type parameters are converted to generics in `simplify_fn_type` clean::Slice(_) => Some(RenderTypeId::Primitive(clean::PrimitiveType::Slice)), clean::Array(_, _) => Some(RenderTypeId::Primitive(clean::PrimitiveType::Array)), @@ -2113,7 +2113,7 @@ fn simplify_fn_type<'a, 'tcx>( generics: Some(ty_generics), }); } - Type::BorrowedRef { lifetime: _, mutability, ref type_ } => { + Type::BorrowedRef { lifetime: _, mutability, ref type_ } | Type::RawPointer(mutability, ref type_)=> { let mut ty_generics = Vec::new(); if mutability.is_mut() { ty_generics.push(RenderType { -- cgit 1.4.1-3-g733a5 From df3d79793b9eab2320bb41b5473274d5aefd4dbc Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 Aug 2025 21:51:20 +1000 Subject: Remove `dirs-sys-0.4.1` dependency. By updating rustfmt to use `dirs-6.0.0`. --- Cargo.lock | 20 ++++---------------- src/tools/rustfmt/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/Cargo.lock b/Cargo.lock index 85df0dda818..fb41728b999 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1129,16 +1129,16 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" dependencies = [ - "dirs-sys 0.5.0", + "dirs-sys", ] [[package]] name = "dirs" -version = "5.0.1" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" dependencies = [ - "dirs-sys 0.4.1", + "dirs-sys", ] [[package]] @@ -1151,18 +1151,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users 0.4.6", - "windows-sys 0.48.0", -] - [[package]] name = "dirs-sys" version = "0.5.0" diff --git a/src/tools/rustfmt/Cargo.toml b/src/tools/rustfmt/Cargo.toml index e497b792342..6392ffbe409 100644 --- a/src/tools/rustfmt/Cargo.toml +++ b/src/tools/rustfmt/Cargo.toml @@ -40,7 +40,7 @@ cargo_metadata = "0.18" clap = { version = "4.4.2", features = ["derive"] } clap-cargo = "0.12.0" diff = "0.1" -dirs = "5.0" +dirs = "6.0" getopts = "0.2" ignore = "0.4" itertools = "0.12" -- cgit 1.4.1-3-g733a5 From c54db96b8bc25f371b26d57e9d03f4ff5ffe293b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 Aug 2025 22:01:01 +1000 Subject: Remove `toml-0.5.11` dependency. We also depend on `toml-0.7.8` and `toml-0.8.23`, but this one is easy to get rid of. --- Cargo.lock | 13 ++----------- src/tools/build-manifest/Cargo.toml | 2 +- src/tools/bump-stage0/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/Cargo.lock b/Cargo.lock index fb41728b999..25ba977fd2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -315,7 +315,7 @@ dependencies = [ "serde_json", "sha2", "tar", - "toml 0.5.11", + "toml 0.7.8", "xz2", ] @@ -336,7 +336,7 @@ dependencies = [ "curl", "indexmap", "serde", - "toml 0.5.11", + "toml 0.7.8", ] [[package]] @@ -5513,15 +5513,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml" version = "0.7.8" diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index 7e0c4bee2b3..efa99f181b3 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -toml = "0.5" +toml = "0.7" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" anyhow = "1.0.32" diff --git a/src/tools/bump-stage0/Cargo.toml b/src/tools/bump-stage0/Cargo.toml index 6ee7a831839..b7f3625da91 100644 --- a/src/tools/bump-stage0/Cargo.toml +++ b/src/tools/bump-stage0/Cargo.toml @@ -11,4 +11,4 @@ build_helper = { path = "../../build_helper" } curl = "0.4.38" indexmap = { version = "2.0.0", features = ["serde"] } serde = { version = "1.0.125", features = ["derive"] } -toml = "0.5.7" +toml = "0.7" -- cgit 1.4.1-3-g733a5 From 4b730a2010884c3478bf53d55321a5987edf6fda Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 16:12:07 -0500 Subject: rustdoc search: accept *mut T syntax for raw pointers --- src/librustdoc/html/static/js/search.js | 75 ++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 42b87d56252..6f90575fe65 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -587,6 +587,44 @@ function getNextElem(query, parserState, elems, isInGenerics) { /** @type {rustdoc.ParserQueryElement[]} */ const generics = []; + /** @type {function(string, string): void} */ + const handleRefOrPtr = (chr, name) => { + if (parserState.typeFilter !== null && parserState.typeFilter !== "primitive") { + throw [ + "Invalid search type: primitive ", + chr, + " and ", + parserState.typeFilter, + " both specified", + ]; + } + parserState.typeFilter = null; + parserState.pos += 1; + let c = parserState.userQuery[parserState.pos]; + while (c === " " && parserState.pos < parserState.length) { + parserState.pos += 1; + c = parserState.userQuery[parserState.pos]; + } + const generics = []; + if (parserState.userQuery.slice(parserState.pos, parserState.pos + 3) === "mut") { + generics.push(makePrimitiveElement("mut", { typeFilter: "keyword" })); + parserState.pos += 3; + c = parserState.userQuery[parserState.pos]; + } else if (chr === "*" && parserState.userQuery.slice(pos, pos + 5) === "const") { + // make *const T parse the same as *T + parserState.pos += 5; + c = parserState.userQuery[parserState.pos]; + } + while (c === " " && parserState.pos < parserState.length) { + parserState.pos += 1; + c = parserState.userQuery[parserState.pos]; + } + if (!isEndCharacter(c) && parserState.pos < parserState.length) { + getFilteredNextElem(query, parserState, generics, isInGenerics); + } + elems.push(makePrimitiveElement(name, { generics })); + } + skipWhitespace(parserState); let start = parserState.pos; let end; @@ -636,36 +674,9 @@ function getNextElem(query, parserState, elems, isInGenerics) { elems.push(makePrimitiveElement(name, { bindingName, generics })); } } else if (parserState.userQuery[parserState.pos] === "&") { - if (parserState.typeFilter !== null && parserState.typeFilter !== "primitive") { - throw [ - "Invalid search type: primitive ", - "&", - " and ", - parserState.typeFilter, - " both specified", - ]; - } - parserState.typeFilter = null; - parserState.pos += 1; - let c = parserState.userQuery[parserState.pos]; - while (c === " " && parserState.pos < parserState.length) { - parserState.pos += 1; - c = parserState.userQuery[parserState.pos]; - } - const generics = []; - if (parserState.userQuery.slice(parserState.pos, parserState.pos + 3) === "mut") { - generics.push(makePrimitiveElement("mut", { typeFilter: "keyword" })); - parserState.pos += 3; - c = parserState.userQuery[parserState.pos]; - } - while (c === " " && parserState.pos < parserState.length) { - parserState.pos += 1; - c = parserState.userQuery[parserState.pos]; - } - if (!isEndCharacter(c) && parserState.pos < parserState.length) { - getFilteredNextElem(query, parserState, generics, isInGenerics); - } - elems.push(makePrimitiveElement("reference", { generics })); + handleRefOrPtr("&", "reference"); + } else if (parserState.userQuery[parserState.pos] === "*") { + handleRefOrPtr("*", "pointer"); } else { const isStringElem = parserState.userQuery[start] === "\""; // We handle the strings on their own mostly to make code easier to follow. @@ -1185,6 +1196,7 @@ class DocSearch { this.typeNameIdOfUnit = -1; this.typeNameIdOfTupleOrUnit = -1; this.typeNameIdOfReference = -1; + this.typeNameIdOfPointer = -1; this.typeNameIdOfHof = -1; this.utf8decoder = new TextDecoder(); @@ -1224,6 +1236,7 @@ class DocSearch { tupleOrUnit, // reference matches `&` reference, + pointer, // never matches `!` never, ] = await Promise.all([ @@ -1239,6 +1252,7 @@ class DocSearch { nn.search("unit"), nn.search("()"), nn.search("reference"), + nn.search("pointer"), nn.search("never"), ]); /** @@ -1270,6 +1284,7 @@ class DocSearch { this.typeNameIdOfUnit = await first(unit, TY_PRIMITIVE, ""); this.typeNameIdOfTupleOrUnit = await first(tupleOrUnit, TY_PRIMITIVE, ""); this.typeNameIdOfReference = await first(reference, TY_PRIMITIVE, ""); + this.typeNameIdOfPointer = await first(pointer, TY_PRIMITIVE, ""); this.typeNameIdOfHof = await first(hof, TY_PRIMITIVE, ""); this.typeNameIdOfNever = await first(never, TY_PRIMITIVE, ""); } -- cgit 1.4.1-3-g733a5 From ae9845fbc9397956cfeb56f532e3b0eee841f315 Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 17:14:08 -0500 Subject: add special formatting for displaying raw pointers in signatures --- src/librustdoc/html/static/js/search.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 6f90575fe65..5e65791bb66 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -606,7 +606,8 @@ function getNextElem(query, parserState, elems, isInGenerics) { c = parserState.userQuery[parserState.pos]; } const generics = []; - if (parserState.userQuery.slice(parserState.pos, parserState.pos + 3) === "mut") { + const pos = parserState.pos; + if (parserState.userQuery.slice(pos, pos + 3) === "mut") { generics.push(makePrimitiveElement("mut", { typeFilter: "keyword" })); parserState.pos += 3; c = parserState.userQuery[parserState.pos]; @@ -623,7 +624,7 @@ function getNextElem(query, parserState, elems, isInGenerics) { getFilteredNextElem(query, parserState, generics, isInGenerics); } elems.push(makePrimitiveElement(name, { generics })); - } + }; skipWhitespace(parserState); let start = parserState.pos; @@ -2324,6 +2325,25 @@ class DocSearch { }, result), ); return true; + } else if (fnType.id === this.typeNameIdOfPointer) { + pushText({ name: "*", highlighted: fnType.highlighted }, result); + if (fnType.generics.length < 2) { + pushText({ name: "const ", highlighted: fnType.highlighted }, result); + } + let prevHighlighted = false; + await onEachBtwnAsync( + fnType.generics, + async value => { + prevHighlighted = !!value.highlighted; + await writeFn(value, result); + }, + // @ts-expect-error + value => pushText({ + name: " ", + highlighted: prevHighlighted && value.highlighted, + }, result), + ); + return true; } else if ( fnType.id === this.typeNameIdOfFn || fnType.id === this.typeNameIdOfFnMut || -- cgit 1.4.1-3-g733a5 From eeaad503df184e75b870cfb4492388711d7a6947 Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 17:18:20 -0500 Subject: unbox raw pointers in type-based search --- src/librustdoc/html/render/search_index.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 1ccffef15bb..dddc087d124 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -1494,7 +1494,9 @@ pub(crate) fn build_index( let search_unbox = match id { RenderTypeId::Mut => false, RenderTypeId::DefId(defid) => utils::has_doc_flag(tcx, defid, sym::search_unbox), - RenderTypeId::Primitive(PrimitiveType::Reference | PrimitiveType::Tuple) => true, + RenderTypeId::Primitive( + PrimitiveType::Reference | PrimitiveType::RawPointer | PrimitiveType::Tuple, + ) => true, RenderTypeId::Primitive(..) => false, RenderTypeId::AssociatedType(..) => false, // this bool is only used by `insert_into_map`, so it doesn't matter what we set here @@ -1855,7 +1857,7 @@ fn get_index_type_id( } clean::Primitive(p) => Some(RenderTypeId::Primitive(p)), clean::BorrowedRef { .. } => Some(RenderTypeId::Primitive(clean::PrimitiveType::Reference)), - clean::RawPointer{ .. } => Some(RenderTypeId::Primitive(clean::PrimitiveType::RawPointer)), + clean::RawPointer { .. } => Some(RenderTypeId::Primitive(clean::PrimitiveType::RawPointer)), // The type parameters are converted to generics in `simplify_fn_type` clean::Slice(_) => Some(RenderTypeId::Primitive(clean::PrimitiveType::Slice)), clean::Array(_, _) => Some(RenderTypeId::Primitive(clean::PrimitiveType::Array)), @@ -2113,7 +2115,8 @@ fn simplify_fn_type<'a, 'tcx>( generics: Some(ty_generics), }); } - Type::BorrowedRef { lifetime: _, mutability, ref type_ } | Type::RawPointer(mutability, ref type_)=> { + Type::BorrowedRef { lifetime: _, mutability, ref type_ } + | Type::RawPointer(mutability, ref type_) => { let mut ty_generics = Vec::new(); if mutability.is_mut() { ty_generics.push(RenderType { -- cgit 1.4.1-3-g733a5 From 291da71b2ae2e5d313739a7d6a8ffa634f408db5 Mon Sep 17 00:00:00 2001 From: Luca Versari Date: Mon, 18 Aug 2025 15:09:45 +0200 Subject: Add an experimental unsafe(force_target_feature) attribute. This uses the feature gate for https://github.com/rust-lang/rust/issues/143352, but is described in https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to the experiment. --- compiler/rustc_ast_lowering/src/item.rs | 2 +- .../src/attributes/codegen_attrs.rs | 118 ++++++++++++++------- compiler/rustc_attr_parsing/src/context.rs | 5 +- compiler/rustc_codegen_ssa/src/codegen_attrs.rs | 7 +- compiler/rustc_codegen_ssa/src/target_features.rs | 12 ++- compiler/rustc_feature/src/builtin_attrs.rs | 4 + compiler/rustc_feature/src/unstable.rs | 2 + compiler/rustc_hir/src/attrs/data_structures.rs | 5 +- compiler/rustc_hir/src/attrs/encode_cross_crate.rs | 2 +- .../rustc_middle/src/middle/codegen_fn_attrs.rs | 16 ++- compiler/rustc_mir_build/src/check_unsafety.rs | 4 +- compiler/rustc_passes/src/check_attr.rs | 2 +- compiler/rustc_span/src/symbol.rs | 2 + .../src/error_reporting/infer/note_and_explain.rs | 2 +- src/librustdoc/clean/types.rs | 3 +- src/librustdoc/json/conversions.rs | 2 +- src/tools/miri/src/machine.rs | 3 +- tests/assembly-llvm/force-target-feature.rs | 33 ++++++ ...e-gate-effective-target-features.default.stderr | 37 +++++++ ...e-gate-effective-target-features.feature.stderr | 35 ++++++ .../feature-gate-effective-target-features.rs | 27 +++++ 21 files changed, 262 insertions(+), 61 deletions(-) create mode 100644 tests/assembly-llvm/force-target-feature.rs create mode 100644 tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr create mode 100644 tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr create mode 100644 tests/ui/feature-gates/feature-gate-effective-target-features.rs (limited to 'src') diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index cd0f9f2403e..bb559bd8921 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1596,7 +1596,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let safety = self.lower_safety(h.safety, default_safety); // Treat safe `#[target_feature]` functions as unsafe, but also remember that we did so. - let safety = if find_attr!(attrs, AttributeKind::TargetFeature { .. }) + let safety = if find_attr!(attrs, AttributeKind::TargetFeature { was_forced: false, .. }) && safety.is_safe() && !self.tcx.sess.target.is_like_wasm { diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 6ea073896c2..706d51e182d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -385,57 +385,68 @@ impl AttributeParser for UsedParser { } } +fn parse_tf_attribute<'c, S: Stage>( + cx: &'c mut AcceptContext<'_, '_, S>, + args: &'c ArgParser<'_>, +) -> impl IntoIterator + 'c { + let mut features = Vec::new(); + let ArgParser::List(list) = args else { + cx.expected_list(cx.attr_span); + return features; + }; + if list.is_empty() { + cx.warn_empty_attribute(cx.attr_span); + return features; + } + for item in list.mixed() { + let Some(name_value) = item.meta_item() else { + cx.expected_name_value(item.span(), Some(sym::enable)); + return features; + }; + + // Validate name + let Some(name) = name_value.path().word_sym() else { + cx.expected_name_value(name_value.path().span(), Some(sym::enable)); + return features; + }; + if name != sym::enable { + cx.expected_name_value(name_value.path().span(), Some(sym::enable)); + return features; + } + + // Use value + let Some(name_value) = name_value.args().name_value() else { + cx.expected_name_value(item.span(), Some(sym::enable)); + return features; + }; + let Some(value_str) = name_value.value_as_str() else { + cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit())); + return features; + }; + for feature in value_str.as_str().split(",") { + features.push((Symbol::intern(feature), item.span())); + } + } + features +} + pub(crate) struct TargetFeatureParser; impl CombineAttributeParser for TargetFeatureParser { type Item = (Symbol, Span); const PATH: &[Symbol] = &[sym::target_feature]; - const CONVERT: ConvertFn = |items, span| AttributeKind::TargetFeature(items, span); + const CONVERT: ConvertFn = |items, span| AttributeKind::TargetFeature { + features: items, + attr_span: span, + was_forced: false, + }; const TEMPLATE: AttributeTemplate = template!(List: &["enable = \"feat1, feat2\""]); fn extend<'c>( cx: &'c mut AcceptContext<'_, '_, S>, args: &'c ArgParser<'_>, ) -> impl IntoIterator + 'c { - let mut features = Vec::new(); - let ArgParser::List(list) = args else { - cx.expected_list(cx.attr_span); - return features; - }; - if list.is_empty() { - cx.warn_empty_attribute(cx.attr_span); - return features; - } - for item in list.mixed() { - let Some(name_value) = item.meta_item() else { - cx.expected_name_value(item.span(), Some(sym::enable)); - return features; - }; - - // Validate name - let Some(name) = name_value.path().word_sym() else { - cx.expected_name_value(name_value.path().span(), Some(sym::enable)); - return features; - }; - if name != sym::enable { - cx.expected_name_value(name_value.path().span(), Some(sym::enable)); - return features; - } - - // Use value - let Some(name_value) = name_value.args().name_value() else { - cx.expected_name_value(item.span(), Some(sym::enable)); - return features; - }; - let Some(value_str) = name_value.value_as_str() else { - cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit())); - return features; - }; - for feature in value_str.as_str().split(",") { - features.push((Symbol::intern(feature), item.span())); - } - } - features + parse_tf_attribute(cx, args) } const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ @@ -449,3 +460,30 @@ impl CombineAttributeParser for TargetFeatureParser { Warn(Target::MacroDef), ]); } + +pub(crate) struct ForceTargetFeatureParser; + +impl CombineAttributeParser for ForceTargetFeatureParser { + type Item = (Symbol, Span); + const PATH: &[Symbol] = &[sym::force_target_feature]; + const CONVERT: ConvertFn = |items, span| AttributeKind::TargetFeature { + features: items, + attr_span: span, + was_forced: true, + }; + const TEMPLATE: AttributeTemplate = template!(List: &["enable = \"feat1, feat2\""]); + + fn extend<'c>( + cx: &'c mut AcceptContext<'_, '_, S>, + args: &'c ArgParser<'_>, + ) -> impl IntoIterator + 'c { + parse_tf_attribute(cx, args) + } + + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); +} diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index c0d3bc99ba9..0791d6eb778 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -21,8 +21,8 @@ use crate::attributes::allow_unstable::{ }; use crate::attributes::body::CoroutineParser; use crate::attributes::codegen_attrs::{ - ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser, - TargetFeatureParser, TrackCallerParser, UsedParser, + ColdParser, CoverageParser, ExportNameParser, ForceTargetFeatureParser, NakedParser, + NoMangleParser, OptimizeParser, TargetFeatureParser, TrackCallerParser, UsedParser, }; use crate::attributes::confusables::ConfusablesParser; use crate::attributes::deprecation::DeprecationParser; @@ -161,6 +161,7 @@ attribute_parsers!( // tidy-alphabetical-start Combine, Combine, + Combine, Combine, Combine, Combine, diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index c8690251bd0..23e2abd6de3 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -193,7 +193,7 @@ fn process_builtin_attrs( } } AttributeKind::Optimize(optimize, _) => codegen_fn_attrs.optimize = *optimize, - AttributeKind::TargetFeature(features, attr_span) => { + AttributeKind::TargetFeature { features, attr_span, was_forced } => { let Some(sig) = tcx.hir_node_by_def_id(did).fn_sig() else { tcx.dcx().span_delayed_bug(*attr_span, "target_feature applied to non-fn"); continue; @@ -201,7 +201,7 @@ fn process_builtin_attrs( let safe_target_features = matches!(sig.header.safety, hir::HeaderSafety::SafeTargetFeatures); codegen_fn_attrs.safe_target_features = safe_target_features; - if safe_target_features { + if safe_target_features && !was_forced { if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc { // The `#[target_feature]` attribute is allowed on // WebAssembly targets on all functions. Prior to stabilizing @@ -232,6 +232,7 @@ fn process_builtin_attrs( tcx, did, features, + *was_forced, rust_target_features, &mut codegen_fn_attrs.target_features, ); @@ -462,7 +463,7 @@ fn check_result( .collect(), ) { let span = - find_attr!(tcx.get_all_attrs(did), AttributeKind::TargetFeature(_, span) => *span) + find_attr!(tcx.get_all_attrs(did), AttributeKind::TargetFeature{attr_span: span, ..} => *span) .unwrap_or_else(|| tcx.def_span(did)); tcx.dcx() diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index b5aa50f4851..54584999d61 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -3,7 +3,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_hir::attrs::InstructionSetAttr; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; -use rustc_middle::middle::codegen_fn_attrs::TargetFeature; +use rustc_middle::middle::codegen_fn_attrs::{TargetFeature, TargetFeatureKind}; use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::Session; @@ -22,6 +22,7 @@ pub(crate) fn from_target_feature_attr( tcx: TyCtxt<'_>, did: LocalDefId, features: &[(Symbol, Span)], + was_forced: bool, rust_target_features: &UnordMap, target_features: &mut Vec, ) { @@ -88,7 +89,14 @@ pub(crate) fn from_target_feature_attr( } } } - target_features.push(TargetFeature { name, implied: name != feature }) + let kind = if name != feature { + TargetFeatureKind::Implied + } else if was_forced { + TargetFeatureKind::Forced + } else { + TargetFeatureKind::Enabled + }; + target_features.push(TargetFeature { name, kind }) } } } diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 8f632bcebc7..e81003b1897 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -744,6 +744,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ template!(List: &["set"], "https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute"), ErrorPreceding, EncodeCrossCrate::No ), + gated!( + unsafe force_target_feature, Normal, template!(List: &[r#"enable = "name""#]), + DuplicatesOk, EncodeCrossCrate::No, effective_target_features, experimental!(force_target_feature) + ), gated!( sanitize, Normal, template!(List: &[r#"address = "on|off""#, r#"kernel_address = "on|off""#, r#"cfi = "on|off""#, r#"hwaddress = "on|off""#, r#"kcfi = "on|off""#, r#"memory = "on|off""#, r#"memtag = "on|off""#, r#"shadow_call_stack = "on|off""#, r#"thread = "on|off""#]), ErrorPreceding, EncodeCrossCrate::No, sanitize, experimental!(sanitize), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 746871982ce..705d5db4595 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -480,6 +480,8 @@ declare_features! ( (unstable, doc_cfg_hide, "1.57.0", Some(43781)), /// Allows `#[doc(masked)]`. (unstable, doc_masked, "1.21.0", Some(44027)), + /// Allows features to allow target_feature to better interact with traits. + (incomplete, effective_target_features, "CURRENT_RUSTC_VERSION", Some(143352)), /// Allows the .use postfix syntax `x.use` and use closures `use |x| { ... }` (incomplete, ergonomic_clones, "1.87.0", Some(132290)), /// Allows exhaustive pattern matching on types that contain uninhabited types. diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index a17350f0392..2209b18df3f 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -524,8 +524,9 @@ pub enum AttributeKind { /// Represents `#[rustc_std_internal_symbol]`. StdInternalSymbol(Span), - /// Represents `#[target_feature(enable = "...")]` - TargetFeature(ThinVec<(Symbol, Span)>, Span), + /// Represents `#[target_feature(enable = "...")]` and + /// `#[unsafe(force_target_feature(enable = "...")]`. + TargetFeature { features: ThinVec<(Symbol, Span)>, attr_span: Span, was_forced: bool }, /// Represents `#[track_caller]` TrackCaller(Span), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index defabdccc02..485ded3981f 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -78,7 +78,7 @@ impl AttributeKind { SpecializationTrait(..) => No, Stability { .. } => Yes, StdInternalSymbol(..) => No, - TargetFeature(..) => No, + TargetFeature { .. } => No, TrackCaller(..) => Yes, TypeConst(..) => Yes, UnsafeSpecializationMarker(..) => No, diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs index 347319b07c9..78cafe8566b 100644 --- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs +++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs @@ -72,13 +72,23 @@ pub struct CodegenFnAttrs { pub patchable_function_entry: Option, } +#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable, PartialEq, Eq)] +pub enum TargetFeatureKind { + /// The feature is implied by another feature, rather than explicitly added by the + /// `#[target_feature]` attribute + Implied, + /// The feature is added by the regular `target_feature` attribute. + Enabled, + /// The feature is added by the unsafe `force_target_feature` attribute. + Forced, +} + #[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)] pub struct TargetFeature { /// The name of the target feature (e.g. "avx") pub name: Symbol, - /// The feature is implied by another feature, rather than explicitly added by the - /// `#[target_feature]` attribute - pub implied: bool, + /// The way this feature was enabled. + pub kind: TargetFeatureKind, } #[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)] diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index cdab785e842..b5e165c7517 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -8,7 +8,7 @@ use rustc_errors::DiagArgValue; use rustc_hir::attrs::AttributeKind; use rustc_hir::def::DefKind; use rustc_hir::{self as hir, BindingMode, ByRef, HirId, Mutability, find_attr}; -use rustc_middle::middle::codegen_fn_attrs::TargetFeature; +use rustc_middle::middle::codegen_fn_attrs::{TargetFeature, TargetFeatureKind}; use rustc_middle::mir::BorrowKind; use rustc_middle::span_bug; use rustc_middle::thir::visit::Visitor; @@ -522,7 +522,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { .iter() .copied() .filter(|feature| { - !feature.implied + feature.kind == TargetFeatureKind::Enabled && !self .body_target_features .iter() diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 70eae82392c..077afd6dd23 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -167,7 +167,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { Attribute::Parsed(AttributeKind::Deprecation { .. }) => { self.check_deprecated(hir_id, attr, span, target) } - Attribute::Parsed(AttributeKind::TargetFeature(_, attr_span)) => { + Attribute::Parsed(AttributeKind::TargetFeature{ attr_span, ..}) => { self.check_target_feature(hir_id, *attr_span, target, attrs) } Attribute::Parsed(AttributeKind::RustcObjectLifetimeDefault) => { diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index dcb1becc957..a18cc21a972 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -901,6 +901,7 @@ symbols! { dynamic_no_pic: "dynamic-no-pic", e, edition_panic, + effective_target_features, effects, eh_catch_typeinfo, eh_personality, @@ -1061,6 +1062,7 @@ symbols! { fn_ptr_addr, fn_ptr_trait, forbid, + force_target_feature, forget, format, format_args, diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs index f31a85ec07a..40285e5d0e9 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs @@ -537,7 +537,7 @@ impl Trait for X { } } TypeError::TargetFeatureCast(def_id) => { - let target_spans = find_attr!(tcx.get_all_attrs(def_id), AttributeKind::TargetFeature(.., span) => *span); + let target_spans = find_attr!(tcx.get_all_attrs(def_id), AttributeKind::TargetFeature{attr_span: span, was_forced: false, ..} => *span); diag.note( "functions with `#[target_feature]` can only be coerced to `unsafe` function pointers" ); diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 46aaa0068de..92bd4a498ca 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1087,7 +1087,8 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator // treat #[target_feature(enable = "feat")] attributes as if they were // #[doc(cfg(target_feature = "feat"))] attributes as well - if let Some(features) = find_attr!(attrs, AttributeKind::TargetFeature(features, _) => features) + if let Some(features) = + find_attr!(attrs, AttributeKind::TargetFeature { features, .. } => features) { for (feature, _) in features { cfg &= Cfg::Cfg(sym::target_feature, Some(*feature)); diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index f966d926562..5fab8ad2a4b 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -930,7 +930,7 @@ fn maybe_from_hir_attr( ), AK::ExportName { name, span: _ } => Attribute::ExportName(name.to_string()), AK::LinkSection { name, span: _ } => Attribute::LinkSection(name.to_string()), - AK::TargetFeature(features, _span) => Attribute::TargetFeature { + AK::TargetFeature { features, .. } => Attribute::TargetFeature { enable: features.iter().map(|(feat, _span)| feat.to_string()).collect(), }, diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 52c4bd142c6..0b2ce900414 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -16,6 +16,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; #[allow(unused)] use rustc_data_structures::static_assert_size; use rustc_hir::attrs::InlineAttr; +use rustc_middle::middle::codegen_fn_attrs::TargetFeatureKind; use rustc_middle::mir; use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::layout::{ @@ -1076,7 +1077,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { .target_features .iter() .filter(|&feature| { - !feature.implied && !ecx.tcx.sess.target_features.contains(&feature.name) + feature.kind != TargetFeatureKind::Implied && !ecx.tcx.sess.target_features.contains(&feature.name) }) .fold(String::new(), |mut s, feature| { if !s.is_empty() { diff --git a/tests/assembly-llvm/force-target-feature.rs b/tests/assembly-llvm/force-target-feature.rs new file mode 100644 index 00000000000..c11060d8d6d --- /dev/null +++ b/tests/assembly-llvm/force-target-feature.rs @@ -0,0 +1,33 @@ +//@ only-x86_64 +//@ assembly-output: emit-asm +//@ compile-flags: -C opt-level=3 -C target-feature=-avx2 +//@ ignore-sgx Tests incompatible with LVI mitigations + +#![feature(effective_target_features)] + +use std::arch::x86_64::{__m256i, _mm256_add_epi32, _mm256_setzero_si256}; +use std::ops::Add; + +#[derive(Clone, Copy)] +struct AvxU32(__m256i); + +impl Add for AvxU32 { + type Output = Self; + + #[no_mangle] + #[inline(never)] + #[unsafe(force_target_feature(enable = "avx2"))] + fn add(self, oth: AvxU32) -> AvxU32 { + // CHECK-LABEL: add: + // CHECK-NOT: callq + // CHECK: vpaddd + // CHECK: retq + Self(_mm256_add_epi32(self.0, oth.0)) + } +} + +fn main() { + assert!(is_x86_feature_detected!("avx2")); + let v = AvxU32(unsafe { _mm256_setzero_si256() }); + v + v; +} diff --git a/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr b/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr new file mode 100644 index 00000000000..34a56fe342e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr @@ -0,0 +1,37 @@ +error[E0658]: the `#[force_target_feature]` attribute is an experimental feature + --> $DIR/feature-gate-effective-target-features.rs:13:5 + | +LL | #[unsafe(force_target_feature(enable = "avx2"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #143352 for more information + = help: add `#![feature(effective_target_features)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: `#[target_feature(..)]` cannot be applied to safe trait method + --> $DIR/feature-gate-effective-target-features.rs:21:5 + | +LL | #[target_feature(enable = "avx2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method +LL | +LL | fn foo(&self) {} + | ------------- not an `unsafe` function + +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/feature-gate-effective-target-features.rs:23:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn + | +note: type in trait + --> $DIR/feature-gate-effective-target-features.rs:7:5 + | +LL | fn foo(&self); + | ^^^^^^^^^^^^^^ + = note: expected signature `fn(&Bar2)` + found signature `#[target_features] fn(&Bar2)` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0053, E0658. +For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr b/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr new file mode 100644 index 00000000000..d51956fa4d2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr @@ -0,0 +1,35 @@ +warning: the feature `effective_target_features` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/feature-gate-effective-target-features.rs:3:30 + | +LL | #![cfg_attr(feature, feature(effective_target_features))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #143352 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: `#[target_feature(..)]` cannot be applied to safe trait method + --> $DIR/feature-gate-effective-target-features.rs:21:5 + | +LL | #[target_feature(enable = "avx2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method +LL | +LL | fn foo(&self) {} + | ------------- not an `unsafe` function + +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/feature-gate-effective-target-features.rs:23:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn + | +note: type in trait + --> $DIR/feature-gate-effective-target-features.rs:7:5 + | +LL | fn foo(&self); + | ^^^^^^^^^^^^^^ + = note: expected signature `fn(&Bar2)` + found signature `#[target_features] fn(&Bar2)` + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/feature-gates/feature-gate-effective-target-features.rs b/tests/ui/feature-gates/feature-gate-effective-target-features.rs new file mode 100644 index 00000000000..d383897e438 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-effective-target-features.rs @@ -0,0 +1,27 @@ +//@ revisions: default feature +//@ only-x86_64 +#![cfg_attr(feature, feature(effective_target_features))] +//[feature]~^ WARN the feature `effective_target_features` is incomplete and may not be safe to use and/or cause compiler crashes + +trait Foo { + fn foo(&self); +} + +struct Bar; + +impl Foo for Bar { + #[unsafe(force_target_feature(enable = "avx2"))] + //[default]~^ ERROR the `#[force_target_feature]` attribute is an experimental feature + fn foo(&self) {} +} + +struct Bar2; + +impl Foo for Bar2 { + #[target_feature(enable = "avx2")] + //~^ ERROR `#[target_feature(..)]` cannot be applied to safe trait method + fn foo(&self) {} + //~^ ERROR method `foo` has an incompatible type for trait +} + +fn main() {} -- cgit 1.4.1-3-g733a5 From 5d28ce45cacbe3825bc5c2b1abb2f701bfa9ec05 Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 22:08:11 -0500 Subject: typecheck window.searchIndex --- src/librustdoc/html/static/js/main.js | 1 - src/librustdoc/html/static/js/rustdoc.d.ts | 2 ++ src/librustdoc/html/static/js/search.js | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 20fc6b75d37..3dbddb8176b 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -409,7 +409,6 @@ function preLoadCss(cssUrl) { searchLoaded = true; // @ts-expect-error window.rr_ = data => { - // @ts-expect-error window.searchIndex = data; }; if (!window.StringdexOnload) { diff --git a/src/librustdoc/html/static/js/rustdoc.d.ts b/src/librustdoc/html/static/js/rustdoc.d.ts index 28852125fe1..c9253e2cdc5 100644 --- a/src/librustdoc/html/static/js/rustdoc.d.ts +++ b/src/librustdoc/html/static/js/rustdoc.d.ts @@ -93,6 +93,8 @@ declare global { pending_type_impls?: rustdoc.TypeImpls, rustdoc_add_line_numbers_to_examples?: function(), rustdoc_remove_line_numbers_from_examples?: function(), + /** JSON-encoded raw search index */ + searchIndex: string, } interface HTMLElement { /** Used by the popover tooltip code. */ diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 42b87d56252..0cc29f03b1d 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -5244,7 +5244,6 @@ if (typeof window !== "undefined") { // search.index/root is loaded by main.js, so // this script doesn't need to launch it, but // must pick it up - // @ts-ignore if (window.searchIndex) { // @ts-ignore window.rr_(window.searchIndex); -- cgit 1.4.1-3-g733a5 From 4b73a7ec7887f3ca5116d15cb4a277040708337c Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 22:19:46 -0500 Subject: typecheck window.rr_ --- src/librustdoc/html/static/js/main.js | 1 - src/librustdoc/html/static/js/rustdoc.d.ts | 2 ++ src/librustdoc/html/static/js/search.js | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 3dbddb8176b..9dbcc9cd138 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -407,7 +407,6 @@ function preLoadCss(cssUrl) { function loadSearch() { if (!searchLoaded) { searchLoaded = true; - // @ts-expect-error window.rr_ = data => { window.searchIndex = data; }; diff --git a/src/librustdoc/html/static/js/rustdoc.d.ts b/src/librustdoc/html/static/js/rustdoc.d.ts index c9253e2cdc5..8dfbb2bb9ed 100644 --- a/src/librustdoc/html/static/js/rustdoc.d.ts +++ b/src/librustdoc/html/static/js/rustdoc.d.ts @@ -95,6 +95,8 @@ declare global { rustdoc_remove_line_numbers_from_examples?: function(), /** JSON-encoded raw search index */ searchIndex: string, + /** Used in search index shards in order to load data into the in-memory database */ + rr_: function(string), } interface HTMLElement { /** Used by the popover tooltip code. */ diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 0cc29f03b1d..bd9dfe45889 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -5245,7 +5245,6 @@ if (typeof window !== "undefined") { // this script doesn't need to launch it, but // must pick it up if (window.searchIndex) { - // @ts-ignore window.rr_(window.searchIndex); } }, -- cgit 1.4.1-3-g733a5 From 6c22ef501e6df233bb71e7bdac683f547571ba62 Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 22:42:37 -0500 Subject: typecheck window.NOTABLE_TRAITS --- src/librustdoc/html/static/js/main.js | 2 -- src/librustdoc/html/static/js/rustdoc.d.ts | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 9dbcc9cd138..a7a3da0a4bc 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1327,11 +1327,9 @@ function preLoadCss(cssUrl) { */ function showTooltip(e) { const notable_ty = e.getAttribute("data-notable-ty"); - // @ts-expect-error if (!window.NOTABLE_TRAITS && notable_ty) { const data = document.getElementById("notable-traits-data"); if (data) { - // @ts-expect-error window.NOTABLE_TRAITS = JSON.parse(data.innerText); } else { throw new Error("showTooltip() called with notable without any notable traits!"); diff --git a/src/librustdoc/html/static/js/rustdoc.d.ts b/src/librustdoc/html/static/js/rustdoc.d.ts index 8dfbb2bb9ed..3f78ad535af 100644 --- a/src/librustdoc/html/static/js/rustdoc.d.ts +++ b/src/librustdoc/html/static/js/rustdoc.d.ts @@ -28,6 +28,8 @@ declare global { currentTheme: HTMLLinkElement|null; /** Generated in `render/context.rs` */ SIDEBAR_ITEMS?: { [key: string]: string[] }; + /** Notable trait data */ + NOTABLE_TRAITS?: { [key: string]: string }; /** Used by the popover tooltip code. */ RUSTDOC_TOOLTIP_HOVER_MS: number; /** Used by the popover tooltip code. */ -- cgit 1.4.1-3-g733a5 From 78bdd86c676a4e08849677c351591db3564d87e8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 22 Aug 2025 09:22:02 +0200 Subject: miri: also detect aliasing of in-place argument and return place --- compiler/rustc_const_eval/src/interpret/step.rs | 23 ++++++++++----- .../function_calls/arg_inplace_locals_alias.rs | 2 ++ .../function_calls/arg_inplace_locals_alias_ret.rs | 34 ++++++++++++++++++++++ .../arg_inplace_locals_alias_ret.stack.stderr | 25 ++++++++++++++++ .../arg_inplace_locals_alias_ret.tree.stderr | 34 ++++++++++++++++++++++ 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.rs create mode 100644 src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.stack.stderr create mode 100644 src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.tree.stderr (limited to 'src') diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 084d45cf2cb..23d362de308 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -2,6 +2,8 @@ //! //! The main entry point is the `step` method. +use std::iter; + use either::Either; use rustc_abi::{FIRST_VARIANT, FieldIdx}; use rustc_data_structures::fx::FxHashSet; @@ -426,6 +428,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { terminator: &mir::Terminator<'tcx>, func: &mir::Operand<'tcx>, args: &[Spanned>], + dest: &mir::Place<'tcx>, ) -> InterpResult<'tcx, EvaluatedCalleeAndArgs<'tcx, M>> { let func = self.eval_operand(func, None)?; @@ -435,14 +438,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // protection, but then we'd force *a lot* of arguments into memory. So we do some syntactic // pre-processing here where if all `move` arguments are syntactically distinct local // variables (and none is indirect), we can skip the in-memory forcing. + // We have to include `dest` in that list so that we can detect aliasing of an in-place + // argument with the return place. let move_definitely_disjoint = 'move_definitely_disjoint: { let mut previous_locals = FxHashSet::::default(); - for arg in args { - let mir::Operand::Move(place) = arg.node else { - continue; // we can skip non-`Move` arguments. - }; + for place in args + .iter() + .filter_map(|a| { + // We only have to care about `Move` arguments. + if let mir::Operand::Move(place) = &a.node { Some(place) } else { None } + }) + .chain(iter::once(dest)) + { if place.is_indirect_first_projection() { - // An indirect `Move` argument could alias with anything else... + // An indirect in-place argument could alias with anything else... break 'move_definitely_disjoint false; } if !previous_locals.insert(place.local) { @@ -544,7 +553,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let old_loc = self.frame().loc; let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } = - self.eval_callee_and_args(terminator, func, args)?; + self.eval_callee_and_args(terminator, func, args, &destination)?; let destination = self.eval_place(destination)?; self.init_fn_call( @@ -567,7 +576,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let old_frame_idx = self.frame_idx(); let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } = - self.eval_callee_and_args(terminator, func, args)?; + self.eval_callee_and_args(terminator, func, args, &mir::Place::return_place())?; self.init_fn_tail_call(callee, (fn_sig.abi, fn_abi), &args, with_caller_location)?; diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias.rs b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias.rs index b91a41d7650..744d64b9b1e 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias.rs +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias.rs @@ -1,3 +1,5 @@ +//! Ensure we detect aliasing of two in-place arguments for the tricky case where they do not +//! live in memory. //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Validation forces more things into memory, which we can't have here. diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.rs b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.rs new file mode 100644 index 00000000000..dff724f8d96 --- /dev/null +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.rs @@ -0,0 +1,34 @@ +//! Ensure we detect aliasing of a in-place argument with the return place for the tricky case where +//! they do not live in memory. +//@revisions: stack tree +//@[tree]compile-flags: -Zmiri-tree-borrows +// Validation forces more things into memory, which we can't have here. +//@compile-flags: -Zmiri-disable-validation +#![feature(custom_mir, core_intrinsics)] +use std::intrinsics::mir::*; + +#[allow(unused)] +pub struct S(i32); + +#[custom_mir(dialect = "runtime", phase = "optimized")] +fn main() { + mir! { + let _unit: (); + { + let staging = S(42); // This forces `staging` into memory... + let _non_copy = staging; // ... so we move it to a non-inmemory local here. + // This specifically uses a type with scalar representation to tempt Miri to use the + // efficient way of storing local variables (outside adressable memory). + Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue()) + //~[stack]^ ERROR: not granting access + //~[tree]| ERROR: /reborrow .* forbidden/ + } + after_call = { + Return() + } + } +} + +pub fn callee(x: S) -> S { + x +} diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.stack.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.stack.stderr new file mode 100644 index 00000000000..fcd5b8752e7 --- /dev/null +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.stack.stderr @@ -0,0 +1,25 @@ +error: Undefined Behavior: not granting access to tag because that would remove [Unique for ] which is strongly protected + --> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + | +LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created here, as the root tag for ALLOC + --> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + | +LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: is this argument + --> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + | +LL | x + | ^ + = note: BACKTRACE (of the first span): + = note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.tree.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.tree.stderr new file mode 100644 index 00000000000..b7f514de0af --- /dev/null +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_locals_alias_ret.tree.stderr @@ -0,0 +1,34 @@ +error: Undefined Behavior: reborrow through (root of the allocation) at ALLOC[0x0] is forbidden + --> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + | +LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information + = help: the accessed tag (root of the allocation) is foreign to the protected tag (i.e., it is not a child) + = help: this reborrow (acting as a foreign read access) would cause the protected tag (currently Active) to become Disabled + = help: protected tags must never be Disabled +help: the accessed tag was created here + --> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + | +LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: the protected tag was created here, in the initial state Reserved + --> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + | +LL | x + | ^ +help: the protected tag later transitioned to Active due to a child write access at offsets [0x0..0x4] + --> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + | +LL | x + | ^ + = help: this transition corresponds to the first write to a 2-phase borrowed mutable reference + = note: BACKTRACE (of the first span): + = note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + -- cgit 1.4.1-3-g733a5 From c058ce594bb6b899af6402bb6b894448f36ca3c8 Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Fri, 22 Aug 2025 12:08:58 +0200 Subject: Sort Config fields and remove some `mut`s from bindings --- src/bootstrap/src/core/config/config.rs | 408 ++++++++++++++++---------------- 1 file changed, 210 insertions(+), 198 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index efc76a0df64..51e7012d1c4 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -463,7 +463,6 @@ impl Config { ); // Set config values based on flags. - let mut exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast()); exec_ctx.set_dry_run(if flags_dry_run { DryRun::UserSelected } else { DryRun::Disabled }); let mut src = { @@ -479,8 +478,6 @@ impl Config { // Now load the TOML config, as soon as possible let (mut toml, toml_path) = load_toml_config(&src, flags_config, &get_toml); - let is_running_on_ci = flags_ci.unwrap_or(CiEnv::is_ci()); - postprocess_toml(&mut toml, &src, toml_path.clone(), &exec_ctx, &flags_set, &get_toml); // Now override TOML values with flags, to make sure that we won't later override flags with @@ -613,7 +610,7 @@ impl Config { optimize: llvm_optimize, thin_lto: llvm_thin_lto, release_debuginfo: llvm_release_debuginfo, - assertions: llvm_assertions_, + assertions: llvm_assertions, tests: llvm_tests, enzyme: llvm_enzyme, plugins: llvm_plugin, @@ -678,23 +675,33 @@ impl Config { }) .unwrap_or_else(|| vec![host_target]); - let llvm_assertions = llvm_assertions_.unwrap_or(false); + let llvm_assertions = llvm_assertions.unwrap_or(false); let mut target_config = HashMap::new(); let mut channel = "dev".to_string(); - let mut out = flags_build_dir - .or(build_build_dir.map(PathBuf::from)) - .unwrap_or_else(|| PathBuf::from("build")); - - if cfg!(test) { - // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. - if out == Path::new("build") { - out = Path::new( + let out = flags_build_dir.or(build_build_dir.map(PathBuf::from)).unwrap_or_else(|| { + if cfg!(test) { + // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. + Path::new( &env::var_os("CARGO_TARGET_DIR").expect("cargo test directly is not supported"), ) .parent() .unwrap() - .to_path_buf(); + .to_path_buf() + } else { + PathBuf::from("build") } + }); + + // NOTE: Bootstrap spawns various commands with different working directories. + // To avoid writing to random places on the file system, `config.out` needs to be an absolute path. + let mut out = if !out.is_absolute() { + // `canonicalize` requires the path to already exist. Use our vendored copy of `absolute` instead. + absolute(&out).expect("can't make empty path absolute") + } else { + out + }; + + if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the // same ones used to call the tests (if custom ones are not defined in the toml). If we // don't do that, bootstrap will use its own detection logic to find a suitable rustc @@ -704,13 +711,6 @@ impl Config { build_cargo = build_cargo.take().or(std::env::var_os("CARGO").map(|p| p.into())); } - // NOTE: Bootstrap spawns various commands with different working directories. - // To avoid writing to random places on the file system, `config.out` needs to be an absolute path. - if !out.is_absolute() { - // `canonicalize` requires the path to already exist. Use our vendored copy of `absolute` instead. - out = absolute(&out).expect("can't make empty path absolute"); - } - if !flags_skip_stage0_validation { if let Some(rustc) = &build_rustc { check_stage0_version(rustc, "rustc", &src, &exec_ctx); @@ -726,6 +726,7 @@ impl Config { ); } + let is_running_on_ci = flags_ci.unwrap_or(CiEnv::is_ci()); let dwn_ctx = DownloadContext { path_modification_cache: path_modification_cache.clone(), src: &src, @@ -1142,220 +1143,231 @@ impl Config { }) .collect(); + let cargo_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/cargo")); + let clippy_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/clippy")); + let in_tree_gcc_info = git_info(&exec_ctx, false, &src.join("src/gcc")); + let in_tree_llvm_info = git_info(&exec_ctx, false, &src.join("src/llvm-project")); + let enzyme_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/enzyme")); + let miri_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/miri")); + let rust_analyzer_info = + git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/rust-analyzer")); + let rustfmt_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/rustfmt")); + + let optimized_compiler_builtins = + build_optimized_compiler_builtins.unwrap_or(channel != "dev"); + let vendor = build_vendor.unwrap_or( + rust_info.is_from_tarball() + && src.join("vendor").exists() + && src.join(".cargo/config.toml").exists(), + ); + let verbose_tests = rust_verbose_tests.unwrap_or(exec_ctx.is_verbose()); + Config { - change_id: toml.change_id.inner, + // tidy-alphabetical-start + android_ndk: build_android_ndk, + backtrace: rust_backtrace.unwrap_or(true), + backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), + bindir: install_bindir.map(PathBuf::from).unwrap_or("bin".into()), + bootstrap_cache_path: build_bootstrap_cache_path, bypass_bootstrap_lock: flags_bypass_bootstrap_lock, + cargo_info, + cargo_native_static: build_cargo_native_static.unwrap_or(false), ccache, - ninja_in_file: llvm_ninja.unwrap_or(true), + change_id: toml.change_id.inner, + channel, + clippy_info, + cmd: flags_cmd, + codegen_tests: rust_codegen_tests.unwrap_or(true), + color: flags_color, + compile_time_deps: flags_compile_time_deps, compiler_docs: build_compiler_docs.unwrap_or(false), - library_docs_private_items: build_library_docs_private_items.unwrap_or(false), - docs_minification: build_docs_minification.unwrap_or(true), + compiletest_allow_stage0: build_compiletest_allow_stage0.unwrap_or(false), + compiletest_diff_tool: build_compiletest_diff_tool, + compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest.unwrap_or(true), + config: toml_path, + configure_args: build_configure_args.unwrap_or_default(), + control_flow_guard: rust_control_flow_guard.unwrap_or(false), + datadir: install_datadir.map(PathBuf::from), + deny_warnings, + description: build_description, + dist_compression_formats, + dist_compression_profile: dist_compression_profile.unwrap_or("fast".into()), + dist_include_mingw_linker: dist_include_mingw_linker.unwrap_or(true), + dist_sign_folder: dist_sign_folder.map(PathBuf::from), + dist_upload_addr, + dist_vendor: dist_vendor.unwrap_or_else(|| { + // If we're building from git or tarball sources, enable it by default. + rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball() + }), + docdir: install_docdir.map(PathBuf::from), docs: build_docs.unwrap_or(true), - locked_deps: build_locked_deps.unwrap_or(false), - full_bootstrap: build_full_bootstrap.unwrap_or(false), - bootstrap_cache_path: build_bootstrap_cache_path, + docs_minification: build_docs_minification.unwrap_or(true), + download_rustc_commit, + dump_bootstrap_shims: flags_dump_bootstrap_shims, + ehcont_guard: rust_ehcont_guard.unwrap_or(false), + enable_bolt_settings: flags_enable_bolt_settings, + enzyme_info, + exec_ctx, + explicit_stage_from_cli: flags_stage.is_some(), + explicit_stage_from_config, extended: build_extended.unwrap_or(false), - tools: build_tools, - tool: build_tool.unwrap_or_default(), - sanitizers: build_sanitizers.unwrap_or(false), - profiler: build_profiler.unwrap_or(false), + free_args: flags_free_args, + full_bootstrap: build_full_bootstrap.unwrap_or(false), + gcc_ci_mode, + gdb: build_gdb.map(PathBuf::from), + host_target, + hosts, + in_tree_gcc_info, + in_tree_llvm_info, include_default_paths: flags_include_default_paths, - rustc_error_format: flags_rustc_error_format, + incremental: flags_incremental || rust_incremental == Some(true), + initial_cargo, + initial_cargo_clippy: build_cargo_clippy, + initial_rustc, + initial_rustfmt, + initial_sysroot, + is_running_on_ci, + jemalloc: rust_jemalloc.unwrap_or(false), + jobs: Some(threads_from_config(flags_jobs.or(build_jobs).unwrap_or(0))), json_output: flags_json_output, - compile_time_deps: flags_compile_time_deps, - test_compare_mode: rust_test_compare_mode.unwrap_or(false), - color: flags_color, - android_ndk: build_android_ndk, - optimized_compiler_builtins: build_optimized_compiler_builtins - .unwrap_or(channel != "dev"), - stdout_is_tty: std::io::stdout().is_terminal(), - stderr_is_tty: std::io::stderr().is_terminal(), - on_fail: flags_on_fail, - explicit_stage_from_cli: flags_stage.is_some(), - explicit_stage_from_config, - keep_stage: flags_keep_stage, keep_stage_std: flags_keep_stage_std, - jobs: Some(threads_from_config(flags_jobs.or(build_jobs).unwrap_or(0))), - incremental: flags_incremental || rust_incremental == Some(true), - dump_bootstrap_shims: flags_dump_bootstrap_shims, - free_args: flags_free_args, - deny_warnings, - backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), - llvm_tests: llvm_tests.unwrap_or(false), + libdir: install_libdir.map(PathBuf::from), + library_docs_private_items: build_library_docs_private_items.unwrap_or(false), + lld_enabled, + lld_mode: rust_lld_mode.unwrap_or_default(), + lldb: build_lldb.map(PathBuf::from), + llvm_allow_old_toolchain: llvm_allow_old_toolchain.unwrap_or(false), + llvm_assertions, + llvm_bitcode_linker_enabled: rust_llvm_bitcode_linker.unwrap_or(false), + llvm_build_config: llvm_build_config.clone().unwrap_or(Default::default()), + llvm_cflags, + llvm_clang: llvm_clang.unwrap_or(false), + llvm_clang_cl, + llvm_cxxflags, + llvm_enable_warnings: llvm_enable_warnings.unwrap_or(false), llvm_enzyme: llvm_enzyme.unwrap_or(false), + llvm_experimental_targets, + llvm_from_ci, + llvm_ldflags, + llvm_libunwind_default: rust_llvm_libunwind + .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")), + llvm_libzstd: llvm_libzstd.unwrap_or(false), + llvm_link_jobs, + // If we're building with ThinLTO on, by default we want to link + // to LLVM shared, to avoid re-doing ThinLTO (which happens in + // the link step) with each stage. + llvm_link_shared: Cell::new( + llvm_link_shared + .or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)), + ), llvm_offload: llvm_offload.unwrap_or(false), - llvm_plugins: llvm_plugin.unwrap_or(false), llvm_optimize: llvm_optimize.unwrap_or(true), + llvm_plugins: llvm_plugin.unwrap_or(false), + llvm_polly: llvm_polly.unwrap_or(false), + llvm_profile_generate: flags_llvm_profile_generate, + llvm_profile_use: flags_llvm_profile_use, llvm_release_debuginfo: llvm_release_debuginfo.unwrap_or(false), llvm_static_stdcpp: llvm_static_libstdcpp.unwrap_or(false), - llvm_libzstd: llvm_libzstd.unwrap_or(false), - llvm_clang_cl, llvm_targets, - llvm_experimental_targets, - llvm_link_jobs, - llvm_version_suffix, - llvm_use_linker, - llvm_allow_old_toolchain: llvm_allow_old_toolchain.unwrap_or(false), - llvm_polly: llvm_polly.unwrap_or(false), - llvm_clang: llvm_clang.unwrap_or(false), - llvm_enable_warnings: llvm_enable_warnings.unwrap_or(false), - llvm_build_config: llvm_build_config.clone().unwrap_or(Default::default()), + llvm_tests: llvm_tests.unwrap_or(false), + llvm_thin_lto: llvm_thin_lto.unwrap_or(false), llvm_tools_enabled: rust_llvm_tools.unwrap_or(true), - llvm_bitcode_linker_enabled: rust_llvm_bitcode_linker.unwrap_or(false), - llvm_cflags, - llvm_cxxflags, - llvm_ldflags, llvm_use_libcxx: llvm_use_libcxx.unwrap_or(false), - gcc_ci_mode, - rust_optimize: rust_optimize.unwrap_or(RustOptimize::Bool(true)), + llvm_use_linker, + llvm_version_suffix, + local_rebuild: build_local_rebuild.unwrap_or(false), + locked_deps: build_locked_deps.unwrap_or(false), + low_priority: build_low_priority.unwrap_or(false), + mandir: install_mandir.map(PathBuf::from), + miri_info, + musl_root: rust_musl_root.map(PathBuf::from), + ninja_in_file: llvm_ninja.unwrap_or(true), + nodejs: build_nodejs.map(PathBuf::from), + npm: build_npm.map(PathBuf::from), + omit_git_hash, + on_fail: flags_on_fail, + optimized_compiler_builtins, + out, + patch_binaries_for_nix: build_patch_binaries_for_nix, + path_modification_cache, + paths: flags_paths, + prefix: install_prefix.map(PathBuf::from), + print_step_rusage: build_print_step_rusage.unwrap_or(false), + print_step_timings: build_print_step_timings.unwrap_or(false), + profiler: build_profiler.unwrap_or(false), + python: build_python.map(PathBuf::from), + reproducible_artifacts: flags_reproducible_artifact, + reuse: build_reuse.map(PathBuf::from), + rust_analyzer_info, + rust_codegen_backends: rust_codegen_backends + .map(|backends| parse_codegen_backends(backends, "rust")) + .unwrap_or(vec![CodegenBackendKind::Llvm]), rust_codegen_units: rust_codegen_units.map(threads_from_config), rust_codegen_units_std: rust_codegen_units_std.map(threads_from_config), - std_debug_assertions: rust_std_debug_assertions - .or(rust_rustc_debug_assertions) - .unwrap_or(rust_debug == Some(true)), - tools_debug_assertions: rust_tools_debug_assertions - .or(rust_rustc_debug_assertions) - .unwrap_or(rust_debug == Some(true)), - rust_overflow_checks_std: rust_overflow_checks_std - .or(rust_overflow_checks) - .unwrap_or(rust_debug == Some(true)), - rust_overflow_checks: rust_overflow_checks.unwrap_or(rust_debug == Some(true)), rust_debug_logging: rust_debug_logging .or(rust_rustc_debug_assertions) .unwrap_or(rust_debug == Some(true)), rust_debuginfo_level_rustc: with_defaults(rust_debuginfo_level_rustc), rust_debuginfo_level_std: with_defaults(rust_debuginfo_level_std), - rust_debuginfo_level_tools: with_defaults(rust_debuginfo_level_tools), rust_debuginfo_level_tests: rust_debuginfo_level_tests.unwrap_or(DebuginfoLevel::None), - rust_rpath: rust_rpath.unwrap_or(true), - rust_strip: rust_strip.unwrap_or(false), - rust_frame_pointers: rust_frame_pointers.unwrap_or(false), - rust_stack_protector, - rustc_default_linker: rust_default_linker, - rust_optimize_tests: rust_optimize_tests.unwrap_or(true), + rust_debuginfo_level_tools: with_defaults(rust_debuginfo_level_tools), rust_dist_src: dist_src_tarball.unwrap_or_else(|| rust_dist_src.unwrap_or(true)), - rust_codegen_backends: rust_codegen_backends - .map(|backends| parse_codegen_backends(backends, "rust")) - .unwrap_or(vec![CodegenBackendKind::Llvm]), - rust_verify_llvm_ir: rust_verify_llvm_ir.unwrap_or(false), - rust_thin_lto_import_instr_limit, - rust_randomize_layout: rust_randomize_layout.unwrap_or(false), - rust_remap_debuginfo: rust_remap_debuginfo.unwrap_or(false), - rust_new_symbol_mangling, - rust_profile_use: flags_rust_profile_use.or(rust_profile_use), - rust_profile_generate: flags_rust_profile_generate.or(rust_profile_generate), + rust_frame_pointers: rust_frame_pointers.unwrap_or(false), + rust_info, rust_lto: rust_lto .as_deref() .map(|value| RustcLto::from_str(value).unwrap()) .unwrap_or_default(), - rust_validate_mir_opts, + rust_new_symbol_mangling, + rust_optimize: rust_optimize.unwrap_or(RustOptimize::Bool(true)), + rust_optimize_tests: rust_optimize_tests.unwrap_or(true), + rust_overflow_checks: rust_overflow_checks.unwrap_or(rust_debug == Some(true)), + rust_overflow_checks_std: rust_overflow_checks_std + .or(rust_overflow_checks) + .unwrap_or(rust_debug == Some(true)), + rust_profile_generate: flags_rust_profile_generate.or(rust_profile_generate), + rust_profile_use: flags_rust_profile_use.or(rust_profile_use), + rust_randomize_layout: rust_randomize_layout.unwrap_or(false), + rust_remap_debuginfo: rust_remap_debuginfo.unwrap_or(false), + rust_rpath: rust_rpath.unwrap_or(true), + rust_stack_protector, rust_std_features: rust_std_features .unwrap_or(BTreeSet::from([String::from("panic-unwind")])), - llvm_profile_use: flags_llvm_profile_use, - llvm_profile_generate: flags_llvm_profile_generate, - llvm_libunwind_default: rust_llvm_libunwind - .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")), - enable_bolt_settings: flags_enable_bolt_settings, - reproducible_artifacts: flags_reproducible_artifact, - local_rebuild: build_local_rebuild.unwrap_or(false), - jemalloc: rust_jemalloc.unwrap_or(false), - control_flow_guard: rust_control_flow_guard.unwrap_or(false), - ehcont_guard: rust_ehcont_guard.unwrap_or(false), - dist_sign_folder: dist_sign_folder.map(PathBuf::from), - dist_upload_addr, - dist_compression_formats, - dist_compression_profile: dist_compression_profile.unwrap_or("fast".into()), - dist_include_mingw_linker: dist_include_mingw_linker.unwrap_or(true), - backtrace: rust_backtrace.unwrap_or(true), - low_priority: build_low_priority.unwrap_or(false), - description: build_description, - verbose_tests: rust_verbose_tests.unwrap_or(exec_ctx.is_verbose()), + rust_strip: rust_strip.unwrap_or(false), + rust_thin_lto_import_instr_limit, + rust_validate_mir_opts, + rust_verify_llvm_ir: rust_verify_llvm_ir.unwrap_or(false), + rustc_debug_assertions: rust_rustc_debug_assertions.unwrap_or(rust_debug == Some(true)), + rustc_default_linker: rust_default_linker, + rustc_error_format: flags_rustc_error_format, + rustfmt_info, + sanitizers: build_sanitizers.unwrap_or(false), save_toolstates: rust_save_toolstates.map(PathBuf::from), - print_step_timings: build_print_step_timings.unwrap_or(false), - print_step_rusage: build_print_step_rusage.unwrap_or(false), - musl_root: rust_musl_root.map(PathBuf::from), - prefix: install_prefix.map(PathBuf::from), - sysconfdir: install_sysconfdir.map(PathBuf::from), - datadir: install_datadir.map(PathBuf::from), - docdir: install_docdir.map(PathBuf::from), - bindir: install_bindir.map(PathBuf::from).unwrap_or("bin".into()), - libdir: install_libdir.map(PathBuf::from), - mandir: install_mandir.map(PathBuf::from), - codegen_tests: rust_codegen_tests.unwrap_or(true), - nodejs: build_nodejs.map(PathBuf::from), - npm: build_npm.map(PathBuf::from), - gdb: build_gdb.map(PathBuf::from), - lldb: build_lldb.map(PathBuf::from), - python: build_python.map(PathBuf::from), - reuse: build_reuse.map(PathBuf::from), - cargo_native_static: build_cargo_native_static.unwrap_or(false), - configure_args: build_configure_args.unwrap_or_default(), - compiletest_diff_tool: build_compiletest_diff_tool, - compiletest_allow_stage0: build_compiletest_allow_stage0.unwrap_or(false), - compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest.unwrap_or(true), - tidy_extra_checks: build_tidy_extra_checks, - skip_std_check_if_no_download_rustc: flags_skip_std_check_if_no_download_rustc, - cargo_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/cargo")), - rust_analyzer_info: git_info( - &exec_ctx, - omit_git_hash, - &src.join("src/tools/rust-analyzer"), - ), - clippy_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/clippy")), - miri_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/miri")), - rustfmt_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/rustfmt")), - enzyme_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/enzyme")), - in_tree_llvm_info: git_info(&exec_ctx, false, &src.join("src/llvm-project")), - in_tree_gcc_info: git_info(&exec_ctx, false, &src.join("src/gcc")), - dist_vendor: dist_vendor.unwrap_or_else(|| { - // If we're building from git or tarball sources, enable it by default. - rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball() - }), - targets, skip, - paths: flags_paths, - config: toml_path, - llvm_thin_lto: llvm_thin_lto.unwrap_or(false), - rustc_debug_assertions: rust_rustc_debug_assertions.unwrap_or(rust_debug == Some(true)), - lld_mode: rust_lld_mode.unwrap_or_default(), - initial_cargo_clippy: build_cargo_clippy, - vendor: build_vendor.unwrap_or( - rust_info.is_from_tarball() - && src.join("vendor").exists() - && src.join(".cargo/config.toml").exists(), - ), - patch_binaries_for_nix: build_patch_binaries_for_nix, - cmd: flags_cmd, - submodules: build_submodules, - // If we're building with ThinLTO on, by default we want to link - // to LLVM shared, to avoid re-doing ThinLTO (which happens in - // the link step) with each stage. - llvm_link_shared: Cell::new( - llvm_link_shared - .or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)), - ), - exec_ctx, - out, - rust_info, - initial_cargo, - initial_rustc, - initial_sysroot, - initial_rustfmt, - target_config, - omit_git_hash, - stage, + skip_std_check_if_no_download_rustc: flags_skip_std_check_if_no_download_rustc, src, - llvm_from_ci, - llvm_assertions, - lld_enabled, - host_target, - hosts, - channel, - is_running_on_ci, - path_modification_cache, + stage, stage0_metadata, - download_rustc_commit, + std_debug_assertions: rust_std_debug_assertions + .or(rust_rustc_debug_assertions) + .unwrap_or(rust_debug == Some(true)), + stderr_is_tty: std::io::stderr().is_terminal(), + stdout_is_tty: std::io::stdout().is_terminal(), + submodules: build_submodules, + sysconfdir: install_sysconfdir.map(PathBuf::from), + target_config, + targets, + test_compare_mode: rust_test_compare_mode.unwrap_or(false), + tidy_extra_checks: build_tidy_extra_checks, + tool: build_tool.unwrap_or_default(), + tools: build_tools, + tools_debug_assertions: rust_tools_debug_assertions + .or(rust_rustc_debug_assertions) + .unwrap_or(rust_debug == Some(true)), + vendor, + verbose_tests, + // tidy-alphabetical-end } } -- cgit 1.4.1-3-g733a5 From dfec2bbdca6e7b83b108e87753d4c6dde5d758fd Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 22:54:43 -0500 Subject: typecheck window.CURRENT_TOOLTIP_ELEMENT --- src/librustdoc/html/static/js/main.js | 36 +++++------------------------- src/librustdoc/html/static/js/rustdoc.d.ts | 1 + src/librustdoc/html/static/js/storage.js | 2 +- 3 files changed, 7 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index a7a3da0a4bc..e55265f68b4 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1275,13 +1275,11 @@ function preLoadCss(cssUrl) { } window.addEventListener("resize", () => { - // @ts-expect-error if (window.CURRENT_TOOLTIP_ELEMENT) { // As a workaround to the behavior of `contains: layout` used in doc togglers, // tooltip popovers are positioned using javascript. // // This means when the window is resized, we need to redo the layout. - // @ts-expect-error const base = window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE; const force_visible = base.TOOLTIP_FORCE_VISIBLE; hideTooltip(false); @@ -1337,14 +1335,15 @@ function preLoadCss(cssUrl) { } // Make this function idempotent. If the tooltip is already shown, avoid doing extra work // and leave it alone. - // @ts-expect-error if (window.CURRENT_TOOLTIP_ELEMENT && window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE === e) { - // @ts-expect-error clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT); return; } window.hideAllModals(false); - const wrapper = document.createElement("div"); + // use Object.assign to make sure the object has the correct type + // with all of the correct fields before it is assigned to a variable, + // as typescript has no way to change the type of a variable once it is initialized. + const wrapper = Object.assign(document.createElement("div"), {TOOLTIP_BASE: e}); if (notable_ty) { wrapper.innerHTML = "
" + // @ts-expect-error @@ -1390,11 +1389,7 @@ function preLoadCss(cssUrl) { ); } wrapper.style.visibility = ""; - // @ts-expect-error window.CURRENT_TOOLTIP_ELEMENT = wrapper; - // @ts-expect-error - window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE = e; - // @ts-expect-error clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT); wrapper.onpointerenter = ev => { // If this is a synthetic touch event, ignore it. A click event will be along shortly. @@ -1429,19 +1424,15 @@ function preLoadCss(cssUrl) { */ function setTooltipHoverTimeout(element, show) { clearTooltipHoverTimeout(element); - // @ts-expect-error if (!show && !window.CURRENT_TOOLTIP_ELEMENT) { // To "hide" an already hidden element, just cancel its timeout. return; } - // @ts-expect-error if (show && window.CURRENT_TOOLTIP_ELEMENT) { // To "show" an already visible element, just cancel its timeout. return; } - // @ts-expect-error if (window.CURRENT_TOOLTIP_ELEMENT && - // @ts-expect-error window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE !== element) { // Don't do anything if another tooltip is already visible. return; @@ -1464,7 +1455,6 @@ function preLoadCss(cssUrl) { */ function clearTooltipHoverTimeout(element) { if (element.TOOLTIP_HOVER_TIMEOUT !== undefined) { - // @ts-expect-error removeClass(window.CURRENT_TOOLTIP_ELEMENT, "fade-out"); clearTimeout(element.TOOLTIP_HOVER_TIMEOUT); delete element.TOOLTIP_HOVER_TIMEOUT; @@ -1473,15 +1463,10 @@ function preLoadCss(cssUrl) { // @ts-expect-error function tooltipBlurHandler(event) { - // @ts-expect-error if (window.CURRENT_TOOLTIP_ELEMENT && - // @ts-expect-error !window.CURRENT_TOOLTIP_ELEMENT.contains(document.activeElement) && - // @ts-expect-error !window.CURRENT_TOOLTIP_ELEMENT.contains(event.relatedTarget) && - // @ts-expect-error !window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.contains(document.activeElement) && - // @ts-expect-error !window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.contains(event.relatedTarget) ) { // Work around a difference in the focus behaviour between Firefox, Chrome, and Safari. @@ -1503,30 +1488,22 @@ function preLoadCss(cssUrl) { * If set to `false`, leave keyboard focus alone. */ function hideTooltip(focus) { - // @ts-expect-error if (window.CURRENT_TOOLTIP_ELEMENT) { - // @ts-expect-error if (window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.TOOLTIP_FORCE_VISIBLE) { if (focus) { - // @ts-expect-error window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.focus(); } - // @ts-expect-error window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.TOOLTIP_FORCE_VISIBLE = false; } - // @ts-expect-error document.body.removeChild(window.CURRENT_TOOLTIP_ELEMENT); - // @ts-expect-error clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT); - // @ts-expect-error - window.CURRENT_TOOLTIP_ELEMENT = null; + window.CURRENT_TOOLTIP_ELEMENT = undefined; } } onEachLazy(document.getElementsByClassName("tooltip"), e => { e.onclick = () => { e.TOOLTIP_FORCE_VISIBLE = e.TOOLTIP_FORCE_VISIBLE ? false : true; - // @ts-expect-error if (window.CURRENT_TOOLTIP_ELEMENT && !e.TOOLTIP_FORCE_VISIBLE) { hideTooltip(true); } else { @@ -1562,9 +1539,7 @@ function preLoadCss(cssUrl) { if (ev.pointerType !== "mouse") { return; } - // @ts-expect-error if (!e.TOOLTIP_FORCE_VISIBLE && window.CURRENT_TOOLTIP_ELEMENT && - // @ts-expect-error !window.CURRENT_TOOLTIP_ELEMENT.contains(ev.relatedTarget)) { // Tooltip pointer leave gesture: // @@ -1597,7 +1572,6 @@ function preLoadCss(cssUrl) { // * https://www.nngroup.com/articles/tooltip-guidelines/ // * https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown setTooltipHoverTimeout(e, false); - // @ts-expect-error addClass(window.CURRENT_TOOLTIP_ELEMENT, "fade-out"); } }; diff --git a/src/librustdoc/html/static/js/rustdoc.d.ts b/src/librustdoc/html/static/js/rustdoc.d.ts index 3f78ad535af..3ac10742e41 100644 --- a/src/librustdoc/html/static/js/rustdoc.d.ts +++ b/src/librustdoc/html/static/js/rustdoc.d.ts @@ -30,6 +30,7 @@ declare global { SIDEBAR_ITEMS?: { [key: string]: string[] }; /** Notable trait data */ NOTABLE_TRAITS?: { [key: string]: string }; + CURRENT_TOOLTIP_ELEMENT?: HTMLElement & { TOOLTIP_BASE: HTMLElement }; /** Used by the popover tooltip code. */ RUSTDOC_TOOLTIP_HOVER_MS: number; /** Used by the popover tooltip code. */ diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index c055eb0f808..40ab8be03c9 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -117,7 +117,7 @@ function addClass(elem, className) { * Remove a class from a DOM Element. If `elem` is null, * does nothing. This function is idempotent. * - * @param {Element|null} elem + * @param {Element|null|undefined} elem * @param {string} className */ // eslint-disable-next-line no-unused-vars -- cgit 1.4.1-3-g733a5 From cb572cb876cb901f279fbe64d6e7a6462ac8097c Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 22:59:37 -0500 Subject: typecheck tooltipBlurHandler --- src/librustdoc/html/static/js/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index e55265f68b4..bfa9e789944 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1461,7 +1461,9 @@ function preLoadCss(cssUrl) { } } - // @ts-expect-error + /** + * @param {Event & { relatedTarget: Node }} event + */ function tooltipBlurHandler(event) { if (window.CURRENT_TOOLTIP_ELEMENT && !window.CURRENT_TOOLTIP_ELEMENT.contains(document.activeElement) && -- cgit 1.4.1-3-g733a5 From 4a2d6dfe26706b058b045dd2d4cc73832ede7728 Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 23:04:26 -0500 Subject: typecheck: add nonnull around element known to exist --- src/librustdoc/html/static/js/main.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index bfa9e789944..c09cc5da35e 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1679,8 +1679,7 @@ function preLoadCss(cssUrl) { if (isHelpPage) { const help_section = document.createElement("section"); help_section.appendChild(container); - // @ts-expect-error - document.getElementById("main-content").appendChild(help_section); + nonnull(document.getElementById("main-content")).appendChild(help_section); } else { onEachLazy(document.getElementsByClassName("help-menu"), menu => { if (menu.offsetWidth !== 0) { -- cgit 1.4.1-3-g733a5 From 771c6415b295407fb380c859b243354d61d41cf7 Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 23:05:50 -0500 Subject: main.js: only call window.rustdocToggleSrcSidebar if it exists --- src/librustdoc/html/static/js/main.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index c09cc5da35e..4fcba5f120b 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1825,8 +1825,7 @@ function preLoadCss(cssUrl) { sidebarButton.addEventListener("click", e => { removeClass(document.documentElement, "hide-sidebar"); updateLocalStorage("hide-sidebar", "false"); - if (document.querySelector(".rustdoc.src")) { - // @ts-expect-error + if (window.rustdocToggleSrcSidebar) { window.rustdocToggleSrcSidebar(); } e.preventDefault(); -- cgit 1.4.1-3-g733a5 From 65847490bbf232d152daf445b66698fb2f96b986 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Fri, 22 Aug 2025 20:25:11 +0200 Subject: Add aarch64_be-unknown-hermit target Signed-off-by: Jens Reidel --- compiler/rustc_target/src/spec/mod.rs | 1 + .../src/spec/targets/aarch64_be_unknown_hermit.rs | 25 ++++++++++++++++++++++ src/bootstrap/src/core/sanity.rs | 1 + src/doc/rustc/src/platform-support.md | 1 + src/doc/rustc/src/platform-support/hermit.md | 2 ++ tests/assembly-llvm/targets/targets-elf.rs | 3 +++ 6 files changed, 33 insertions(+) create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs (limited to 'src') diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 399770022b2..a67795e3e93 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2116,6 +2116,7 @@ supported_targets! { ("msp430-none-elf", msp430_none_elf), + ("aarch64_be-unknown-hermit", aarch64_be_unknown_hermit), ("aarch64-unknown-hermit", aarch64_unknown_hermit), ("riscv64gc-unknown-hermit", riscv64gc_unknown_hermit), ("x86_64-unknown-hermit", x86_64_unknown_hermit), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs new file mode 100644 index 00000000000..cad57abc2b1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs @@ -0,0 +1,25 @@ +use rustc_abi::Endian; + +use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; + +pub(crate) fn target() -> Target { + Target { + llvm_target: "aarch64_be-unknown-hermit".into(), + metadata: TargetMetadata { + description: Some("ARM64 Hermit (big-endian)".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(true), + }, + pointer_width: 64, + arch: "aarch64".into(), + data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), + options: TargetOptions { + features: "+v8a,+strict-align,+neon,+fp-armv8".into(), + max_atomic_width: Some(128), + stack_probes: StackProbeType::Inline, + endian: Endian::Big, + ..base::hermit::opts() + }, + } +} diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index bd02131b7fe..3c68192302a 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -35,6 +35,7 @@ pub struct Finder { const STAGE0_MISSING_TARGETS: &[&str] = &[ "armv7a-vex-v5", // just a dummy comment so the list doesn't get onelined + "aarch64_be-unknown-hermit", "aarch64_be-unknown-none-softfloat", ]; diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index c039517a970..3bf87994297 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -270,6 +270,7 @@ target | std | host | notes [`aarch64-unknown-trusty`](platform-support/trusty.md) | ✓ | | [`aarch64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | | [`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS +[`aarch64_be-unknown-hermit`](platform-support/hermit.md) | ✓ | | ARM64 Hermit (big-endian) `aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian) `aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI) [`aarch64_be-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD (big-endian) diff --git a/src/doc/rustc/src/platform-support/hermit.md b/src/doc/rustc/src/platform-support/hermit.md index 069c253bd38..8362d6f55fd 100644 --- a/src/doc/rustc/src/platform-support/hermit.md +++ b/src/doc/rustc/src/platform-support/hermit.md @@ -10,6 +10,7 @@ Target triplets available so far: - `x86_64-unknown-hermit` - `aarch64-unknown-hermit` +- `aarch64_be-unknown-hermit` - `riscv64gc-unknown-hermit` ## Target maintainers @@ -42,6 +43,7 @@ target = [ "", "x86_64-unknown-hermit", "aarch64-unknown-hermit", + "aarch64_be-unknown-hermit", "riscv64gc-unknown-hermit", ] diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index a1d759ede2b..79347d0bbf6 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -1,6 +1,9 @@ //@ add-core-stubs //@ assembly-output: emit-asm // ignore-tidy-linelength +//@ revisions: aarch64_be_unknown_hermit +//@ [aarch64_be_unknown_hermit] compile-flags: --target aarch64_be-unknown-hermit +//@ [aarch64_be_unknown_hermit] needs-llvm-components: aarch64 //@ revisions: aarch64_be_unknown_linux_gnu //@ [aarch64_be_unknown_linux_gnu] compile-flags: --target aarch64_be-unknown-linux-gnu //@ [aarch64_be_unknown_linux_gnu] needs-llvm-components: aarch64 -- cgit 1.4.1-3-g733a5 From 7785efd1b000cd3824d465c485ee1929aa0059bd Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Fri, 22 Aug 2025 18:01:31 +0200 Subject: Rename `llvm_config` to `host_llvm_config` to avoid confusion --- src/bootstrap/src/core/build_steps/compile.rs | 8 +++---- src/bootstrap/src/core/build_steps/dist.rs | 7 +++--- src/bootstrap/src/core/build_steps/llvm.rs | 32 +++++++++++++-------------- src/bootstrap/src/core/build_steps/test.rs | 14 +++++++----- src/bootstrap/src/core/builder/mod.rs | 6 ++--- src/bootstrap/src/core/builder/tests.rs | 8 +++---- 6 files changed, 39 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index be09cfa41af..0ebea02ed75 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1394,8 +1394,8 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect if builder.config.llvm_enzyme { cargo.env("LLVM_ENZYME", "1"); } - let llvm::LlvmResult { llvm_config, .. } = builder.ensure(llvm::Llvm { target }); - cargo.env("LLVM_CONFIG", &llvm_config); + let llvm::LlvmResult { host_llvm_config, .. } = builder.ensure(llvm::Llvm { target }); + cargo.env("LLVM_CONFIG", &host_llvm_config); // Some LLVM linker flags (-L and -l) may be needed to link `rustc_llvm`. Its build script // expects these to be passed via the `LLVM_LINKER_FLAGS` env variable, separated by @@ -2001,13 +2001,13 @@ impl Step for Assemble { if builder.config.llvm_enabled(target_compiler.host) { trace!("target_compiler.host" = ?target_compiler.host, "LLVM enabled"); - let llvm::LlvmResult { llvm_config, .. } = + let llvm::LlvmResult { host_llvm_config, .. } = builder.ensure(llvm::Llvm { target: target_compiler.host }); if !builder.config.dry_run() && builder.config.llvm_tools_enabled { trace!("LLVM tools enabled"); let llvm_bin_dir = - command(llvm_config).arg("--bindir").run_capture_stdout(builder).stdout(); + command(host_llvm_config).arg("--bindir").run_capture_stdout(builder).stdout(); let llvm_bin_dir = Path::new(llvm_bin_dir.trim()); // Since we've already built the LLVM tools, install them to the sysroot. diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index beb71e70035..daac75c03e2 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -2230,11 +2230,12 @@ fn maybe_install_llvm( builder.install(&llvm_dylib_path, dst_libdir, FileType::NativeLibrary); } !builder.config.dry_run() - } else if let llvm::LlvmBuildStatus::AlreadyBuilt(llvm::LlvmResult { llvm_config, .. }) = - llvm::prebuilt_llvm_config(builder, target, true) + } else if let llvm::LlvmBuildStatus::AlreadyBuilt(llvm::LlvmResult { + host_llvm_config, .. + }) = llvm::prebuilt_llvm_config(builder, target, true) { trace!("LLVM already built, installing LLVM files"); - let mut cmd = command(llvm_config); + let mut cmd = command(host_llvm_config); cmd.arg("--libfiles"); builder.verbose(|| println!("running {cmd:?}")); let files = cmd.run_capture_stdout(builder).stdout(); diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 024cac2f2fe..70259f0d1d7 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -29,7 +29,7 @@ use crate::{CLang, GitRepo, Kind, trace}; pub struct LlvmResult { /// Path to llvm-config binary. /// NB: This is always the host llvm-config! - pub llvm_config: PathBuf, + pub host_llvm_config: PathBuf, /// Path to LLVM cmake directory for the target. pub llvm_cmake_dir: PathBuf, } @@ -109,14 +109,14 @@ pub fn prebuilt_llvm_config( && let Some(ref s) = config.llvm_config { check_llvm_version(builder, s); - let llvm_config = s.to_path_buf(); - let mut llvm_cmake_dir = llvm_config.clone(); + let host_llvm_config = s.to_path_buf(); + let mut llvm_cmake_dir = host_llvm_config.clone(); llvm_cmake_dir.pop(); llvm_cmake_dir.pop(); llvm_cmake_dir.push("lib"); llvm_cmake_dir.push("cmake"); llvm_cmake_dir.push("llvm"); - return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir }); + return LlvmBuildStatus::AlreadyBuilt(LlvmResult { host_llvm_config, llvm_cmake_dir }); } if handle_submodule_when_needed { @@ -141,7 +141,7 @@ pub fn prebuilt_llvm_config( }; let llvm_cmake_dir = out_dir.join("lib/cmake/llvm"); - let res = LlvmResult { llvm_config: build_llvm_config, llvm_cmake_dir }; + let res = LlvmResult { host_llvm_config: build_llvm_config, llvm_cmake_dir }; static STAMP_HASH_MEMO: OnceLock = OnceLock::new(); let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| { @@ -483,11 +483,11 @@ impl Step for Llvm { // https://llvm.org/docs/HowToCrossCompileLLVM.html if !builder.config.is_host_target(target) { - let LlvmResult { llvm_config, .. } = + let LlvmResult { host_llvm_config, .. } = builder.ensure(Llvm { target: builder.config.host_target }); if !builder.config.dry_run() { let llvm_bindir = - command(&llvm_config).arg("--bindir").run_capture_stdout(builder).stdout(); + command(&host_llvm_config).arg("--bindir").run_capture_stdout(builder).stdout(); let host_bin = Path::new(llvm_bindir.trim()); cfg.define( "LLVM_TABLEGEN", @@ -496,7 +496,7 @@ impl Step for Llvm { // LLVM_NM is required for cross compiling using MSVC cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); } - cfg.define("LLVM_CONFIG_PATH", llvm_config); + cfg.define("LLVM_CONFIG_PATH", host_llvm_config); if builder.config.llvm_clang { let build_bin = builder.llvm_out(builder.config.host_target).join("build").join("bin"); @@ -538,7 +538,7 @@ impl Step for Llvm { // Helper to find the name of LLVM's shared library on darwin and linux. let find_llvm_lib_name = |extension| { - let major = get_llvm_version_major(builder, &res.llvm_config); + let major = get_llvm_version_major(builder, &res.host_llvm_config); match &llvm_version_suffix { Some(version_suffix) => format!("libLLVM-{major}{version_suffix}.{extension}"), None => format!("libLLVM-{major}.{extension}"), @@ -915,7 +915,7 @@ impl Step for Enzyme { } let target = self.target; - let LlvmResult { llvm_config, .. } = builder.ensure(Llvm { target: self.target }); + let LlvmResult { host_llvm_config, .. } = builder.ensure(Llvm { target: self.target }); static STAMP_HASH_MEMO: OnceLock = OnceLock::new(); let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| { @@ -969,7 +969,7 @@ impl Step for Enzyme { cfg.out_dir(&out_dir) .profile(profile) - .env("LLVM_CONFIG_REAL", &llvm_config) + .env("LLVM_CONFIG_REAL", &host_llvm_config) .define("LLVM_ENABLE_ASSERTIONS", "ON") .define("ENZYME_EXTERNAL_SHARED_LIB", "ON") .define("ENZYME_BC_LOADER", "OFF") @@ -1006,13 +1006,13 @@ impl Step for Lld { } let target = self.target; - let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target }); + let LlvmResult { host_llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target }); // The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path // we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin` // subfolder. We check if that's the case, and if LLD's binary already exists there next to // `llvm-config`: if so, we can use it instead of building LLVM/LLD from source. - let ci_llvm_bin = llvm_config.parent().unwrap(); + let ci_llvm_bin = host_llvm_config.parent().unwrap(); if ci_llvm_bin.is_dir() && ci_llvm_bin.file_name().unwrap() == "bin" { let lld_path = ci_llvm_bin.join(exe("lld", target)); if lld_path.exists() { @@ -1095,7 +1095,7 @@ impl Step for Lld { // Use the host llvm-tblgen binary. cfg.define( "LLVM_TABLEGEN_EXE", - llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION), + host_llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION), ); } @@ -1136,7 +1136,7 @@ impl Step for Sanitizers { return runtimes; } - let LlvmResult { llvm_config, .. } = + let LlvmResult { host_llvm_config, .. } = builder.ensure(Llvm { target: builder.config.host_target }); static STAMP_HASH_MEMO: OnceLock = OnceLock::new(); @@ -1176,7 +1176,7 @@ impl Step for Sanitizers { cfg.define("COMPILER_RT_BUILD_XRAY", "OFF"); cfg.define("COMPILER_RT_DEFAULT_TARGET_ONLY", "ON"); cfg.define("COMPILER_RT_USE_LIBCXX", "OFF"); - cfg.define("LLVM_CONFIG_PATH", &llvm_config); + cfg.define("LLVM_CONFIG_PATH", &host_llvm_config); if self.target.contains("ohos") { cfg.define("COMPILER_RT_USE_BUILTINS_LIBRARY", "ON"); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 56e7582a6ff..269e7da8d7b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2038,12 +2038,14 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?} let mut llvm_components_passed = false; let mut copts_passed = false; if builder.config.llvm_enabled(compiler.host) { - let llvm::LlvmResult { llvm_config, .. } = + let llvm::LlvmResult { host_llvm_config, .. } = builder.ensure(llvm::Llvm { target: builder.config.host_target }); if !builder.config.dry_run() { - let llvm_version = get_llvm_version(builder, &llvm_config); - let llvm_components = - command(&llvm_config).arg("--components").run_capture_stdout(builder).stdout(); + let llvm_version = get_llvm_version(builder, &host_llvm_config); + let llvm_components = command(&host_llvm_config) + .arg("--components") + .run_capture_stdout(builder) + .stdout(); // Remove trailing newline from llvm-config output. cmd.arg("--llvm-version") .arg(llvm_version.trim()) @@ -2061,7 +2063,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?} // rustc args as a workaround. if !builder.config.dry_run() && suite.ends_with("fulldeps") { let llvm_libdir = - command(&llvm_config).arg("--libdir").run_capture_stdout(builder).stdout(); + command(&host_llvm_config).arg("--libdir").run_capture_stdout(builder).stdout(); let link_llvm = if target.is_msvc() { format!("-Clink-arg=-LIBPATH:{llvm_libdir}") } else { @@ -2075,7 +2077,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?} // tools. Pass the path to run-make tests so they can use them. // (The coverage-run tests also need these tools to process // coverage reports.) - let llvm_bin_path = llvm_config + let llvm_bin_path = host_llvm_config .parent() .expect("Expected llvm-config to be contained in directory"); assert!(llvm_bin_path.is_dir()); diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 043cb1c2666..b5fcf1e436b 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1649,9 +1649,9 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s /// check build or dry-run, where there's no need to build all of LLVM. pub fn llvm_config(&self, target: TargetSelection) -> Option { if self.config.llvm_enabled(target) && self.kind != Kind::Check && !self.config.dry_run() { - let llvm::LlvmResult { llvm_config, .. } = self.ensure(llvm::Llvm { target }); - if llvm_config.is_file() { - return Some(llvm_config); + let llvm::LlvmResult { host_llvm_config, .. } = self.ensure(llvm::Llvm { target }); + if host_llvm_config.is_file() { + return Some(host_llvm_config); } } None diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index a2fe546c60a..2afba25ae59 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -434,14 +434,14 @@ fn test_prebuilt_llvm_config_path_resolution() { false, ) .llvm_result() - .llvm_config + .host_llvm_config .clone(); let actual = drop_win_disk_prefix_if_present(actual); assert_eq!(expected, actual); let actual = prebuilt_llvm_config(&builder, builder.config.host_target, false) .llvm_result() - .llvm_config + .host_llvm_config .clone(); let actual = drop_win_disk_prefix_if_present(actual); assert_eq!(expected, actual); @@ -459,7 +459,7 @@ fn test_prebuilt_llvm_config_path_resolution() { let actual = prebuilt_llvm_config(&builder, builder.config.host_target, false) .llvm_result() - .llvm_config + .host_llvm_config .clone(); let expected = builder .out @@ -482,7 +482,7 @@ fn test_prebuilt_llvm_config_path_resolution() { let actual = prebuilt_llvm_config(&builder, builder.config.host_target, false) .llvm_result() - .llvm_config + .host_llvm_config .clone(); let expected = builder .out -- cgit 1.4.1-3-g733a5 From c064521cc7fd4d2548bcf30aca2424556c9cf82c Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Fri, 22 Aug 2025 21:00:35 +0200 Subject: Ship LLVM tools for the correct target when cross-compiling --- src/bootstrap/src/core/build_steps/compile.rs | 48 ++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 0ebea02ed75..6ca32aca345 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -2001,14 +2001,52 @@ impl Step for Assemble { if builder.config.llvm_enabled(target_compiler.host) { trace!("target_compiler.host" = ?target_compiler.host, "LLVM enabled"); - let llvm::LlvmResult { host_llvm_config, .. } = - builder.ensure(llvm::Llvm { target: target_compiler.host }); + let target = target_compiler.host; + let llvm::LlvmResult { host_llvm_config, .. } = builder.ensure(llvm::Llvm { target }); if !builder.config.dry_run() && builder.config.llvm_tools_enabled { trace!("LLVM tools enabled"); - let llvm_bin_dir = - command(host_llvm_config).arg("--bindir").run_capture_stdout(builder).stdout(); - let llvm_bin_dir = Path::new(llvm_bin_dir.trim()); + let host_llvm_bin_dir = command(&host_llvm_config) + .arg("--bindir") + .run_capture_stdout(builder) + .stdout() + .trim() + .to_string(); + + let llvm_bin_dir = if target == builder.host_target { + PathBuf::from(host_llvm_bin_dir) + } else { + // If we're cross-compiling, we cannot run the target llvm-config in order to + // figure out where binaries are located. We thus have to guess. + let external_llvm_config = builder + .config + .target_config + .get(&target) + .and_then(|t| t.llvm_config.clone()); + if let Some(external_llvm_config) = external_llvm_config { + // If we have an external LLVM, just hope that the bindir is the directory + // where the LLVM config is located + external_llvm_config.parent().unwrap().to_path_buf() + } else { + // If we have built LLVM locally, then take the path of the host bindir + // relative to its output build directory, and then apply it to the target + // LLVM output build directory. + let host_llvm_out = builder.llvm_out(builder.host_target); + let target_llvm_out = builder.llvm_out(target); + if let Ok(relative_path) = + Path::new(&host_llvm_bin_dir).strip_prefix(host_llvm_out) + { + target_llvm_out.join(relative_path) + } else { + // This is the most desperate option, just replace the host target with + // the actual target in the directory path... + PathBuf::from( + host_llvm_bin_dir + .replace(&*builder.host_target.triple, &target.triple), + ) + } + } + }; // Since we've already built the LLVM tools, install them to the sysroot. // This is the equivalent of installing the `llvm-tools-preview` component via -- cgit 1.4.1-3-g733a5 From 6315b4973a8e5090ce041ca9a4eaf81ed7b70e29 Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Fri, 22 Aug 2025 21:06:49 +0200 Subject: Add warning to the `Builder::llvm_config` function --- src/bootstrap/src/core/builder/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index b5fcf1e436b..40460bf168d 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1647,6 +1647,10 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s /// /// Note that this returns `None` if LLVM is disabled, or if we're in a /// check build or dry-run, where there's no need to build all of LLVM. + /// + /// FIXME(@kobzol) + /// **WARNING**: This actually returns the **HOST** LLVM config, not LLVM config for the given + /// *target*. pub fn llvm_config(&self, target: TargetSelection) -> Option { if self.config.llvm_enabled(target) && self.kind != Kind::Check && !self.config.dry_run() { let llvm::LlvmResult { host_llvm_config, .. } = self.ensure(llvm::Llvm { target }); -- cgit 1.4.1-3-g733a5 From 7046ce89c666bb9e8695eb9b92721156c7b2b0ec Mon Sep 17 00:00:00 2001 From: Nia Espera Date: Wed, 16 Jul 2025 05:29:09 +0200 Subject: interpret/allocation: get_range on ProvenanceMap --- .../src/mir/interpret/allocation/provenance_map.rs | 11 +++++++++++ src/tools/miri/src/shims/native_lib/mod.rs | 11 +++-------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs index ea8596ea286..dbbd95408c8 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs @@ -120,6 +120,17 @@ impl ProvenanceMap { } } + /// Gets the provenances of all bytes (including from pointers) in a range. + pub fn get_range( + &self, + cx: &impl HasDataLayout, + range: AllocRange, + ) -> impl Iterator { + let ptr_provs = self.range_ptrs_get(range, cx).iter().map(|(_, p)| *p); + let byte_provs = self.range_bytes_get(range).iter().map(|(_, (p, _))| *p); + ptr_provs.chain(byte_provs) + } + /// Attempt to merge per-byte provenance back into ptr chunks, if the right fragments /// sit next to each other. Return `false` is that is not possible due to partial pointers. pub fn merge_bytes(&mut self, cx: &impl HasDataLayout) -> bool { diff --git a/src/tools/miri/src/shims/native_lib/mod.rs b/src/tools/miri/src/shims/native_lib/mod.rs index e2a0bdbd9b4..74b9b704fea 100644 --- a/src/tools/miri/src/shims/native_lib/mod.rs +++ b/src/tools/miri/src/shims/native_lib/mod.rs @@ -242,14 +242,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { match evt { AccessEvent::Read(_) => { - // FIXME: ProvenanceMap should have something like get_range(). - let p_map = alloc.provenance(); - for idx in overlap { - // If a provenance was read by the foreign code, expose it. - if let Some((prov, _idx)) = p_map.get_byte(Size::from_bytes(idx), this) - { - this.expose_provenance(prov)?; - } + // If a provenance was read by the foreign code, expose it. + for prov in alloc.provenance().get_range(this, overlap.into()) { + this.expose_provenance(prov)?; } } AccessEvent::Write(_, certain) => { -- cgit 1.4.1-3-g733a5 From 75dc02878d916a285c1dd840999ca5f5f150d5c1 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 22 Aug 2025 19:32:50 -0400 Subject: Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/cargo b/src/tools/cargo index 71eb84f21ae..623d536836b 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 71eb84f21aef43c07580c6aed6f806a6299f5042 +Subproject commit 623d536836b4cde09ce38609232a024d5b25da81 -- cgit 1.4.1-3-g733a5 From b244f29777611e696854d8fd8d5313bb94dd1ce5 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Sat, 23 Aug 2025 07:30:27 +0530 Subject: remove default opts from config --- src/bootstrap/src/core/config/config.rs | 53 --------------------------------- 1 file changed, 53 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index f579bdd847f..84c9f9cc4d2 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -327,59 +327,6 @@ pub struct Config { } impl Config { - #[cfg_attr( - feature = "tracing", - instrument(target = "CONFIG_HANDLING", level = "trace", name = "Config::default_opts") - )] - pub fn default_opts() -> Config { - #[cfg(feature = "tracing")] - span!(target: "CONFIG_HANDLING", tracing::Level::TRACE, "constructing default config"); - - Config { - bypass_bootstrap_lock: false, - llvm_optimize: true, - ninja_in_file: true, - llvm_static_stdcpp: false, - llvm_libzstd: false, - backtrace: true, - rust_optimize: RustOptimize::Bool(true), - rust_optimize_tests: true, - rust_randomize_layout: false, - submodules: None, - docs: true, - docs_minification: true, - rust_rpath: true, - rust_strip: false, - channel: "dev".to_string(), - codegen_tests: true, - rust_dist_src: true, - rust_codegen_backends: vec![CodegenBackendKind::Llvm], - deny_warnings: true, - bindir: "bin".into(), - dist_include_mingw_linker: true, - dist_compression_profile: "fast".into(), - - stdout_is_tty: std::io::stdout().is_terminal(), - stderr_is_tty: std::io::stderr().is_terminal(), - - // set by build.rs - host_target: get_host_target(), - - src: { - let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - // Undo `src/bootstrap` - manifest_dir.parent().unwrap().parent().unwrap().to_owned() - }, - out: PathBuf::from("build"), - - // This is needed by codegen_ssa on macOS to ship `llvm-objcopy` aliased to - // `rust-objcopy` to workaround bad `strip`s on macOS. - llvm_tools_enabled: true, - - ..Default::default() - } - } - pub fn set_dry_run(&mut self, dry_run: DryRun) { self.exec_ctx.set_dry_run(dry_run); } -- cgit 1.4.1-3-g733a5 From 32b193c248b2538d8397c74fb6a55aef1730a6aa Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Sat, 23 Aug 2025 10:14:52 +0200 Subject: Remove profile section from Clippy To avoid workspace warnings. --- src/tools/clippy/Cargo.toml | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/tools/clippy/Cargo.toml b/src/tools/clippy/Cargo.toml index 2add525b7e8..b3618932ded 100644 --- a/src/tools/clippy/Cargo.toml +++ b/src/tools/clippy/Cargo.toml @@ -65,13 +65,6 @@ harness = false name = "dogfood" harness = false -# quine-mc_cluskey makes up a significant part of the runtime in dogfood -# due to the number of conditions in the clippy_lints crate -# and enabling optimizations for that specific dependency helps a bit -# without increasing total build times. -[profile.dev.package.quine-mc_cluskey] -opt-level = 3 - [lints.rust.unexpected_cfgs] level = "warn" check-cfg = ['cfg(bootstrap)'] -- cgit 1.4.1-3-g733a5 From 3ac32cace1df3edfd559c77bf2922c915253fbc0 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Fri, 22 Aug 2025 18:04:12 +0200 Subject: rustdoc: make attributes render consistently * make attributes render inside code elements and inside divs with class `code-attribute` * render attributes for macros, associated constants, and struct/union fields --- src/librustdoc/html/render/mod.rs | 37 +++++----- src/librustdoc/html/render/print_item.rs | 100 +++++++++++++------------- src/librustdoc/html/templates/item_union.html | 1 - 3 files changed, 68 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 8d7f0577506..673947ad308 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1029,6 +1029,7 @@ fn assoc_const( ) -> impl fmt::Display { let tcx = cx.tcx(); fmt::from_fn(move |w| { + render_attributes_in_code(w, it, &" ".repeat(indent), cx); write!( w, "{indent}{vis}const {name}{generics}: {ty}", @@ -1136,10 +1137,10 @@ fn assoc_method( let (indent, indent_str, end_newline) = if parent == ItemType::Trait { header_len += 4; let indent_str = " "; - write!(w, "{}", render_attributes_in_pre(meth, indent_str, cx))?; + render_attributes_in_code(w, meth, indent_str, cx); (4, indent_str, Ending::NoNewline) } else { - render_attributes_in_code(w, meth, cx); + render_attributes_in_code(w, meth, "", cx); (0, "", Ending::Newline) }; write!( @@ -1309,28 +1310,28 @@ fn render_assoc_item( }) } -// When an attribute is rendered inside a `
` tag, it is formatted using
-// a whitespace prefix and newline.
-fn render_attributes_in_pre(it: &clean::Item, prefix: &str, cx: &Context<'_>) -> impl fmt::Display {
-    fmt::from_fn(move |f| {
-        for a in it.attributes(cx.tcx(), cx.cache()) {
-            writeln!(f, "{prefix}{a}")?;
-        }
-        Ok(())
-    })
-}
-
 struct CodeAttribute(String);
 
-fn render_code_attribute(code_attr: CodeAttribute, w: &mut impl fmt::Write) {
-    write!(w, "
{}
", code_attr.0).unwrap(); +fn render_code_attribute(prefix: &str, code_attr: CodeAttribute, w: &mut impl fmt::Write) { + write!( + w, + "
{prefix}{attr}
", + prefix = prefix, + attr = code_attr.0 + ) + .unwrap(); } // When an attribute is rendered inside a tag, it is formatted using // a div to produce a newline after it. -fn render_attributes_in_code(w: &mut impl fmt::Write, it: &clean::Item, cx: &Context<'_>) { +fn render_attributes_in_code( + w: &mut impl fmt::Write, + it: &clean::Item, + prefix: &str, + cx: &Context<'_>, +) { for attr in it.attributes(cx.tcx(), cx.cache()) { - render_code_attribute(CodeAttribute(attr), w); + render_code_attribute(prefix, CodeAttribute(attr), w); } } @@ -1342,7 +1343,7 @@ fn render_repr_attributes_in_code( item_type: ItemType, ) { if let Some(repr) = clean::repr_attributes(cx.tcx(), cx.cache(), def_id, item_type) { - render_code_attribute(CodeAttribute(repr), w); + render_code_attribute("", CodeAttribute(repr), w); } } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 407238d66b8..2618ec272ca 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -20,8 +20,8 @@ use super::{ AssocItemLink, AssocItemRender, Context, ImplRenderingParameters, RenderMode, collect_paths_for_type, document, ensure_trailing_slash, get_filtered_impls_for_reference, item_ty_to_section, notable_traits_button, notable_traits_json, render_all_impls, - render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre, - render_impl, render_repr_attributes_in_code, render_rightside, render_stability_since_raw, + render_assoc_item, render_assoc_items, render_attributes_in_code, render_impl, + render_repr_attributes_in_code, render_rightside, render_stability_since_raw, render_stability_since_raw_with_extra, write_section_heading, }; use crate::clean; @@ -107,13 +107,6 @@ macro_rules! item_template_methods { } item_template_methods!($($rest)*); }; - (render_attributes_in_pre $($rest:tt)*) => { - fn render_attributes_in_pre(&self) -> impl fmt::Display { - let (item, cx) = self.item_and_cx(); - render_attributes_in_pre(item, "", cx) - } - item_template_methods!($($rest)*); - }; (render_assoc_items $($rest:tt)*) => { fn render_assoc_items(&self) -> impl fmt::Display { let (item, cx) = self.item_and_cx(); @@ -457,7 +450,12 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i write!( w, "\ - {vis}{imp}{stab_tags}\ + " + )?; + render_attributes_in_code(w, myitem, "", cx); + write!( + w, + "{vis}{imp}{stab_tags}\ ", vis = visibility_print_with_space(myitem, cx), imp = import.print(cx) @@ -625,11 +623,11 @@ fn item_function(cx: &Context<'_>, it: &clean::Item, f: &clean::Function) -> imp let notable_traits = notable_traits_button(&f.decl.output, cx).maybe_display(); wrap_item(w, |w| { + render_attributes_in_code(w, it, "", cx); write!( w, - "{attrs}{vis}{constness}{asyncness}{safety}{abi}fn \ + "{vis}{constness}{asyncness}{safety}{abi}fn \ {name}{generics}{decl}{notable_traits}{where_clause}", - attrs = render_attributes_in_pre(it, "", cx), vis = visibility, constness = constness, asyncness = asyncness, @@ -666,10 +664,10 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt: // Output the trait definition wrap_item(w, |mut w| { + render_attributes_in_code(&mut w, it, "", cx); write!( w, - "{attrs}{vis}{safety}{is_auto}trait {name}{generics}{bounds}", - attrs = render_attributes_in_pre(it, "", cx), + "{vis}{safety}{is_auto}trait {name}{generics}{bounds}", vis = visibility_print_with_space(it, cx), safety = t.safety(tcx).print_with_space(), is_auto = if t.is_auto(tcx) { "auto " } else { "" }, @@ -1240,10 +1238,10 @@ fn item_trait_alias( ) -> impl fmt::Display { fmt::from_fn(|w| { wrap_item(w, |w| { + render_attributes_in_code(w, it, "", cx); write!( w, - "{attrs}trait {name}{generics} = {bounds}{where_clause};", - attrs = render_attributes_in_pre(it, "", cx), + "trait {name}{generics} = {bounds}{where_clause};", name = it.name.unwrap(), generics = t.generics.print(cx), bounds = print_bounds(&t.bounds, true, cx), @@ -1268,10 +1266,10 @@ fn item_trait_alias( fn item_type_alias(cx: &Context<'_>, it: &clean::Item, t: &clean::TypeAlias) -> impl fmt::Display { fmt::from_fn(|w| { wrap_item(w, |w| { + render_attributes_in_code(w, it, "", cx); write!( w, - "{attrs}{vis}type {name}{generics}{where_clause} = {type_};", - attrs = render_attributes_in_pre(it, "", cx), + "{vis}type {name}{generics}{where_clause} = {type_};", vis = visibility_print_with_space(it, cx), name = it.name.unwrap(), generics = t.generics.print(cx), @@ -1452,7 +1450,14 @@ item_template!( impl<'a, 'cx: 'a> ItemUnion<'a, 'cx> { fn render_union(&self) -> impl Display { - render_union(self.it, Some(self.generics), self.fields, self.cx) + render_union( + self.it, + Some(self.generics), + self.fields, + self.def_id, + self.is_type_alias, + self.cx, + ) } fn document_field(&self, field: &'a clean::Item) -> impl Display { @@ -1479,27 +1484,6 @@ impl<'a, 'cx: 'a> ItemUnion<'a, 'cx> { _ => None, }) } - - fn render_attributes_in_pre(&self) -> impl fmt::Display { - fmt::from_fn(move |f| { - if self.is_type_alias { - // For now the only attributes we render for type aliases are `repr` attributes. - if let Some(repr) = clean::repr_attributes( - self.cx.tcx(), - self.cx.cache(), - self.def_id, - ItemType::Union, - ) { - writeln!(f, "{repr}")?; - }; - } else { - for a in self.it.attributes(self.cx.tcx(), self.cx.cache()) { - writeln!(f, "{a}")?; - } - } - Ok(()) - }) - } } fn item_union(cx: &Context<'_>, it: &clean::Item, s: &clean::Union) -> impl fmt::Display { @@ -1563,7 +1547,7 @@ impl<'clean> DisplayEnum<'clean> { // For now the only attributes we render for type aliases are `repr` attributes. render_repr_attributes_in_code(w, cx, self.def_id, ItemType::Enum); } else { - render_attributes_in_code(w, it, cx); + render_attributes_in_code(w, it, "", cx); } write!( w, @@ -1702,7 +1686,7 @@ fn render_enum_fields( if v.is_stripped() { continue; } - write!(w, "{}", render_attributes_in_pre(v, TAB, cx))?; + render_attributes_in_code(w, v, TAB, cx); w.write_str(TAB)?; match v.kind { clean::VariantItem(ref var) => match var.kind { @@ -1882,6 +1866,7 @@ fn item_macro(cx: &Context<'_>, it: &clean::Item, t: &clean::Macro) -> impl fmt: fmt::from_fn(|w| { wrap_item(w, |w| { // FIXME: Also print `#[doc(hidden)]` for `macro_rules!` if it `is_doc_hidden`. + render_attributes_in_code(w, it, "", cx); if !t.macro_rules { write!(w, "{}", visibility_print_with_space(it, cx))?; } @@ -1950,7 +1935,7 @@ fn item_constant( fmt::from_fn(|w| { wrap_item(w, |w| { let tcx = cx.tcx(); - render_attributes_in_code(w, it, cx); + render_attributes_in_code(w, it, "", cx); write!( w, @@ -2018,7 +2003,7 @@ impl<'a> DisplayStruct<'a> { // For now the only attributes we render for type aliases are `repr` attributes. render_repr_attributes_in_code(w, cx, self.def_id, ItemType::Struct); } else { - render_attributes_in_code(w, it, cx); + render_attributes_in_code(w, it, "", cx); } write!( w, @@ -2115,7 +2100,7 @@ fn item_static( ) -> impl fmt::Display { fmt::from_fn(move |w| { wrap_item(w, |w| { - render_attributes_in_code(w, it, cx); + render_attributes_in_code(w, it, "", cx); write!( w, "{vis}{safe}static {mutability}{name}: {typ}", @@ -2135,7 +2120,7 @@ fn item_foreign_type(cx: &Context<'_>, it: &clean::Item) -> impl fmt::Display { fmt::from_fn(|w| { wrap_item(w, |w| { w.write_str("extern {\n")?; - render_attributes_in_code(w, it, cx); + render_attributes_in_code(w, it, "", cx); write!(w, " {}type {};\n}}", visibility_print_with_space(it, cx), it.name.unwrap(),) })?; @@ -2358,9 +2343,17 @@ fn render_union( it: &clean::Item, g: Option<&clean::Generics>, fields: &[clean::Item], + def_id: DefId, + is_type_alias: bool, cx: &Context<'_>, ) -> impl Display { fmt::from_fn(move |mut f| { + if is_type_alias { + // For now the only attributes we render for type aliases are `repr` attributes. + render_repr_attributes_in_code(f, cx, def_id, ItemType::Union); + } else { + render_attributes_in_code(f, it, "", cx); + } write!(f, "{}union {}", visibility_print_with_space(it, cx), it.name.unwrap(),)?; let where_displayed = if let Some(generics) = g { @@ -2390,6 +2383,7 @@ fn render_union( for field in fields { if let clean::StructFieldItem(ref ty) = field.kind { + render_attributes_in_code(&mut f, field, " ", cx); writeln!( f, " {}{}: {},", @@ -2481,11 +2475,15 @@ fn render_struct_fields( if toggle { toggle_open(&mut *w, format_args!("{count_fields} fields")); } + if has_visible_fields { + writeln!(w)?; + } for field in fields { if let clean::StructFieldItem(ref ty) = field.kind { - write!( + render_attributes_in_code(w, field, &format!("{tab} "), cx); + writeln!( w, - "\n{tab} {vis}{name}: {ty},", + "{tab} {vis}{name}: {ty},", vis = visibility_print_with_space(field, cx), name = field.name.unwrap(), ty = ty.print(cx) @@ -2495,12 +2493,12 @@ fn render_struct_fields( if has_visible_fields { if has_stripped_entries { - write!( + writeln!( w, - "\n{tab} /* private fields */" + "{tab} /* private fields */" )?; } - write!(w, "\n{tab}")?; + write!(w, "{tab}")?; } else if has_stripped_entries { write!(w, " /* private fields */ ")?; } diff --git a/src/librustdoc/html/templates/item_union.html b/src/librustdoc/html/templates/item_union.html index b5d3367a6a1..5dba43ca255 100644 --- a/src/librustdoc/html/templates/item_union.html +++ b/src/librustdoc/html/templates/item_union.html @@ -1,5 +1,4 @@

-    {{ self.render_attributes_in_pre()|safe }}
     {{ self.render_union()|safe }}
 
{% if !self.is_type_alias %} -- cgit 1.4.1-3-g733a5 From d8b40bdb5ac4a2cb078de2f0ba95144e4b026a6c Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 23 Aug 2025 13:08:07 +0200 Subject: citool: cleanup `mismatched_lifetime_syntaxes` warnings --- src/ci/citool/src/analysis.rs | 2 +- src/ci/citool/src/test_dashboard.rs | 2 +- src/ci/citool/src/utils.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ci/citool/src/analysis.rs b/src/ci/citool/src/analysis.rs index 62974be2dbe..8ba8f1ab564 100644 --- a/src/ci/citool/src/analysis.rs +++ b/src/ci/citool/src/analysis.rs @@ -75,7 +75,7 @@ fn format_build_step_diffs(current: &BuildStep, parent: &BuildStep) -> String { } } - fn get_steps(step: &BuildStep) -> Vec { + fn get_steps(step: &BuildStep) -> Vec> { step.linearize_steps().into_iter().map(|v| StepByName(v)).collect() } diff --git a/src/ci/citool/src/test_dashboard.rs b/src/ci/citool/src/test_dashboard.rs index 8fbd0d3f200..c9de38852e5 100644 --- a/src/ci/citool/src/test_dashboard.rs +++ b/src/ci/citool/src/test_dashboard.rs @@ -33,7 +33,7 @@ fn write_page(dir: &Path, name: &str, template: &T) -> anyhow::Resu Ok(()) } -fn gather_test_suites(job_metrics: &HashMap) -> TestSuites { +fn gather_test_suites(job_metrics: &HashMap) -> TestSuites<'_> { struct CoarseTestSuite<'a> { tests: BTreeMap>, } diff --git a/src/ci/citool/src/utils.rs b/src/ci/citool/src/utils.rs index 0367d349a1e..3176cb62f60 100644 --- a/src/ci/citool/src/utils.rs +++ b/src/ci/citool/src/utils.rs @@ -31,6 +31,6 @@ where } /// Normalizes Windows-style path delimiters to Unix-style paths. -pub fn normalize_path_delimiters(name: &str) -> Cow { +pub fn normalize_path_delimiters(name: &str) -> Cow<'_, str> { if name.contains("\\") { name.replace('\\', "/").into() } else { name.into() } } -- cgit 1.4.1-3-g733a5 From 8c2d2c07ff7af6e9d10e00833d8e82a483f2acae Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Sun, 24 Aug 2025 04:54:24 +0000 Subject: Prepare for merging from rust-lang/rust This updates the rust-version file to f6d23413c399fb530be362ebcf25a4e788e16137. --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index d0757e58bf9..3450f18334a 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -8e3710ef31a0b2cdf5a1c2f3929b7735d1e28c20 +f6d23413c399fb530be362ebcf25a4e788e16137 -- cgit 1.4.1-3-g733a5 From 9e18b7b0e1b014833ec49a10fc3544d400ca1acc Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Sun, 24 Aug 2025 05:02:39 +0000 Subject: fmt --- src/tools/miri/src/machine.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 0b2ce900414..0136de55216 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -1077,7 +1077,8 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { .target_features .iter() .filter(|&feature| { - feature.kind != TargetFeatureKind::Implied && !ecx.tcx.sess.target_features.contains(&feature.name) + feature.kind != TargetFeatureKind::Implied + && !ecx.tcx.sess.target_features.contains(&feature.name) }) .fold(String::new(), |mut s, feature| { if !s.is_empty() { -- cgit 1.4.1-3-g733a5