2016-09-27 13:22:10 +08:00
|
|
|
extern crate gcc;
|
|
|
|
|
|
|
|
use std::env;
|
|
|
|
use std::path::Path;
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
struct Sources {
|
|
|
|
files: Vec<&'static str>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Sources {
|
|
|
|
fn new() -> Sources {
|
|
|
|
Sources { files: Vec::new() }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn extend(&mut self, sources: &[&'static str]) {
|
|
|
|
self.files.extend(sources);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if !Path::new("compiler-rt/.git").exists() {
|
|
|
|
let _ = Command::new("git").args(&["submodule", "update", "--init"])
|
|
|
|
.status();
|
|
|
|
}
|
|
|
|
|
|
|
|
let target = env::var("TARGET").expect("TARGET was not set");
|
|
|
|
let cfg = &mut gcc::Config::new();
|
|
|
|
|
|
|
|
if target.contains("msvc") {
|
|
|
|
cfg.define("__func__", Some("__FUNCTION__"));
|
|
|
|
} else {
|
|
|
|
cfg.flag("-fno-builtin");
|
|
|
|
cfg.flag("-fomit-frame-pointer");
|
|
|
|
cfg.flag("-ffreestanding");
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut sources = Sources::new();
|
|
|
|
|
|
|
|
sources.extend(&[
|
|
|
|
"muldi3.c",
|
|
|
|
"mulosi4.c",
|
|
|
|
"mulodi4.c",
|
|
|
|
"divsi3.c",
|
|
|
|
"divdi3.c",
|
|
|
|
"modsi3.c",
|
|
|
|
"moddi3.c",
|
|
|
|
"divmodsi4.c",
|
|
|
|
"divmoddi4.c",
|
|
|
|
"ashldi3.c",
|
|
|
|
"ashrdi3.c",
|
|
|
|
"lshrdi3.c",
|
|
|
|
"udivdi3.c",
|
|
|
|
"umoddi3.c",
|
|
|
|
"udivmoddi4.c",
|
|
|
|
"udivsi3.c",
|
|
|
|
"umodsi3.c",
|
|
|
|
"udivmodsi4.c",
|
|
|
|
"adddf3.c",
|
|
|
|
"addsf3.c",
|
2016-10-01 06:15:44 +08:00
|
|
|
"powidf2.c",
|
|
|
|
"powisf2.c",
|
2017-02-04 05:06:36 +08:00
|
|
|
// 128 bit integers
|
|
|
|
"lshrti3.c",
|
|
|
|
"modti3.c",
|
|
|
|
"muloti4.c",
|
|
|
|
"multi3.c",
|
|
|
|
"udivmodti4.c",
|
|
|
|
"udivti3.c",
|
|
|
|
"umodti3.c",
|
|
|
|
"ashlti3.c",
|
|
|
|
"ashrti3.c",
|
|
|
|
"divti3.c",
|
2016-09-27 13:22:10 +08:00
|
|
|
]);
|
|
|
|
|
2017-02-04 09:00:24 +08:00
|
|
|
let builtins_dir = Path::new("compiler-rt/lib/builtins");
|
2016-09-27 13:22:10 +08:00
|
|
|
for src in sources.files.iter() {
|
2017-02-04 09:00:24 +08:00
|
|
|
cfg.file(builtins_dir.join(src));
|
2016-09-27 13:22:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cfg.compile("libcompiler-rt.a");
|
2017-02-04 09:00:24 +08:00
|
|
|
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
|
|
|
|
for source in sources.files.iter() {
|
|
|
|
println!("cargo:rerun-if-changed={}", builtins_dir.join(source).display());
|
|
|
|
}
|
2016-09-27 13:22:10 +08:00
|
|
|
}
|