From a3d5e34903fbd966d96017d52bb14e92fca874d0 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Mon, 3 Jun 2019 13:06:35 -0700 Subject: [PATCH 1/8] Fix cfg(test) build for x86_64-fortanix-unknown-sgx --- src/libstd/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index e044b46e0d076..a3356e6be2c3f 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -223,7 +223,8 @@ #![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"), feature(global_asm, slice_index_methods, decl_macro, coerce_unsized, sgx_platform, ptr_wrapping_offset_from))] -#![cfg_attr(all(test, target_vendor = "fortanix", target_env = "sgx"), feature(fixed_size_array))] +#![cfg_attr(all(test, target_vendor = "fortanix", target_env = "sgx"), + feature(fixed_size_array, maybe_uninit_extra))] // std is implemented with unstable features, many of which are internal // compiler details that will never be stable From 674f24e13270db4e172bb1eb4d8a3b5c4da20cb5 Mon Sep 17 00:00:00 2001 From: Reinier Maas Date: Wed, 5 Jun 2019 08:41:37 +0200 Subject: [PATCH 2/8] Edit docs of ExitStatus The documentation of [`ExitStatus`] are extended to be at the same depth as [`Output`]. --- src/libstd/process.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 6e4c6e4c366e4..6d20c8b49f4e5 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1153,10 +1153,13 @@ impl From for Stdio { /// /// This `struct` is used to represent the exit status of a child process. /// Child processes are created via the [`Command`] struct and their exit -/// status is exposed through the [`status`] method. +/// status is exposed through the [`status`] method, or the [`wait`] method +/// of a [`Child`] process. /// /// [`Command`]: struct.Command.html +/// [`Child`]: struct.Child.html /// [`status`]: struct.Command.html#method.status +/// [`wait`]: struct.Child.html#method.wait #[derive(PartialEq, Eq, Clone, Copy, Debug)] #[stable(feature = "process", since = "1.0.0")] pub struct ExitStatus(imp::ExitStatus); From dcd46d6b67710b4991aebdb4d6e53b15fe26479a Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 5 Jun 2019 09:37:16 +0200 Subject: [PATCH 3/8] Don't allow using const fn arguments as "args_required_const" --- src/librustc_mir/transform/qualify_consts.rs | 4 +++- src/test/ui/consts/const_arg_promotable2.rs | 9 +++++++++ src/test/ui/consts/const_arg_promotable2.stderr | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/consts/const_arg_promotable2.rs create mode 100644 src/test/ui/consts/const_arg_promotable2.stderr diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index fe94181047fcd..8696291e05875 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1304,7 +1304,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { } } - if self.mode == Mode::Fn { + // No need to do anything in constants and statics, as everything is "constant" anyway + // so promotion would be useless. + if self.mode != Mode::Static && self.mode != Mode::Const { let constant_args = callee_def_id.and_then(|id| { args_required_const(self.tcx, id) }).unwrap_or_default(); diff --git a/src/test/ui/consts/const_arg_promotable2.rs b/src/test/ui/consts/const_arg_promotable2.rs new file mode 100644 index 0000000000000..5d9400a907bde --- /dev/null +++ b/src/test/ui/consts/const_arg_promotable2.rs @@ -0,0 +1,9 @@ +#![feature(rustc_attrs)] +const fn foo(a: i32) { + bar(a); //~ ERROR argument 1 is required to be a constant +} + +#[rustc_args_required_const(0)] +const fn bar(_: i32) {} + +fn main() {} diff --git a/src/test/ui/consts/const_arg_promotable2.stderr b/src/test/ui/consts/const_arg_promotable2.stderr new file mode 100644 index 0000000000000..67a1132f830f2 --- /dev/null +++ b/src/test/ui/consts/const_arg_promotable2.stderr @@ -0,0 +1,8 @@ +error: argument 1 is required to be a constant + --> $DIR/const_arg_promotable2.rs:3:5 + | +LL | bar(a); + | ^^^^^^ + +error: aborting due to previous error + From dd12f39b359093b19034bf2384f9ed195d61d586 Mon Sep 17 00:00:00 2001 From: Reinier Maas Date: Wed, 5 Jun 2019 09:58:39 +0200 Subject: [PATCH 4/8] Tidy: trailing whitespace Removed trailing whitespace from documentation of ExitStatus. --- src/libstd/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 6d20c8b49f4e5..a568f46663730 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1153,7 +1153,7 @@ impl From for Stdio { /// /// This `struct` is used to represent the exit status of a child process. /// Child processes are created via the [`Command`] struct and their exit -/// status is exposed through the [`status`] method, or the [`wait`] method +/// status is exposed through the [`status`] method, or the [`wait`] method /// of a [`Child`] process. /// /// [`Command`]: struct.Command.html From 77e93358686f725012109f8bb0c8738182d74701 Mon Sep 17 00:00:00 2001 From: coypoop Date: Wed, 5 Jun 2019 12:19:34 +0300 Subject: [PATCH 5/8] Don't use GNU noexec stack note NetBSD ignores this note and marks the stack no-exec unconditionally --- src/librustc_target/spec/netbsd_base.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/librustc_target/spec/netbsd_base.rs b/src/librustc_target/spec/netbsd_base.rs index e9cd98c0e7151..72e2fd59cf8d6 100644 --- a/src/librustc_target/spec/netbsd_base.rs +++ b/src/librustc_target/spec/netbsd_base.rs @@ -9,9 +9,6 @@ pub fn opts() -> TargetOptions { // libraries which follow this flag. Thus, use it before // specifying libraries to link to. "-Wl,--as-needed".to_string(), - - // Always enable NX protection when it is available - "-Wl,-z,noexecstack".to_string(), ]); TargetOptions { From 192c1d0717f2ba123b449a021257f2df571242d2 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 5 Jun 2019 13:25:17 +0200 Subject: [PATCH 6/8] Explain the existience of the regression test --- src/test/ui/consts/const_arg_promotable2.rs | 11 ++++++++++- src/test/ui/consts/const_arg_promotable2.stderr | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/ui/consts/const_arg_promotable2.rs b/src/test/ui/consts/const_arg_promotable2.rs index 5d9400a907bde..3399e51ed4edb 100644 --- a/src/test/ui/consts/const_arg_promotable2.rs +++ b/src/test/ui/consts/const_arg_promotable2.rs @@ -1,3 +1,8 @@ +// This test is a regression test for a bug where we only checked function calls in no-const +// functions for `rustc_args_required_const` arguments. This meant that even though `bar` needs its +// argument to be const, inside a const fn (callable at runtime), the value for it may come from a +// non-constant (namely an argument to the const fn). + #![feature(rustc_attrs)] const fn foo(a: i32) { bar(a); //~ ERROR argument 1 is required to be a constant @@ -6,4 +11,8 @@ const fn foo(a: i32) { #[rustc_args_required_const(0)] const fn bar(_: i32) {} -fn main() {} +fn main() { + // this function call will pass a runtime-value (number of program arguments) to `foo`, which + // will in turn forward it to `bar`, which expects a compile-time argument + foo(std::env::args().count() as i32); +} diff --git a/src/test/ui/consts/const_arg_promotable2.stderr b/src/test/ui/consts/const_arg_promotable2.stderr index 67a1132f830f2..149d1ce89408d 100644 --- a/src/test/ui/consts/const_arg_promotable2.stderr +++ b/src/test/ui/consts/const_arg_promotable2.stderr @@ -1,5 +1,5 @@ error: argument 1 is required to be a constant - --> $DIR/const_arg_promotable2.rs:3:5 + --> $DIR/const_arg_promotable2.rs:8:5 | LL | bar(a); | ^^^^^^ From 0b88e5a87e4b20810d1b2a2964cbacd4a58e64b6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 4 Jun 2019 07:30:33 -0700 Subject: [PATCH 7/8] azure: Make sure docker directory exists Looks like the Azure image changed recently so let's account for that! --- .azure-pipelines/steps/run.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/steps/run.yml b/.azure-pipelines/steps/run.yml index cfa28a6a1d70f..05b14eb45b216 100644 --- a/.azure-pipelines/steps/run.yml +++ b/.azure-pipelines/steps/run.yml @@ -50,6 +50,7 @@ steps: # on since libstd tests require it - bash: | set -e + sudo mkdir -p /etc/docker echo '{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}' | sudo tee /etc/docker/daemon.json sudo service docker restart displayName: Enable IPv6 From fb3bd58e4f75c6752d0e2d32a04270044515c00d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 5 Jun 2019 07:36:19 -0700 Subject: [PATCH 8/8] azure: Uninstall previous rustc from builders if any Looks like Azure has updated images recently to install Rust by default, but that can interfere with our own compiler (for example Cargo's test suite we think) so be sure to uninstall it before proceeding. --- .azure-pipelines/steps/run.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.azure-pipelines/steps/run.yml b/.azure-pipelines/steps/run.yml index 05b14eb45b216..a646b34fe7d02 100644 --- a/.azure-pipelines/steps/run.yml +++ b/.azure-pipelines/steps/run.yml @@ -102,6 +102,10 @@ steps: - bash: | set -e + # Remove any preexisting rustup installation since it can interfere + # with the cargotest step and its auto-detection of things like Clippy in + # the environment + rustup self uninstall -y || true if [ "$IMAGE" = "" ]; then src/ci/run.sh else