Add a Cargo-based build system

This commit is the start of a series of commits which start to replace the
makefiles with a Cargo-based build system. The aim is not to remove the
makefiles entirely just yet but rather just replace the portions that invoke the
compiler to do the bootstrap. This commit specifically adds enough support to
perform the bootstrap (and all the cross compilation within) along with
generating documentation.

More commits will follow up in this series to actually wire up the makefiles to
call this build system, so stay tuned!
This commit is contained in:
Alex Crichton
2015-11-19 15:20:12 -08:00
parent a91ff1c9d1
commit 046e6874c4
33 changed files with 3324 additions and 1 deletions

356
src/rustc/Cargo.lock generated Normal file
View File

@@ -0,0 +1,356 @@
[root]
name = "rustc-main"
version = "0.0.0"
dependencies = [
"rustbook 0.0.0",
"rustc_back 0.0.0",
"rustc_driver 0.0.0",
"rustdoc 0.0.0",
]
[[package]]
name = "advapi32-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "arena"
version = "0.0.0"
[[package]]
name = "build_helper"
version = "0.1.0"
[[package]]
name = "flate"
version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"gcc 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fmt_macros"
version = "0.0.0"
[[package]]
name = "gcc"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "getopts"
version = "0.0.0"
[[package]]
name = "graphviz"
version = "0.0.0"
[[package]]
name = "log"
version = "0.0.0"
[[package]]
name = "rbml"
version = "0.0.0"
dependencies = [
"log 0.0.0",
"serialize 0.0.0",
]
[[package]]
name = "rustbook"
version = "0.0.0"
dependencies = [
"rustc_back 0.0.0",
"rustdoc 0.0.0",
]
[[package]]
name = "rustc"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"flate 0.0.0",
"fmt_macros 0.0.0",
"getopts 0.0.0",
"graphviz 0.0.0",
"log 0.0.0",
"rbml 0.0.0",
"rustc_back 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_front 0.0.0",
"rustc_llvm 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_back"
version = "0.0.0"
dependencies = [
"log 0.0.0",
"rustc_front 0.0.0",
"rustc_llvm 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_borrowck"
version = "0.0.0"
dependencies = [
"graphviz 0.0.0",
"log 0.0.0",
"rustc 0.0.0",
"rustc_front 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_data_structures"
version = "0.0.0"
dependencies = [
"log 0.0.0",
"serialize 0.0.0",
]
[[package]]
name = "rustc_driver"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"flate 0.0.0",
"getopts 0.0.0",
"graphviz 0.0.0",
"log 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_borrowck 0.0.0",
"rustc_front 0.0.0",
"rustc_lint 0.0.0",
"rustc_llvm 0.0.0",
"rustc_metadata 0.0.0",
"rustc_mir 0.0.0",
"rustc_plugin 0.0.0",
"rustc_privacy 0.0.0",
"rustc_resolve 0.0.0",
"rustc_trans 0.0.0",
"rustc_typeck 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
"syntax_ext 0.0.0",
]
[[package]]
name = "rustc_front"
version = "0.0.0"
dependencies = [
"log 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_lint"
version = "0.0.0"
dependencies = [
"log 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_front 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_llvm"
version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"gcc 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc_metadata"
version = "0.0.0"
dependencies = [
"flate 0.0.0",
"log 0.0.0",
"rbml 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_front 0.0.0",
"rustc_llvm 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_mir"
version = "0.0.0"
dependencies = [
"graphviz 0.0.0",
"log 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_front 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_platform_intrinsics"
version = "0.0.0"
dependencies = [
"rustc 0.0.0",
"rustc_llvm 0.0.0",
]
[[package]]
name = "rustc_plugin"
version = "0.0.0"
dependencies = [
"log 0.0.0",
"rustc 0.0.0",
"rustc_front 0.0.0",
"rustc_metadata 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_privacy"
version = "0.0.0"
dependencies = [
"log 0.0.0",
"rustc 0.0.0",
"rustc_front 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_resolve"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"log 0.0.0",
"rustc 0.0.0",
"rustc_front 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_trans"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"flate 0.0.0",
"getopts 0.0.0",
"graphviz 0.0.0",
"log 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_front 0.0.0",
"rustc_llvm 0.0.0",
"rustc_mir 0.0.0",
"rustc_platform_intrinsics 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustc_typeck"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"fmt_macros 0.0.0",
"log 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_front 0.0.0",
"rustc_platform_intrinsics 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "rustdoc"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"build_helper 0.1.0",
"gcc 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.0.0",
"log 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_driver 0.0.0",
"rustc_front 0.0.0",
"rustc_lint 0.0.0",
"rustc_metadata 0.0.0",
"rustc_resolve 0.0.0",
"rustc_trans 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
"test 0.0.0",
]
[[package]]
name = "serialize"
version = "0.0.0"
dependencies = [
"log 0.0.0",
]
[[package]]
name = "syntax"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"fmt_macros 0.0.0",
"log 0.0.0",
"serialize 0.0.0",
"term 0.0.0",
]
[[package]]
name = "syntax_ext"
version = "0.0.0"
dependencies = [
"fmt_macros 0.0.0",
"syntax 0.0.0",
]
[[package]]
name = "term"
version = "0.0.0"
dependencies = [
"log 0.0.0",
]
[[package]]
name = "test"
version = "0.0.0"
dependencies = [
"getopts 0.0.0",
"serialize 0.0.0",
"term 0.0.0",
]
[[package]]
name = "winapi"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

36
src/rustc/Cargo.toml Normal file
View File

@@ -0,0 +1,36 @@
[package]
authors = ["The Rust Project Developers"]
name = "rustc-main"
version = "0.0.0"
[[bin]]
name = "rustc"
path = "rustc.rs"
[[bin]]
name = "rustdoc"
path = "rustdoc.rs"
[[bin]]
name = "rustbook"
path = "rustbook.rs"
[profile.release]
opt-level = 2
# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
debug = false
debug-assertions = false
# All optional dependencies so the features passed to this Cargo.toml select
# what should actually be built.
[dependencies]
rustbook = { path = "../rustbook", optional = true }
rustc_back = { path = "../librustc_back" }
rustc_driver = { path = "../librustc_driver" }
rustdoc = { path = "../librustdoc", optional = true }
[features]
jemalloc = ["rustc_back/jemalloc"]

View File

@@ -0,0 +1,20 @@
# This is a shim Cargo.toml over the "real Cargo.toml" found in the libc
# repository itself. The purpose for this is to add a build script which prints
# out `--cfg stdbuild` to mirror the makefiles' build system.
#
# Note that other than that this isn't actually needed, and we should probably
# remove this shim in favor of just working with cargo features directly with
# libc. That should make everything nicer!
[package]
name = "libc"
version = "0.0.0"
authors = ["The Rust Project Developers"]
build = "build.rs"
[lib]
name = "libc"
path = "../../liblibc/src/lib.rs"
[dependencies]
core = { path = "../../libcore" }

View File

@@ -0,0 +1,15 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// See comments in Cargo.toml for why this exists
fn main() {
println!("cargo:rustc-cfg=stdbuild");
}

14
src/rustc/rustbook.rs Normal file
View File

@@ -0,0 +1,14 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate rustbook;
fn main() { rustbook::main() }

15
src/rustc/rustc.rs Normal file
View File

@@ -0,0 +1,15 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_private)]
extern crate rustc_driver;
fn main() { rustc_driver::main() }

15
src/rustc/rustdoc.rs Normal file
View File

@@ -0,0 +1,15 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustdoc)]
extern crate rustdoc;
fn main() { rustdoc::main() }

124
src/rustc/std_shim/Cargo.lock generated Normal file
View File

@@ -0,0 +1,124 @@
[root]
name = "std_shim"
version = "0.1.0"
dependencies = [
"std 0.0.0",
]
[[package]]
name = "advapi32-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "alloc"
version = "0.0.0"
dependencies = [
"alloc_system 0.0.0",
"core 0.0.0",
"libc 0.0.0",
]
[[package]]
name = "alloc_jemalloc"
version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"core 0.0.0",
"gcc 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.0.0",
]
[[package]]
name = "alloc_system"
version = "0.0.0"
dependencies = [
"core 0.0.0",
"libc 0.0.0",
]
[[package]]
name = "build_helper"
version = "0.1.0"
[[package]]
name = "collections"
version = "0.0.0"
dependencies = [
"alloc 0.0.0",
"core 0.0.0",
"rustc_unicode 0.0.0",
]
[[package]]
name = "core"
version = "0.0.0"
[[package]]
name = "gcc"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.0.0"
dependencies = [
"core 0.0.0",
]
[[package]]
name = "rand"
version = "0.0.0"
dependencies = [
"core 0.0.0",
]
[[package]]
name = "rustc_bitflags"
version = "0.0.0"
dependencies = [
"core 0.0.0",
]
[[package]]
name = "rustc_unicode"
version = "0.0.0"
dependencies = [
"core 0.0.0",
]
[[package]]
name = "std"
version = "0.0.0"
dependencies = [
"alloc 0.0.0",
"alloc_jemalloc 0.0.0",
"alloc_system 0.0.0",
"build_helper 0.1.0",
"collections 0.0.0",
"core 0.0.0",
"gcc 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.0.0",
"rand 0.0.0",
"rustc_bitflags 0.0.0",
"rustc_unicode 0.0.0",
]
[[package]]
name = "winapi"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

View File

@@ -0,0 +1,46 @@
# This is a shim Cargo.toml which serves as a proxy for building the standard
# library. The reason for this is a little subtle, as one might reasonably
# expect that we just `cargo build` the standard library itself.
#
# One of the output artifacts for the standard library is a dynamic library, and
# on platforms like OSX the name of the output artifact is actually encoded into
# the library itself (similar to a soname on Linux). When the library is linked
# against, this encoded name is what's literally looked for at runtime when the
# dynamic loader is probing for libraries.
#
# Cargo, however, by default will not mangle the output filename of the
# top-level target. If we were to run `cargo build` on libstd itself, we would
# generate a file `libstd.so`. When installing, however, this file is called
# something like `libstd-abcdef0123.so`. On OSX at least this causes a failure
# at runtime because the encoded "soname" is `libstd.so`, not what the file is
# actually called.
#
# By using this shim library to build the standard library by proxy we sidestep
# this problem. The standard library is built with mangled hex already in its
# name so there's nothing extra we need to do.
[package]
name = "std_shim"
version = "0.1.0"
authors = ["The Rust Project Developers"]
[lib]
name = "std_shim"
path = "lib.rs"
[profile.release]
opt-level = 2
# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
debug = false
debug-assertions = false
[dependencies]
std = { path = "../../libstd" }
# Reexport features from std
[features]
jemalloc = ["std/jemalloc"]
debug-jemalloc = ["std/debug-jemalloc"]

11
src/rustc/std_shim/lib.rs Normal file
View File

@@ -0,0 +1,11 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// See comments in Cargo.toml for why this exists