Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented Jan 24, 2025

fixes bug #90429

@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 24, 2025
@hkBst hkBst changed the title Document powf and powi values that are always 1.0 Document powf and powi values that are always 1.0 (f64) Jan 24, 2025
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

Like @matthiaskrgr noted in the other PR, please merge these into one. I'm gonna leave this one open and close the rest.

@compiler-errors
Copy link
Member

compiler-errors commented Jan 24, 2025

Also regarding this and those other PRs, please squash them into a single commit. A commit named "Add semicolon", "add space", etc is not adding much value to a 1 file change PR -- if you need help learning how to squash commits into one, I think any of us can point you how to do that :)

@workingjubilee
Copy link
Member

@hkBst While we will not necessarily refuse PRs that have a remunerative motivation, we will definitely not accept degrading the quality of PRs to do so. I will accept this when you push an actual fix and it passes the standard of my review, and no sooner.

@workingjubilee workingjubilee added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 24, 2025
@workingjubilee workingjubilee changed the title Document powf and powi values that are always 1.0 (f64) Document powf and powi values that are always 1.0 Jan 24, 2025
@hkBst
Copy link
Member Author

hkBst commented Jan 25, 2025

@workingjubilee no remunerative motivation I can assure you. Apologies for any confusion arising from my use of the word "payout".

EDIT: I meant "payoff" when I used "payout" (in the other comment), so I guess I was unidiomatic. Again, apologies for the confusion.

@workingjubilee
Copy link
Member

workingjubilee commented Jan 27, 2025

Thank you.

Yes, idiomatic English can be somewhat challenging, so I understand the slip. I also understand why you think it would be more efficient (or otherwise better) to send 4 PRs. It's just actually worse to have 4 people look at basically the same diff and have to individually activate their neurons to decide if the change is okay.

Most importantly, they might decide differently, which is very bad. This documentation should absolutely be consistent between types (modulo where it needs to deviate, like value ranges).

Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, thank you.

@workingjubilee
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jan 27, 2025

📌 Commit 5297fc1 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 27, 2025
@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 28, 2025
@hkBst
Copy link
Member Author

hkBst commented Jan 28, 2025

@tgross35 Ah, I wondered what those were for, but could not find anywhere that explained them... Now added.

Comment on lines 330 to 340
/// ```
/// #![feature(f128)]
/// # #[cfg(reliable_f128_math)] {
///
/// let x = 2.0_f128;
/// let abs_difference = (x.powi(2) - (x * x)).abs();
/// assert!(abs_difference <= f128::EPSILON);
///
/// assert_eq!(f128::powi(f128::NAN, 0), 1.0);
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need the trailing # } to match the opening # #[cfg(...)] {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, of course... done now.

@rust-log-analyzer

This comment has been minimized.

@hkBst
Copy link
Member Author

hkBst commented Jan 28, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 28, 2025
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, LGTM but I'll wait for PR CI to pass.

@tgross35 Ah, I wondered what those were for, but could not find anywhere that explained them... Now added.

For reference, these get set here and the reasons are reasonably well documented

rust/library/std/build.rs

Lines 82 to 186 in 2f348cb

// Emit these on platforms that have no known ABI bugs, LLVM selection bugs, lowering bugs,
// missing symbols, or other problems, to determine when tests get run.
// If more broken platforms are found, please update the tracking issue at
// <https://github.com/rust-lang/rust/issues/116909>
//
// Some of these match arms are redundant; the goal is to separate reasons that the type is
// unreliable, even when multiple reasons might fail the same platform.
println!("cargo:rustc-check-cfg=cfg(reliable_f16)");
println!("cargo:rustc-check-cfg=cfg(reliable_f128)");
// This is a step beyond only having the types and basic functions available. Math functions
// aren't consistently available or correct.
println!("cargo:rustc-check-cfg=cfg(reliable_f16_math)");
println!("cargo:rustc-check-cfg=cfg(reliable_f128_math)");
let has_reliable_f16 = match (target_arch.as_str(), target_os.as_str()) {
// We can always enable these in Miri as that is not affected by codegen bugs.
_ if is_miri => true,
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
("s390x", _) => false,
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
("arm64ec", _) => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
("csky", _) => false,
("hexagon", _) => false,
("loongarch64", _) => false,
("mips" | "mips64" | "mips32r6" | "mips64r6", _) => false,
("powerpc" | "powerpc64", _) => false,
("sparc" | "sparc64", _) => false,
("wasm32" | "wasm64", _) => false,
// `f16` support only requires that symbols converting to and from `f32` are available. We
// provide these in `compiler-builtins`, so `f16` should be available on all platforms that
// do not have other ABI issues or LLVM crashes.
_ => true,
};
let has_reliable_f128 = match (target_arch.as_str(), target_os.as_str()) {
// We can always enable these in Miri as that is not affected by codegen bugs.
_ if is_miri => true,
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
("arm64ec", _) => false,
// Selection bug <https://github.com/llvm/llvm-project/issues/96432>
("mips64" | "mips64r6", _) => false,
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>
("nvptx64", _) => false,
// ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
// list at <https://github.com/rust-lang/rust/issues/116909>)
("powerpc" | "powerpc64", _) => false,
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
("sparc", _) => false,
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
// not fail if our compiler-builtins is linked.
("x86", _) => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
// There are no known problems on other platforms, so the only requirement is that symbols
// are available. `compiler-builtins` provides all symbols required for core `f128`
// support, so this should work for everything else.
_ => true,
};
// Configure platforms that have reliable basics but may have unreliable math.
// LLVM is currently adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
let has_reliable_f16_math = has_reliable_f16
&& match (target_arch.as_str(), target_os.as_str()) {
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
_ if is_miri => false,
// x86 has a crash for `powi`: <https://github.com/llvm/llvm-project/issues/105747>
("x86" | "x86_64", _) => false,
// Assume that working `f16` means working `f16` math for most platforms, since
// operations just go through `f32`.
_ => true,
};
let has_reliable_f128_math = has_reliable_f128
&& match (target_arch.as_str(), target_os.as_str()) {
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
_ if is_miri => false,
// LLVM lowers `fp128` math to `long double` symbols even on platforms where
// `long double` is not IEEE binary128. See
// <https://github.com/llvm/llvm-project/issues/44744>.
//
// This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
// (ld is `f64`), anything other than Linux (Windows and MacOS use `f64`), and `x86`
// (ld is 80-bit extended precision).
("x86_64", _) => false,
(_, "linux") if target_pointer_width == 64 => true,
_ => false,
};
if has_reliable_f16 {
println!("cargo:rustc-cfg=reliable_f16");
}
if has_reliable_f128 {
println!("cargo:rustc-cfg=reliable_f128");
}
if has_reliable_f16_math {
println!("cargo:rustc-cfg=reliable_f16_math");
}
if has_reliable_f128_math {
println!("cargo:rustc-cfg=reliable_f128_math");
}
. Each LLVM bump makes a few more things work, but a few of the still-failing platforms do get tested in CI.

@tgross35
Copy link
Contributor

@bors r=workingjubilee,tgross35

@bors
Copy link
Collaborator

bors commented Jan 28, 2025

📌 Commit 3d6c6fa has been approved by workingjubilee,tgross35

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 28, 2025
@bors bors merged commit 9a192b2 into rust-lang:master Jan 28, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 28, 2025
@hkBst hkBst deleted the patch-22 branch February 2, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants