summaryrefslogtreecommitdiffstats
path: root/build.rs
blob: b97dd250a13053f4b37043666af8118afa4f6a23 (plain)
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
#[cfg(feature = "simdcompression")]
mod build {
    extern crate gcc;

    pub fn build() {
        let mut config = gcc::Config::new();
        config
            .include("./cpp/simdcomp/include")
            .file("cpp/simdcomp/src/avxbitpacking.c")
            .file("cpp/simdcomp/src/simdintegratedbitpacking.c")
            .file("cpp/simdcomp/src/simdbitpacking.c")
            .file("cpp/simdcomp/src/simdpackedsearch.c")
            .file("cpp/simdcomp/src/simdcomputil.c")
            .file("cpp/simdcomp/src/simdpackedselect.c")
            .file("cpp/simdcomp/src/simdfor.c")
            .file("cpp/simdcomp_wrapper.c");

        if !cfg!(debug_assertions) {
            config.opt_level(3);

            if cfg!(target_env = "msvc") {
                config
                    .define("NDEBUG", None)
                    .flag("/Gm-")
                    .flag("/GS-")
                    .flag("/Gy")
                    .flag("/Oi")
                    .flag("/GL");
            }
        }

        if !cfg!(target_env = "msvc") {
            config
                .include("./cpp/streamvbyte/include")
                .file("cpp/streamvbyte/src/streamvbyte.c")
                .file("cpp/streamvbyte/src/streamvbytedelta.c")
                .flag("-msse4.1")
                .flag("-march=native")
                .flag("-std=c99");
        }

        config.compile("libsimdcomp.a");

        // Workaround for linking static libraries built with /GL
        // https://github.com/rust-lang/rust/issues/26003
        if !cfg!(debug_assertions) && cfg!(target_env = "msvc") {
            println!("cargo:rustc-link-lib=dylib=simdcomp");
        }

        println!("cargo:rerun-if-changed=cpp");
    }
}

#[cfg(not(feature = "simdcompression"))]
mod build {
    pub fn build() {}
}

fn main() {
    build::build();
}