File tree 1 file changed +25
-25
lines changed
1 file changed +25
-25
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,28 @@ use syntax::parse::token::InternedString;
16
16
use syntax:: parse:: token:: intern_and_get_ident as intern;
17
17
use libc:: c_char;
18
18
19
+ // WARNING: the features must be known to LLVM or the feature
20
+ // detection code will walk past the end of the feature array,
21
+ // leading to crashes.
22
+
23
+ const ARM_WHITELIST : & ' static [ & ' static str ] = & [
24
+ "neon\0 " ,
25
+ "vfp2\0 " ,
26
+ "vfp3\0 " ,
27
+ "vfp4\0 " ,
28
+ ] ;
29
+
30
+ const X86_WHITELIST : & ' static [ & ' static str ] = & [
31
+ "avx\0 " ,
32
+ "avx2\0 " ,
33
+ "sse\0 " ,
34
+ "sse2\0 " ,
35
+ "sse3\0 " ,
36
+ "sse4.1\0 " ,
37
+ "sse4.2\0 " ,
38
+ "ssse3\0 " ,
39
+ ] ;
40
+
19
41
/// Add `target_feature = "..."` cfgs for a variety of platform
20
42
/// specific features (SSE, NEON etc.).
21
43
///
@@ -24,32 +46,10 @@ use libc::c_char;
24
46
pub fn add_configuration ( cfg : & mut ast:: CrateConfig , sess : & Session ) {
25
47
let target_machine = create_target_machine ( sess) ;
26
48
27
- // WARNING: the features must be known to LLVM or the feature
28
- // detection code will walk past the end of the feature array,
29
- // leading to crashes.
30
-
31
- let arm_whitelist = [
32
- "neon\0 " ,
33
- "vfp2\0 " ,
34
- "vfp3\0 " ,
35
- "vfp4\0 " ,
36
- ] ;
37
-
38
- let x86_whitelist = [
39
- "avx\0 " ,
40
- "avx2\0 " ,
41
- "sse\0 " ,
42
- "sse2\0 " ,
43
- "sse3\0 " ,
44
- "sse4.1\0 " ,
45
- "sse4.2\0 " ,
46
- "ssse3\0 " ,
47
- ] ;
48
-
49
49
let whitelist = match & * sess. target . target . arch {
50
- "arm" => & arm_whitelist [ .. ] ,
51
- "x86" | "x86_64" => & x86_whitelist [ .. ] ,
52
- _ => & [ ] [ .. ] ,
50
+ "arm" => ARM_WHITELIST ,
51
+ "x86" | "x86_64" => X86_WHITELIST ,
52
+ _ => & [ ] ,
53
53
} ;
54
54
55
55
let tf = InternedString :: new ( "target_feature" ) ;
You can’t perform that action at this time.
0 commit comments