From fc83c8a17858f619c8c6dd4546da7b2466748a3f Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 21 Oct 2024 10:32:23 -0700 Subject: [PATCH 1/6] ci: Enable full `debuginfo-level=2` in `DEPLOY_ALT` It will be slower to build and produce larger artifacts, but hopefully it will help catch debuginfo regressions sooner, especially for problems that LLVM assertions would uncover. --- src/ci/run.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ci/run.sh b/src/ci/run.sh index 9f39ad9c55c54..fe8fd448e6d22 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -115,7 +115,12 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNE if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo" - RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1" + + if [ "$DEPLOY_ALT" != "" ]; then + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level=2" + else + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1" + fi if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" From 61013f040e6e3e91b012791d2b77a9d3e47e390b Mon Sep 17 00:00:00 2001 From: Jakob Koschel Date: Fri, 8 Nov 2024 13:24:54 +0000 Subject: [PATCH 2/6] PassWrapper: disable UseOdrIndicator for Asan Win32 As described here UseOdrIndicator should be disabled on Windows since link.exe does not support duplicate weak definitions (https://reviews.llvm.org/D137227). Co-Authored-By: Bastian Kersting --- .../rustc_llvm/llvm-wrapper/PassWrapper.cpp | 15 +++++++++++---- tests/ui/asan-odr-win/asan_odr_windows.rs | 18 ++++++++++++++++++ .../asan-odr-win/auxiliary/asan_odr_win-2.rs | 11 +++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 tests/ui/asan-odr-win/asan_odr_windows.rs create mode 100644 tests/ui/asan-odr-win/auxiliary/asan_odr_win-2.rs diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 1ed702ab4cbd2..489c911d7eedd 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -882,10 +882,12 @@ extern "C" LLVMRustResult LLVMRustOptimize( SanitizerOptions->SanitizeKernelAddress) { OptimizerLastEPCallbacks.push_back( #if LLVM_VERSION_GE(20, 0) - [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level, - ThinOrFullLTOPhase phase) { + [SanitizerOptions, TM](ModulePassManager &MPM, + OptimizationLevel Level, + ThinOrFullLTOPhase phase) { #else - [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) { + [SanitizerOptions, TM](ModulePassManager &MPM, + OptimizationLevel Level) { #endif auto CompileKernel = SanitizerOptions->SanitizeKernelAddress; AddressSanitizerOptions opts = AddressSanitizerOptions{ @@ -895,7 +897,12 @@ extern "C" LLVMRustResult LLVMRustOptimize( /*UseAfterScope=*/true, AsanDetectStackUseAfterReturnMode::Runtime, }; - MPM.addPass(AddressSanitizerPass(opts)); + MPM.addPass(AddressSanitizerPass( + opts, + /*UseGlobalGC*/ true, + // UseOdrIndicator should be false on windows machines + // https://reviews.llvm.org/D137227 + !TM->getTargetTriple().isOSWindows())); }); } if (SanitizerOptions->SanitizeHWAddress) { diff --git a/tests/ui/asan-odr-win/asan_odr_windows.rs b/tests/ui/asan-odr-win/asan_odr_windows.rs new file mode 100644 index 0000000000000..c618ac02a66d8 --- /dev/null +++ b/tests/ui/asan-odr-win/asan_odr_windows.rs @@ -0,0 +1,18 @@ +//! Check that crates can be linked together with `-Z sanitizer=address` on msvc. +//! See . + +//@ run-pass +//@ compile-flags:-Zsanitizer=address +//@ aux-build: asan_odr_win-2.rs +//@ only-windows-msvc + +extern crate othercrate; + +fn main() { + let result = std::panic::catch_unwind(|| { + println!("hello!"); + }); + assert!(result.is_ok()); + + othercrate::exposed_func(); +} diff --git a/tests/ui/asan-odr-win/auxiliary/asan_odr_win-2.rs b/tests/ui/asan-odr-win/auxiliary/asan_odr_win-2.rs new file mode 100644 index 0000000000000..75488a29e5e0d --- /dev/null +++ b/tests/ui/asan-odr-win/auxiliary/asan_odr_win-2.rs @@ -0,0 +1,11 @@ +//@ no-prefer-dynamic +//@ compile-flags: -Z sanitizer=address +#![crate_name = "othercrate"] +#![crate_type = "rlib"] + +pub fn exposed_func() { + let result = std::panic::catch_unwind(|| { + println!("hello!"); + }); + assert!(result.is_ok()); +} From 73c6494f7ad5da5c0548f5e0efe3c265bb7da641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 13 Nov 2024 22:33:45 +0100 Subject: [PATCH 3/6] compiletest: known-bug / crashes: allow for an "auxiliary" directory to contain files that do not have a "known-bug" directive Fixes #133009 --- src/tools/tidy/src/known_bug.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/known_bug.rs b/src/tools/tidy/src/known_bug.rs index 182a81c6ec9ef..a877165414400 100644 --- a/src/tools/tidy/src/known_bug.rs +++ b/src/tools/tidy/src/known_bug.rs @@ -6,8 +6,22 @@ use crate::walk::*; pub fn check(filepath: &Path, bad: &mut bool) { walk(filepath, |path, _is_dir| filter_not_rust(path), &mut |entry, contents| { - let file = entry.path(); - if !contents.lines().any(|line| line.starts_with("//@ known-bug: ")) { + let file: &Path = entry.path(); + + // files in "auxiliary" do not need to crash by themselves + let test_path_segments = + file.iter().map(|s| s.to_string_lossy().into()).collect::>(); + let test_path_segments_str = + test_path_segments.iter().map(|s| s.as_str()).collect::>(); + + if !matches!(test_path_segments_str[..], [ + .., + "tests", + "crashes", + "auxiliary", + _aux_file_rs + ]) && !contents.lines().any(|line| line.starts_with("//@ known-bug: ")) + { tidy_error!( bad, "{} crash/ice test does not have a \"//@ known-bug: \" directive", From 79e2af285a23d29e362870689cc47e26a57d5074 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 14 Nov 2024 14:50:30 +0800 Subject: [PATCH 4/6] Fix a copy-paste issue in the NuttX raw type definition This file is copied from the rtems as initial implementation, and forgot to change the OS name in the comment. Signed-off-by: Huang Qi --- library/std/src/os/nuttx/raw.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/os/nuttx/raw.rs b/library/std/src/os/nuttx/raw.rs index 113079cf4abdc..431e66d69a372 100644 --- a/library/std/src/os/nuttx/raw.rs +++ b/library/std/src/os/nuttx/raw.rs @@ -1,4 +1,4 @@ -//! rtems raw type definitions +//! NuttX raw type definitions #![stable(feature = "raw_ext", since = "1.1.0")] #![deprecated( From 7eee9faea1e5dd7b836027bbfcd9cf106ad88f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:55:31 +0800 Subject: [PATCH 5/6] compiletest: add `max-llvm-major-version` directive There's already `min-llvm-version`, and contributors were using `ignore-llvm-version: 20 - 99` to emulate `max-llvm-major-version: 19`. --- src/tools/compiletest/src/directive-list.rs | 1 + src/tools/compiletest/src/header.rs | 14 ++++++++++++++ src/tools/compiletest/src/header/tests.rs | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/src/tools/compiletest/src/directive-list.rs b/src/tools/compiletest/src/directive-list.rs index 038de9036bf98..bdd0b80b3957c 100644 --- a/src/tools/compiletest/src/directive-list.rs +++ b/src/tools/compiletest/src/directive-list.rs @@ -120,6 +120,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "incremental", "known-bug", "llvm-cov-flags", + "max-llvm-major-version", "min-cdb-version", "min-gdb-version", "min-lldb-version", diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 0e81f675474aa..3539e85ba632b 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1546,6 +1546,20 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision { ), }; } + } else if let Some(version_string) = + config.parse_name_value_directive(line, "max-llvm-major-version") + { + let max_version = extract_llvm_version(&version_string); + // Ignore if actual major version is larger than the maximum required major version. + if actual_version.major > max_version.major { + return IgnoreDecision::Ignore { + reason: format!( + "ignored when the LLVM version ({actual_version}) is newer than major\ + version {}", + max_version.major + ), + }; + } } else if let Some(version_string) = config.parse_name_value_directive(line, "min-system-llvm-version") { diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 6c52a1b950782..4d75c38dd3206 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -299,6 +299,15 @@ fn llvm_version() { let config: Config = cfg().llvm_version("10.6.2").build(); assert!(!check_ignore(&config, "//@ exact-llvm-major-version: 10")); + + let config: Config = cfg().llvm_version("19.0.0").build(); + assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19")); + + let config: Config = cfg().llvm_version("19.1.2").build(); + assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19")); + + let config: Config = cfg().llvm_version("20.0.0").build(); + assert!(check_ignore(&config, "//@ max-llvm-major-version: 19")); } #[test] From 91fa16b211957f6d56bd2ec697c36b2301f2690a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:14:34 +0800 Subject: [PATCH 6/6] tests: use `max-llvm-major-version` instead of `ignore-llvm-version` range like `N - 99` For tests that use `ignore-llvm-version: N - M`, replace that with `max-llvm-major-version: N-1`. --- tests/assembly/riscv-soft-abi-with-float-features.rs | 2 +- tests/assembly/x86_64-cmp.rs | 2 +- tests/codegen/branch-protection-old-llvm.rs | 2 +- tests/codegen/call-metadata.rs | 2 +- tests/codegen/integer-cmp.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/assembly/riscv-soft-abi-with-float-features.rs b/tests/assembly/riscv-soft-abi-with-float-features.rs index 6d6001af0845d..8ccfa72a7b6f1 100644 --- a/tests/assembly/riscv-soft-abi-with-float-features.rs +++ b/tests/assembly/riscv-soft-abi-with-float-features.rs @@ -2,7 +2,7 @@ //@ compile-flags: --target riscv64imac-unknown-none-elf -Ctarget-feature=+f,+d //@ needs-llvm-components: riscv //@ revisions: LLVM-PRE-20 LLVM-POST-20 -//@ [LLVM-PRE-20] ignore-llvm-version: 20 - 99 +//@ [LLVM-PRE-20] max-llvm-major-version: 19 //@ [LLVM-POST-20] min-llvm-version: 20 #![feature(no_core, lang_items, f16)] diff --git a/tests/assembly/x86_64-cmp.rs b/tests/assembly/x86_64-cmp.rs index 67b7ff99ae2d9..8cccab7d40dab 100644 --- a/tests/assembly/x86_64-cmp.rs +++ b/tests/assembly/x86_64-cmp.rs @@ -1,7 +1,7 @@ //@ revisions: DEBUG LLVM-PRE-20-OPTIM LLVM-20-OPTIM //@ [DEBUG] compile-flags: -C opt-level=0 //@ [LLVM-PRE-20-OPTIM] compile-flags: -C opt-level=3 -//@ [LLVM-PRE-20-OPTIM] ignore-llvm-version: 20 - 99 +//@ [LLVM-PRE-20-OPTIM] max-llvm-major-version: 19 //@ [LLVM-20-OPTIM] compile-flags: -C opt-level=3 //@ [LLVM-20-OPTIM] min-llvm-version: 20 //@ assembly-output: emit-asm diff --git a/tests/codegen/branch-protection-old-llvm.rs b/tests/codegen/branch-protection-old-llvm.rs index bb3c7a4b70c3c..1846f35479db4 100644 --- a/tests/codegen/branch-protection-old-llvm.rs +++ b/tests/codegen/branch-protection-old-llvm.rs @@ -7,7 +7,7 @@ //@ [LEAF] compile-flags: -Z branch-protection=pac-ret,leaf //@ [BKEY] compile-flags: -Z branch-protection=pac-ret,b-key //@ compile-flags: --target aarch64-unknown-linux-gnu -//@ ignore-llvm-version: 19 - 99 +//@ max-llvm-major-version: 18 #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/call-metadata.rs b/tests/codegen/call-metadata.rs index 73c4b33e2cfb7..b986b4467face 100644 --- a/tests/codegen/call-metadata.rs +++ b/tests/codegen/call-metadata.rs @@ -2,7 +2,7 @@ // scalar value. //@ compile-flags: -O -C no-prepopulate-passes -//@ ignore-llvm-version: 19 - 99 +//@ max-llvm-major-version: 18 #![crate_type = "lib"] diff --git a/tests/codegen/integer-cmp.rs b/tests/codegen/integer-cmp.rs index 8df68d8d4906e..9bbf243946d1a 100644 --- a/tests/codegen/integer-cmp.rs +++ b/tests/codegen/integer-cmp.rs @@ -3,7 +3,7 @@ //@ revisions: llvm-pre-20 llvm-20 //@ [llvm-20] min-llvm-version: 20 -//@ [llvm-pre-20] ignore-llvm-version: 20 - 99 +//@ [llvm-pre-20] max-llvm-major-version: 19 //@ compile-flags: -C opt-level=3 #![crate_type = "lib"]