From eac0a8bc3070e45047fff57e7b024a059289a36d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 21 Jan 2016 15:36:25 -0800 Subject: bootstrap: Add directives to not double-link libs Have all Cargo-built crates pass `--cfg cargobuild` and then add appropriate `#[cfg]` definitions to all crates to avoid linking anything if this is passed. This should help allow libstd to compile with both the makefiles and with Cargo. --- src/libflate/build.rs | 1 + src/libflate/lib.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libflate') diff --git a/src/libflate/build.rs b/src/libflate/build.rs index 12016980a2c..245c705dfcc 100644 --- a/src/libflate/build.rs +++ b/src/libflate/build.rs @@ -11,6 +11,7 @@ extern crate gcc; fn main() { + println!("cargo:rustc-cfg=cargobuild"); gcc::Config::new() .file("../rt/miniz.c") .compile("libminiz.a"); diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index f316250d96d..a6bf735e459 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -79,7 +79,10 @@ impl Drop for Bytes { } #[link(name = "miniz", kind = "static")] -extern "C" { +#[cfg(not(cargobuild))] +extern {} + +extern { /// Raw miniz compression function. fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void, src_buf_len: size_t, -- cgit 1.4.1-3-g733a5