diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs
index de198115fa00b..cf1d5c68eadd0 100644
--- a/compiler/rustc_builtin_macros/src/cfg.rs
+++ b/compiler/rustc_builtin_macros/src/cfg.rs
@@ -43,7 +43,7 @@ fn parse_cfg<'a>(cx: &ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a,
         return Err(cx.dcx().create_err(errors::RequiresCfgPattern { span }));
     }
 
-    let cfg = p.parse_meta_item(AllowLeadingUnsafe::Yes)?;
+    let cfg = p.parse_meta_item(AllowLeadingUnsafe::No)?;
 
     let _ = p.eat(&token::Comma);
 
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs
index 3b8077bb3fcee..bd38b3c109a41 100644
--- a/compiler/rustc_interface/src/interface.rs
+++ b/compiler/rustc_interface/src/interface.rs
@@ -174,7 +174,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
             }
         };
 
-        let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::Yes) {
+        let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) {
             Ok(meta_item) if parser.token == token::Eof => meta_item,
             Ok(..) => expected_error(),
             Err(err) => {
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index eaa982d4e2bbd..bb1d8d279288d 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -1053,10 +1053,6 @@ pub fn rustc_cargo(
 
     cargo.rustdocflag("-Zcrate-attr=warn(rust_2018_idioms)");
 
-    // If the rustc output is piped to e.g. `head -n1` we want the process to be
-    // killed, rather than having an error bubble up and cause a panic.
-    cargo.rustflag("-Zon-broken-pipe=kill");
-
     if builder.config.llvm_enzyme {
         cargo.rustflag("-l").rustflag("Enzyme-19");
     }
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs
index 64dfe054d9c77..fa2c1b8360f4c 100644
--- a/src/bootstrap/src/core/build_steps/tool.rs
+++ b/src/bootstrap/src/core/build_steps/tool.rs
@@ -200,6 +200,10 @@ pub fn prepare_tool_cargo(
         cargo.arg("--features").arg(features.join(", "));
     }
 
+    // Warning: be very careful with RUSTFLAGS or command-line options, as conditionally applied
+    // RUSTFLAGS or cli flags can lead to hard-to-diagnose rebuilds due to flag differences, causing
+    // previous tool build artifacts to get invalidated.
+
     // Enable internal lints for clippy and rustdoc
     // NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]`
     // See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776
@@ -209,13 +213,6 @@ pub fn prepare_tool_cargo(
     // See https://github.com/rust-lang/rust/issues/116538
     cargo.rustflag("-Zunstable-options");
 
-    // `-Zon-broken-pipe=kill` breaks cargo tests
-    if !path.ends_with("cargo") {
-        // If the output is piped to e.g. `head -n1` we want the process to be killed,
-        // rather than having an error bubble up and cause a panic.
-        cargo.rustflag("-Zon-broken-pipe=kill");
-    }
-
     cargo
 }
 
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
index 6ba669f3b1034..77cfd40474488 100644
--- a/src/bootstrap/src/core/builder.rs
+++ b/src/bootstrap/src/core/builder.rs
@@ -1564,8 +1564,8 @@ impl<'a> Builder<'a> {
         let libdir = self.rustc_libdir(compiler);
 
         let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8");
-        if !matches!(self.config.dry_run, DryRun::SelfCheck) {
-            self.verbose_than(0, || println!("using sysroot {sysroot_str}"));
+        if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) {
+            println!("using sysroot {sysroot_str}");
         }
 
         let mut rustflags = Rustflags::new(target);
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 3c0afb858f852..07460b81412ac 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -2450,7 +2450,7 @@ impl Config {
 
     /// Runs a function if verbosity is greater than 0
     pub fn verbose(&self, f: impl Fn()) {
-        if self.verbose > 0 {
+        if self.is_verbose() {
             f()
         }
     }
@@ -2735,7 +2735,7 @@ impl Config {
         .success();
         if has_changes {
             if if_unchanged {
-                if self.verbose > 0 {
+                if self.is_verbose() {
                     println!(
                         "WARNING: saw changes to compiler/ or library/ since {commit}; \
                             ignoring `download-rustc`"
@@ -2832,7 +2832,7 @@ impl Config {
         let has_changes = !t!(git.as_command_mut().status()).success();
         if has_changes {
             if if_unchanged {
-                if self.verbose > 0 {
+                if self.is_verbose() {
                     println!(
                         "warning: saw changes to one of {modified_paths:?} since {commit}; \
                             ignoring `{option_name}`"
diff --git a/tests/ui/asm/aarch64/type-check-4.rs b/tests/ui/asm/aarch64/type-check-4.rs
deleted file mode 100644
index c24567bd5b002..0000000000000
--- a/tests/ui/asm/aarch64/type-check-4.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-//@ only-aarch64
-//@ build-fail
-
-use std::arch::global_asm;
-
-fn main() {}
-
-// Constants must be... constant
-
-static mut S: i32 = 1;
-const fn const_foo(x: i32) -> i32 {
-    x
-}
-const fn const_bar<T>(x: T) -> T {
-    x
-}
-global_asm!("{}", const unsafe { S });
-//~^ ERROR: evaluation of constant value failed
-//~| mutable global memory
-global_asm!("{}", const const_foo(0));
-global_asm!("{}", const const_foo(unsafe { S }));
-//~^ ERROR: evaluation of constant value failed
-//~| mutable global memory
-global_asm!("{}", const const_bar(0));
-global_asm!("{}", const const_bar(unsafe { S }));
-//~^ ERROR: evaluation of constant value failed
-//~| mutable global memory
diff --git a/tests/ui/asm/aarch64/type-check-4.stderr b/tests/ui/asm/aarch64/type-check-4.stderr
deleted file mode 100644
index 8c22dfcdb5ed6..0000000000000
--- a/tests/ui/asm/aarch64/type-check-4.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0080]: evaluation of constant value failed
-  --> $DIR/type-check-4.rs:17:34
-   |
-LL | global_asm!("{}", const unsafe { S });
-   |                                  ^ constant accesses mutable global memory
-
-error[E0080]: evaluation of constant value failed
-  --> $DIR/type-check-4.rs:21:44
-   |
-LL | global_asm!("{}", const const_foo(unsafe { S }));
-   |                                            ^ constant accesses mutable global memory
-
-error[E0080]: evaluation of constant value failed
-  --> $DIR/type-check-4.rs:25:44
-   |
-LL | global_asm!("{}", const const_bar(unsafe { S }));
-   |                                            ^ constant accesses mutable global memory
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/asm/non-const.rs b/tests/ui/asm/non-const.rs
new file mode 100644
index 0000000000000..63c4656322610
--- /dev/null
+++ b/tests/ui/asm/non-const.rs
@@ -0,0 +1,11 @@
+//@ needs-asm-support
+
+use std::arch::global_asm;
+
+fn main() {}
+
+// Constants must be... constant
+fn non_const_fn(x: i32) -> i32 { x }
+
+global_asm!("/* {} */", const non_const_fn(0));
+//~^ERROR: cannot call non-const fn
diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr
new file mode 100644
index 0000000000000..5fae2ac984378
--- /dev/null
+++ b/tests/ui/asm/non-const.stderr
@@ -0,0 +1,11 @@
+error[E0015]: cannot call non-const fn `non_const_fn` in constants
+  --> $DIR/non-const.rs:10:31
+   |
+LL | global_asm!("/* {} */", const non_const_fn(0));
+   |                               ^^^^^^^^^^^^^^^
+   |
+   = note: calls in constants are limited to constant functions, tuple structs and tuple variants
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0015`.
diff --git a/tests/ui/asm/x86_64/type-check-4.rs b/tests/ui/asm/x86_64/type-check-4.rs
deleted file mode 100644
index ebc6edc07e4cd..0000000000000
--- a/tests/ui/asm/x86_64/type-check-4.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-//@ only-x86_64
-//@ build-fail
-
-use std::arch::global_asm;
-
-fn main() {}
-
-// Constants must be... constant
-
-static mut S: i32 = 1;
-const fn const_foo(x: i32) -> i32 {
-    x
-}
-const fn const_bar<T>(x: T) -> T {
-    x
-}
-global_asm!("{}", const unsafe { S });
-//~^ ERROR evaluation of constant value failed
-//~| mutable global memory
-global_asm!("{}", const const_foo(0));
-global_asm!("{}", const const_foo(unsafe { S }));
-//~^ ERROR evaluation of constant value failed
-//~| mutable global memory
-global_asm!("{}", const const_bar(0));
-global_asm!("{}", const const_bar(unsafe { S }));
-//~^ ERROR evaluation of constant value failed
-//~| mutable global memory
diff --git a/tests/ui/asm/x86_64/type-check-4.stderr b/tests/ui/asm/x86_64/type-check-4.stderr
deleted file mode 100644
index 8c22dfcdb5ed6..0000000000000
--- a/tests/ui/asm/x86_64/type-check-4.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0080]: evaluation of constant value failed
-  --> $DIR/type-check-4.rs:17:34
-   |
-LL | global_asm!("{}", const unsafe { S });
-   |                                  ^ constant accesses mutable global memory
-
-error[E0080]: evaluation of constant value failed
-  --> $DIR/type-check-4.rs:21:44
-   |
-LL | global_asm!("{}", const const_foo(unsafe { S }));
-   |                                            ^ constant accesses mutable global memory
-
-error[E0080]: evaluation of constant value failed
-  --> $DIR/type-check-4.rs:25:44
-   |
-LL | global_asm!("{}", const const_bar(unsafe { S }));
-   |                                            ^ constant accesses mutable global memory
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs
index b561550c19843..273b127bf9cb4 100644
--- a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs
+++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs
@@ -27,4 +27,8 @@ mod inner {
 #[unsafe(used)] //~ ERROR: is not an unsafe attribute
 static FOO: usize = 0;
 
-fn main() {}
+fn main() {
+    let _a = cfg!(unsafe(foo));
+    //~^ ERROR: expected identifier, found keyword `unsafe`
+    //~^^ ERROR: invalid predicate `r#unsafe`
+}
diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr
index 9fb7f062b912b..445d239d86729 100644
--- a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr
+++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr
@@ -22,6 +22,23 @@ LL | #[unsafe(test)]
    |
    = note: extraneous unsafe is not allowed in attributes
 
+error: expected identifier, found keyword `unsafe`
+  --> $DIR/extraneous-unsafe-attributes.rs:31:19
+   |
+LL |     let _a = cfg!(unsafe(foo));
+   |                   ^^^^^^ expected identifier, found keyword
+   |
+help: escape `unsafe` to use it as an identifier
+   |
+LL |     let _a = cfg!(r#unsafe(foo));
+   |                   ++
+
+error[E0537]: invalid predicate `r#unsafe`
+  --> $DIR/extraneous-unsafe-attributes.rs:31:19
+   |
+LL |     let _a = cfg!(unsafe(foo));
+   |                   ^^^^^^^^^^^
+
 error: `ignore` is not an unsafe attribute
   --> $DIR/extraneous-unsafe-attributes.rs:13:3
    |
@@ -62,5 +79,6 @@ LL | #[unsafe(used)]
    |
    = note: extraneous unsafe is not allowed in attributes
 
-error: aborting due to 8 previous errors
+error: aborting due to 10 previous errors
 
+For more information about this error, try `rustc --explain E0537`.
diff --git a/tests/ui/check-cfg/invalid-arguments.rs b/tests/ui/check-cfg/invalid-arguments.rs
index b8588ecb4ff68..c6b1218ce27c9 100644
--- a/tests/ui/check-cfg/invalid-arguments.rs
+++ b/tests/ui/check-cfg/invalid-arguments.rs
@@ -8,7 +8,7 @@
 //@ revisions: values_any_missing_values values_any_before_ident ident_in_values_1
 //@ revisions: ident_in_values_2 unknown_meta_item_1 unknown_meta_item_2 unknown_meta_item_3
 //@ revisions: mixed_values_any mixed_any any_values giberich unterminated
-//@ revisions: none_not_empty cfg_none
+//@ revisions: none_not_empty cfg_none unsafe_attr
 //
 //@ [anything_else]compile-flags: --check-cfg=anything_else(...)
 //@ [boolean]compile-flags: --check-cfg=cfg(true)
@@ -33,5 +33,6 @@
 //@ [cfg_none]compile-flags: --check-cfg=cfg(none())
 //@ [giberich]compile-flags: --check-cfg=cfg(...)
 //@ [unterminated]compile-flags: --check-cfg=cfg(
+//@ [unsafe_attr]compile-flags: --check-cfg=unsafe(cfg(foo))
 
 fn main() {}
diff --git a/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr b/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr
new file mode 100644
index 0000000000000..5236ed6f60547
--- /dev/null
+++ b/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr
@@ -0,0 +1,5 @@
+error: invalid `--check-cfg` argument: `unsafe(cfg(foo))`
+   |
+   = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
+   = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
+