From a122d555eb6d0613af30cfe4054c7e56921038c0 Mon Sep 17 00:00:00 2001 From: The8472 Date: Thu, 12 Nov 2020 23:47:37 +0100 Subject: [PATCH 01/14] [beta] always disable copy_file_range to avoid EOVERFLOW errors --- library/std/src/sys/unix/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 96594095cc36d..f3dd1558f1fdf 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1209,7 +1209,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { // Kernel prior to 4.5 don't have copy_file_range // We store the availability in a global to avoid unnecessary syscalls - static HAS_COPY_FILE_RANGE: AtomicBool = AtomicBool::new(true); + static HAS_COPY_FILE_RANGE: AtomicBool = AtomicBool::new(false); unsafe fn copy_file_range( fd_in: libc::c_int, From ebdd67695b8c169b9418a0878f8646ef960de442 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 10 Oct 2020 20:13:03 +0200 Subject: [PATCH 02/14] Fix outdated comment about not needing to flush stderr. --- library/std/src/io/stdio.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 2eb5fb4528620..824fae1a60606 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -754,13 +754,9 @@ pub struct StderrLock<'a> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn stderr() -> Stderr { - // Note that unlike `stdout()` we don't use `Lazy` here which registers a - // destructor. Stderr is not buffered nor does the `stderr_raw` type consume - // any owned resources, so there's no need to run any destructors at some - // point in the future. - // - // This has the added benefit of allowing `stderr` to be usable during - // process shutdown as well! + // Note that unlike `stdout()` we don't use `at_exit` here to register a + // destructor. Stderr is not buffered , so there's no need to run a + // destructor for flushing the buffer static INSTANCE: SyncOnceCell>> = SyncOnceCell::new(); Stderr { From 5195c149be667a3ef4b4f8a1449ae7898b85bcf1 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 10 Oct 2020 20:15:55 +0200 Subject: [PATCH 03/14] Remove unnecessary import of `crate::marker` in std::sys_common::remutex. It was used for marker::Send, but Send is already in scope. --- library/std/src/sys_common/remutex.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/std/src/sys_common/remutex.rs b/library/std/src/sys_common/remutex.rs index 162eab2388d55..35d6701efd0bd 100644 --- a/library/std/src/sys_common/remutex.rs +++ b/library/std/src/sys_common/remutex.rs @@ -2,7 +2,6 @@ mod tests; use crate::fmt; -use crate::marker; use crate::ops::Deref; use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sys::mutex as sys; @@ -40,7 +39,7 @@ pub struct ReentrantMutexGuard<'a, T: 'a> { lock: &'a ReentrantMutex, } -impl !marker::Send for ReentrantMutexGuard<'_, T> {} +impl !Send for ReentrantMutexGuard<'_, T> {} impl ReentrantMutex { /// Creates a new reentrant mutex in an unlocked state. From 76567e99dcb43f948d328ad7e8e8434d8cf1572a Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 10 Oct 2020 20:20:14 +0200 Subject: [PATCH 04/14] Use Pin for the 'don't move' requirement of ReentrantMutex. --- library/std/src/sys_common/remutex.rs | 52 ++++++++++----------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/library/std/src/sys_common/remutex.rs b/library/std/src/sys_common/remutex.rs index 35d6701efd0bd..475bfca9b6dcc 100644 --- a/library/std/src/sys_common/remutex.rs +++ b/library/std/src/sys_common/remutex.rs @@ -1,9 +1,10 @@ #[cfg(all(test, not(target_os = "emscripten")))] mod tests; -use crate::fmt; +use crate::marker::PhantomPinned; use crate::ops::Deref; use crate::panic::{RefUnwindSafe, UnwindSafe}; +use crate::pin::Pin; use crate::sys::mutex as sys; /// A re-entrant mutual exclusion @@ -14,6 +15,7 @@ use crate::sys::mutex as sys; pub struct ReentrantMutex { inner: sys::ReentrantMutex, data: T, + _pinned: PhantomPinned, } unsafe impl Send for ReentrantMutex {} @@ -36,7 +38,7 @@ impl RefUnwindSafe for ReentrantMutex {} /// guarded data. #[must_use = "if unused the ReentrantMutex will immediately unlock"] pub struct ReentrantMutexGuard<'a, T: 'a> { - lock: &'a ReentrantMutex, + lock: Pin<&'a ReentrantMutex>, } impl !Send for ReentrantMutexGuard<'_, T> {} @@ -50,7 +52,11 @@ impl ReentrantMutex { /// once this mutex is in its final resting place, and only then are the /// lock/unlock methods safe. pub const unsafe fn new(t: T) -> ReentrantMutex { - ReentrantMutex { inner: sys::ReentrantMutex::uninitialized(), data: t } + ReentrantMutex { + inner: sys::ReentrantMutex::uninitialized(), + data: t, + _pinned: PhantomPinned, + } } /// Initializes this mutex so it's ready for use. @@ -59,8 +65,8 @@ impl ReentrantMutex { /// /// Unsafe to call more than once, and must be called after this will no /// longer move in memory. - pub unsafe fn init(&self) { - self.inner.init(); + pub unsafe fn init(self: Pin<&mut Self>) { + self.get_unchecked_mut().inner.init() } /// Acquires a mutex, blocking the current thread until it is able to do so. @@ -75,9 +81,9 @@ impl ReentrantMutex { /// If another user of this mutex panicked while holding the mutex, then /// this call will return failure if the mutex would otherwise be /// acquired. - pub fn lock(&self) -> ReentrantMutexGuard<'_, T> { + pub fn lock(self: Pin<&Self>) -> ReentrantMutexGuard<'_, T> { unsafe { self.inner.lock() } - ReentrantMutexGuard::new(&self) + ReentrantMutexGuard { lock: self } } /// Attempts to acquire this lock. @@ -92,8 +98,12 @@ impl ReentrantMutex { /// If another user of this mutex panicked while holding the mutex, then /// this call will return failure if the mutex would otherwise be /// acquired. - pub fn try_lock(&self) -> Option> { - if unsafe { self.inner.try_lock() } { Some(ReentrantMutexGuard::new(&self)) } else { None } + pub fn try_lock(self: Pin<&Self>) -> Option> { + if unsafe { self.inner.try_lock() } { + Some(ReentrantMutexGuard { lock: self }) + } else { + None + } } } @@ -106,30 +116,6 @@ impl Drop for ReentrantMutex { } } -impl fmt::Debug for ReentrantMutex { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.try_lock() { - Some(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(), - None => { - struct LockedPlaceholder; - impl fmt::Debug for LockedPlaceholder { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("") - } - } - - f.debug_struct("ReentrantMutex").field("data", &LockedPlaceholder).finish() - } - } - } -} - -impl<'mutex, T> ReentrantMutexGuard<'mutex, T> { - fn new(lock: &'mutex ReentrantMutex) -> ReentrantMutexGuard<'mutex, T> { - ReentrantMutexGuard { lock } - } -} - impl Deref for ReentrantMutexGuard<'_, T> { type Target = T; From b4c0f99853a26ac9330b96f4de9822a829300fa3 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 10 Oct 2020 20:21:36 +0200 Subject: [PATCH 05/14] Update ReentrantMutex tests to use Pin. --- library/std/src/lib.rs | 1 + library/std/src/sys_common/remutex/tests.rs | 35 ++++++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index fa2608e6fb6d3..b24e89dd30eb5 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -267,6 +267,7 @@ #![feature(format_args_nl)] #![feature(gen_future)] #![feature(generator_trait)] +#![feature(get_mut_unchecked)] #![feature(global_asm)] #![feature(hashmap_internals)] #![feature(int_error_internals)] diff --git a/library/std/src/sys_common/remutex/tests.rs b/library/std/src/sys_common/remutex/tests.rs index 9c686e579d735..88453ded2f9fb 100644 --- a/library/std/src/sys_common/remutex/tests.rs +++ b/library/std/src/sys_common/remutex/tests.rs @@ -1,4 +1,6 @@ +use crate::boxed::Box; use crate::cell::RefCell; +use crate::pin::Pin; use crate::sync::Arc; use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; use crate::thread; @@ -6,10 +8,11 @@ use crate::thread; #[test] fn smoke() { let m = unsafe { - let m = ReentrantMutex::new(()); - m.init(); + let mut m = Box::pin(ReentrantMutex::new(())); + m.as_mut().init(); m }; + let m = m.as_ref(); { let a = m.lock(); { @@ -27,18 +30,19 @@ fn smoke() { #[test] fn is_mutex() { let m = unsafe { - let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); - m.init(); - m + // FIXME: Simplify this if Arc gets a Arc::get_pin_mut. + let mut m = Arc::new(ReentrantMutex::new(RefCell::new(0))); + Pin::new_unchecked(Arc::get_mut_unchecked(&mut m)).init(); + Pin::new_unchecked(m) }; let m2 = m.clone(); - let lock = m.lock(); + let lock = m.as_ref().lock(); let child = thread::spawn(move || { - let lock = m2.lock(); + let lock = m2.as_ref().lock(); assert_eq!(*lock.borrow(), 4950); }); for i in 0..100 { - let lock = m.lock(); + let lock = m.as_ref().lock(); *lock.borrow_mut() += i; } drop(lock); @@ -48,20 +52,21 @@ fn is_mutex() { #[test] fn trylock_works() { let m = unsafe { - let m = Arc::new(ReentrantMutex::new(())); - m.init(); - m + // FIXME: Simplify this if Arc gets a Arc::get_pin_mut. + let mut m = Arc::new(ReentrantMutex::new(())); + Pin::new_unchecked(Arc::get_mut_unchecked(&mut m)).init(); + Pin::new_unchecked(m) }; let m2 = m.clone(); - let _lock = m.try_lock(); - let _lock2 = m.try_lock(); + let _lock = m.as_ref().try_lock(); + let _lock2 = m.as_ref().try_lock(); thread::spawn(move || { - let lock = m2.try_lock(); + let lock = m2.as_ref().try_lock(); assert!(lock.is_none()); }) .join() .unwrap(); - let _lock3 = m.try_lock(); + let _lock3 = m.as_ref().try_lock(); } pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell>); From 91cb6283d8a1ae38309bbca5f2c6e262761e0744 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 7 Oct 2020 17:19:38 +0200 Subject: [PATCH 06/14] Add (internal-only) SyncOnceCell::get_or_init_pin. --- library/std/src/lazy.rs | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/library/std/src/lazy.rs b/library/std/src/lazy.rs index e0095e64faf31..091c69ca083ad 100644 --- a/library/std/src/lazy.rs +++ b/library/std/src/lazy.rs @@ -10,6 +10,7 @@ use crate::{ mem::MaybeUninit, ops::{Deref, Drop}, panic::{RefUnwindSafe, UnwindSafe}, + pin::Pin, sync::Once, }; @@ -297,6 +298,57 @@ impl SyncOnceCell { Ok(unsafe { self.get_unchecked() }) } + /// Internal-only API that gets the contents of the cell, initializing it + /// in two steps with `f` and `g` if the cell was empty. + /// + /// `f` is called to construct the value, which is then moved into the cell + /// and given as a (pinned) mutable reference to `g` to finish + /// initialization. + /// + /// This allows `g` to inspect an manipulate the value after it has been + /// moved into its final place in the cell, but before the cell is + /// considered initialized. + /// + /// # Panics + /// + /// If `f` or `g` panics, the panic is propagated to the caller, and the + /// cell remains uninitialized. + /// + /// With the current implementation, if `g` panics, the value from `f` will + /// not be dropped. This should probably be fixed if this is ever used for + /// a type where this matters. + /// + /// It is an error to reentrantly initialize the cell from `f`. The exact + /// outcome is unspecified. Current implementation deadlocks, but this may + /// be changed to a panic in the future. + pub(crate) fn get_or_init_pin(self: Pin<&Self>, f: F, g: G) -> &T + where + F: FnOnce() -> T, + G: FnOnce(Pin<&mut T>), + { + if let Some(value) = self.get_ref().get() { + return value; + } + + let slot = &self.value; + + // Ignore poisoning from other threads + // If another thread panics, then we'll be able to run our closure + self.once.call_once_force(|_| { + let value = f(); + // SAFETY: We use the Once (self.once) to guarantee unique access + // to the UnsafeCell (slot). + let value: &mut T = unsafe { (&mut *slot.get()).write(value) }; + // SAFETY: The value has been written to its final place in + // self.value. We do not to move it anymore, which we promise here + // with a Pin<&mut T>. + g(unsafe { Pin::new_unchecked(value) }); + }); + + // SAFETY: The inner value has been initialized. + unsafe { self.get_ref().get_unchecked() } + } + /// Consumes the `SyncOnceCell`, returning the wrapped value. Returns /// `None` if the cell was empty. /// From 4137adeba301b41f4ff5d2c8b3e5dd8ce918d13b Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 10 Oct 2020 20:14:33 +0200 Subject: [PATCH 07/14] Return a Pin from SyncOnceCell::get_or_init_pin. --- library/std/src/lazy.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/std/src/lazy.rs b/library/std/src/lazy.rs index 091c69ca083ad..68f57958bb233 100644 --- a/library/std/src/lazy.rs +++ b/library/std/src/lazy.rs @@ -321,13 +321,15 @@ impl SyncOnceCell { /// It is an error to reentrantly initialize the cell from `f`. The exact /// outcome is unspecified. Current implementation deadlocks, but this may /// be changed to a panic in the future. - pub(crate) fn get_or_init_pin(self: Pin<&Self>, f: F, g: G) -> &T + pub(crate) fn get_or_init_pin(self: Pin<&Self>, f: F, g: G) -> Pin<&T> where F: FnOnce() -> T, G: FnOnce(Pin<&mut T>), { if let Some(value) = self.get_ref().get() { - return value; + // SAFETY: The inner value was already initialized, and will not be + // moved anymore. + return unsafe { Pin::new_unchecked(value) }; } let slot = &self.value; @@ -345,8 +347,9 @@ impl SyncOnceCell { g(unsafe { Pin::new_unchecked(value) }); }); - // SAFETY: The inner value has been initialized. - unsafe { self.get_ref().get_unchecked() } + // SAFETY: The inner value has been initialized, and will not be moved + // anymore. + unsafe { Pin::new_unchecked(self.get_ref().get_unchecked()) } } /// Consumes the `SyncOnceCell`, returning the wrapped value. Returns From 88c006b1b9999d8c5e918e03c111d66d0ad31c4e Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 10 Oct 2020 20:22:15 +0200 Subject: [PATCH 08/14] Pin the ReentrantMutexes in sys::io::stdio. The code before this change misused the ReentrantMutexes, by calling init() on them and moving them afterwards. Now that ReentrantMutex requires Pin for init(), this mistake is no longer easy to make. --- library/std/src/io/stdio.rs | 54 ++++++++++++++++++++----------------- library/std/src/lib.rs | 1 + 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 824fae1a60606..360c435affa27 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -9,6 +9,7 @@ use crate::cell::RefCell; use crate::fmt; use crate::io::{self, BufReader, Initializer, IoSlice, IoSliceMut, LineWriter}; use crate::lazy::SyncOnceCell; +use crate::pin::Pin; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sync::{Mutex, MutexGuard}; use crate::sys::stdio; @@ -488,7 +489,7 @@ pub struct Stdout { // FIXME: this should be LineWriter or BufWriter depending on the state of // stdout (tty or not). Note that if this is not line buffered it // should also flush-on-panic or some form of flush-on-abort. - inner: &'static ReentrantMutex>>, + inner: Pin<&'static ReentrantMutex>>>, } /// A locked reference to the `Stdout` handle. @@ -548,25 +549,29 @@ pub struct StdoutLock<'a> { pub fn stdout() -> Stdout { static INSTANCE: SyncOnceCell>>> = SyncOnceCell::new(); + + fn cleanup() { + if let Some(instance) = INSTANCE.get() { + // Flush the data and disable buffering during shutdown + // by replacing the line writer by one with zero + // buffering capacity. + // We use try_lock() instead of lock(), because someone + // might have leaked a StdoutLock, which would + // otherwise cause a deadlock here. + if let Some(lock) = Pin::static_ref(instance).try_lock() { + *lock.borrow_mut() = LineWriter::with_capacity(0, stdout_raw()); + } + } + } + Stdout { - inner: INSTANCE.get_or_init(|| unsafe { - let _ = sys_common::at_exit(|| { - if let Some(instance) = INSTANCE.get() { - // Flush the data and disable buffering during shutdown - // by replacing the line writer by one with zero - // buffering capacity. - // We use try_lock() instead of lock(), because someone - // might have leaked a StdoutLock, which would - // otherwise cause a deadlock here. - if let Some(lock) = instance.try_lock() { - *lock.borrow_mut() = LineWriter::with_capacity(0, stdout_raw()); - } - } - }); - let r = ReentrantMutex::new(RefCell::new(LineWriter::new(stdout_raw()))); - r.init(); - r - }), + inner: Pin::static_ref(&INSTANCE).get_or_init_pin( + || unsafe { + let _ = sys_common::at_exit(cleanup); + ReentrantMutex::new(RefCell::new(LineWriter::new(stdout_raw()))) + }, + |mutex| unsafe { mutex.init() }, + ), } } @@ -698,7 +703,7 @@ impl fmt::Debug for StdoutLock<'_> { /// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct Stderr { - inner: &'static ReentrantMutex>, + inner: Pin<&'static ReentrantMutex>>, } /// A locked reference to the `Stderr` handle. @@ -760,11 +765,10 @@ pub fn stderr() -> Stderr { static INSTANCE: SyncOnceCell>> = SyncOnceCell::new(); Stderr { - inner: INSTANCE.get_or_init(|| unsafe { - let r = ReentrantMutex::new(RefCell::new(stderr_raw())); - r.init(); - r - }), + inner: Pin::static_ref(&INSTANCE).get_or_init_pin( + || unsafe { ReentrantMutex::new(RefCell::new(stderr_raw())) }, + |mutex| unsafe { mutex.init() }, + ), } } diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index b24e89dd30eb5..667d109fb2c42 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -294,6 +294,7 @@ #![feature(panic_info_message)] #![feature(panic_internals)] #![feature(panic_unwind)] +#![feature(pin_static_ref)] #![feature(prelude_import)] #![feature(ptr_internals)] #![feature(raw)] From d7ff9b0bccfe6b1728d46dd92192fbc8438c8155 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 17 Nov 2020 12:52:21 +0100 Subject: [PATCH 09/14] bootstrap: use the same version number for rustc and cargo Historically the stable tarballs were named after the version number of the specific tool, instead of the version number of Rust. For example, both of the following tarballs were part of the same release: rustc-1.48.0-x86_64-unknown-linux-gnu.tar.xz cargo-0.49.0-x86_64-unknown-linux-gnu.tar.xz PR #77336 changed the dist code to instead use Rust's version number for all the tarballs, regardless of the tool they contain: rustc-1.48.0-x86_64-unknown-linux-gnu.tar.xz cargo-1.48.0-x86_64-unknown-linux-gnu.tar.xz Because of that there is no need anymore to have a separate `cargo` field in src/stage0.txt, as the Cargo version will always be the same as the rustc version. This PR removes the field, simplifying the code and the maintenance work required while producing releases. --- src/bootstrap/bootstrap.py | 29 ++++------------------------- src/stage0.txt | 11 +++++------ 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 54d0a23dec58d..4fb58034ce216 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -360,7 +360,6 @@ def output(filepath): class RustBuild(object): """Provide all the methods required to build Rust""" def __init__(self): - self.cargo_channel = '' self.date = '' self._download_url = '' self.rustc_channel = '' @@ -387,7 +386,6 @@ def download_stage0(self): will move all the content to the right place. """ rustc_channel = self.rustc_channel - cargo_channel = self.cargo_channel rustfmt_channel = self.rustfmt_channel if self.rustc().startswith(self.bin_root()) and \ @@ -400,12 +398,15 @@ def download_stage0(self): rustc_channel, self.build, tarball_suffix) pattern = "rust-std-{}".format(self.build) self._download_stage0_helper(filename, pattern, tarball_suffix) - filename = "rustc-{}-{}{}".format(rustc_channel, self.build, tarball_suffix) self._download_stage0_helper(filename, "rustc", tarball_suffix) + filename = "cargo-{}-{}{}".format(rustc_channel, self.build, + tarball_suffix) + self._download_stage0_helper(filename, "cargo", tarball_suffix) self.fix_bin_or_dylib("{}/bin/rustc".format(self.bin_root())) self.fix_bin_or_dylib("{}/bin/rustdoc".format(self.bin_root())) + self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root())) lib_dir = "{}/lib".format(self.bin_root()) for lib in os.listdir(lib_dir): if lib.endswith(".so"): @@ -413,17 +414,6 @@ def download_stage0(self): with output(self.rustc_stamp()) as rust_stamp: rust_stamp.write(self.date) - if self.cargo().startswith(self.bin_root()) and \ - (not os.path.exists(self.cargo()) or - self.program_out_of_date(self.cargo_stamp())): - tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz' - filename = "cargo-{}-{}{}".format(cargo_channel, self.build, - tarball_suffix) - self._download_stage0_helper(filename, "cargo", tarball_suffix) - self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root())) - with output(self.cargo_stamp()) as cargo_stamp: - cargo_stamp.write(self.date) - if self.rustfmt() and self.rustfmt().startswith(self.bin_root()) and ( not os.path.exists(self.rustfmt()) or self.program_out_of_date(self.rustfmt_stamp(), self.rustfmt_channel) @@ -601,16 +591,6 @@ def rustc_stamp(self): """ return os.path.join(self.bin_root(), '.rustc-stamp') - def cargo_stamp(self): - """Return the path for .cargo-stamp - - >>> rb = RustBuild() - >>> rb.build_dir = "build" - >>> rb.cargo_stamp() == os.path.join("build", "stage0", ".cargo-stamp") - True - """ - return os.path.join(self.bin_root(), '.cargo-stamp') - def rustfmt_stamp(self): """Return the path for .rustfmt-stamp @@ -1056,7 +1036,6 @@ def bootstrap(help_triggered): data = stage0_data(build.rust_root) build.date = data['date'] build.rustc_channel = data['rustc'] - build.cargo_channel = data['cargo'] if "rustfmt" in data: build.rustfmt_channel = data['rustfmt'] diff --git a/src/stage0.txt b/src/stage0.txt index e5fe11004ab6c..69a2513c9ca85 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -1,6 +1,5 @@ # This file describes the stage0 compiler that's used to then bootstrap the Rust -# compiler itself. For the rustbuild build system, this also describes the -# relevant Cargo revision that we're using. +# compiler itself. # # Currently Rust always bootstraps from the previous stable release, and in our # train model this means that the master branch bootstraps from beta, beta @@ -8,13 +7,13 @@ # release. # # If you're looking at this file on the master branch, you'll likely see that -# rustc and cargo are configured to `beta`, whereas if you're looking at a -# source tarball for a stable release you'll likely see `1.x.0` for rustc and -# `0.(x+1).0` for Cargo where they were released on `date`. +# rustc is configured to `beta`, whereas if you're looking at a source tarball +# for a stable release you'll likely see `1.x.0` for rustc, with the previous +# stable release's version number. `date` is the date where the release we're +# bootstrapping off was released. date: 2020-11-16 rustc: 1.48.0 -cargo: 1.48.0 # We use a nightly rustfmt to format the source because it solves some # bootstrapping issues with use of new syntax in this repo. If you're looking at From a12d2aa3e11d7f922c1831030931f19cc23edc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 17 Nov 2020 18:04:37 +0100 Subject: [PATCH 10/14] Revert "Enable ASLR for windows-gnu" This reverts commit 0ad3da06843089c0bf10d6caa3fbbc72fa67787a. --- compiler/rustc_target/src/spec/windows_gnu_base.rs | 4 ---- compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs | 5 +---- compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs | 5 +---- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs index f556a13a5197f..4ae940ee5c494 100644 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs @@ -11,10 +11,6 @@ pub fn opts() -> TargetOptions { "-fno-use-linker-plugin".to_string(), // Always enable DEP (NX bit) when it is available "-Wl,--nxcompat".to_string(), - // Enable ASLR - "-Wl,--dynamicbase".to_string(), - // ASLR will rebase it anyway so leaving that option enabled only leads to confusion - "-Wl,--disable-auto-image-base".to_string(), ], ); diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs index 36726ab4aedab..e8dee94cceeaa 100644 --- a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs @@ -3,10 +3,7 @@ use crate::spec::{LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut base = super::windows_gnu_base::opts(); base.cpu = "x86-64".to_string(); - let gcc_pre_link_args = base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap(); - gcc_pre_link_args.push("-m64".to_string()); - // Use high-entropy 64 bit address space for ASLR - gcc_pre_link_args.push("-Wl,--high-entropy-va".to_string()); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); base.pre_link_args .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pep".to_string()]); base.max_atomic_width = Some(64); diff --git a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs index 57913ba0dab6e..e2ba553c5fde4 100644 --- a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs @@ -3,10 +3,7 @@ use crate::spec::{LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut base = super::windows_uwp_gnu_base::opts(); base.cpu = "x86-64".to_string(); - let gcc_pre_link_args = base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap(); - gcc_pre_link_args.push("-m64".to_string()); - // Use high-entropy 64 bit address space for ASLR - gcc_pre_link_args.push("-Wl,--high-entropy-va".to_string()); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); base.pre_link_args .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pep".to_string()]); base.max_atomic_width = Some(64); From 4364835366f4afca31fbd415d2693d264f5981bd Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 30 Nov 2020 09:09:55 -0800 Subject: [PATCH 11/14] [beta] revert #78790, vendor libtest for rustc-src --- src/bootstrap/dist.rs | 26 ++------------------------ src/bootstrap/lib.rs | 21 --------------------- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 29fccc0533bfe..a72aa72828519 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1040,30 +1040,6 @@ impl Step for Src { builder.copy(&builder.src.join(file), &dst_src.join(file)); } - // libtest includes std and everything else, so vendoring it - // creates exactly what's needed for `cargo -Zbuild-std` or any - // other analysis of the stdlib's source. Cargo also needs help - // finding the lock, so we copy it to libtest temporarily. - // - // Note that this requires std to only have one version of each - // crate. e.g. two versions of getopts won't be patchable. - let dst_libtest = dst_src.join("library/test"); - let dst_vendor = dst_src.join("vendor"); - let root_lock = dst_src.join("Cargo.lock"); - let temp_lock = dst_libtest.join("Cargo.lock"); - - // `cargo vendor` will delete everything from the lockfile that - // isn't used by libtest, so we need to not use any links! - builder.really_copy(&root_lock, &temp_lock); - - let mut cmd = Command::new(&builder.initial_cargo); - cmd.arg("vendor").arg(dst_vendor).current_dir(&dst_libtest); - builder.info("Dist src"); - let _time = timeit(builder); - builder.run(&mut cmd); - - builder.remove(&temp_lock); - // Create source tarball in rust-installer format let mut cmd = rust_installer(builder); cmd.arg("generate") @@ -1080,6 +1056,8 @@ impl Step for Src { .arg("--component-name=rust-src") .arg("--legacy-manifest-dirs=rustlib,cargo"); + builder.info("Dist src"); + let _time = timeit(builder); builder.run(&mut cmd); builder.remove_dir(&image); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 9f037890483cf..ff8548a0f0bb8 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1175,27 +1175,6 @@ impl Build { paths } - /// Copies a file from `src` to `dst` and doesn't use links, so - /// that the copy can be modified without affecting the original. - pub fn really_copy(&self, src: &Path, dst: &Path) { - if self.config.dry_run { - return; - } - self.verbose_than(1, &format!("Copy {:?} to {:?}", src, dst)); - if src == dst { - return; - } - let _ = fs::remove_file(&dst); - let metadata = t!(src.symlink_metadata()); - if let Err(e) = fs::copy(src, dst) { - panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e) - } - t!(fs::set_permissions(dst, metadata.permissions())); - let atime = FileTime::from_last_access_time(&metadata); - let mtime = FileTime::from_last_modification_time(&metadata); - t!(filetime::set_file_times(dst, atime, mtime)); - } - /// Copies a file from `src` to `dst` pub fn copy(&self, src: &Path, dst: &Path) { if self.config.dry_run { From fe1e664bb1d7216c76e40089314812071ac59a91 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 25 Nov 2020 21:42:39 -0500 Subject: [PATCH 12/14] Mirror centos vault to S3 --- .../dist-powerpc64le-linux/build-powerpc64le-toolchain.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh index f866a24287f9e..f78d2b7d1e843 100755 --- a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh +++ b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh @@ -14,9 +14,11 @@ SYSROOT=/usr/local/$TARGET/sysroot mkdir -p $SYSROOT pushd $SYSROOT -centos_base=http://vault.centos.org/altarch/7.3.1611/os/ppc64le/Packages/ -glibc_v=2.17-157.el7 -kernel_v=3.10.0-514.el7 +# centos_base=http://vault.centos.org/altarch/7.3.1611/os/ppc64le/Packages/ +# Mirrored from centos_base above +centos_base=https://ci-mirrors.rust-lang.org/rustc +glibc_v=2.17-157-2020-11-25.el7 +kernel_v=3.10.0-514-2020-11-25.el7 for package in glibc{,-devel,-headers}-$glibc_v kernel-headers-$kernel_v; do curl $centos_base/$package.ppc64le.rpm | \ rpm2cpio - | cpio -idm From f630fd8c029ac9f8ef5e9c3ac08468c7308fd74a Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 8 Dec 2020 17:01:20 -0500 Subject: [PATCH 13/14] Non-dev bootstrap on beta --- src/stage0.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stage0.txt b/src/stage0.txt index 69a2513c9ca85..f31fa797262db 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # stable release's version number. `date` is the date where the release we're # bootstrapping off was released. -date: 2020-11-16 +date: 2020-11-19 rustc: 1.48.0 # We use a nightly rustfmt to format the source because it solves some @@ -39,4 +39,4 @@ rustc: 1.48.0 # looking at a beta source tarball and it's uncommented we'll shortly comment it # out. -dev: 1 +#dev: 1 From b857cb648fb0842bfe46e9f27c7e4e554e3a3a2f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 5 Dec 2020 07:58:39 -0800 Subject: [PATCH 14/14] [beta] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index b9216831aac72..d00d64df9f803 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit b9216831aac72cfa8167996e3a94d976461e3fd9 +Subproject commit d00d64df9f803bf5bba8714ca498d8f9159d07f6