Auto merge of #143 - rust-lang-nursery:no-gcc, r=alexcrichton

make the gcc crate optional

it's only required when the "c" feature is enabled

r? @alexcrichton
This commit is contained in:
bors 2017-02-21 16:25:47 +00:00
commit 0507842b24
2 changed files with 343 additions and 330 deletions

View File

@ -6,7 +6,10 @@ version = "0.1.0"
[build-dependencies] [build-dependencies]
rustc-cfg = "0.3.0" rustc-cfg = "0.3.0"
gcc = "0.3.36"
[build-dependencies.gcc]
optional = true
version = "0.3.36"
[dev-dependencies] [dev-dependencies]
quickcheck = "0.3.1" quickcheck = "0.3.1"
@ -16,7 +19,7 @@ compiler-rt = { path = "compiler-rt" }
[features] [features]
# Build the missing intrinsics from compiler-rt C source code # Build the missing intrinsics from compiler-rt C source code
c = [] c = ["gcc"]
# Mark this crate as the #![compiler_builtins] crate # Mark this crate as the #![compiler_builtins] crate
compiler-builtins = [] compiler-builtins = []
default = ["compiler-builtins"] default = ["compiler-builtins"]

View File

@ -1,18 +1,23 @@
#[cfg(feature = "c")]
extern crate gcc; extern crate gcc;
extern crate rustc_cfg; extern crate rustc_cfg;
#[cfg(feature = "c")]
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::Write; use std::io::Write;
#[cfg(feature = "c")]
use std::path::Path; use std::path::Path;
use std::{env, io, process}; use std::{env, io, process};
use rustc_cfg::Cfg; use rustc_cfg::Cfg;
#[cfg(feature = "c")]
struct Sources { struct Sources {
// SYMBOL -> PATH TO SOURCE // SYMBOL -> PATH TO SOURCE
map: BTreeMap<&'static str, &'static str>, map: BTreeMap<&'static str, &'static str>,
} }
#[cfg(feature = "c")]
impl Sources { impl Sources {
fn new() -> Sources { fn new() -> Sources {
Sources { map: BTreeMap::new() } Sources { map: BTreeMap::new() }
@ -65,10 +70,12 @@ fn main() {
// target triple. This is usually correct for our built-in targets but can break in presence of // target triple. This is usually correct for our built-in targets but can break in presence of
// custom targets, which can have arbitrary names. // custom targets, which can have arbitrary names.
let llvm_target = target.split('-').collect::<Vec<_>>(); let llvm_target = target.split('-').collect::<Vec<_>>();
let target_vendor = target_vendor.as_ref().unwrap();
// Build missing intrinsics from compiler-rt C source code // Build missing intrinsics from compiler-rt C source code
if env::var_os("CARGO_FEATURE_C").is_some() { match () {
#[cfg(feature = "c")]
() => {
let target_vendor = target_vendor.as_ref().unwrap();
let cfg = &mut gcc::Config::new(); let cfg = &mut gcc::Config::new();
if target_env == "msvc" { if target_env == "msvc" {
@ -406,6 +413,9 @@ fn main() {
cfg.compile("libcompiler-rt.a"); cfg.compile("libcompiler-rt.a");
} }
#[cfg(not(feature = "c"))]
() => {}
}
// To filter away some flaky test (see src/float/add.rs for details) // To filter away some flaky test (see src/float/add.rs for details)
if llvm_target[0].starts_with("arm") && if llvm_target[0].starts_with("arm") &&