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.
15 files changed:
use build_helper::run;
fn main() {
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());
let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
let build_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
not(target_os = "android"),
not(target_env = "musl")),
link(name = "pthread"))]
not(target_os = "android"),
not(target_env = "musl")),
link(name = "pthread"))]
+#[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;
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;
extern crate gcc;
fn main() {
extern crate gcc;
fn main() {
+ println!("cargo:rustc-cfg=cargobuild");
gcc::Config::new()
.file("../rt/miniz.c")
.compile("libminiz.a");
gcc::Config::new()
.file("../rt/miniz.c")
.compile("libminiz.a");
}
#[link(name = "miniz", kind = "static")]
}
#[link(name = "miniz", kind = "static")]
+#[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,
/// Raw miniz compression function.
fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
use build_helper::output;
fn main() {
use build_helper::output;
fn main() {
+ println!("cargo:rustc-cfg=cargobuild");
+
let target = env::var("TARGET").unwrap();
let llvm_config = env::var_os("LLVM_CONFIG").map(PathBuf::from)
.unwrap_or_else(|| {
let target = env::var("TARGET").unwrap();
let llvm_config = env::var_os("LLVM_CONFIG").map(PathBuf::from)
.unwrap_or_else(|| {
// automatically updated whenever LLVM is updated to include an up-to-date
// set of the libraries we need to link to LLVM for.
#[link(name = "rustllvm", kind = "static")]
// automatically updated whenever LLVM is updated to include an up-to-date
// set of the libraries we need to link to LLVM for.
#[link(name = "rustllvm", kind = "static")]
+#[cfg(not(cargobuild))]
+extern {}
+
#[linked_from = "rustllvm"] // not quite true but good enough
extern {
/* Create and destroy contexts. */
#[linked_from = "rustllvm"] // not quite true but good enough
extern {
/* Create and destroy contexts. */
// parts of LLVM that rustllvm depends on aren't thrown away by the linker.
// Works to the above fix for #15460 to ensure LLVM dependencies that
// are only used by rustllvm don't get stripped by the linker.
// parts of LLVM that rustllvm depends on aren't thrown away by the linker.
// Works to the above fix for #15460 to ensure LLVM dependencies that
// are only used by rustllvm don't get stripped by the linker.
mod llvmdeps {
include! { env!("CFG_LLVM_LINKAGE_FILE") }
}
mod llvmdeps {
include! { env!("CFG_LLVM_LINKAGE_FILE") }
}
extern crate gcc;
fn main() {
extern crate gcc;
fn main() {
+ println!("cargo:rustc-cfg=cargobuild");
let mut cfg = gcc::Config::new();
cfg.file("../rt/hoedown/src/autolink.c")
.file("../rt/hoedown/src/buffer.c")
let mut cfg = gcc::Config::new();
cfg.file("../rt/hoedown/src/autolink.c")
.file("../rt/hoedown/src/buffer.c")
// hoedown FFI
#[link(name = "hoedown", kind = "static")]
// hoedown FFI
#[link(name = "hoedown", kind = "static")]
+#[cfg(not(cargobuild))]
+extern {}
+
extern {
fn hoedown_html_renderer_new(render_flags: libc::c_uint,
nesting_level: libc::c_int)
extern {
fn hoedown_html_renderer_new(render_flags: libc::c_uint,
nesting_level: libc::c_int)
use build_helper::run;
fn main() {
use build_helper::run;
fn main() {
+ println!("cargo:rustc-cfg=cargobuild");
+
let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
if !target.contains("apple") && !target.contains("msvc") {
let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
if !target.contains("apple") && !target.contains("msvc") {
const kSecRandomDefault: *const SecRandom = ptr::null();
#[link(name = "Security", kind = "framework")]
const kSecRandomDefault: *const SecRandom = ptr::null();
#[link(name = "Security", kind = "framework")]
+ #[cfg(not(cargobuild))]
+ extern {}
+
+ extern {
fn SecRandomCopyBytes(rnd: *const SecRandom,
count: size_t, bytes: *mut u8) -> c_int;
}
fn SecRandomCopyBytes(rnd: *const SecRandom,
count: size_t, bytes: *mut u8) -> c_int;
}
//! the standard library This varies per-platform, but these libraries are
//! necessary for running libstd.
//! the standard library This varies per-platform, but these libraries are
//! necessary for running libstd.
+#![cfg(not(cargobuild))]
+
// LLVM implements the `frem` instruction as a call to `fmod`, which lives in
// libm. Hence, we must explicitly link to it.
//
// LLVM implements the `frem` instruction as a call to `fmod`, which lives in
// libm. Hence, we must explicitly link to it.
//
errnum: libc::c_int);
enum backtrace_state {}
#[link(name = "backtrace", kind = "static")]
errnum: libc::c_int);
enum backtrace_state {}
#[link(name = "backtrace", kind = "static")]
+ #[cfg(all(not(test), not(cargobuild)))]
// See also: rtbegin.rs, `unwind` module.
#[link(name = "gcc_eh")]
// See also: rtbegin.rs, `unwind` module.
#[link(name = "gcc_eh")]
+ #[cfg(not(cargobuild))]
+ extern {}
+
extern {
fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8);
fn __deregister_frame_info(eh_frame_begin: *const u8, object: *mut u8);
extern {
fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8);
fn __deregister_frame_info(eh_frame_begin: *const u8, object: *mut u8);
pub fn args() -> Args {
use mem;
pub fn args() -> Args {
use mem;
extern {
fn sel_registerName(name: *const libc::c_uchar) -> Sel;
fn objc_msgSend(obj: NsId, sel: Sel, ...) -> NsId;
extern {
fn sel_registerName(name: *const libc::c_uchar) -> Sel;
fn objc_msgSend(obj: NsId, sel: Sel, ...) -> NsId;
}
#[link(name = "Foundation", kind = "framework")]
}
#[link(name = "Foundation", kind = "framework")]
+ #[link(name = "objc")]
+ #[cfg(not(cargobuild))]
extern {}
type Sel = *const libc::c_void;
extern {}
type Sel = *const libc::c_void;
#[link(name = "userenv")]
#[link(name = "shell32")]
#[link(name = "advapi32")]
#[link(name = "userenv")]
#[link(name = "shell32")]
#[link(name = "advapi32")]
+#[cfg(not(cargobuild))]
+extern {}
+
extern "system" {
pub fn WSAStartup(wVersionRequested: WORD,
lpWSAData: LPWSADATA) -> c_int;
extern "system" {
pub fn WSAStartup(wVersionRequested: WORD,
lpWSAData: LPWSADATA) -> c_int;