add a dist-thumb builder to build rust-std for the THUMB targets
the rust-std component only contains the core and compiler-builtins (+c +mem) crates cc #49382
This commit is contained in:
parent
cb1f89864e
commit
68b54a5f43
7 changed files with 89 additions and 37 deletions
|
@ -140,48 +140,55 @@ pub fn std_cargo(build: &Builder,
|
||||||
compiler: &Compiler,
|
compiler: &Compiler,
|
||||||
target: Interned<String>,
|
target: Interned<String>,
|
||||||
cargo: &mut Command) {
|
cargo: &mut Command) {
|
||||||
let mut features = build.std_features();
|
|
||||||
|
|
||||||
if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
|
if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
|
||||||
cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
|
cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When doing a local rebuild we tell cargo that we're stage1 rather than
|
if build.no_std(target) == Some(true) {
|
||||||
// stage0. This works fine if the local rust and being-built rust have the
|
// for no-std targets we only compile core and compiler-builtins
|
||||||
// same view of what the default allocator is, but fails otherwise. Since
|
cargo.arg("--features").arg("c mem")
|
||||||
// we don't have a way to express an allocator preference yet, work
|
.arg("--manifest-path")
|
||||||
// around the issue in the case of a local rebuild with jemalloc disabled.
|
.arg(build.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
|
||||||
if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
|
} else {
|
||||||
features.push_str(" force_alloc_system");
|
let mut features = build.std_features();
|
||||||
}
|
|
||||||
|
|
||||||
if compiler.stage != 0 && build.config.sanitizers {
|
// When doing a local rebuild we tell cargo that we're stage1 rather than
|
||||||
// This variable is used by the sanitizer runtime crates, e.g.
|
// stage0. This works fine if the local rust and being-built rust have the
|
||||||
// rustc_lsan, to build the sanitizer runtime from C code
|
// same view of what the default allocator is, but fails otherwise. Since
|
||||||
// When this variable is missing, those crates won't compile the C code,
|
// we don't have a way to express an allocator preference yet, work
|
||||||
// so we don't set this variable during stage0 where llvm-config is
|
// around the issue in the case of a local rebuild with jemalloc disabled.
|
||||||
// missing
|
if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
|
||||||
// We also only build the runtimes when --enable-sanitizers (or its
|
features.push_str(" force_alloc_system");
|
||||||
// config.toml equivalent) is used
|
|
||||||
let llvm_config = build.ensure(native::Llvm {
|
|
||||||
target: build.config.build,
|
|
||||||
emscripten: false,
|
|
||||||
});
|
|
||||||
cargo.env("LLVM_CONFIG", llvm_config);
|
|
||||||
}
|
|
||||||
|
|
||||||
cargo.arg("--features").arg(features)
|
|
||||||
.arg("--manifest-path")
|
|
||||||
.arg(build.src.join("src/libstd/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 compiler.stage != 0 && build.config.sanitizers {
|
||||||
if let Some(p) = build.musl_root(target) {
|
// This variable is used by the sanitizer runtime crates, e.g.
|
||||||
cargo.env("MUSL_ROOT", p);
|
// rustc_lsan, to build the sanitizer runtime from C code
|
||||||
|
// When this variable is missing, those crates won't compile the C code,
|
||||||
|
// so we don't set this variable during stage0 where llvm-config is
|
||||||
|
// missing
|
||||||
|
// We also only build the runtimes when --enable-sanitizers (or its
|
||||||
|
// config.toml equivalent) is used
|
||||||
|
let llvm_config = build.ensure(native::Llvm {
|
||||||
|
target: build.config.build,
|
||||||
|
emscripten: false,
|
||||||
|
});
|
||||||
|
cargo.env("LLVM_CONFIG", llvm_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
cargo.arg("--features").arg(features)
|
||||||
|
.arg("--manifest-path")
|
||||||
|
.arg(build.src.join("src/libstd/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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,7 @@ pub struct Target {
|
||||||
pub crt_static: Option<bool>,
|
pub crt_static: Option<bool>,
|
||||||
pub musl_root: Option<PathBuf>,
|
pub musl_root: Option<PathBuf>,
|
||||||
pub qemu_rootfs: Option<PathBuf>,
|
pub qemu_rootfs: Option<PathBuf>,
|
||||||
|
pub no_std: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structure of the `config.toml` file that configuration is read from.
|
/// Structure of the `config.toml` file that configuration is read from.
|
||||||
|
|
|
@ -649,7 +649,12 @@ impl Step for Std {
|
||||||
if build.hosts.iter().any(|t| t == target) {
|
if build.hosts.iter().any(|t| t == target) {
|
||||||
builder.ensure(compile::Rustc { compiler, target });
|
builder.ensure(compile::Rustc { compiler, target });
|
||||||
} else {
|
} else {
|
||||||
builder.ensure(compile::Test { compiler, target });
|
if build.no_std(target) == Some(true) {
|
||||||
|
// the `test` doesn't compile for no-std targets
|
||||||
|
builder.ensure(compile::Std { compiler, target });
|
||||||
|
} else {
|
||||||
|
builder.ensure(compile::Test { compiler, target });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let image = tmpdir(build).join(format!("{}-{}-image", name, target));
|
let image = tmpdir(build).join(format!("{}-{}-image", name, target));
|
||||||
|
|
|
@ -709,6 +709,12 @@ impl Build {
|
||||||
.map(|p| &**p)
|
.map(|p| &**p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if this is a no-std `target`, if defined
|
||||||
|
fn no_std(&self, target: Interned<String>) -> Option<bool> {
|
||||||
|
self.config.target_config.get(&target)
|
||||||
|
.map(|t| t.no_std)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns whether the target will be tested using the `remote-test-client`
|
/// Returns whether the target will be tested using the `remote-test-client`
|
||||||
/// and `remote-test-server` binaries.
|
/// and `remote-test-server` binaries.
|
||||||
fn remote_tested(&self, target: Interned<String>) -> bool {
|
fn remote_tested(&self, target: Interned<String>) -> bool {
|
||||||
|
|
|
@ -169,6 +169,19 @@ pub fn check(build: &mut Build) {
|
||||||
panic!("the iOS target is only supported on macOS");
|
panic!("the iOS target is only supported on macOS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if target.starts_with("thumbv") {
|
||||||
|
if build.no_std(*target).is_none() {
|
||||||
|
let target = build.config.target_config.entry(target.clone())
|
||||||
|
.or_insert(Default::default());
|
||||||
|
|
||||||
|
target.no_std = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if build.no_std(*target) == Some(false) {
|
||||||
|
panic!("All the THUMB targets are no-std targets")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure musl-root is valid
|
// Make sure musl-root is valid
|
||||||
if target.contains("musl") {
|
if target.contains("musl") {
|
||||||
// If this is a native target (host is also musl) and no musl-root is given,
|
// If this is a native target (host is also musl) and no musl-root is given,
|
||||||
|
|
19
src/ci/docker/dist-various-3/Dockerfile
Normal file
19
src/ci/docker/dist-various-3/Dockerfile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
FROM ubuntu:17.10
|
||||||
|
|
||||||
|
COPY scripts/cross-apt-packages.sh /scripts/
|
||||||
|
RUN sh /scripts/cross-apt-packages.sh
|
||||||
|
|
||||||
|
RUN apt-get build-dep -y clang llvm && apt-get install -y --no-install-recommends \
|
||||||
|
gcc-arm-none-eabi \
|
||||||
|
libnewlib-arm-none-eabi
|
||||||
|
|
||||||
|
COPY scripts/sccache.sh /scripts/
|
||||||
|
RUN sh /scripts/sccache.sh
|
||||||
|
|
||||||
|
ENV TARGETS=thumbv6m-none-eabi
|
||||||
|
ENV TARGETS=$TARGETS,thumbv7m-none-eabi
|
||||||
|
ENV TARGETS=$TARGETS,thumbv7em-none-eabi
|
||||||
|
ENV TARGETS=$TARGETS,thumbv7em-none-eabihf
|
||||||
|
|
||||||
|
ENV RUST_CONFIGURE_ARGS --disable-docs
|
||||||
|
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
|
|
@ -35,5 +35,6 @@ cc = "1.0.1"
|
||||||
[features]
|
[features]
|
||||||
c = []
|
c = []
|
||||||
default = ["c", "rustbuild", "compiler-builtins"]
|
default = ["c", "rustbuild", "compiler-builtins"]
|
||||||
|
mem = []
|
||||||
rustbuild = []
|
rustbuild = []
|
||||||
compiler-builtins = []
|
compiler-builtins = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue