From f1ff74ff967cff9634fff73a88cd9d4b93c2ba3f Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Tue, 12 Jul 2022 18:30:05 -0400 Subject: [PATCH 1/9] Fix gdb-cmd for rust-gdbgui --- src/etc/rust-gdbgui | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/etc/rust-gdbgui b/src/etc/rust-gdbgui index 9744913b68650..590e488e643aa 100755 --- a/src/etc/rust-gdbgui +++ b/src/etc/rust-gdbgui @@ -58,7 +58,6 @@ GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" -iex \"add-auto-load-safe # Finally we execute gdbgui. PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \ exec ${RUST_GDBGUI} \ - --gdb ${RUST_GDB} \ - --gdb-args "${GDB_ARGS}" \ + --gdb-cmd "${RUST_GDB} ${GDB_ARGS}" \ "${@}" From 8abcd4d23538aa1e4c1164bca2c96ce0d7eb57ed Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 29 Jul 2022 00:17:05 +0000 Subject: [PATCH 2/9] EscapeAscii is not an ExactSizeIterator --- library/core/src/slice/ascii.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/core/src/slice/ascii.rs b/library/core/src/slice/ascii.rs index 63715a6b86b97..5e5399acc1b0f 100644 --- a/library/core/src/slice/ascii.rs +++ b/library/core/src/slice/ascii.rs @@ -215,8 +215,6 @@ impl<'a> iter::DoubleEndedIterator for EscapeAscii<'a> { } } #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] -impl<'a> iter::ExactSizeIterator for EscapeAscii<'a> {} -#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> iter::FusedIterator for EscapeAscii<'a> {} #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> fmt::Display for EscapeAscii<'a> { From 67220d69702b4428a811d063fce3045da7a4040d Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 2 Oct 2022 08:33:54 -0500 Subject: [PATCH 3/9] Make the `config.src` handling for downloadable bootstrap a little more conservative In particular, this supports build directories within an unrelated git repository. As a side effect, it will fall back to the old logic when the source directory is being built from a tarball within an unrelated git repository. However, that second case is unsupported and untested; we reserve the right to break it in the future. --- src/bootstrap/config.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index f29b5170ea5e2..1a9134125226f 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -829,10 +829,19 @@ impl Config { let s = git_root.to_str().unwrap(); // Bootstrap is quite bad at handling /? in front of paths - config.src = match s.strip_prefix("\\\\?\\") { + let src = match s.strip_prefix("\\\\?\\") { Some(p) => PathBuf::from(p), None => PathBuf::from(git_root), }; + // If this doesn't have at least `stage0.json`, we guessed wrong. This can happen when, + // for example, the build directory is inside of another unrelated git directory. + // In that case keep the original `CARGO_MANIFEST_DIR` handling. + // + // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside + // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1. + if src.join("src").join("stage0.json").exists() { + config.src = src; + } } else { // We're building from a tarball, not git sources. // We don't support pre-downloaded bootstrap in this case. From e4549d5526b8626f1060c346eaf30ef776ecfcf5 Mon Sep 17 00:00:00 2001 From: Anirudh Date: Mon, 3 Oct 2022 04:47:14 +0530 Subject: [PATCH 4/9] Improve readability of bootstrap's README by adding commas and minor changes (cherry picked from commit e5e4b85feba6463310d0fc0c27e8ff38891efac3) --- src/bootstrap/README.md | 64 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index a2e596bf4e958..54b2d1b4bef76 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -1,7 +1,7 @@ # rustbuild - Bootstrapping Rust This is an in-progress README which is targeted at helping to explain how Rust -is bootstrapped and in general some of the technical details of the build +is bootstrapped and in general, some of the technical details of the build system. ## Using rustbuild @@ -12,7 +12,7 @@ The rustbuild build system has a primary entry point, a top level `x.py` script: $ python ./x.py build ``` -Note that if you're on Unix you should be able to execute the script directly: +Note that if you're on Unix, you should be able to execute the script directly: ```sh $ ./x.py build @@ -20,8 +20,8 @@ $ ./x.py build The script accepts commands, flags, and arguments to determine what to do: -* `build` - a general purpose command for compiling code. Alone `build` will - bootstrap the entire compiler, and otherwise arguments passed indicate what to +* `build` - a general purpose command for compiling code. Alone, `build` will + bootstrap the entire compiler, and otherwise, arguments passed indicate what to build. For example: ``` @@ -38,7 +38,7 @@ The script accepts commands, flags, and arguments to determine what to do: ./x.py build --stage 0 library/test ``` - If files are dirty that would normally be rebuilt from stage 0, that can be + If files that would normally be rebuilt from stage 0 are dirty, the rebuild can be overridden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps that belong to stage n or earlier: @@ -47,8 +47,8 @@ The script accepts commands, flags, and arguments to determine what to do: ./x.py build --keep-stage 0 ``` -* `test` - a command for executing unit tests. Like the `build` command this - will execute the entire test suite by default, and otherwise it can be used to +* `test` - a command for executing unit tests. Like the `build` command, this + will execute the entire test suite by default, and otherwise, it can be used to select which test suite is run: ``` @@ -75,7 +75,7 @@ The script accepts commands, flags, and arguments to determine what to do: ./x.py test src/doc ``` -* `doc` - a command for building documentation. Like above can take arguments +* `doc` - a command for building documentation. Like above, can take arguments for what to document. ## Configuring rustbuild @@ -110,12 +110,12 @@ compiler. What actually happens when you invoke rustbuild is: compiles the build system itself (this folder). Finally, it then invokes the actual `bootstrap` binary build system. 2. In Rust, `bootstrap` will slurp up all configuration, perform a number of - sanity checks (compilers exist for example), and then start building the + sanity checks (whether compilers exist, for example), and then start building the stage0 artifacts. -3. The stage0 `cargo` downloaded earlier is used to build the standard library +3. The stage0 `cargo`, downloaded earlier, is used to build the standard library and the compiler, and then these binaries are then copied to the `stage1` directory. That compiler is then used to generate the stage1 artifacts which - are then copied to the stage2 directory, and then finally the stage2 + are then copied to the stage2 directory, and then finally, the stage2 artifacts are generated using that compiler. The goal of each stage is to (a) leverage Cargo as much as possible and failing @@ -149,7 +149,7 @@ like this: build/ # Location where the stage0 compiler downloads are all cached. This directory - # only contains the tarballs themselves as they're extracted elsewhere. + # only contains the tarballs themselves, as they're extracted elsewhere. cache/ 2015-12-19/ 2016-01-15/ @@ -172,10 +172,10 @@ build/ # hand. x86_64-unknown-linux-gnu/ - # The build artifacts for the `compiler-rt` library for the target this - # folder is under. The exact layout here will likely depend on the platform, - # and this is also built with CMake so the build system is also likely - # different. + # The build artifacts for the `compiler-rt` library for the target that + # this folder is under. The exact layout here will likely depend on the + # platform, and this is also built with CMake, so the build system is + # also likely different. compiler-rt/ build/ @@ -183,11 +183,11 @@ build/ llvm/ # build folder (e.g. the platform-specific build system). Like with - # compiler-rt this is compiled with CMake + # compiler-rt, this is compiled with CMake build/ # Installation of LLVM. Note that we run the equivalent of 'make install' - # for LLVM to setup these folders. + # for LLVM, to setup these folders. bin/ lib/ include/ @@ -206,18 +206,18 @@ build/ # Location where the stage0 Cargo and Rust compiler are unpacked. This # directory is purely an extracted and overlaid tarball of these two (done - # by the bootstrapy python script). In theory the build system does not + # by the bootstrap python script). In theory, the build system does not # modify anything under this directory afterwards. stage0/ - # These to build directories are the cargo output directories for builds of - # the standard library and compiler, respectively. Internally these may also + # These to-build directories are the cargo output directories for builds of + # the standard library and compiler, respectively. Internally, these may also # have other target directories, which represent artifacts being compiled # from the host to the specified target. # # Essentially, each of these directories is filled in by one `cargo` # invocation. The build system instruments calling Cargo in the right order - # with the right variables to ensure these are filled in correctly. + # with the right variables to ensure that these are filled in correctly. stageN-std/ stageN-test/ stageN-rustc/ @@ -232,8 +232,8 @@ build/ # being compiled (e.g. after libstd has been built), *this* is used as the # sysroot for the stage0 compiler being run. # - # Basically this directory is just a temporary artifact use to configure the - # stage0 compiler to ensure that the libstd we just built is used to + # Basically, this directory is just a temporary artifact used to configure the + # stage0 compiler to ensure that the libstd that we just built is used to # compile the stage1 compiler. stage0-sysroot/lib/ @@ -242,7 +242,7 @@ build/ # system will link (using hard links) output from stageN-{std,rustc} into # each of these directories. # - # In theory there is no extra build output in these directories. + # In theory, there is no extra build output in these directories. stage1/ stage2/ stage3/ @@ -265,14 +265,14 @@ structure here serves two goals: depend on `std`, so libstd is a separate project compiled ahead of time before the actual compiler builds. 2. Splitting "host artifacts" from "target artifacts". That is, when building - code for an arbitrary target you don't need the entire compiler, but you'll + code for an arbitrary target, you don't need the entire compiler, but you'll end up needing libraries like libtest that depend on std but also want to use crates.io dependencies. Hence, libtest is split out as its own project that is sequenced after `std` but before `rustc`. This project is built for all targets. There is some loss in build parallelism here because libtest can be compiled in -parallel with a number of rustc artifacts, but in theory the loss isn't too bad! +parallel with a number of rustc artifacts, but in theory, the loss isn't too bad! ## Build tools @@ -285,13 +285,13 @@ appropriate libstd/libtest/librustc compile above. ## Extending rustbuild -So you'd like to add a feature to the rustbuild build system or just fix a bug. +So, you'd like to add a feature to the rustbuild build system or just fix a bug. Great! One of the major motivational factors for moving away from `make` is that Rust is in theory much easier to read, modify, and write. If you find anything -excessively confusing, please open an issue on this and we'll try to get it -documented or simplified pronto. +excessively confusing, please open an issue on this, and we'll try to get it +documented or simplified, pronto. -First up, you'll probably want to read over the documentation above as that'll +First up, you'll probably want to read over the documentation above, as that'll give you a high level overview of what rustbuild is doing. You also probably want to play around a bit yourself by just getting it up and running before you dive too much into the actual build system itself. @@ -326,7 +326,7 @@ A 'major change' includes Changes that do not affect contributors to the compiler or users building rustc from source don't need an update to `VERSION`. -If you have any questions feel free to reach out on the `#t-infra` channel in +If you have any questions, feel free to reach out on the `#t-infra` channel in the [Rust Zulip server][rust-zulip] or ask on internals.rust-lang.org. When you encounter bugs, please file issues on the rust-lang/rust issue tracker. From cddc6434d0ebcdb23745eba4ec3b036702f7d454 Mon Sep 17 00:00:00 2001 From: Anirudh Date: Mon, 3 Oct 2022 05:14:55 +0530 Subject: [PATCH 5/9] Remove trailing whitespaces --- src/bootstrap/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index 54b2d1b4bef76..985727bddc533 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -172,9 +172,9 @@ build/ # hand. x86_64-unknown-linux-gnu/ - # The build artifacts for the `compiler-rt` library for the target that - # this folder is under. The exact layout here will likely depend on the - # platform, and this is also built with CMake, so the build system is + # The build artifacts for the `compiler-rt` library for the target that + # this folder is under. The exact layout here will likely depend on the + # platform, and this is also built with CMake, so the build system is # also likely different. compiler-rt/ build/ From 0567fec8e47f83ddda623f93deccddddd3f6744f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 5 Oct 2022 21:37:23 -0700 Subject: [PATCH 6/9] test: run-make: skip when cross-compiling This test fails when targeting aarch64 Android. Instead of adding yet another architecture here (and one that's increasingly more common as the host), let's replace the growing list of architectures with ignore-cross-compile. --- src/test/run-make/issue-36710/Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/test/run-make/issue-36710/Makefile b/src/test/run-make/issue-36710/Makefile index b5270ad2ba9d4..986a3f4e64bab 100644 --- a/src/test/run-make/issue-36710/Makefile +++ b/src/test/run-make/issue-36710/Makefile @@ -1,10 +1,6 @@ -# ignore-riscv64 $(call RUN,foo) expects to run the target executable natively +# ignore-cross-compile $(call RUN,foo) expects to run the target executable natively # so it won't work with remote-test-server -# ignore-arm Another build using remote-test-server # ignore-none no-std is not supported -# ignore-wasm32 FIXME: don't attempt to compile C++ to WASM -# ignore-wasm64 FIXME: don't attempt to compile C++ to WASM -# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for `std` # ignore-musl FIXME: this makefile needs teaching how to use a musl toolchain # (see dist-i586-gnu-i586-i686-musl Dockerfile) From d2e14e2d114bd3f7b56afdb4f6171577b13272c5 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 8 Oct 2022 10:43:23 -0700 Subject: [PATCH 7/9] rustdoc: remove mobile topbar from source pages instead of hiding it --- src/librustdoc/html/static/css/rustdoc.css | 4 ---- src/librustdoc/html/static/js/main.js | 14 ++++++++------ src/librustdoc/html/templates/page.html | 2 ++ src/test/rustdoc-gui/sidebar-source-code.goml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index e29abbec69c2d..4b96ed204874b 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1807,10 +1807,6 @@ in storage.js plus the media query with (min-width: 701px) top: 0; } - .source .mobile-topbar { - display: none; - } - .sidebar-menu-toggle { width: 45px; /* Rare exception to specifying font sizes in rem. Since this is acting diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 6d21ffdc79254..359dd41b13fed 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -735,14 +735,15 @@ function loadCss(cssFileName) { let oldSidebarScrollPosition = null; function showSidebar() { - if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) { + const mobile_topbar = document.querySelector(".mobile-topbar"); + if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT && mobile_topbar) { // This is to keep the scroll position on mobile. oldSidebarScrollPosition = window.scrollY; document.body.style.width = `${document.body.offsetWidth}px`; document.body.style.position = "fixed"; document.body.style.top = `-${oldSidebarScrollPosition}px`; - document.querySelector(".mobile-topbar").style.top = `${oldSidebarScrollPosition}px`; - document.querySelector(".mobile-topbar").style.position = "relative"; + mobile_topbar.style.top = `${oldSidebarScrollPosition}px`; + mobile_topbar.style.position = "relative"; } else { oldSidebarScrollPosition = null; } @@ -751,13 +752,14 @@ function loadCss(cssFileName) { } function hideSidebar() { - if (oldSidebarScrollPosition !== null) { + const mobile_topbar = document.querySelector(".mobile-topbar"); + if (oldSidebarScrollPosition !== null && mobile_topbar) { // This is to keep the scroll position on mobile. document.body.style.width = ""; document.body.style.position = ""; document.body.style.top = ""; - document.querySelector(".mobile-topbar").style.top = ""; - document.querySelector(".mobile-topbar").style.position = ""; + mobile_topbar.style.top = ""; + mobile_topbar.style.position = ""; // The scroll position is lost when resetting the style, hence why we store it in // `oldSidebarScrollPosition`. window.scrollTo(0, oldSidebarScrollPosition); diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 7caffeae3d610..01a2ea6c2ec33 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -73,6 +73,7 @@ {#- -#} {#- -#} {{- layout.external_html.before_content|safe -}} + {%- if page.css_class != "source" -%} {#- -#} + {%- endif -%}