forked from notflan/stackalloc-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
46 lines (41 loc) · 1.23 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
extern crate rustc_version;
use rustc_version::{version, version_meta, Channel};
fn build_tramp() {
let mut builder = cc::Build::new();
// --std=c99 -W -Wall -Werror -pedantic -O3 -flto
builder
.flag("--std=c99")
.flag_if_supported("-Wall")
.flag_if_supported("-Wextra")
.flag_if_supported("-W")
.flag_if_supported("-Werror")
.flag("-pedantic")
.opt_level(3);
// Not sure if we want these two. We can check the codegen later.
// .pic(false)
// .use_plt(false)
builder
.file("alloca_trampoline_.c")
.compile("calloca_trampoline");
}
fn main() {
// Assert we haven't travelled back in time
assert!(version().unwrap().major >= 1);
println!("cargo::rustc-check-cfg=cfg(nightly)");
// Set cfg flags depending on release channel
match version_meta().unwrap().channel {
Channel::Stable => {
println!("cargo:rustc-cfg=stable");
}
Channel::Beta => {
println!("cargo:rustc-cfg=beta");
}
Channel::Nightly => {
println!("cargo:rustc-cfg=nightly");
}
Channel::Dev => {
println!("cargo:rustc-cfg=dev");
}
}
build_tramp();
}