]>
git.proxmox.com Git - cargo.git/blob - vendor/memchr/build.rs
4 enable_simd_optimizations();
8 // This adds various simd cfgs if this compiler supports it.
10 // This can be disabled with RUSTFLAGS="--cfg memchr_disable_auto_simd", but
11 // this is generally only intended for testing.
12 fn enable_simd_optimizations() {
13 if is_env_set("CARGO_CFG_MEMCHR_DISABLE_AUTO_SIMD") {
16 println
!("cargo:rustc-cfg=memchr_runtime_simd");
17 println
!("cargo:rustc-cfg=memchr_runtime_sse2");
18 println
!("cargo:rustc-cfg=memchr_runtime_sse42");
19 println
!("cargo:rustc-cfg=memchr_runtime_avx");
22 // This adds a `memchr_libc` cfg if and only if libc can be used, if no other
23 // better option is available.
25 // This could be performed in the source code, but it's simpler to do it once
26 // here and consolidate it into one cfg knob.
28 // Basically, we use libc only if its enabled and if we aren't targeting a
29 // known bad platform. For example, wasm32 doesn't have a libc and the
30 // performance of memchr on Windows is seemingly worse than the fallback
33 const NO_ARCH
: &'
static [&'
static str] = &["wasm32", "windows"];
34 const NO_ENV
: &'
static [&'
static str] = &["sgx"];
36 if !is_feature_set("LIBC") {
40 let arch
= match env
::var("CARGO_CFG_TARGET_ARCH") {
44 let env
= match env
::var("CARGO_CFG_TARGET_ENV") {
48 if NO_ARCH
.contains(&&*arch
) || NO_ENV
.contains(&&*env
) {
52 println
!("cargo:rustc-cfg=memchr_libc");
55 fn is_feature_set(name
: &str) -> bool
{
56 is_env_set(&format
!("CARGO_FEATURE_{}", name
))
59 fn is_env_set(name
: &str) -> bool
{
60 env
::var_os(name
).is_some()