Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cfg!(target_feature) directly into is_*_feature_detected!() #1135

Closed
bjorn3 opened this issue Apr 21, 2021 · 0 comments · Fixed by #1141
Closed

Move cfg!(target_feature) directly into is_*_feature_detected!() #1135

bjorn3 opened this issue Apr 21, 2021 · 0 comments · Fixed by #1141

Comments

@bjorn3
Copy link
Member

bjorn3 commented Apr 21, 2021

pub mod __is_feature_detected {
$(
/// PLEASE: do not use this, it is an implementation detail
/// subject to change.
#[inline]
#[doc(hidden)]
#[$stability_attr]
pub fn $feature() -> bool {
cfg!(target_feature = $feature_lit) ||
$crate::detect::check_for($crate::detect::Feature::$feature)
}
)*
}

It is currently part of a function inside the __is_feature_detected module of std_detect, which means that it uses the value of the target feature when compiling libstd instead of the target crate, making -Ctarget-cpu/-Ctarget-feature in RUSTFLAGS ineffective at optimizing the runtime detection away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant