Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions library/std/src/sys/pal/unix/sync/condvar.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use super::Mutex;
use crate::cell::UnsafeCell;
use crate::pin::Pin;
#[cfg(not(target_os = "nto"))]
use crate::sys::pal::time::TIMESPEC_MAX;
#[cfg(target_os = "nto")]
use crate::sys::pal::time::TIMESPEC_MAX_CAPPED;
use crate::time::Duration;

pub struct Condvar {
Expand Down Expand Up @@ -51,10 +55,6 @@ impl Condvar {
/// * `mutex` must be locked by the current thread.
/// * This condition variable may only be used with the same mutex.
pub unsafe fn wait_timeout(&self, mutex: Pin<&Mutex>, dur: Duration) -> bool {
#[cfg(not(target_os = "nto"))]
use crate::sys::pal::time::TIMESPEC_MAX;
#[cfg(target_os = "nto")]
use crate::sys::pal::time::TIMESPEC_MAX_CAPPED;
use crate::sys::pal::time::Timespec;

let mutex = mutex.raw();
Expand Down Expand Up @@ -118,10 +118,12 @@ impl Condvar {

let (dur, clamped) = if dur <= MAX_DURATION { (dur, false) } else { (MAX_DURATION, true) };

let timeout = libc::timespec {
// This cannot overflow because of the clamping above.
tv_sec: dur.as_secs() as i64,
tv_nsec: dur.subsec_nanos() as i64,
// This can overflow on 32-bit platforms, but not on 64-bit because of the clamping above.
let timeout = if let Ok(tv_sec) = dur.as_secs().try_into() {
libc::timespec { tv_sec, tv_nsec: dur.subsec_nanos() as _ }
} else {
// This is less than `MAX_DURATION` on 32-bit platforms.
TIMESPEC_MAX
};

let r = unsafe { libc::pthread_cond_timedwait_relative_np(self.raw(), mutex, &timeout) };
Expand Down
6 changes: 4 additions & 2 deletions src/doc/rustc-dev-guide/src/tests/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ Some examples of `X` in `ignore-X` or `only-X`:
The following directives will check rustc build settings and target
settings:

- `needs-asm-support` — ignores if it is running on a target that doesn't have
stable support for `asm!`
- `needs-asm-support` — ignores if the **host** architecture doesn't have
stable support for `asm!`. For tests that cross-compile to explicit targets
via `--target`, use `needs-llvm-components` instead to ensure the appropriate
backend is available.
- `needs-profiler-runtime` — ignores the test if the profiler runtime was not
enabled for the target
(`build.profiler = true` in rustc's `bootstrap.toml`)
Expand Down
3 changes: 0 additions & 3 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,6 @@ impl CreateRunnableDocTests {
.span(scraped_test.span)
.build(dcx);
let is_standalone = !doctest.can_be_merged
|| scraped_test.langstr.compile_fail
|| scraped_test.langstr.test_harness
|| scraped_test.langstr.standalone_crate
|| self.rustdoc_options.nocapture
|| self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output");
if is_standalone {
Expand Down
72 changes: 61 additions & 11 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,19 @@ pub struct Config {

/// Path to libraries needed to run the *staged* `rustc`-under-test on the **host** platform.
///
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/bin/lib`
///
/// FIXME: maybe rename this to reflect (1) which target platform (host, not target), and (2)
/// which `rustc` (the `rustc`-under-test, not the stage 0 `rustc` unless forced).
pub compile_lib_path: Utf8PathBuf,

/// Path to libraries needed to run the compiled executable for the **target** platform. This
/// corresponds to the **target** sysroot libraries, including the **target** standard library.
///
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib`
///
/// FIXME: maybe rename this to reflect (1) which target platform (target, not host), and (2)
/// what "run libraries" are against.
///
Expand All @@ -266,6 +272,9 @@ pub struct Config {
/// Path to the *staged* `rustc`-under-test. Unless forced, this `rustc` is *staged*, and must
/// not be confused with [`Self::stage0_rustc_path`].
///
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc`
///
/// FIXME: maybe rename this to reflect that this is the `rustc`-under-test.
pub rustc_path: Utf8PathBuf,

Expand All @@ -274,11 +283,17 @@ pub struct Config {
/// *not* used to compile the test recipes), and so must be staged as there may be differences
/// between e.g. beta `cargo` vs in-tree `cargo`.
///
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1-tools-bin/cargo`
///
/// FIXME: maybe rename this to reflect that this is a *staged* host cargo.
pub cargo_path: Option<Utf8PathBuf>,

/// Path to the stage 0 `rustc` used to build `run-make` recipes. This must not be confused with
/// [`Self::rustc_path`].
///
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage0/bin/rustc`
pub stage0_rustc_path: Option<Utf8PathBuf>,

/// Path to the stage 1 or higher `rustc` used to obtain target information via
Expand Down Expand Up @@ -312,6 +327,9 @@ pub struct Config {
pub llvm_filecheck: Option<Utf8PathBuf>,

/// Path to a host LLVM bintools directory.
///
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/llvm/bin`
pub llvm_bin_dir: Option<Utf8PathBuf>,

/// The path to the **target** `clang` executable to run `clang`-based tests with. If `None`,
Expand All @@ -321,28 +339,39 @@ pub struct Config {
/// Path to the directory containing the sources. This corresponds to the root folder of a
/// `rust-lang/rust` checkout.
///
/// For example:
/// - `/home/ferris/rust`
///
/// FIXME: this name is confusing, because this is actually `$checkout_root`, **not** the
/// `$checkout_root/src/` folder.
pub src_root: Utf8PathBuf,

/// Path to the directory containing the test suites sources. This corresponds to the
/// `$src_root/tests/` folder.
///
/// Must be an immediate subdirectory of [`Self::src_root`].
/// Absolute path to the test suite directory.
///
/// FIXME: this name is also confusing, maybe just call it `tests_root`.
/// For example:
/// - `/home/ferris/rust/tests/ui`
/// - `/home/ferris/rust/tests/coverage`
pub src_test_suite_root: Utf8PathBuf,

/// Path to the build directory (e.g. `build/`).
/// Path to the top-level build directory used by bootstrap.
///
/// For example:
/// - `/home/ferris/rust/build`
pub build_root: Utf8PathBuf,

/// Path to the test suite specific build directory (e.g. `build/host/test/ui/`).
/// Path to the build directory used by the current test suite.
///
/// Must be a subdirectory of [`Self::build_root`].
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/test/ui`
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/test/coverage`
pub build_test_suite_root: Utf8PathBuf,

/// Path to the directory containing the sysroot of the `rustc`-under-test.
///
/// For example:
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1`
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage2`
///
/// When stage 0 is forced, this will correspond to the sysroot *of* that specified stage 0
/// `rustc`.
///
Expand Down Expand Up @@ -1075,10 +1104,31 @@ fn query_rustc_output(config: &Config, args: &[&str], envs: HashMap<String, Stri
String::from_utf8(output.stdout).unwrap()
}

/// Path information for a single test file.
#[derive(Debug, Clone)]
pub struct TestPaths {
pub file: Utf8PathBuf, // e.g., compile-test/foo/bar/baz.rs
pub relative_dir: Utf8PathBuf, // e.g., foo/bar
pub(crate) struct TestPaths {
/// Full path to the test file.
///
/// For example:
/// - `/home/ferris/rust/tests/ui/warnings/hello-world.rs`
///
/// ---
///
/// For `run-make` tests, this path is the _directory_ that contains
/// `rmake.rs`.
///
/// For example:
/// - `/home/ferris/rust/tests/run-make/emit`
pub(crate) file: Utf8PathBuf,

/// Subset of the full path that excludes the suite directory and the
/// test filename. For tests in the root of their test suite directory,
/// this is blank.
///
/// For example:
/// - `file`: `/home/ferris/rust/tests/ui/warnings/hello-world.rs`
/// - `relative_dir`: `warnings`
pub(crate) relative_dir: Utf8PathBuf,
}

/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/aarch64/arm64ec-sve.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ add-core-stubs
//@ compile-flags: --target arm64ec-pc-windows-msvc
//@ needs-asm-support
//@ needs-llvm-components: aarch64
//@ ignore-backends: gcc

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/asm/aarch64/arm64ec-sve.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: cannot use register `p0`: x13, x14, x23, x24, x28, v16-v31, p*, ffr cannot be used for Arm64EC
--> $DIR/arm64ec-sve.rs:19:18
--> $DIR/arm64ec-sve.rs:18:18
|
LL | asm!("", out("p0") _);
| ^^^^^^^^^^^

error: cannot use register `ffr`: x13, x14, x23, x24, x28, v16-v31, p*, ffr cannot be used for Arm64EC
--> $DIR/arm64ec-sve.rs:21:18
--> $DIR/arm64ec-sve.rs:20:18
|
LL | asm!("", out("ffr") _);
| ^^^^^^^^^^^^
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/asm/inline-syntax.arm.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LL | .intel_syntax noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:22:15
--> $DIR/inline-syntax.rs:21:15
|
LL | asm!(".intel_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -27,7 +27,7 @@ LL | .intel_syntax noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:25:15
--> $DIR/inline-syntax.rs:24:15
|
LL | asm!(".intel_syntax aaa noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -39,7 +39,7 @@ LL | .intel_syntax aaa noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:28:15
--> $DIR/inline-syntax.rs:27:15
|
LL | asm!(".att_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^
Expand All @@ -51,7 +51,7 @@ LL | .att_syntax noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:31:15
--> $DIR/inline-syntax.rs:30:15
|
LL | asm!(".att_syntax bbb noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -63,7 +63,7 @@ LL | .att_syntax bbb noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:34:15
--> $DIR/inline-syntax.rs:33:15
|
LL | asm!(".intel_syntax noprefix; nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -75,7 +75,7 @@ LL | .intel_syntax noprefix; nop
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:40:13
--> $DIR/inline-syntax.rs:39:13
|
LL | .intel_syntax noprefix
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/inline-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//@[arm] compile-flags: --target armv7-unknown-linux-gnueabihf
//@[arm] build-fail
//@[arm] needs-llvm-components: arm
//@ needs-asm-support
//@ ignore-backends: gcc

#![feature(no_core)]
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/asm/inline-syntax.x86_64.stderr
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:48:14
--> $DIR/inline-syntax.rs:47:14
|
LL | global_asm!(".intel_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(bad_asm_style)]` on by default

warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:22:15
--> $DIR/inline-syntax.rs:21:15
|
LL | asm!(".intel_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^

warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:25:15
--> $DIR/inline-syntax.rs:24:15
|
LL | asm!(".intel_syntax aaa noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
--> $DIR/inline-syntax.rs:28:15
--> $DIR/inline-syntax.rs:27:15
|
LL | asm!(".att_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^

warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
--> $DIR/inline-syntax.rs:31:15
--> $DIR/inline-syntax.rs:30:15
|
LL | asm!(".att_syntax bbb noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^

warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:34:15
--> $DIR/inline-syntax.rs:33:15
|
LL | asm!(".intel_syntax noprefix; nop");
| ^^^^^^^^^^^^^^^^^^^^^^

warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:40:13
--> $DIR/inline-syntax.rs:39:13
|
LL | .intel_syntax noprefix
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/issue-92378.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ add-core-stubs
//@ compile-flags: --target armv5te-unknown-linux-gnueabi
//@ needs-llvm-components: arm
//@ needs-asm-support
//@ build-pass
//@ ignore-backends: gcc

Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/issue-99071.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ add-core-stubs
//@ compile-flags: --target thumbv6m-none-eabi
//@ needs-llvm-components: arm
//@ needs-asm-support
//@ ignore-backends: gcc

#![feature(no_core)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/asm/issue-99071.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: cannot use register `r8`: high registers (r8+) can only be used as clobbers in Thumb-1 code
--> $DIR/issue-99071.rs:16:18
--> $DIR/issue-99071.rs:15:18
|
LL | asm!("", in("r8") 0);
| ^^^^^^^^^^
Expand Down
Loading
Loading