Skip to content

Commit cbc3860

Browse files
committed
Use rust rather than LLVM target features in the target spec
This works better with non-LLVM codegen backends.
1 parent 3e1d537 commit cbc3860

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/gcc_util.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ pub(crate) fn global_gcc_features(sess: &Session) -> Vec<String> {
3333
// should be taken in cases like these.
3434
let mut features = vec![];
3535

36-
// Features implied by an implicit or explicit `--target`.
37-
features.extend(sess.target.features.split(',').filter(|v| !v.is_empty()).map(String::from));
38-
39-
// -Ctarget-features
40-
target_features::flag_to_backend_features(sess, |feature, enable| {
36+
let mut extend_backend_features = |feature: &str, enable: bool| {
4137
// We run through `to_gcc_features` when
4238
// passing requests down to GCC. This means that all in-language
4339
// features also work on the command line instead of having two
@@ -48,7 +44,13 @@ pub(crate) fn global_gcc_features(sess: &Session) -> Vec<String> {
4844
.flat_map(|feat| to_gcc_features(sess, feat).into_iter())
4945
.map(|feature| if !enable { format!("-{}", feature) } else { feature.to_string() }),
5046
);
51-
});
47+
};
48+
49+
// Features implied by an implicit or explicit `--target`.
50+
target_features::target_spec_to_backend_features(sess, &mut extend_backend_features);
51+
52+
// -Ctarget-features
53+
target_features::flag_to_backend_features(sess, extend_backend_features);
5254

5355
gcc_features_by_flags(sess, &mut features);
5456

@@ -66,6 +68,7 @@ pub fn to_gcc_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]>
6668
(&Arch::X86 | &Arch::X86_64, "rdrand") => smallvec!["rdrnd"],
6769
(&Arch::X86 | &Arch::X86_64, "bmi1") => smallvec!["bmi"],
6870
(&Arch::X86 | &Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"],
71+
(&Arch::X86 | &Arch::X86_64, "lahfsahf") => smallvec!["sahf"],
6972
(&Arch::X86 | &Arch::X86_64, "avx512vaes") => smallvec!["vaes"],
7073
(&Arch::X86 | &Arch::X86_64, "avx512gfni") => smallvec!["gfni"],
7174
(&Arch::X86 | &Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],

0 commit comments

Comments
 (0)