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/liballoc_jemalloc/build.rs | 2 ++ src/liballoc_jemalloc/lib.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/liballoc_jemalloc') diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index 18f0527425a..4bc752af48e 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -17,6 +17,8 @@ use std::process::Command; use build_helper::run; fn main() { + println!("cargo:rustc-cfg=cargobuild"); + let target = env::var("TARGET").unwrap(); let host = env::var("HOST").unwrap(); let build_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index d02e9e4ba13..2c46e37ac32 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -38,7 +38,10 @@ use libc::{c_int, c_void, size_t}; not(target_os = "android"), not(target_env = "musl")), link(name = "pthread"))] -extern "C" { +#[cfg(not(cargobuild))] +extern {} + +extern { fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void; fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void; fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; -- cgit 1.4.1-3-g733a5