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.
This commit is contained in:
parent
4da4970767
commit
eac0a8bc30
15 changed files with 38 additions and 5 deletions
|
|
@ -19,6 +19,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();
|
||||
if !target.contains("apple") && !target.contains("msvc") {
|
||||
|
|
|
|||
|
|
@ -269,7 +269,10 @@ mod imp {
|
|||
const kSecRandomDefault: *const SecRandom = ptr::null();
|
||||
|
||||
#[link(name = "Security", kind = "framework")]
|
||||
extern "C" {
|
||||
#[cfg(not(cargobuild))]
|
||||
extern {}
|
||||
|
||||
extern {
|
||||
fn SecRandomCopyBytes(rnd: *const SecRandom,
|
||||
count: size_t, bytes: *mut u8) -> c_int;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
//! 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.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void,
|
|||
errnum: libc::c_int);
|
||||
enum backtrace_state {}
|
||||
#[link(name = "backtrace", kind = "static")]
|
||||
#[cfg(not(test))]
|
||||
#[cfg(all(not(test), not(cargobuild)))]
|
||||
extern {}
|
||||
|
||||
extern {
|
||||
|
|
|
|||
|
|
@ -252,6 +252,9 @@ pub mod eh_frame_registry {
|
|||
// 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);
|
||||
|
|
|
|||
|
|
@ -339,7 +339,6 @@ pub fn args() -> Args {
|
|||
pub fn args() -> Args {
|
||||
use mem;
|
||||
|
||||
#[link(name = "objc")]
|
||||
extern {
|
||||
fn sel_registerName(name: *const libc::c_uchar) -> Sel;
|
||||
fn objc_msgSend(obj: NsId, sel: Sel, ...) -> NsId;
|
||||
|
|
@ -347,6 +346,8 @@ pub fn args() -> Args {
|
|||
}
|
||||
|
||||
#[link(name = "Foundation", kind = "framework")]
|
||||
#[link(name = "objc")]
|
||||
#[cfg(not(cargobuild))]
|
||||
extern {}
|
||||
|
||||
type Sel = *const libc::c_void;
|
||||
|
|
|
|||
|
|
@ -966,6 +966,9 @@ pub enum EXCEPTION_DISPOSITION {
|
|||
#[link(name = "userenv")]
|
||||
#[link(name = "shell32")]
|
||||
#[link(name = "advapi32")]
|
||||
#[cfg(not(cargobuild))]
|
||||
extern {}
|
||||
|
||||
extern "system" {
|
||||
pub fn WSAStartup(wVersionRequested: WORD,
|
||||
lpWSAData: LPWSADATA) -> c_int;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue