about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-11-08 03:32:51 +0000
committerbors <bors@rust-lang.org>2024-11-08 03:32:51 +0000
commit78bb5ee79e0261e8e47476b631da02acc1cb03ef (patch)
tree0a4c7d02d444cd7dbf030fd01c63257f0748cbb4 /src
parent5b20c459997590eda4d324b53cdc55439a56265d (diff)
parent97dbab9124ff8ecaf4ced5720996e67e51fc62ea (diff)
Auto merge of #132756 - workingjubilee:rollup-bed2akn, r=workingjubilee
Rollup of 10 pull requests

Successful merges:

 - #130586 (Set "symbol name" in raw-dylib import libraries to the decorated name)
 - #131913 (Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support)
 - #132095 (Fix #131977 parens mangled in shared mut static lint suggestion)
 - #132131 ([StableMIR] API to retrieve definitions from crates)
 - #132639 (core: move intrinsics.rs into intrinsics folder)
 - #132696 (Compile `test_num_f128` conditionally on `reliable_f128_math` config)
 - #132737 (bootstrap: Print better message if lock pid isn't available)
 - #132739 (Fix `librustdoc/scrape_examples.rs` formatting)
 - #132740 (Update test for LLVM 20's new vector splat syntax)
 - #132741 (Update mips64 data layout to match LLVM 20 change)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/bin/main.rs8
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs10
-rw-r--r--src/bootstrap/src/core/builder/cargo.rs4
-rw-r--r--src/bootstrap/src/core/config/config.rs33
-rw-r--r--src/librustdoc/scrape_examples.rs33
-rw-r--r--src/tools/compiletest/src/common.rs7
-rw-r--r--src/tools/compiletest/src/directive-list.rs5
-rw-r--r--src/tools/compiletest/src/header/cfg.rs11
-rw-r--r--src/tools/compiletest/src/header/needs.rs10
-rw-r--r--src/tools/compiletest/src/header/tests.rs44
-rw-r--r--src/tools/compiletest/src/lib.rs9
11 files changed, 131 insertions, 43 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs
index e9ec79e417b..409a644b9be 100644
--- a/src/bootstrap/src/bin/main.rs
+++ b/src/bootstrap/src/bin/main.rs
@@ -33,7 +33,7 @@ fn main() {
         // Display PID of process holding the lock
         // PID will be stored in a lock file
         let lock_path = config.out.join("lock");
-        let pid = fs::read_to_string(&lock_path).unwrap_or_default();
+        let pid = fs::read_to_string(&lock_path);
 
         build_lock = fd_lock::RwLock::new(t!(fs::OpenOptions::new()
             .write(true)
@@ -47,7 +47,11 @@ fn main() {
             }
             err => {
                 drop(err);
-                println!("WARNING: build directory locked by process {pid}, waiting for lock");
+                if let Ok(pid) = pid {
+                    println!("WARNING: build directory locked by process {pid}, waiting for lock");
+                } else {
+                    println!("WARNING: build directory locked, waiting for lock");
+                }
                 let mut lock = t!(build_lock.write());
                 t!(lock.write(process::id().to_string().as_ref()));
                 lock
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index bcce2748c2e..2c36d8bab82 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -1938,9 +1938,13 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
 
         cmd.arg("--json");
 
-        if builder.config.rust_debug_assertions_std {
-            cmd.arg("--with-debug-assertions");
-        };
+        if builder.config.rustc_debug_assertions {
+            cmd.arg("--with-rustc-debug-assertions");
+        }
+
+        if builder.config.std_debug_assertions {
+            cmd.arg("--with-std-debug-assertions");
+        }
 
         let mut llvm_components_passed = false;
         let mut copts_passed = false;
diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs
index c3d0994f164..134da5db96d 100644
--- a/src/bootstrap/src/core/builder/cargo.rs
+++ b/src/bootstrap/src/core/builder/cargo.rs
@@ -833,9 +833,9 @@ impl Builder<'_> {
         cargo.env(
             profile_var("DEBUG_ASSERTIONS"),
             if mode == Mode::Std {
-                self.config.rust_debug_assertions_std.to_string()
+                self.config.std_debug_assertions.to_string()
             } else {
-                self.config.rust_debug_assertions.to_string()
+                self.config.rustc_debug_assertions.to_string()
             },
         );
         cargo.env(
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 8115aea033d..f977c285a74 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -263,8 +263,10 @@ pub struct Config {
     pub rust_optimize: RustOptimize,
     pub rust_codegen_units: Option<u32>,
     pub rust_codegen_units_std: Option<u32>,
-    pub rust_debug_assertions: bool,
-    pub rust_debug_assertions_std: bool,
+
+    pub rustc_debug_assertions: bool,
+    pub std_debug_assertions: bool,
+
     pub rust_overflow_checks: bool,
     pub rust_overflow_checks_std: bool,
     pub rust_debug_logging: bool,
@@ -1115,9 +1117,9 @@ define_config! {
         debug: Option<bool> = "debug",
         codegen_units: Option<u32> = "codegen-units",
         codegen_units_std: Option<u32> = "codegen-units-std",
-        debug_assertions: Option<bool> = "debug-assertions",
+        rustc_debug_assertions: Option<bool> = "debug-assertions",
         randomize_layout: Option<bool> = "randomize-layout",
-        debug_assertions_std: Option<bool> = "debug-assertions-std",
+        std_debug_assertions: Option<bool> = "debug-assertions-std",
         overflow_checks: Option<bool> = "overflow-checks",
         overflow_checks_std: Option<bool> = "overflow-checks-std",
         debug_logging: Option<bool> = "debug-logging",
@@ -1652,8 +1654,8 @@ impl Config {
         let mut llvm_offload = None;
         let mut llvm_plugins = None;
         let mut debug = None;
-        let mut debug_assertions = None;
-        let mut debug_assertions_std = None;
+        let mut rustc_debug_assertions = None;
+        let mut std_debug_assertions = None;
         let mut overflow_checks = None;
         let mut overflow_checks_std = None;
         let mut debug_logging = None;
@@ -1675,8 +1677,8 @@ impl Config {
                 debug: debug_toml,
                 codegen_units,
                 codegen_units_std,
-                debug_assertions: debug_assertions_toml,
-                debug_assertions_std: debug_assertions_std_toml,
+                rustc_debug_assertions: rustc_debug_assertions_toml,
+                std_debug_assertions: std_debug_assertions_toml,
                 overflow_checks: overflow_checks_toml,
                 overflow_checks_std: overflow_checks_std_toml,
                 debug_logging: debug_logging_toml,
@@ -1734,8 +1736,8 @@ impl Config {
                 config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
 
             debug = debug_toml;
-            debug_assertions = debug_assertions_toml;
-            debug_assertions_std = debug_assertions_std_toml;
+            rustc_debug_assertions = rustc_debug_assertions_toml;
+            std_debug_assertions = std_debug_assertions_toml;
             overflow_checks = overflow_checks_toml;
             overflow_checks_std = overflow_checks_std_toml;
             debug_logging = debug_logging_toml;
@@ -2148,14 +2150,13 @@ impl Config {
         config.rust_std_features = std_features.unwrap_or(default_std_features);
 
         let default = debug == Some(true);
-        config.rust_debug_assertions = debug_assertions.unwrap_or(default);
-        config.rust_debug_assertions_std =
-            debug_assertions_std.unwrap_or(config.rust_debug_assertions);
+        config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default);
+        config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions);
         config.rust_overflow_checks = overflow_checks.unwrap_or(default);
         config.rust_overflow_checks_std =
             overflow_checks_std.unwrap_or(config.rust_overflow_checks);
 
-        config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions);
+        config.rust_debug_logging = debug_logging.unwrap_or(config.rustc_debug_assertions);
 
         let with_defaults = |debuginfo_level_specific: Option<_>| {
             debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) {
@@ -3075,8 +3076,8 @@ fn check_incompatible_options_for_ci_rustc(
         debug: _,
         codegen_units: _,
         codegen_units_std: _,
-        debug_assertions: _,
-        debug_assertions_std: _,
+        rustc_debug_assertions: _,
+        std_debug_assertions: _,
         overflow_checks: _,
         overflow_checks_std: _,
         debuginfo_level: _,
diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs
index 3134d25e544..980a9f7a47c 100644
--- a/src/librustdoc/scrape_examples.rs
+++ b/src/librustdoc/scrape_examples.rs
@@ -42,10 +42,16 @@ impl ScrapeExamplesOptions {
                 scrape_tests,
             }),
             (Some(_), false, _) | (None, true, _) => {
-                dcx.fatal("must use --scrape-examples-output-path and --scrape-examples-target-crate together");
+                dcx.fatal(
+                    "must use --scrape-examples-output-path and --scrape-examples-target-crate \
+                     together",
+                );
             }
             (None, false, true) => {
-                dcx.fatal("must use --scrape-examples-output-path and --scrape-examples-target-crate with --scrape-tests");
+                dcx.fatal(
+                    "must use --scrape-examples-output-path and \
+                     --scrape-examples-target-crate with --scrape-tests",
+                );
             }
             (None, false, false) => None,
         }
@@ -163,14 +169,15 @@ where
         };
 
         // If this span comes from a macro expansion, then the source code may not actually show
-        // a use of the given item, so it would be a poor example. Hence, we skip all uses in macros.
+        // a use of the given item, so it would be a poor example. Hence, we skip all uses in
+        // macros.
         if call_span.from_expansion() {
             trace!("Rejecting expr from macro: {call_span:?}");
             return;
         }
 
-        // If the enclosing item has a span coming from a proc macro, then we also don't want to include
-        // the example.
+        // If the enclosing item has a span coming from a proc macro, then we also don't want to
+        // include the example.
         let enclosing_item_span =
             tcx.hir().span_with_body(tcx.hir().get_parent_item(ex.hir_id).into());
         if enclosing_item_span.from_expansion() {
@@ -178,11 +185,12 @@ where
             return;
         }
 
-        // If the enclosing item doesn't actually enclose the call, this means we probably have a weird
-        // macro issue even though the spans aren't tagged as being from an expansion.
+        // If the enclosing item doesn't actually enclose the call, this means we probably have a
+        // weird macro issue even though the spans aren't tagged as being from an expansion.
         if !enclosing_item_span.contains(call_span) {
             warn!(
-                "Attempted to scrape call at [{call_span:?}] whose enclosing item [{enclosing_item_span:?}] doesn't contain the span of the call."
+                "Attempted to scrape call at [{call_span:?}] whose enclosing item \
+                 [{enclosing_item_span:?}] doesn't contain the span of the call."
             );
             return;
         }
@@ -190,7 +198,8 @@ where
         // Similarly for the call w/ the function ident.
         if !call_span.contains(ident_span) {
             warn!(
-                "Attempted to scrape call at [{call_span:?}] whose identifier [{ident_span:?}] was not contained in the span of the call."
+                "Attempted to scrape call at [{call_span:?}] whose identifier [{ident_span:?}] was \
+                 not contained in the span of the call."
             );
             return;
         }
@@ -224,7 +233,8 @@ where
                     Some(url) => url,
                     None => {
                         trace!(
-                            "Rejecting expr ({call_span:?}) whose clean span ({clean_span:?}) cannot be turned into a link"
+                            "Rejecting expr ({call_span:?}) whose clean span ({clean_span:?}) \
+                             cannot be turned into a link"
                         );
                         return;
                     }
@@ -272,7 +282,8 @@ pub(crate) fn run(
         let (cx, _) = Context::init(krate, renderopts, cache, tcx).map_err(|e| e.to_string())?;
 
         // Collect CrateIds corresponding to provided target crates
-        // If two different versions of the crate in the dependency tree, then examples will be collected from both.
+        // If two different versions of the crate in the dependency tree, then examples will be
+        // collected from both.
         let all_crates = tcx
             .crates(())
             .iter()
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index ecb8343fba3..e6fbba943a4 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -236,8 +236,11 @@ pub struct Config {
     /// Run ignored tests
     pub run_ignored: bool,
 
-    /// Whether to run tests with `ignore-debug` header
-    pub with_debug_assertions: bool,
+    /// Whether rustc was built with debug assertions.
+    pub with_rustc_debug_assertions: bool,
+
+    /// Whether std was built with debug assertions.
+    pub with_std_debug_assertions: bool,
 
     /// Only run tests that match these filters
     pub filters: Vec<String>,
diff --git a/src/tools/compiletest/src/directive-list.rs b/src/tools/compiletest/src/directive-list.rs
index 980b3f6829a..8570a8ce115 100644
--- a/src/tools/compiletest/src/directive-list.rs
+++ b/src/tools/compiletest/src/directive-list.rs
@@ -46,7 +46,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "ignore-coverage-map",
     "ignore-coverage-run",
     "ignore-cross-compile",
-    "ignore-debug",
     "ignore-eabi",
     "ignore-emscripten",
     "ignore-endian-big",
@@ -82,6 +81,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "ignore-powerpc",
     "ignore-remote",
     "ignore-riscv64",
+    "ignore-rustc-debug-assertions",
     "ignore-s390x",
     "ignore-sgx",
     "ignore-sparc64",
@@ -89,6 +89,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "ignore-stable",
     "ignore-stage1",
     "ignore-stage2",
+    "ignore-std-debug-assertions",
     "ignore-test",
     "ignore-thumb",
     "ignore-thumbv8m.base-none-eabi",
@@ -135,6 +136,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "needs-relocation-model-pic",
     "needs-run-enabled",
     "needs-rust-lld",
+    "needs-rustc-debug-assertions",
     "needs-sanitizer-address",
     "needs-sanitizer-cfi",
     "needs-sanitizer-dataflow",
@@ -147,6 +149,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "needs-sanitizer-shadow-call-stack",
     "needs-sanitizer-support",
     "needs-sanitizer-thread",
+    "needs-std-debug-assertions",
     "needs-symlink",
     "needs-threads",
     "needs-unwind",
diff --git a/src/tools/compiletest/src/header/cfg.rs b/src/tools/compiletest/src/header/cfg.rs
index b9314f0abbb..3ab552903dc 100644
--- a/src/tools/compiletest/src/header/cfg.rs
+++ b/src/tools/compiletest/src/header/cfg.rs
@@ -202,9 +202,14 @@ pub(super) fn parse_cfg_name_directive<'a>(
         message: "when running tests remotely",
     }
     condition! {
-        name: "debug",
-        condition: config.with_debug_assertions,
-        message: "when running tests with `ignore-debug` header",
+        name: "rustc-debug-assertions",
+        condition: config.with_rustc_debug_assertions,
+        message: "when rustc is built with debug assertions",
+    }
+    condition! {
+        name: "std-debug-assertions",
+        condition: config.with_std_debug_assertions,
+        message: "when std is built with debug assertions",
     }
     condition! {
         name: config.debugger.as_ref().map(|d| d.to_str()),
diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs
index a744fb61b9c..77570c58db5 100644
--- a/src/tools/compiletest/src/header/needs.rs
+++ b/src/tools/compiletest/src/header/needs.rs
@@ -159,6 +159,16 @@ pub(super) fn handle_needs(
             condition: cache.llvm_zstd,
             ignore_reason: "ignored if LLVM wasn't build with zstd for ELF section compression",
         },
+        Need {
+            name: "needs-rustc-debug-assertions",
+            condition: config.with_rustc_debug_assertions,
+            ignore_reason: "ignored if rustc wasn't built with debug assertions",
+        },
+        Need {
+            name: "needs-std-debug-assertions",
+            condition: config.with_std_debug_assertions,
+            ignore_reason: "ignored if std wasn't built with debug assertions",
+        },
     ];
 
     let (name, comment) = match ln.split_once([':', ' ']) {
diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs
index c79825e9e2a..c3fb8d4ab80 100644
--- a/src/tools/compiletest/src/header/tests.rs
+++ b/src/tools/compiletest/src/header/tests.rs
@@ -74,6 +74,8 @@ struct ConfigBuilder {
     git_hash: bool,
     system_llvm: bool,
     profiler_runtime: bool,
+    rustc_debug_assertions: bool,
+    std_debug_assertions: bool,
 }
 
 impl ConfigBuilder {
@@ -122,6 +124,16 @@ impl ConfigBuilder {
         self
     }
 
+    fn rustc_debug_assertions(&mut self, is_enabled: bool) -> &mut Self {
+        self.rustc_debug_assertions = is_enabled;
+        self
+    }
+
+    fn std_debug_assertions(&mut self, is_enabled: bool) -> &mut Self {
+        self.std_debug_assertions = is_enabled;
+        self
+    }
+
     fn build(&mut self) -> Config {
         let args = &[
             "compiletest",
@@ -170,6 +182,12 @@ impl ConfigBuilder {
         if self.profiler_runtime {
             args.push("--profiler-runtime".to_owned());
         }
+        if self.rustc_debug_assertions {
+            args.push("--with-rustc-debug-assertions".to_owned());
+        }
+        if self.std_debug_assertions {
+            args.push("--with-std-debug-assertions".to_owned());
+        }
 
         args.push("--rustc-path".to_string());
         // This is a subtle/fragile thing. On rust-lang CI, there is no global
@@ -315,6 +333,32 @@ fn only_target() {
 }
 
 #[test]
+fn rustc_debug_assertions() {
+    let config: Config = cfg().rustc_debug_assertions(false).build();
+
+    assert!(check_ignore(&config, "//@ needs-rustc-debug-assertions"));
+    assert!(!check_ignore(&config, "//@ ignore-rustc-debug-assertions"));
+
+    let config: Config = cfg().rustc_debug_assertions(true).build();
+
+    assert!(!check_ignore(&config, "//@ needs-rustc-debug-assertions"));
+    assert!(check_ignore(&config, "//@ ignore-rustc-debug-assertions"));
+}
+
+#[test]
+fn std_debug_assertions() {
+    let config: Config = cfg().std_debug_assertions(false).build();
+
+    assert!(check_ignore(&config, "//@ needs-std-debug-assertions"));
+    assert!(!check_ignore(&config, "//@ ignore-std-debug-assertions"));
+
+    let config: Config = cfg().std_debug_assertions(true).build();
+
+    assert!(!check_ignore(&config, "//@ needs-std-debug-assertions"));
+    assert!(check_ignore(&config, "//@ ignore-std-debug-assertions"));
+}
+
+#[test]
 fn stage() {
     let config: Config = cfg().stage_id("stage1-x86_64-unknown-linux-gnu").build();
 
diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs
index 5c06a39c477..bf4a3124075 100644
--- a/src/tools/compiletest/src/lib.rs
+++ b/src/tools/compiletest/src/lib.rs
@@ -88,7 +88,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
         .optopt("", "run", "whether to execute run-* tests", "auto | always | never")
         .optflag("", "ignored", "run tests marked as ignored")
         .optflag("", "has-enzyme", "run tests that require enzyme")
-        .optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
+        .optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
+        .optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
         .optmulti(
             "",
             "skip",
@@ -235,7 +236,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
 
     let src_base = opt_path(matches, "src-base");
     let run_ignored = matches.opt_present("ignored");
-    let with_debug_assertions = matches.opt_present("with-debug-assertions");
+    let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
+    let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions");
     let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
     let has_html_tidy = if mode == Mode::Rustdoc {
         Command::new("tidy")
@@ -293,7 +295,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
         suite: matches.opt_str("suite").unwrap(),
         debugger: None,
         run_ignored,
-        with_debug_assertions,
+        with_rustc_debug_assertions,
+        with_std_debug_assertions,
         filters,
         skip: matches.opt_strs("skip"),
         filter_exact: matches.opt_present("exact"),