-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.rs
52 lines (46 loc) · 1.57 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
use std::env;
fn main() {
groth16_cuda();
}
fn groth16_cuda() {
let mut nvcc = cc::Build::new();
nvcc.cuda(true);
nvcc.flag("-arch=sm_80");
nvcc.flag("-gencode").flag("arch=compute_70,code=sm_70");
nvcc.flag("-t0");
nvcc.define("TAKE_RESPONSIBILITY_FOR_ERROR_MESSAGE", None);
nvcc.define("FEATURE_BLS12_381", None);
apply_blst_flags(&mut nvcc);
if let Some(include) = env::var_os("DEP_BLST_C_SRC") {
nvcc.include(&include);
}
if let Some(include) = env::var_os("DEP_SPPARK_ROOT") {
nvcc.include(include);
}
nvcc.flag("-Xcompiler").flag("-Wno-subobject-linkage");
nvcc.flag("-Xcompiler").flag("-Wno-unused-function");
nvcc.file("cuda/groth16_cuda.cu").compile("groth16_cuda");
println!("cargo:rerun-if-changed=cuda");
println!("cargo:rerun-if-env-changed=CXXFLAGS");
}
fn apply_blst_flags(nvcc: &mut cc::Build) {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
match (cfg!(feature = "portable"), cfg!(feature = "force-adx")) {
(true, false) => {
nvcc.define("__BLST_PORTABLE__", None);
}
(false, true) => {
if target_arch.eq("x86_64") {
nvcc.define("__ADX__", None);
}
}
(false, false) =>
{
#[cfg(target_arch = "x86_64")]
if target_arch.eq("x86_64") && std::is_x86_feature_detected!("adx") {
nvcc.define("__ADX__", None);
}
}
(true, true) => panic!("Cannot compile with both `portable` and `force-adx` features"),
}
}