diff --git a/.gitmodules b/.gitmodules index 7cd896b763f54..791404344ef3a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,7 +13,7 @@ path = src/jemalloc url = https://github.com/rust-lang/jemalloc.git [submodule "src/rust-installer"] - path = src/rust-installer + path = src/tools/rust-installer url = https://github.com/rust-lang/rust-installer.git [submodule "src/liblibc"] path = src/liblibc diff --git a/src/Cargo.lock b/src/Cargo.lock index 3dd8231a49f69..0b6597ce4e836 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -58,6 +58,29 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "backtrace" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "0.5.0" @@ -102,6 +125,11 @@ dependencies = [ name = "cargotest2" version = "0.1.0" +[[package]] +name = "cfg-if" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "clap" version = "2.22.1" @@ -115,6 +143,7 @@ dependencies = [ "unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -158,6 +187,15 @@ dependencies = [ name = "core" version = "0.0.0" +[[package]] +name = "dbghelp-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (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 = "diff" version = "0.1.10" @@ -177,6 +215,14 @@ dependencies = [ "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "error-chain" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error_index_generator" version = "0.0.0" @@ -197,6 +243,15 @@ dependencies = [ "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "flate2" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fmt_macros" version = "0.0.0" @@ -224,7 +279,7 @@ name = "handlebars" version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -233,6 +288,21 @@ dependencies = [ "serde_json 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "installer" +version = "0.0.0" +dependencies = [ + "clap 2.22.1 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "xz2 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "itoa" version = "0.3.1" @@ -249,7 +319,7 @@ dependencies = [ [[package]] name = "lazy_static" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -273,6 +343,16 @@ name = "log" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lzma-sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mdbook" version = "0.0.21" @@ -298,6 +378,15 @@ dependencies = [ "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "miniz-sys" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-traits" version = "0.1.37" @@ -453,6 +542,11 @@ dependencies = [ "syntax_pos 0.0.0", ] +[[package]] +name = "rustc-demangle" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rustc-main" version = "0.0.0" @@ -800,6 +894,15 @@ dependencies = [ "syntax_pos 0.0.0", ] +[[package]] +name = "same-file" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "serde" version = "0.9.11" @@ -887,6 +990,16 @@ dependencies = [ "serialize 0.0.0", ] +[[package]] +name = "tar" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "xattr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "term" version = "0.0.0" @@ -980,6 +1093,16 @@ name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "walkdir" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi" version = "0.2.8" @@ -990,28 +1113,57 @@ name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "xattr" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "xz2" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lzma-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "yaml-rust" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159" +"checksum backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f551bc2ddd53aea015d453ef0b635af89444afa5ed2405dd0b2062ad5d600d80" +"checksum backtrace-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d192fd129132fbc97497c1f2ec2c2c5174e376b95f535199ef4fe0a293d33842" "checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23" "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" +"checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" "checksum clap 2.22.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e17a4a72ffea176f77d6e2db609c6c919ef221f23862c9915e687fb54d833485" "checksum cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "d18d68987ed4c516dcc3e7913659bfa4076f5182eea4a7e0038bb060953e76ac" +"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" "checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472" "checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90" "checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83" +"checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" +"checksum flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "36df0166e856739905cd3d7e0b210fe818592211a008862599845e012d8d304c" "checksum gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "40899336fb50db0c78710f53e87afc54d8c7266fb76262fecc78ca1a7f09deae" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" "checksum handlebars 0.25.2 (registry+https://github.com/rust-lang/crates.io-index)" = "663e1728d8037fb0d4e13bcd1b1909fb5d913690a9929eb385922df157c2ff8f" "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4732c563b9a21a406565c4747daa7b46742f082911ae4753f390dc9ec7ee1a97" +"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" "checksum libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135" "checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad" +"checksum lzma-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "506a25e3491881f47407458f95429d153437d3a5bc4685c747de69e1ec7e897d" "checksum mdbook 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "f1e2e9d848514dcfad4195788d0d42ae5153a477c191d75d5b84fab10f222fbd" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" +"checksum miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "28eaee17666671fa872e567547e8428e83308ebe5808cdf6a0e28397dbe2c726" "checksum num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "e1cbfa3781f3fe73dc05321bed52a06d2d491eaa764c52335cf4399f046ece99" "checksum num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca313f1862c7ec3e0dfe8ace9fa91b1d9cb5c84ace3d00f5ec4216238e93c167" "checksum open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3478ed1686bd1300c8a981a940abc92b06fac9cbef747f4c668d4e032ff7b842" @@ -1023,10 +1175,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457" "checksum rls-data 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc4277ce3c57f456b11fe3145b181a844a25201bab5cbaa1978457e6e2f27d47" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" +"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95" "checksum rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "684ce48436d6465300c9ea783b6b14c4361d6b8dcbb1375b486a69cc19e2dfb0" +"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" "checksum serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)" = "a702319c807c016e51f672e5c77d6f0b46afddd744b5e437d6b8436b888b458f" "checksum serde_json 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)" = "dbc45439552eb8fb86907a2c41c1fd0ef97458efb87ff7f878db466eb581824e" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" +"checksum tar 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c2374f318bbe2c5ac6c83dd6240d5f1a73106f72d39b3f7d6f8d8637c7b425d8" "checksum term_size 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "07b6c1ac5b3fffd75073276bca1ceed01f67a28537097a2a9539e116e50fb21a" "checksum thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a" "checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7" @@ -1038,5 +1193,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum vec_map 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8cdc8b93bd0198ed872357fb2e667f7125646b1762f16d60b2c96350d361897" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum xattr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "5f04de8a1346489a2f9e9bd8526b73d135ec554227b17568456e86aa35b6f3fc" +"checksum xz2 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e9510bdf100731599107c61f77daf46713a69a568f75458999c1f9dbf6ba25b0" +"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" diff --git a/src/Cargo.toml b/src/Cargo.toml index 9aca3e134d655..99e8b9f256afc 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -13,6 +13,7 @@ members = [ "tools/build-manifest", "tools/remote-test-client", "tools/remote-test-server", + "tools/rust-installer", ] # These projects have their own Cargo.lock diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 1b69f7413b569..6557b8410b196 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -26,12 +26,6 @@ use std::process::{Command, Stdio}; use build_helper::output; -#[cfg(not(target_os = "solaris"))] -const SH_CMD: &'static str = "sh"; -// On Solaris, sh is the historical bourne shell, not a POSIX shell, or bash. -#[cfg(target_os = "solaris")] -const SH_CMD: &'static str = "bash"; - use {Build, Compiler, Mode}; use channel; use util::{cp_r, libdir, is_dylib, cp_filtered, copy, exe}; @@ -55,6 +49,10 @@ pub fn tmpdir(build: &Build) -> PathBuf { build.out.join("tmp/dist") } +fn rust_installer(build: &Build) -> Command { + build.tool_cmd(&Compiler::new(0, &build.config.build), "rust-installer") +} + /// Builds the `rust-docs` installer component. /// /// Slurps up documentation from the `stage`'s `host`. @@ -74,14 +72,14 @@ pub fn docs(build: &Build, stage: u32, host: &str) { let src = build.out.join(host).join("doc"); cp_r(&src, &dst); - let mut cmd = Command::new(SH_CMD); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust-Documentation") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-documentation-is-installed.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rust-docs") .arg("--legacy-manifest-dirs=rustlib,cargo") @@ -124,14 +122,14 @@ pub fn mingw(build: &Build, host: &str) { .arg(host); build.run(&mut cmd); - let mut cmd = Command::new(SH_CMD); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust-MinGW") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-MinGW-is-installed.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rust-mingw") .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -190,15 +188,15 @@ pub fn rustc(build: &Build, stage: u32, host: &str) { } // Finally, wrap everything up in a nice tarball! - let mut cmd = Command::new(SH_CMD); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-is-ready-to-roll.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) - .arg(format!("--non-installed-overlay={}", sanitize_sh(&overlay))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) + .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rustc") .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -300,14 +298,14 @@ pub fn std(build: &Build, compiler: &Compiler, target: &str) { let src = build.sysroot(compiler).join("lib/rustlib"); cp_r(&src.join(target), &dst); - let mut cmd = Command::new(SH_CMD); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=std-is-standing-at-the-ready.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) .arg(format!("--package-name={}-{}", name, target)) .arg(format!("--component-name=rust-std-{}", target)) .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -356,14 +354,14 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) { println!("image_src: {:?}, dst: {:?}", image_src, dst); cp_r(&image_src, &dst); - let mut cmd = Command::new(SH_CMD); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=save-analysis-saved.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) .arg(format!("--package-name={}-{}", name, target)) .arg(format!("--component-name=rust-analysis-{}", target)) .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -471,13 +469,17 @@ pub fn rust_src(build: &Build) { write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes()); // Create plain source tarball - let tarball = rust_src_location(build); + let mut tarball = rust_src_location(build); + tarball.set_extension(""); // strip .gz + tarball.set_extension(""); // strip .tar if let Some(dir) = tarball.parent() { t!(fs::create_dir_all(dir)); } - let mut cmd = Command::new("tar"); - cmd.arg("-czf").arg(sanitize_sh(&tarball)) - .arg(&plain_name) + let mut cmd = rust_installer(build); + cmd.arg("tarball") + .arg("--input").arg(&plain_name) + .arg("--output").arg(&tarball) + .arg("--work-dir=.") .current_dir(tmpdir(build)); build.run(&mut cmd); @@ -521,14 +523,14 @@ pub fn rust_src(build: &Build) { } // Create source tarball in rust-installer format - let mut cmd = Command::new(SH_CMD); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Awesome-Source.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) .arg(format!("--package-name={}", name)) .arg("--component-name=rust-src") .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -622,15 +624,15 @@ pub fn cargo(build: &Build, stage: u32, target: &str) { t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); // Generate the installer tarball - let mut cmd = Command::new("sh"); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-is-ready-to-roll.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) - .arg(format!("--non-installed-overlay={}", sanitize_sh(&overlay))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) + .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, target)) .arg("--component-name=cargo") .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -671,15 +673,15 @@ pub fn rls(build: &Build, stage: u32, target: &str) { t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); // Generate the installer tarball - let mut cmd = Command::new("sh"); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("generate") .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=RLS-ready-to-serve.") - .arg(format!("--image-dir={}", sanitize_sh(&image))) - .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) - .arg(format!("--non-installed-overlay={}", sanitize_sh(&overlay))) + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) + .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, target)) .arg("--component-name=rls") .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -730,29 +732,28 @@ pub fn extended(build: &Build, stage: u32, target: &str) { // upgrades rustc was upgraded before rust-std. To avoid rustc clobbering // the std files during uninstall. To do this ensure that rustc comes // before rust-std in the list below. - let mut input_tarballs = format!("{},{},{},{},{},{}", - sanitize_sh(&rustc_installer), - sanitize_sh(&cargo_installer), - sanitize_sh(&rls_installer), - sanitize_sh(&analysis_installer), - sanitize_sh(&docs_installer), - sanitize_sh(&std_installer)); + let mut tarballs = vec![rustc_installer, cargo_installer, rls_installer, + analysis_installer, docs_installer, std_installer]; if target.contains("pc-windows-gnu") { - input_tarballs.push_str(","); - input_tarballs.push_str(&sanitize_sh(&mingw_installer)); + tarballs.push(mingw_installer); + } + let mut input_tarballs = tarballs[0].as_os_str().to_owned(); + for tarball in &tarballs[1..] { + input_tarballs.push(","); + input_tarballs.push(tarball); } - let mut cmd = Command::new(SH_CMD); - cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/combine-installers.sh"))) + let mut cmd = rust_installer(build); + cmd.arg("combine") .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-is-ready-to-roll.") - .arg(format!("--work-dir={}", sanitize_sh(&work))) - .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) + .arg("--work-dir").arg(&work) + .arg("--output-dir").arg(&distdir(build)) .arg(format!("--package-name={}-{}", pkgname(build, "rust"), target)) .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg(format!("--input-tarballs={}", input_tarballs)) - .arg(format!("--non-installed-overlay={}", sanitize_sh(&overlay))); + .arg("--input-tarballs").arg(input_tarballs) + .arg("--non-installed-overlay").arg(&overlay); build.run(&mut cmd); let mut license = String::new(); diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 970c0bc565d86..92666e8e63907 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -574,6 +574,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-client")); + rules.build("tool-rust-installer", "src/tools/rust-installer") + .dep(|s| s.name("maybe-clean-tools")) + .dep(|s| s.name("libstd-tool")) + .run(move |s| compile::tool(build, s.stage, s.target, "rust-installer")); rules.build("tool-cargo", "src/tools/cargo") .host(true) .default(build.config.extended) @@ -704,6 +708,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .host(true) .only_host_build(true) .default(true) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| dist::rustc(build, s.stage, s.target)); rules.dist("dist-std", "src/libstd") .dep(move |s| { @@ -718,10 +723,12 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { }) .default(true) .only_host_build(true) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| dist::std(build, &s.compiler(), s.target)); rules.dist("dist-mingw", "path/to/nowhere") .default(true) .only_host_build(true) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| { if s.target.contains("pc-windows-gnu") { dist::mingw(build, s.target) @@ -732,21 +739,25 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .host(true) .only_build(true) .only_host_build(true) + .dep(move |s| tool_rust_installer(build, s)) .run(move |_| dist::rust_src(build)); rules.dist("dist-docs", "src/doc") .default(true) .only_host_build(true) .dep(|s| s.name("default:doc")) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| dist::docs(build, s.stage, s.target)); rules.dist("dist-analysis", "analysis") .default(build.config.extended) .dep(|s| s.name("dist-std")) .only_host_build(true) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| dist::analysis(build, &s.compiler(), s.target)); rules.dist("dist-rls", "rls") .host(true) .only_host_build(true) .dep(|s| s.name("tool-rls")) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| dist::rls(build, s.stage, s.target)); rules.dist("install", "path/to/nowhere") .dep(|s| s.name("default:dist")) @@ -755,6 +766,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .host(true) .only_host_build(true) .dep(|s| s.name("tool-cargo")) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| dist::cargo(build, s.stage, s.target)); rules.dist("dist-extended", "extended") .default(build.config.extended) @@ -767,6 +779,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .dep(|d| d.name("dist-cargo")) .dep(|d| d.name("dist-rls")) .dep(|d| d.name("dist-analysis")) + .dep(move |s| tool_rust_installer(build, s)) .run(move |s| dist::extended(build, s.stage, s.target)); rules.dist("dist-sign", "hash-and-sign") @@ -778,6 +791,14 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { rules.verify(); return rules; + + /// Helper to depend on a stage0 build-only rust-installer tool. + fn tool_rust_installer<'a>(build: &'a Build, step: &Step<'a>) -> Step<'a> { + step.name("tool-rust-installer") + .host(&build.config.build) + .target(&build.config.build) + .stage(0) + } } #[derive(PartialEq, Eq, Hash, Clone, Debug)] diff --git a/src/ci/docker/android-ndk.sh b/src/ci/docker/android-ndk.sh new file mode 100644 index 0000000000000..4849f84300729 --- /dev/null +++ b/src/ci/docker/android-ndk.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Copyright 2017 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 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +URL=https://dl.google.com/android/repository + +download_ndk() { + mkdir -p /android/ndk + cd /android/ndk + curl -O $URL/$1 + unzip -q $1 + rm $1 + mv android-ndk-* ndk +} + +make_standalone_toolchain() { + # See https://developer.android.com/ndk/guides/standalone_toolchain.htm + python2.7 /android/ndk/ndk/build/tools/make_standalone_toolchain.py \ + --install-dir /android/ndk/$1-$2 \ + --arch $1 \ + --api $2 +} + +remove_ndk() { + rm -rf /android/ndk/ndk +} diff --git a/src/ci/docker/arm-android/Dockerfile b/src/ci/docker/arm-android/Dockerfile index 04ca6d76c557b..86f0cc5d467d7 100644 --- a/src/ci/docker/arm-android/Dockerfile +++ b/src/ci/docker/arm-android/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:16.04 -RUN dpkg --add-architecture i386 && \ - apt-get update && \ +RUN apt-get update && \ apt-get install -y --no-install-recommends \ g++ \ make \ @@ -12,35 +11,54 @@ RUN dpkg --add-architecture i386 && \ git \ cmake \ unzip \ - expect \ - openjdk-9-jre-headless \ sudo \ - libstdc++6:i386 \ xz-utils \ libssl-dev \ pkg-config -WORKDIR /android/ -ENV PATH=$PATH:/android/ndk-arm-9/bin:/android/sdk/tools:/android/sdk/platform-tools - -COPY install-ndk.sh install-sdk.sh accept-licenses.sh /android/ -RUN sh /android/install-ndk.sh -RUN sh /android/install-sdk.sh - RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ dpkg -i dumb-init_*.deb && \ rm dumb-init_*.deb -COPY start-emulator.sh /android/ +RUN curl -o /usr/local/bin/sccache \ + https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-29-sccache-x86_64-unknown-linux-musl && \ + chmod +x /usr/local/bin/sccache -ENTRYPOINT ["/usr/bin/dumb-init", "--", "/android/start-emulator.sh"] +# Install NDK +COPY install-ndk.sh /tmp +RUN . /tmp/install-ndk.sh && \ + download_ndk android-ndk-r13b-linux-x86_64.zip && \ + make_standalone_toolchain arm 9 && \ + remove_ndk -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-unknown-linux-gnu && \ - chmod +x /usr/local/bin/sccache +# Install SDK +RUN dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + openjdk-9-jre-headless \ + tzdata \ + libstdc++6:i386 \ + libgl1-mesa-glx \ + libpulse0 + +COPY install-sdk.sh /tmp +RUN . /tmp/install-sdk.sh && \ + download_sdk tools_r25.2.5-linux.zip && \ + download_sysimage armeabi-v7a 18 && \ + create_avd armeabi-v7a 18 + +# Setup env +ENV PATH=$PATH:/android/sdk/tools +ENV PATH=$PATH:/android/sdk/platform-tools + +ENV TARGETS=arm-linux-androideabi ENV RUST_CONFIGURE_ARGS \ - --target=arm-linux-androideabi \ - --arm-linux-androideabi-ndk=/android/ndk-arm-9 + --target=$TARGETS \ + --arm-linux-androideabi-ndk=/android/ndk/arm-9 + +ENV SCRIPT python2.7 ../x.py test --target $TARGETS --verbose -ENV SCRIPT python2.7 ../x.py test --target arm-linux-androideabi +# Entrypoint +COPY start-emulator.sh /android/ +ENTRYPOINT ["/usr/bin/dumb-init", "--", "/android/start-emulator.sh"] diff --git a/src/ci/docker/arm-android/accept-licenses.sh b/src/ci/docker/arm-android/accept-licenses.sh deleted file mode 100755 index 8d8f60a5ec260..0000000000000 --- a/src/ci/docker/arm-android/accept-licenses.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/expect -f -# ignore-license - -set timeout 1800 -set cmd [lindex $argv 0] -set licenses [lindex $argv 1] - -spawn {*}$cmd -expect { - "Do you accept the license '*'*" { - exp_send "y\r" - exp_continue - } - eof -} diff --git a/src/ci/docker/arm-android/install-ndk.sh b/src/ci/docker/arm-android/install-ndk.sh index 389ec062110e0..8081872119983 100644 --- a/src/ci/docker/arm-android/install-ndk.sh +++ b/src/ci/docker/arm-android/install-ndk.sh @@ -11,23 +11,25 @@ set -ex -cpgdb() { - cp android-ndk-r11c/prebuilt/linux-x86_64/bin/gdb /android/$1/bin/$2-gdb - cp android-ndk-r11c/prebuilt/linux-x86_64/bin/gdb-orig /android/$1/bin/gdb-orig - cp -r android-ndk-r11c/prebuilt/linux-x86_64/share /android/$1/share +URL=https://dl.google.com/android/repository + +download_ndk() { + mkdir -p /android/ndk + cd /android/ndk + curl -O $URL/$1 + unzip -q $1 + rm $1 + mv android-ndk-* ndk } -# Prep the Android NDK -# -# See https://github.com/servo/servo/wiki/Building-for-Android -curl -O https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip -unzip -q android-ndk-r11c-linux-x86_64.zip -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-9 \ - --toolchain=arm-linux-androideabi-4.9 \ - --install-dir=/android/ndk-arm-9 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=arm -cpgdb ndk-arm-9 arm-linux-androideabi +make_standalone_toolchain() { + # See https://developer.android.com/ndk/guides/standalone_toolchain.html + python2.7 /android/ndk/ndk/build/tools/make_standalone_toolchain.py \ + --install-dir /android/ndk/$1-$2 \ + --arch $1 \ + --api $2 +} -rm -rf ./android-ndk-r11c-linux-x86_64.zip ./android-ndk-r11c +remove_ndk() { + rm -rf /android/ndk/ndk +} diff --git a/src/ci/docker/arm-android/install-sdk.sh b/src/ci/docker/arm-android/install-sdk.sh index 2db1d46ba2273..258fc47a7a692 100644 --- a/src/ci/docker/arm-android/install-sdk.sh +++ b/src/ci/docker/arm-android/install-sdk.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. # @@ -11,23 +11,39 @@ set -ex -# Prep the SDK and emulator -# -# Note that the update process requires that we accept a bunch of licenses, and -# we can't just pipe `yes` into it for some reason, so we take the same strategy -# located in https://github.com/appunite/docker by just wrapping it in a script -# which apparently magically accepts the licenses. +URL=https://dl.google.com/android/repository + +download_sdk() { + mkdir -p /android/sdk + cd /android/sdk + curl -O $URL/$1 + unzip -q $1 + rm -rf $1 +} + +download_sysimage() { + # See https://developer.android.com/studio/tools/help/android.html + abi=$1 + api=$2 + + filter="platform-tools,android-$api" + filter="$filter,sys-img-$abi-android-$api" -mkdir sdk -curl https://dl.google.com/android/android-sdk_r24.4-linux.tgz | \ - tar xzf - -C sdk --strip-components=1 + # Keep printing yes to accept the licenses + while true; do echo yes; sleep 10; done | \ + /android/sdk/tools/android update sdk -a --no-ui \ + --filter "$filter" +} -filter="platform-tools,android-18" -filter="$filter,sys-img-armeabi-v7a-android-18" +create_avd() { + # See https://developer.android.com/studio/tools/help/android.html + abi=$1 + api=$2 -./accept-licenses.sh "android - update sdk -a --no-ui --filter $filter" + echo no | \ + /android/sdk/tools/android create avd \ + --name $abi-$api \ + --target android-$api \ + --abi $abi +} -echo "no" | android create avd \ - --name arm-18 \ - --target android-18 \ - --abi armeabi-v7a diff --git a/src/ci/docker/arm-android/start-emulator.sh b/src/ci/docker/arm-android/start-emulator.sh index 4a73637e9ddbf..cd3369d5eaddc 100755 --- a/src/ci/docker/arm-android/start-emulator.sh +++ b/src/ci/docker/arm-android/start-emulator.sh @@ -14,5 +14,12 @@ set -ex # Setting SHELL to a file instead on a symlink helps android # emulator identify the system export SHELL=/bin/bash -nohup nohup emulator @arm-18 -no-window -partition-size 2047 0<&- &>/dev/null & + +# Using the default qemu2 engine makes time::tests::since_epoch fails because +# the emulator date is set to unix epoch (in armeabi-v7a-18 image). Using +# classic engine the emulator starts with the current date and the tests run +# fine. If another image is used, this need to be evaluated again. +nohup nohup emulator @armeabi-v7a-18 \ + -engine classic -no-window -partition-size 2047 0<&- &>/dev/null & + exec "$@" diff --git a/src/ci/docker/disabled/dist-aarch64-android/Dockerfile b/src/ci/docker/disabled/dist-aarch64-android/Dockerfile new file mode 100644 index 0000000000000..34e112a1f4f41 --- /dev/null +++ b/src/ci/docker/disabled/dist-aarch64-android/Dockerfile @@ -0,0 +1,49 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + unzip \ + sudo \ + xz-utils \ + libssl-dev \ + pkg-config + +RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ + dpkg -i dumb-init_*.deb && \ + rm dumb-init_*.deb + +RUN curl -o /usr/local/bin/sccache \ + https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-29-sccache-x86_64-unknown-linux-musl && \ + chmod +x /usr/local/bin/sccache + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +COPY android-ndk.sh / +RUN . /android-ndk.sh && \ + download_ndk android-ndk-r13b-linux-x86_64.zip && \ + make_standalone_toolchain arm64 21 && \ + remove_ndk + +ENV PATH=$PATH:/android/ndk/arm64-21/bin + +ENV DEP_Z_ROOT=/android/ndk/arm64-21/sysroot/usr/ + +ENV HOSTS=aarch64-linux-android + +ENV RUST_CONFIGURE_ARGS \ + --host=$HOSTS \ + --target=$HOSTS \ + --aarch64-linux-android-ndk=/android/ndk/arm64-21 \ + --disable-rpath \ + --enable-extended \ + --enable-cargo-openssl-static + +ENV SCRIPT python2.7 ../x.py dist --target $HOSTS --host $HOSTS diff --git a/src/ci/docker/disabled/dist-armv7-android/Dockerfile b/src/ci/docker/disabled/dist-armv7-android/Dockerfile new file mode 100644 index 0000000000000..34468969b88eb --- /dev/null +++ b/src/ci/docker/disabled/dist-armv7-android/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + unzip \ + sudo \ + xz-utils \ + libssl-dev \ + pkg-config + +RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ + dpkg -i dumb-init_*.deb && \ + rm dumb-init_*.deb + +RUN curl -o /usr/local/bin/sccache \ + https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-29-sccache-x86_64-unknown-linux-musl && \ + chmod +x /usr/local/bin/sccache + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +COPY android-ndk.sh / +RUN . /android-ndk.sh && \ + download_ndk android-ndk-r13b-linux-x86_64.zip && \ + make_standalone_toolchain arm 9 && \ + make_standalone_toolchain arm 21 && \ + remove_ndk + +ENV PATH=$PATH:/android/ndk/arm-9/bin + +ENV DEP_Z_ROOT=/android/ndk/arm-9/sysroot/usr/ + +ENV HOSTS=armv7-linux-androideabi + +ENV RUST_CONFIGURE_ARGS \ + --host=$HOSTS \ + --target=$HOSTS \ + --armv7-linux-androideabi-ndk=/android/ndk/arm \ + --disable-rpath \ + --enable-extended \ + --enable-cargo-openssl-static + +# We support api level 9, but api level 21 is required to build llvm. To +# overcome this problem we use a ndk with api level 21 to build llvm and then +# switch to a ndk with api level 9 to complete the build. When the linker is +# invoked there are missing symbols (like sigsetempty, not available with api +# level 9), the default linker behavior is to generate an error, to allow the +# build to finish we use --warn-unresolved-symbols. Note that the missing +# symbols does not affect std, only the compiler (llvm) and cargo (openssl). +RUN chmod 777 /android/ndk && \ + ln -s /android/ndk/arm-21 /android/ndk/arm + +ENV SCRIPT \ + python2.7 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \ + (export RUSTFLAGS="\"-C link-arg=-Wl,--warn-unresolved-symbols\""; \ + rm /android/ndk/arm && \ + ln -s /android/ndk/arm-9 /android/ndk/arm && \ + python2.7 ../x.py dist --host $HOSTS --target $HOSTS) diff --git a/src/ci/docker/disabled/dist-i686-android/Dockerfile b/src/ci/docker/disabled/dist-i686-android/Dockerfile new file mode 100644 index 0000000000000..cb9c76b22818c --- /dev/null +++ b/src/ci/docker/disabled/dist-i686-android/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + unzip \ + sudo \ + xz-utils \ + libssl-dev \ + pkg-config + +RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ + dpkg -i dumb-init_*.deb && \ + rm dumb-init_*.deb + +RUN curl -o /usr/local/bin/sccache \ + https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-29-sccache-x86_64-unknown-linux-musl && \ + chmod +x /usr/local/bin/sccache + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +COPY android-ndk.sh / +RUN . /android-ndk.sh && \ + download_ndk android-ndk-r13b-linux-x86_64.zip && \ + make_standalone_toolchain x86 9 && \ + make_standalone_toolchain x86 21 && \ + remove_ndk + +ENV PATH=$PATH:/android/ndk/x86-9/bin + +ENV DEP_Z_ROOT=/android/ndk/x86-9/sysroot/usr/ + +ENV HOSTS=i686-linux-android + +ENV RUST_CONFIGURE_ARGS \ + --host=$HOSTS \ + --target=$HOSTS \ + --i686-linux-android-ndk=/android/ndk/x86 \ + --disable-rpath \ + --enable-extended \ + --enable-cargo-openssl-static + +# We support api level 9, but api level 21 is required to build llvm. To +# overcome this problem we use a ndk with api level 21 to build llvm and then +# switch to a ndk with api level 9 to complete the build. When the linker is +# invoked there are missing symbols (like sigsetempty, not available with api +# level 9), the default linker behavior is to generate an error, to allow the +# build to finish we use --warn-unresolved-symbols. Note that the missing +# symbols does not affect std, only the compiler (llvm) and cargo (openssl). +RUN chmod 777 /android/ndk && \ + ln -s /android/ndk/x86-21 /android/ndk/x86 + +ENV SCRIPT \ + python2.7 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \ + (export RUSTFLAGS="\"-C link-arg=-Wl,--warn-unresolved-symbols\""; \ + rm /android/ndk/x86 && \ + ln -s /android/ndk/x86-9 /android/ndk/x86 && \ + python2.7 ../x.py dist --host $HOSTS --target $HOSTS) diff --git a/src/ci/docker/disabled/dist-x86_64-android/Dockerfile b/src/ci/docker/disabled/dist-x86_64-android/Dockerfile new file mode 100644 index 0000000000000..11a80abf8f9fc --- /dev/null +++ b/src/ci/docker/disabled/dist-x86_64-android/Dockerfile @@ -0,0 +1,49 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + unzip \ + sudo \ + xz-utils \ + libssl-dev \ + pkg-config + +RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ + dpkg -i dumb-init_*.deb && \ + rm dumb-init_*.deb + +RUN curl -o /usr/local/bin/sccache \ + https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-29-sccache-x86_64-unknown-linux-musl && \ + chmod +x /usr/local/bin/sccache + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +COPY android-ndk.sh / +RUN . /android-ndk.sh && \ + download_ndk android-ndk-r13b-linux-x86_64.zip && \ + make_standalone_toolchain x86_64 21 && \ + remove_ndk + +ENV PATH=$PATH:/android/ndk/x86_64-21/bin + +ENV DEP_Z_ROOT=/android/ndk/x86_64-21/sysroot/usr/ + +ENV HOSTS=x86_64-linux-android + +ENV RUST_CONFIGURE_ARGS \ + --host=$HOSTS \ + --target=$HOSTS \ + --x86_64-linux-android-ndk=/android/ndk/x86_64-21 \ + --disable-rpath \ + --enable-extended \ + --enable-cargo-openssl-static + +ENV SCRIPT python2.7 ../x.py dist --target $HOSTS --host $HOSTS diff --git a/src/ci/docker/dist-android/Dockerfile b/src/ci/docker/dist-android/Dockerfile index 1dd97fd4e0471..a3658225bc47c 100644 --- a/src/ci/docker/dist-android/Dockerfile +++ b/src/ci/docker/dist-android/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:16.04 -RUN dpkg --add-architecture i386 && \ - apt-get update && \ +RUN apt-get update && \ apt-get install -y --no-install-recommends \ g++ \ make \ @@ -12,28 +11,30 @@ RUN dpkg --add-architecture i386 && \ git \ cmake \ unzip \ - expect \ - openjdk-9-jre \ sudo \ - libstdc++6:i386 \ xz-utils \ libssl-dev \ pkg-config -WORKDIR /android/ -ENV PATH=$PATH:/android/ndk-arm-9/bin:/android/sdk/tools:/android/sdk/platform-tools - -COPY install-ndk.sh /android/ -RUN sh /android/install-ndk.sh - RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ dpkg -i dumb-init_*.deb && \ rm dumb-init_*.deb -ENTRYPOINT ["/usr/bin/dumb-init", "--"] RUN curl -o /usr/local/bin/sccache \ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-29-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache + chmod +x /usr/local/bin/sccache + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +# Install NDK +COPY install-ndk.sh /tmp +RUN . /tmp/install-ndk.sh && \ + download_ndk android-ndk-r13b-linux-x86_64.zip && \ + make_standalone_toolchain arm 9 && \ + make_standalone_toolchain x86 9 && \ + make_standalone_toolchain arm64 21 && \ + make_standalone_toolchain x86_64 21 && \ + remove_ndk ENV TARGETS=arm-linux-androideabi ENV TARGETS=$TARGETS,armv7-linux-androideabi @@ -44,10 +45,10 @@ ENV TARGETS=$TARGETS,x86_64-linux-android ENV RUST_CONFIGURE_ARGS \ --target=$TARGETS \ --enable-extended \ - --arm-linux-androideabi-ndk=/android/ndk-arm-9 \ - --armv7-linux-androideabi-ndk=/android/ndk-arm-9 \ - --i686-linux-android-ndk=/android/ndk-x86-9 \ - --aarch64-linux-android-ndk=/android/ndk-arm64-21 \ - --x86_64-linux-android-ndk=/android/ndk-x86_64-21 + --arm-linux-androideabi-ndk=/android/ndk/arm-9 \ + --armv7-linux-androideabi-ndk=/android/ndk/arm-9 \ + --i686-linux-android-ndk=/android/ndk/x86-9 \ + --aarch64-linux-android-ndk=/android/ndk/arm64-21 \ + --x86_64-linux-android-ndk=/android/ndk/x86_64-21 ENV SCRIPT python2.7 ../x.py dist --target $TARGETS diff --git a/src/ci/docker/dist-android/install-ndk.sh b/src/ci/docker/dist-android/install-ndk.sh index d3a2d31754543..8081872119983 100644 --- a/src/ci/docker/dist-android/install-ndk.sh +++ b/src/ci/docker/dist-android/install-ndk.sh @@ -11,34 +11,25 @@ set -ex -# Prep the Android NDK -# -# See https://github.com/servo/servo/wiki/Building-for-Android -curl -O https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip -unzip -q android-ndk-r11c-linux-x86_64.zip -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-9 \ - --toolchain=arm-linux-androideabi-4.9 \ - --install-dir=/android/ndk-arm-9 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=arm -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-21 \ - --toolchain=aarch64-linux-android-4.9 \ - --install-dir=/android/ndk-arm64-21 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=arm64 -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-9 \ - --toolchain=x86-4.9 \ - --install-dir=/android/ndk-x86-9 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=x86 -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-21 \ - --toolchain=x86_64-4.9 \ - --install-dir=/android/ndk-x86_64-21 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=x86_64 +URL=https://dl.google.com/android/repository + +download_ndk() { + mkdir -p /android/ndk + cd /android/ndk + curl -O $URL/$1 + unzip -q $1 + rm $1 + mv android-ndk-* ndk +} + +make_standalone_toolchain() { + # See https://developer.android.com/ndk/guides/standalone_toolchain.html + python2.7 /android/ndk/ndk/build/tools/make_standalone_toolchain.py \ + --install-dir /android/ndk/$1-$2 \ + --arch $1 \ + --api $2 +} -rm -rf ./android-ndk-r11c-linux-x86_64.zip ./android-ndk-r11c +remove_ndk() { + rm -rf /android/ndk/ndk +} diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 59b93b784b2f6..6abbf0530afa6 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -21,11 +21,27 @@ root_dir="`dirname $src_dir`" source "$ci_dir/shared.sh" -retry docker \ - build \ - --rm \ - -t rust-ci \ - "`dirname "$script"`/$image" +if [ -f "$docker_dir/$image/Dockerfile" ]; then + retry docker \ + build \ + --rm \ + -t rust-ci \ + "$docker_dir/$image" +elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then + if [ -n "$TRAVIS_OS_NAME" ]; then + echo Cannot run disabled images on travis! + exit 1 + fi + retry docker \ + build \ + --rm \ + -t rust-ci \ + -f "$docker_dir/disabled/$image/Dockerfile" \ + "$docker_dir" +else + echo Invalid image: $image + exit 1 +fi objdir=$root_dir/obj diff --git a/src/doc/unstable-book/src/SUMMARY.md b/src/doc/unstable-book/src/SUMMARY.md index 3d9e7c7fd860d..8f26e4d36cda2 100644 --- a/src/doc/unstable-book/src/SUMMARY.md +++ b/src/doc/unstable-book/src/SUMMARY.md @@ -178,7 +178,7 @@ - [peek](library-features/peek.md) - [placement_in](library-features/placement-in.md) - [placement_new_protocol](library-features/placement-new-protocol.md) - - [print](library-features/print.md) + - [print_internals](library-features/print-internals.md) - [proc_macro_internals](library-features/proc-macro-internals.md) - [process_try_wait](library-features/process-try-wait.md) - [question_mark_carrier](library-features/question-mark-carrier.md) diff --git a/src/doc/unstable-book/src/library-features/print.md b/src/doc/unstable-book/src/library-features/print-internals.md similarity index 84% rename from src/doc/unstable-book/src/library-features/print.md rename to src/doc/unstable-book/src/library-features/print-internals.md index dc25cb237e3b5..a68557872af55 100644 --- a/src/doc/unstable-book/src/library-features/print.md +++ b/src/doc/unstable-book/src/library-features/print-internals.md @@ -1,4 +1,4 @@ -# `print` +# `print_internals` This feature is internal to the Rust compiler and is not intended for general use. diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index af425a95fb19c..25fc5b7a4f6d9 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -159,6 +159,14 @@ pub enum DepNode { DefSpan(D), Stability(D), Deprecation(D), + ItemBodyNestedBodies(D), + ConstIsRvaluePromotableToStatic(D), + ImplParent(D), + TraitOfItem(D), + IsExportedSymbol(D), + IsMirAvailable(D), + ItemAttrs(D), + FnArgNames(D), FileMap(D, Arc), } @@ -273,6 +281,14 @@ impl DepNode { DefSpan(ref d) => op(d).map(DefSpan), Stability(ref d) => op(d).map(Stability), Deprecation(ref d) => op(d).map(Deprecation), + ItemAttrs(ref d) => op(d).map(ItemAttrs), + FnArgNames(ref d) => op(d).map(FnArgNames), + ImplParent(ref d) => op(d).map(ImplParent), + TraitOfItem(ref d) => op(d).map(TraitOfItem), + IsExportedSymbol(ref d) => op(d).map(IsExportedSymbol), + ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies), + ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic), + IsMirAvailable(ref d) => op(d).map(IsMirAvailable), GlobalMetaData(ref d, kind) => op(d).map(|d| GlobalMetaData(d, kind)), FileMap(ref d, ref file_name) => op(d).map(|d| FileMap(d, file_name.clone())), } diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 16b3fcd2f8c32..da899a9130c8b 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -210,27 +210,21 @@ pub trait CrateStore { fn visibility(&self, def: DefId) -> ty::Visibility; fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap>; fn item_generics_cloned(&self, def: DefId) -> ty::Generics; - fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>; - fn fn_arg_names(&self, did: DefId) -> Vec; // trait info fn implementations_of_trait(&self, filter: Option) -> Vec; // impl info fn impl_defaultness(&self, def: DefId) -> hir::Defaultness; - fn impl_parent(&self, impl_def_id: DefId) -> Option; // trait/impl-item info - fn trait_of_item(&self, def_id: DefId) -> Option; fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem; // flags fn is_const_fn(&self, did: DefId) -> bool; fn is_default_impl(&self, impl_did: DefId) -> bool; - fn is_foreign_item(&self, did: DefId) -> bool; fn is_dllimport_foreign_item(&self, def: DefId) -> bool; fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool; - fn is_exported_symbol(&self, def_id: DefId) -> bool; // crate metadata fn dylib_dependency_formats(&self, cnum: CrateNum) @@ -337,28 +331,22 @@ impl CrateStore for DummyCrateStore { } fn item_generics_cloned(&self, def: DefId) -> ty::Generics { bug!("item_generics_cloned") } - fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> { bug!("item_attrs") } - fn fn_arg_names(&self, did: DefId) -> Vec { bug!("fn_arg_names") } // trait info fn implementations_of_trait(&self, filter: Option) -> Vec { vec![] } // impl info fn impl_defaultness(&self, def: DefId) -> hir::Defaultness { bug!("impl_defaultness") } - fn impl_parent(&self, def: DefId) -> Option { bug!("impl_parent") } // trait/impl-item info - fn trait_of_item(&self, def_id: DefId) -> Option { bug!("trait_of_item") } fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem { bug!("associated_item_cloned") } // flags fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") } fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") } - fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") } fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false } fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false } - fn is_exported_symbol(&self, def_id: DefId) -> bool { false } // crate metadata fn dylib_dependency_formats(&self, cnum: CrateNum) diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index e03948db36831..5360a86560d39 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -205,7 +205,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> { } else if match self.tcx.hir.get_if_local(def_id) { Some(hir::map::NodeForeignItem(..)) => true, Some(..) => false, - None => self.tcx.sess.cstore.is_foreign_item(def_id), + None => self.tcx.is_foreign_item(def_id), } { self.require_unsafe_ext(expr.id, expr.span, "use of extern static", true); } diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 82a4c1e1e626a..3b5dc2ae164b6 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -34,6 +34,7 @@ use std::ops::Deref; use std::rc::Rc; use syntax_pos::{Span, DUMMY_SP}; use syntax::attr; +use syntax::ast; use syntax::symbol::Symbol; pub trait Key: Clone + Hash + Eq + Debug { @@ -340,6 +341,36 @@ impl<'tcx> QueryDescription for queries::deprecation<'tcx> { } } +impl<'tcx> QueryDescription for queries::item_attrs<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("item_attrs") + } +} + +impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("is_exported_symbol") + } +} + +impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("fn_arg_names") + } +} + +impl<'tcx> QueryDescription for queries::impl_parent<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("impl_parent") + } +} + +impl<'tcx> QueryDescription for queries::trait_of_item<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("trait_of_item") + } +} + impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> { fn describe(tcx: TyCtxt, def_id: DefId) -> String { format!("nested item bodies of `{}`", tcx.item_path_str(def_id)) @@ -781,9 +812,14 @@ define_maps! { <'tcx> [] def_span: DefSpan(DefId) -> Span, [] stability: Stability(DefId) -> Option, [] deprecation: Deprecation(DefId) -> Option, - [] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc>, - [] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool, - [] is_mir_available: metadata_dep_node(DefId) -> bool, + [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>, + [] fn_arg_names: FnArgNames(DefId) -> Vec, + [] impl_parent: ImplParent(DefId) -> Option, + [] trait_of_item: TraitOfItem(DefId) -> Option, + [] is_exported_symbol: IsExportedSymbol(DefId) -> bool, + [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc>, + [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool, + [] is_mir_available: IsMirAvailable(DefId) -> bool, } fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode { @@ -798,10 +834,6 @@ fn reachability_dep_node(_: CrateNum) -> DepNode { DepNode::Reachability } -fn metadata_dep_node(def_id: DefId) -> DepNode { - DepNode::MetaData(def_id) -} - fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode { instance.dep_node() } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 99a5f6325ac75..51cdba56cf10a 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2360,7 +2360,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if let Some(id) = self.hir.as_local_node_id(did) { Attributes::Borrowed(self.hir.attrs(id)) } else { - Attributes::Owned(self.sess.cstore.item_attrs(did)) + Attributes::Owned(self.item_attrs(did)) } } @@ -2396,7 +2396,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let trait_ref = self.impl_trait_ref(impl_def_id).unwrap(); // Record the trait->implementation mapping. - let parent = self.sess.cstore.impl_parent(impl_def_id).unwrap_or(trait_id); + let parent = self.impl_parent(impl_def_id).unwrap_or(trait_id); def.record_remote_impl(self, impl_def_id, trait_ref, parent); } @@ -2433,22 +2433,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - /// If the given def ID describes an item belonging to a trait, - /// return the ID of the trait that the trait item belongs to. - /// Otherwise, return `None`. - pub fn trait_of_item(self, def_id: DefId) -> Option { - if def_id.krate != LOCAL_CRATE { - return self.sess.cstore.trait_of_item(def_id); - } - self.opt_associated_item(def_id) - .and_then(|associated_item| { - match associated_item.container { - TraitContainer(def_id) => Some(def_id), - ImplContainer(_) => None - } - }) - } - /// Construct a parameter environment suitable for static contexts or other contexts where there /// are no free type/lifetime parameters in scope. pub fn empty_parameter_environment(self) -> ParameterEnvironment<'tcx> { @@ -2688,6 +2672,20 @@ fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span { tcx.hir.span_if_local(def_id).unwrap() } +/// If the given def ID describes an item belonging to a trait, +/// return the ID of the trait that the trait item belongs to. +/// Otherwise, return `None`. +fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option { + tcx.opt_associated_item(def_id) + .and_then(|associated_item| { + match associated_item.container { + TraitContainer(def_id) => Some(def_id), + ImplContainer(_) => None + } + }) +} + + pub fn provide(providers: &mut ty::maps::Providers) { *providers = ty::maps::Providers { associated_item, @@ -2695,6 +2693,7 @@ pub fn provide(providers: &mut ty::maps::Providers) { adt_sized_constraint, adt_dtorck_constraint, def_span, + trait_of_item, ..*providers }; } diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 8b1aa0708807b..e79f23aee1145 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -74,7 +74,7 @@ pub fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // constants, we only try to find the expression for a // trait-associated const if the caller gives us the // substitutions for the reference to it. - if tcx.sess.cstore.trait_of_item(def_id).is_some() { + if tcx.trait_of_item(def_id).is_some() { resolve_trait_associated_const(tcx, def_id, substs) } else { Some((def_id, substs)) diff --git a/src/librustc_incremental/persist/hash.rs b/src/librustc_incremental/persist/hash.rs index 5bc442deafa2b..2f727a80f016e 100644 --- a/src/librustc_incremental/persist/hash.rs +++ b/src/librustc_incremental/persist/hash.rs @@ -79,7 +79,11 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> { DepNode::FileMap(def_id, ref name) => { if def_id.is_local() { - Some(self.incremental_hashes_map[dep_node]) + // We will have been able to retrace the DefId (which is + // always the local CRATE_DEF_INDEX), but the file with the + // given name might have been removed, so we use get() in + // order to allow for that case. + self.incremental_hashes_map.get(dep_node).map(|x| *x) } else { Some(self.metadata_hash(DepNode::FileMap(def_id, name.clone()), def_id.krate, diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 715a769158bc3..3b6516af35a05 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -718,7 +718,6 @@ fn fl_lit_check_expr(cx: &EarlyContext, expr: &ast::Expr) { cx.span_lint(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, l.span, "floating-point literals cannot be used in patterns"); - error!("span mc spanspam"); }, _ => (), } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 6fa6a868605dc..f3fb427fed66f 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -41,8 +41,6 @@ use rustc::hir::svh::Svh; use rustc_back::target::Target; use rustc::hir; -use std::collections::BTreeMap; - macro_rules! provide { (<$lt:tt> $tcx:ident, $def_id:ident, $cdata:ident $($name:ident => $compute:block)*) => { pub fn provide<$lt>(providers: &mut Providers<$lt>) { @@ -113,21 +111,23 @@ provide! { <'tcx> tcx, def_id, cdata def_span => { cdata.get_span(def_id.index, &tcx.sess) } stability => { cdata.get_stability(def_id.index) } deprecation => { cdata.get_deprecation(def_id.index) } - item_body_nested_bodies => { - let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| { - ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body)) - }).collect(); - - Rc::new(map) - } + item_attrs => { cdata.get_item_attrs(def_id.index, &tcx.dep_graph) } + // FIXME(#38501) We've skipped a `read` on the `HirBody` of + // a `fn` when encoding, so the dep-tracking wouldn't work. + // This is only used by rustdoc anyway, which shouldn't have + // incremental recompilation ever enabled. + fn_arg_names => { cdata.get_fn_arg_names(def_id.index) } + impl_parent => { cdata.get_parent_impl(def_id.index) } + trait_of_item => { cdata.get_trait_of_item(def_id.index) } + is_exported_symbol => { + let dep_node = cdata.metadata_dep_node(GlobalMetaDataKind::ExportedSymbols); + cdata.exported_symbols.get(&tcx.dep_graph, dep_node).contains(&def_id.index) + } + item_body_nested_bodies => { Rc::new(cdata.item_body_nested_bodies(def_id.index)) } const_is_rvalue_promotable_to_static => { - cdata.entry(def_id.index).ast.expect("const item missing `ast`") - .decode(cdata).rvalue_promotable_to_static - } - is_mir_available => { - !cdata.is_proc_macro(def_id.index) && - cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some() + cdata.const_is_rvalue_promotable_to_static(def_id.index) } + is_mir_available => { cdata.is_item_mir_available(def_id.index) } } impl CrateStore for cstore::CStore { @@ -145,22 +145,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(def.krate).get_generics(def.index) } - fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> - { - self.get_crate_data(def_id.krate) - .get_item_attrs(def_id.index, &self.dep_graph) - } - - fn fn_arg_names(&self, did: DefId) -> Vec - { - // FIXME(#38501) We've skipped a `read` on the `HirBody` of - // a `fn` when encoding, so the dep-tracking wouldn't work. - // This is only used by rustdoc anyway, which shouldn't have - // incremental recompilation ever enabled. - assert!(!self.dep_graph.is_fully_enabled()); - self.get_crate_data(did.krate).get_fn_arg_names(did.index) - } - fn implementations_of_trait(&self, filter: Option) -> Vec { if let Some(def_id) = filter { @@ -179,16 +163,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(def.krate).get_impl_defaultness(def.index) } - fn impl_parent(&self, impl_def: DefId) -> Option { - self.dep_graph.read(DepNode::MetaData(impl_def)); - self.get_crate_data(impl_def.krate).get_parent_impl(impl_def.index) - } - - fn trait_of_item(&self, def_id: DefId) -> Option { - self.dep_graph.read(DepNode::MetaData(def_id)); - self.get_crate_data(def_id.krate).get_trait_of_item(def_id.index) - } - fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem { self.dep_graph.read(DepNode::MetaData(def)); @@ -206,23 +180,11 @@ impl CrateStore for cstore::CStore { self.get_crate_data(impl_did.krate).is_default_impl(impl_did.index) } - fn is_foreign_item(&self, did: DefId) -> bool { - self.get_crate_data(did.krate).is_foreign_item(did.index) - } - fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { self.do_is_statically_included_foreign_item(def_id) } - fn is_exported_symbol(&self, def_id: DefId) -> bool { - let data = self.get_crate_data(def_id.krate); - let dep_node = data.metadata_dep_node(GlobalMetaDataKind::ExportedSymbols); - data.exported_symbols - .get(&self.dep_graph, dep_node) - .contains(&def_id.index) - } - fn is_dllimport_foreign_item(&self, def_id: DefId) -> bool { if def_id.krate == LOCAL_CRATE { self.dllimport_foreign_items.borrow().contains(&def_id.index) diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 820b5a68bcc9b..ea845f722c345 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -30,6 +30,7 @@ use rustc::mir::Mir; use std::borrow::Cow; use std::cell::Ref; +use std::collections::BTreeMap; use std::io; use std::mem; use std::rc::Rc; @@ -453,16 +454,16 @@ impl<'tcx> EntryKind<'tcx> { } impl<'a, 'tcx> CrateMetadata { - pub fn is_proc_macro(&self, id: DefIndex) -> bool { + fn is_proc_macro(&self, id: DefIndex) -> bool { self.proc_macros.is_some() && id != CRATE_DEF_INDEX } - pub fn maybe_entry(&self, item_id: DefIndex) -> Option>> { + fn maybe_entry(&self, item_id: DefIndex) -> Option>> { assert!(!self.is_proc_macro(item_id)); self.root.index.lookup(self.blob.raw_bytes(), item_id) } - pub fn entry(&self, item_id: DefIndex) -> Entry<'tcx> { + fn entry(&self, item_id: DefIndex) -> Entry<'tcx> { match self.maybe_entry(item_id) { None => { bug!("entry: id not found: {:?} in crate {:?} with number {}", @@ -789,6 +790,22 @@ impl<'a, 'tcx> CrateMetadata { tcx.alloc_tables(ast.tables.decode((self, tcx))) } + pub fn item_body_nested_bodies(&self, id: DefIndex) -> BTreeMap { + self.entry(id).ast.into_iter().flat_map(|ast| { + ast.decode(self).nested_bodies.decode(self).map(|body| (body.id(), body)) + }).collect() + } + + pub fn const_is_rvalue_promotable_to_static(&self, id: DefIndex) -> bool { + self.entry(id).ast.expect("const item missing `ast`") + .decode(self).rvalue_promotable_to_static + } + + pub fn is_item_mir_available(&self, id: DefIndex) -> bool { + !self.is_proc_macro(id) && + self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some() + } + pub fn maybe_get_optimized_mir(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefIndex) diff --git a/src/librustc_trans/back/symbol_names.rs b/src/librustc_trans/back/symbol_names.rs index aef9140ba4556..1aed293294802 100644 --- a/src/librustc_trans/back/symbol_names.rs +++ b/src/librustc_trans/back/symbol_names.rs @@ -223,7 +223,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance _ => false } } else { - tcx.sess.cstore.is_foreign_item(def_id) + tcx.is_foreign_item(def_id) }; if let Some(name) = weak_lang_items::link_name(&attrs) { diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 6d7d95f548721..5f8b79a994a55 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -652,8 +652,8 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan } Some(_) => true, None => { - if tcx.sess.cstore.is_exported_symbol(def_id) || - tcx.sess.cstore.is_foreign_item(def_id) + if tcx.is_exported_symbol(def_id) || + tcx.is_foreign_item(def_id) { // We can link to the item in question, no instance needed // in this crate diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 6afb340107d66..eac0a06256719 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -186,7 +186,7 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef { llvm::set_thread_local(g, true); } } - if ccx.use_dll_storage_attrs() && !ccx.sess().cstore.is_foreign_item(def_id) { + if ccx.use_dll_storage_attrs() && !ccx.tcx().is_foreign_item(def_id) { // This item is external but not foreign, i.e. it originates from an external Rust // crate. Since we don't know whether this crate will be linked dynamically or // statically in the final application, we always mark such symbols as 'dllimport'. diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 24d056035ceec..2dde6d9d4ee55 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1180,7 +1180,7 @@ impl<'a, 'tcx> Clean for (DefId, ty::PolyFnSig<'tcx>) { let mut names = if cx.tcx.hir.as_local_node_id(did).is_some() { vec![].into_iter() } else { - cx.tcx.sess.cstore.fn_arg_names(did).into_iter() + cx.tcx.fn_arg_names(did).into_iter() }.peekable(); FnDecl { output: Return(sig.skip_binder().output().clean(cx)), diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index e2832873e2e67..c872a8e526114 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -287,9 +287,11 @@ pub use self::error::{Result, Error, ErrorKind}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; #[stable(feature = "rust1", since = "1.0.0")] -pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; +pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +#[unstable(feature = "print_internals", issue = "0")] +pub use self::stdio::{_print, _eprint}; #[unstable(feature = "libstd_io_internals", issue = "0")] #[doc(no_inline, hidden)] pub use self::stdio::{set_panic, set_print}; diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 38ad23e14b3eb..a8b0bf0071a22 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -17,7 +17,7 @@ use io::{self, BufReader, LineWriter}; use sync::{Arc, Mutex, MutexGuard}; use sys::stdio; use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; -use thread::LocalKeyState; +use thread::{LocalKey, LocalKeyState}; /// Stdout used by print! and println! macros thread_local! { @@ -659,41 +659,56 @@ pub fn set_print(sink: Option>) -> Option> { }) } -#[unstable(feature = "print", - reason = "implementation detail which may disappear or be replaced at any time", - issue = "0")] -#[doc(hidden)] -pub fn _print(args: fmt::Arguments) { - // As an implementation of the `println!` macro, we want to try our best to - // not panic wherever possible and get the output somewhere. There are - // currently two possible vectors for panics we take care of here: - // - // 1. If the TLS key for the local stdout has been destroyed, accessing it - // would cause a panic. Note that we just lump in the uninitialized case - // here for convenience, we're not trying to avoid a panic. - // 2. If the local stdout is currently in use (e.g. we're in the middle of - // already printing) then accessing again would cause a panic. - // - // If, however, the actual I/O causes an error, we do indeed panic. - let result = match LOCAL_STDOUT.state() { +/// Write `args` to output stream `local_s` if possible, `global_s` +/// otherwise. `label` identifies the stream in a panic message. +/// +/// This function is used to print error messages, so it takes extra +/// care to avoid causing a panic when `local_stream` is unusable. +/// For instance, if the TLS key for the local stream is uninitialized +/// or already destroyed, or if the local stream is locked by another +/// thread, it will just fall back to the global stream. +/// +/// However, if the actual I/O causes an error, this function does panic. +fn print_to(args: fmt::Arguments, + local_s: &'static LocalKey>>>, + global_s: fn() -> T, + label: &str) where T: Write { + let result = match local_s.state() { LocalKeyState::Uninitialized | - LocalKeyState::Destroyed => stdout().write_fmt(args), + LocalKeyState::Destroyed => global_s().write_fmt(args), LocalKeyState::Valid => { - LOCAL_STDOUT.with(|s| { + local_s.with(|s| { if let Ok(mut borrowed) = s.try_borrow_mut() { if let Some(w) = borrowed.as_mut() { return w.write_fmt(args); } } - stdout().write_fmt(args) + global_s().write_fmt(args) }) } }; if let Err(e) = result { - panic!("failed printing to stdout: {}", e); + panic!("failed printing to {}: {}", label, e); } } +#[unstable(feature = "print_internals", + reason = "implementation detail which may disappear or be replaced at any time", + issue = "0")] +#[doc(hidden)] +pub fn _print(args: fmt::Arguments) { + print_to(args, &LOCAL_STDOUT, stdout, "stdout"); +} + +#[unstable(feature = "print_internals", + reason = "implementation detail which may disappear or be replaced at any time", + issue = "0")] +#[doc(hidden)] +pub fn _eprint(args: fmt::Arguments) { + use panicking::LOCAL_STDERR; + print_to(args, &LOCAL_STDERR, stderr, "stderr"); +} + #[cfg(test)] mod tests { use thread; diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index a1f092621cb44..ef78ea6dfe8ee 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -68,6 +68,9 @@ macro_rules! panic { /// necessary to use `io::stdout().flush()` to ensure the output is emitted /// immediately. /// +/// Use `print!` only for the primary output of your program. Use +/// `eprint!` instead to print error and progress messages. +/// /// # Panics /// /// Panics if writing to `io::stdout()` fails. @@ -105,9 +108,12 @@ macro_rules! print { /// Use the `format!` syntax to write data to the standard output. /// See `std::fmt` for more information. /// +/// Use `println!` only for the primary output of your program. Use +/// `eprintln!` instead to print error and progress messages. +/// /// # Panics /// -/// Panics if writing to `io::stdout()` fails. +/// Panics if writing to `io::stdout` fails. /// /// # Examples /// @@ -124,6 +130,45 @@ macro_rules! println { ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); } +/// Macro for printing to the standard error. +/// +/// Equivalent to the `print!` macro, except that output goes to +/// `io::stderr` instead of `io::stdout`. See `print!` for +/// example usage. +/// +/// Use `eprint!` only for error and progress messages. Use `print!` +/// instead for the primary output of your program. +/// +/// # Panics +/// +/// Panics if writing to `io::stderr` fails. +#[macro_export] +#[stable(feature = "eprint", since="1.18.0")] +#[allow_internal_unstable] +macro_rules! eprint { + ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*))); +} + +/// Macro for printing to the standard error, with a newline. +/// +/// Equivalent to the `println!` macro, except that output goes to +/// `io::stderr` instead of `io::stdout`. See `println!` for +/// example usage. +/// +/// Use `eprintln!` only for error and progress messages. Use `println!` +/// instead for the primary output of your program. +/// +/// # Panics +/// +/// Panics if writing to `io::stderr` fails. +#[macro_export] +#[stable(feature = "eprint", since="1.18.0")] +macro_rules! eprintln { + () => (eprint!("\n")); + ($fmt:expr) => (eprint!(concat!($fmt, "\n"))); + ($fmt:expr, $($arg:tt)*) => (eprint!(concat!($fmt, "\n"), $($arg)*)); +} + /// A macro to select an event from a number of receivers. /// /// This macro is used to wait for the first event to occur on a number of diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 5e46069cf7ddf..1646f8cce7232 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -199,7 +199,10 @@ pub const ERROR_TIMEOUT: DWORD = 0x5B4; pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; +pub const FACILITY_NT_BIT: DWORD = 0x1000_0000; + pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; +pub const FORMAT_MESSAGE_FROM_HMODULE: DWORD = 0x00000800; pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200; pub const TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF; diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 7e28dd1e259c8..e2b431cbd3a29 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -32,7 +32,7 @@ pub fn errno() -> i32 { } /// Gets a detailed string description for the given error number. -pub fn error_string(errnum: i32) -> String { +pub fn error_string(mut errnum: i32) -> String { // This value is calculated from the macro // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) let langId = 0x0800 as c::DWORD; @@ -40,9 +40,27 @@ pub fn error_string(errnum: i32) -> String { let mut buf = [0 as c::WCHAR; 2048]; unsafe { - let res = c::FormatMessageW(c::FORMAT_MESSAGE_FROM_SYSTEM | + let mut module = ptr::null_mut(); + let mut flags = 0; + + // NTSTATUS errors may be encoded as HRESULT, which may returned from + // GetLastError. For more information about Windows error codes, see + // `[MS-ERREF]`: https://msdn.microsoft.com/en-us/library/cc231198.aspx + if (errnum & c::FACILITY_NT_BIT as i32) != 0 { + // format according to https://support.microsoft.com/en-us/help/259693 + const NTDLL_DLL: &'static [u16] = &['N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _, + '.' as _, 'D' as _, 'L' as _, 'L' as _, 0]; + module = c::GetModuleHandleW(NTDLL_DLL.as_ptr()); + + if module != ptr::null_mut() { + errnum ^= c::FACILITY_NT_BIT as i32; + flags = c::FORMAT_MESSAGE_FROM_HMODULE; + } + } + + let res = c::FormatMessageW(flags | c::FORMAT_MESSAGE_FROM_SYSTEM | c::FORMAT_MESSAGE_IGNORE_INSERTS, - ptr::null_mut(), + module, errnum as c::DWORD, langId, buf.as_mut_ptr(), @@ -299,3 +317,17 @@ pub fn home_dir() -> Option { pub fn exit(code: i32) -> ! { unsafe { c::ExitProcess(code as c::UINT) } } + +#[cfg(test)] +mod tests { + use io::Error; + use sys::c; + + // tests `error_string` above + #[test] + fn ntstatus_error() { + const STATUS_UNSUCCESSFUL: u32 = 0xc000_0001; + assert!(!Error::from_raw_os_error(STATUS_UNSUCCESSFUL | c::FACILITY_NT_BIT as _) + .to_string().contains("FormatMessageW() returned error")); + } +} diff --git a/src/rust-installer b/src/rust-installer deleted file mode 160000 index 2e6417f6af521..0000000000000 --- a/src/rust-installer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2e6417f6af5218a29a8ee72ed17af085560b9b9c diff --git a/src/test/incremental/remove_source_file/auxiliary/mod.rs b/src/test/incremental/remove_source_file/auxiliary/mod.rs new file mode 100644 index 0000000000000..a2cea65a309ce --- /dev/null +++ b/src/test/incremental/remove_source_file/auxiliary/mod.rs @@ -0,0 +1,13 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn print_hello() { + println!("hello"); +} diff --git a/src/test/incremental/remove_source_file/main.rs b/src/test/incremental/remove_source_file/main.rs new file mode 100644 index 0000000000000..4ba33f3bb3d62 --- /dev/null +++ b/src/test/incremental/remove_source_file/main.rs @@ -0,0 +1,31 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test case makes sure that the compiler doesn't crash due to a failing +// table lookup when a source file is removed. + +// revisions:rpass1 rpass2 + +// Note that we specify -g so that the FileMaps actually get referenced by the +// incr. comp. cache: +// compile-flags: -Z query-dep-graph -g + +#[cfg(rpass1)] +mod auxiliary; + +#[cfg(rpass1)] +fn main() { + auxiliary::print_hello(); +} + +#[cfg(rpass2)] +fn main() { + println!("hello"); +} diff --git a/src/test/run-pass/print-stdout-eprint-stderr.rs b/src/test/run-pass/print-stdout-eprint-stderr.rs new file mode 100644 index 0000000000000..0a0f30aba72c2 --- /dev/null +++ b/src/test/run-pass/print-stdout-eprint-stderr.rs @@ -0,0 +1,40 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-emscripten spawning processes is not supported + +use std::{env, process}; + +fn child() { + print!("[stdout 0]"); + print!("[stdout {}]", 1); + println!("[stdout {}]", 2); + println!(); + eprint!("[stderr 0]"); + eprint!("[stderr {}]", 1); + eprintln!("[stderr {}]", 2); + eprintln!(); +} + +fn parent() { + let this = env::args().next().unwrap(); + let output = process::Command::new(this).arg("-").output().unwrap(); + assert!(output.status.success()); + + let stdout = String::from_utf8(output.stdout).unwrap(); + let stderr = String::from_utf8(output.stderr).unwrap(); + + assert_eq!(stdout, "[stdout 0][stdout 1][stdout 2]\n\n"); + assert_eq!(stderr, "[stderr 0][stderr 1][stderr 2]\n\n"); +} + +fn main() { + if env::args().count() == 2 { child() } else { parent() } +} diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a044282666da0..911f3c51f5f60 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -570,7 +570,7 @@ actual:\n\ format!("-command={}", debugger_script.to_str().unwrap())]; let mut gdb_path = tool_path; - gdb_path.push_str(&format!("/bin/{}-gdb", self.config.target)); + gdb_path.push_str("/bin/gdb"); let procsrv::Result { out, err, @@ -647,6 +647,11 @@ actual:\n\ exe_file.to_str().unwrap() .replace(r"\", r"\\"))); + // Force GDB to print values in the Rust format. + if self.config.gdb_native_rust { + script_str.push_str("set language rust\n"); + } + // Add line breakpoints for line in &breakpoint_lines { script_str.push_str(&format!("break '{}':{}\n", diff --git a/src/tools/rls b/src/tools/rls index 67babd2d63710..207c18da7d73f 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 67babd2d63710444a3071dfd9184648fd85a6a3d +Subproject commit 207c18da7d73faf0217fa433cce3a9d075f2fe25 diff --git a/src/tools/rust-installer b/src/tools/rust-installer new file mode 160000 index 0000000000000..b787d33b0eb4d --- /dev/null +++ b/src/tools/rust-installer @@ -0,0 +1 @@ +Subproject commit b787d33b0eb4dbb4ffb7de71af1027a782dccf0b diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index f14a6a03893b3..6b666fa809f7a 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -81,12 +81,12 @@ fn filter_dirs(path: &Path) -> bool { "src/libbacktrace", "src/compiler-rt", "src/rustllvm", - "src/rust-installer", "src/liblibc", "src/vendor", "src/rt/hoedown", "src/tools/cargo", "src/tools/rls", + "src/tools/rust-installer", ]; skip.iter().any(|p| path.ends_with(p)) }