forked from PoC-Consortium/scavenger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
103 lines (79 loc) · 2.81 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
extern crate cc;
#[macro_use]
extern crate cfg_if;
fn main() {
let mut shared_config = cc::Build::new();
#[cfg(target_env = "msvc")]
shared_config
.flag("/O2")
.flag("/Oi")
.flag("/Ot")
.flag("/Oy")
.flag("/GT")
.flag("/GL");
#[cfg(not(target_env = "msvc"))]
shared_config.flag("-std=c99");
#[cfg(not(target_env = "msvc"))]
shared_config.flag("-mtune=native");
let mut config = shared_config.clone();
config
.file("src/c/sph_shabal.c")
.file("src/c/shabal.c")
.file("src/c/common.c")
.compile("shabal");
cfg_if! {
if #[cfg(feature = "neon")] {
fn build(shared_config: cc::Build){
let mut config = shared_config.clone();
#[cfg(all(not(target_env = "msvc"), not(target_arch = "aarch64")))]
config.flag("-mfpu=neon");
config
.file("src/c/mshabal_128_neon.c")
.file("src/c/shabal_neon.c")
.compile("shabal_neon");
}
}
}
cfg_if! {
if #[cfg(feature = "simd")] {
fn build(shared_config: cc::Build){
let mut config = shared_config.clone();
#[cfg(not(target_env = "msvc"))]
config.flag("-msse2");
config
.file("src/c/mshabal_128_sse2.c")
.file("src/c/shabal_sse2.c")
.compile("shabal_sse2");
let mut config = shared_config.clone();
#[cfg(target_env = "msvc")]
config.flag("/arch:AVX");
#[cfg(not(target_env = "msvc"))]
config.flag("-mavx");
config
.file("src/c/mshabal_128_avx.c")
.file("src/c/shabal_avx.c")
.compile("shabal_avx");
let mut config = shared_config.clone();
#[cfg(target_env = "msvc")]
config.flag("/arch:AVX2");
#[cfg(not(target_env = "msvc"))]
config.flag("-mavx2");
config
.file("src/c/mshabal_256_avx2.c")
.file("src/c/shabal_avx2.c")
.compile("shabal_avx2");
let mut config = shared_config.clone();
#[cfg(target_env = "msvc")]
config.flag("/arch:AVX512");
#[cfg(not(target_env = "msvc"))]
config.flag("-mavx512f");
config
.file("src/c/mshabal_512_avx512f.c")
.file("src/c/shabal_avx512f.c")
.compile("shabal_avx512f");
}
}
}
#[cfg(any(feature = "simd", feature = "neon"))]
build(shared_config);
}