Change signature of target_features_cfg
.
Currently it is called twice, once with `allow_unstable` set to true and once with it set to false. This results in some duplicated work. Most notably, for the LLVM backend, `LLVMRustHasFeature` is called twice for every feature, and it's moderately slow. For very short running compilations on platforms with many features (e.g. a `check` build of hello-world on x86) this is a significant fraction of runtime. This commit changes `target_features_cfg` so it is only called once, and it now returns a pair of feature sets. This halves the number of `LLVMRustHasFeature` calls.
This commit is contained in:
parent
ee5bae8a12
commit
157137a64a
1 changed files with 6 additions and 7 deletions
13
src/lib.rs
13
src/lib.rs
|
@ -176,13 +176,9 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_features_cfg(
|
fn target_features_cfg(&self, sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||||
&self,
|
|
||||||
sess: &Session,
|
|
||||||
_allow_unstable: bool,
|
|
||||||
) -> Vec<rustc_span::Symbol> {
|
|
||||||
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
|
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
|
||||||
if sess.target.arch == "x86_64" && sess.target.os != "none" {
|
let target_features = if sess.target.arch == "x86_64" && sess.target.os != "none" {
|
||||||
// x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled
|
// x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled
|
||||||
vec![sym::fsxr, sym::sse, sym::sse2, Symbol::intern("x87")]
|
vec![sym::fsxr, sym::sse, sym::sse2, Symbol::intern("x87")]
|
||||||
} else if sess.target.arch == "aarch64" {
|
} else if sess.target.arch == "aarch64" {
|
||||||
|
@ -196,7 +192,10 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
};
|
||||||
|
// FIXME do `unstable_target_features` properly
|
||||||
|
let unstable_target_features = target_features.clone();
|
||||||
|
(target_features, unstable_target_features)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_version(&self) {
|
fn print_version(&self) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue