Fix non-associativity of Instant math on aarch64-apple-darwin targets#103594
Fix non-associativity of Instant math on aarch64-apple-darwin targets#103594bors merged 3 commits intorust-lang:masterfrom maniwani:fix-issue-91417
Instant math on aarch64-apple-darwin targets#103594Conversation
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. Please see the contribution instructions for more information. |
|
I have a good amount of familiarity with these targets (and can test on a fairly wide range of them), so I'd like to take this. I'm a little hesitant about this change, but the current situation is admittedly fairly undesirable. I'll probably get to the review this weekend. r? thomcc |
|
This doesn't compile on aarch64-apple-darwin. @rustbot author |
|
I think the problem is the type alias used here. rust/library/std/src/sys/unix/time.rs Lines 315 to 318 in e4d6307 Is there any reason to even have these? |
|
If it's in libc on every platform there's no reason to have it in std::sys |
This comment has been minimized.
This comment has been minimized.
|
Hmm, it seems that miri doesn't emulate |
|
This looks good to me. Seems to work on M1 too. @bors r+ (Also, I like your username and avatar) |
|
Ah, wait, this is failing. I forgot that we need to resolve the situation with miri. @bors r- |
|
Probably the best solution is to continue using the x86_64 code on aarch64 when under miri). Pretty soon we should be able to globally improve the handling of this (assuming the min macOS version bump goes through). |
|
Yeah if further changes are planned soon that might be easiest. Is the plan to use clock_gettime on all macos targets?
We already have clock_gettime for Linux so if the macos version is similar it should be easy to add.
Am 14. November 2022 06:50:40 UTC schrieb Thom Chiovoloni ***@***.***>:
…Probably the best solution is to continue using the x86_64 code on aarch64 when under miri). Pretty soon we should be able to globally improve the handling of this (assuming the min macOS version bump goes through).
--
Reply to this email directly or view it on GitHub:
#103594 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
library/std/src/sys/unix/time.rs
Outdated
|
|
||
| #[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] | ||
| #[cfg(any( | ||
| all(target_os = "macos", not(target_arch = "aarch64")), |
There was a problem hiding this comment.
I guess that would be just adding a not(miri) here. Please also open an issue at https://github.com/rust-lang/miri/issues to track removing this Miri hack.
Plausibly. I'd probably prefer using |
|
The 'np' makes me thing that will require a dedicated implementation. ;) But it's fine, these clock APIs are usually not a lot of work. (Unlike synchronization APIs...) |
Yes, most likely. But yeah, I don't expect it to be very complex. |
|
LGTM @bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#101162 (Migrate rustc_resolve to use SessionDiagnostic, part # 1) - rust-lang#103386 (Don't allow `CoerceUnsized` into `dyn*` (except for trait upcasting)) - rust-lang#103405 (Detect incorrect chaining of if and if let conditions and recover) - rust-lang#103594 (Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets) - rust-lang#104006 (Add variant_name function to `LangItem`) - rust-lang#104494 (Migrate GUI test to use functions) - rust-lang#104516 (rustdoc: clean up sidebar width CSS) - rust-lang#104550 (fix a typo) Failed merges: - rust-lang#104554 (Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less) r? `@ghost` `@rustbot` modify labels: rollup
implement clock_gettime on macos and pull in rustc changes so we can test this against rust-lang/rust#103594.
implement clock_gettime on macos and pull in rustc changes so we can test this against rust-lang/rust#103594. Fixes #2664
implement clock_gettime on macos and pull in rustc changes so we can test this against rust-lang#103594. Fixes rust-lang/miri#2664
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#101162 (Migrate rustc_resolve to use SessionDiagnostic, part # 1) - rust-lang#103386 (Don't allow `CoerceUnsized` into `dyn*` (except for trait upcasting)) - rust-lang#103405 (Detect incorrect chaining of if and if let conditions and recover) - rust-lang#103594 (Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets) - rust-lang#104006 (Add variant_name function to `LangItem`) - rust-lang#104494 (Migrate GUI test to use functions) - rust-lang#104516 (rustdoc: clean up sidebar width CSS) - rust-lang#104550 (fix a typo) Failed merges: - rust-lang#104554 (Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less) r? `@ghost` `@rustbot` modify labels: rollup
This is a duplicate of #94100 (since the original author is unresponsive), which resolves #91417.
On
aarch64-apple-darwintargets, the internal resolution ofInstantis lower than that ofDuration, so math between them becomes non-associative with small-enough durations.This PR makes this target use the standard Unix implementation (where
Instanthas 1ns resolution), but withCLOCK_UPTIME_RAWso it still returns the same values asmach_absolute_time1.(Edit: I need someone to confirm that this still works, I do not have access to an M1 device.)
Footnotes
https://www.manpagez.com/man/3/clock_gettime/ ↩