/// Build the standard library.
///
/// This will build the standard library for a particular stage of the build
/// using the `compiler` targeting the `target` architecture. The artifacts
/// created will also be linked into the sysroot directory.
Build the standard library.
This will build the standard library for a particular stage of the build
using the `compiler` targeting the `target` architecture. The artifacts
created will also be linked into the sysroot directory.
Build the standard library . This will build the standard library for a particular stage of the build using the ` compiler ` targeting the ` target ` architecture . The artifacts created will also be linked into the sysroot directory .
pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
    println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
             compiler.host, target);
    let libdir = build.sysroot_libdir(compiler, target);
    let _ = fs::remove_dir_all(&libdir);
    t!(fs::create_dir_all(&libdir));
    // FIXME(stage0) remove this `if` after the next snapshot
    // The stage0 compiler still passes the `-lcompiler-rt` flag to the linker but now `bootstrap`
    // never builds a `libcopmiler-rt.a`! We'll fill the hole by simply copying stage0's
    // `libcompiler-rt.a` to where the stage1's one is expected (though we could as well just use
    // an empty `.a` archive). Note that the symbols of that stage0 `libcompiler-rt.a` won't make
    // it to the final binary because now `libcore.rlib` also contains the symbols that
    // `libcompiler-rt.a` provides. Since that rlib appears first in the linker arguments, its
    // symbols are used instead of `libcompiler-rt.a`'s.
    if compiler.stage == 0 {
        let rtlib = &staticlib("compiler-rt", target);
        let src = build.rustc.parent().unwrap().parent().unwrap().join("lib").join("rustlib")
            .join(target).join("lib").join(rtlib);
        copy(&src, &libdir.join(rtlib));
    }
    // Some platforms have startup objects that may be required to produce the
    // libstd dynamic library, for example.
    build_startup_objects(build, target, &libdir);
    let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
    build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
    let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
    cargo.arg("--features").arg(build.std_features())
         .arg("--manifest-path")
         .arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
    if let Some(target) = build.config.target_config.get(target) {
        if let Some(ref jemalloc) = target.jemalloc {
            cargo.env("JEMALLOC_OVERRIDE", jemalloc);
        }
    }
    if target.contains("musl") {
        if let Some(p) = build.musl_root(target) {
            cargo.env("MUSL_ROOT", p);
        }
    }
    build.run(&mut cargo);
    std_link(build, target, compiler, compiler.host);
}
pub fn std < ' a > ( build : & ' a Build , target : & str , compiler : & Compiler < ' a > ) { println ! ( " " compiler stage compiler host target ) ; let libdir = build . sysroot_libdir ( compiler , target ) ; let _ = fs :: remove_dir_all ( & libdir ) ; t ! ( fs create_dir_all ( libdir ) ) ; // FIXME(stage0) remove this `if` after the next snapshot // The stage0 compiler still passes the `-lcompiler-rt` flag to the linker but now `bootstrap` // never builds a `libcopmiler-rt.a`! We'll fill the hole by simply copying stage0's // `libcompiler-rt.a` to where the stage1's one is expected (though we could as well just use // an empty `.a` archive). Note that the symbols of that stage0 `libcompiler-rt.a` won't make // it to the final binary because now `libcore.rlib` also contains the symbols that // `libcompiler-rt.a` provides. Since that rlib appears first in the linker arguments, its // symbols are used instead of `libcompiler-rt.a`'s. if compiler . stage == 0 { let rtlib = & staticlib ( " " , target ) ; let src = build . rustc . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) . join ( " " ) . join ( " " ) . join ( target ) . join ( " " ) . join ( rtlib ) ; copy ( & src , & libdir . join ( rtlib ) ) ; } // Some platforms have startup objects that may be required to produce the // libstd dynamic library, for example. build_startup_objects ( build , target , & libdir ) ; let out_dir = build . cargo_out ( compiler , Mode :: Libstd , target ) ; build . clear_if_dirty ( & out_dir , & build . compiler_path ( compiler ) ) ; let mut cargo = build . cargo ( compiler , Mode :: Libstd , target , " " ) ; cargo . arg ( " " ) . arg ( build . std_features ( ) ) . arg ( " " ) . arg ( build . src . join ( " " ) ) ; if let Some ( target ) = build . config . target_config . get ( target ) { if let Some ( ref jemalloc ) = target . jemalloc { cargo . env ( " " , jemalloc ) ; } } if target . contains ( " " ) { if let Some ( p ) = build . musl_root ( target ) { cargo . env ( " " , p ) ; } } build . run ( & mut cargo ) ; std_link ( build , target , compiler , compiler . host ) ; }
Build the standard library.
Build the standard library .
build
&'a Build
target
&str
compiler
&Compiler<'a>