Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6748fd0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 20 + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-patch"] + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7a01f56 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI +on: + pull_request: + push: + branches-ignore: + - 'dependabot/**' +permissions: + contents: read +jobs: + test: + name: Test + strategy: + matrix: + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + rust: ["stable"] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + - uses: Swatinem/rust-cache@v2 + - name: Build + run: cargo test --no-run + - name: Test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: cargo test + - name: Verify that binary works + run: | + cargo run -- bisect-rustc --help | grep "Examples:" + + fmt: + name: rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - name: Run rustfmt check + run: | + cargo fmt --version + cargo fmt --check || (echo "Please reformat your code with 'cargo fmt' (version $(cargo fmt --version))"; false) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..41bf66d --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,40 @@ +name: Documentation Deploy +on: + push: + branches: + - master + +permissions: + contents: read + +jobs: + deploy: + permissions: + contents: write # for Git to git push + runs-on: ubuntu-latest + env: + MDBOOK_VERSION: 0.4.28 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install mdbook + run: | + mkdir mdbook + curl -Lf https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook + echo `pwd`/mdbook >> $GITHUB_PATH + - name: Deploy docs + run: | + cd guide + mdbook build + git worktree add gh-pages + git config user.name "Deploy from CI" + git config user.email "" + cd gh-pages + # Delete the ref to avoid keeping history. + git update-ref -d refs/heads/gh-pages + rm -rf * + mv ../book/* . + git add . + git commit -m "Deploy $GITHUB_SHA to gh-pages" + git push --force --set-upstream origin gh-pages diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ff0c8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/rust.git +/target +**/*.rs.bk diff --git a/404.html b/404.html new file mode 100644 index 0000000..e584356 --- /dev/null +++ b/404.html @@ -0,0 +1,192 @@ + + +
+ + +This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +Each commit also generates what are called “alt” builds. +These are builds of rustc with some different options set. +As of August 2023, these include:
+rust.parallel-compiler
llvm.assertions
rust.verify-llvm-ir
For more information on these settings, see the config.toml
docs.
+These alt settings are defined in ci/run.sh
.
Alt builds are only available for a few targets.
+Look for the -alt
builds in ci.yml
.
This can be useful if you are bisecting an LLVM issue. +With LLVM assertions enabled, alt builds have checks that can help identify broken assumptions.
+Alt builds are only made for commit builds, and not nightly releases.
+You will need to specify --by-commit
(or use a hash in the --start
or --end
flags) to only use commit builds.
cargo bisect-rustc --alt --by-commit
+
+
+ cargo-bisect-rustc
does a binary search for the regression using a start and end boundary.
+You can specify these boundaries with the --start
and --end
CLI flags.
+There are several ways to specify what those boundaries are.
+If you run the command without specifying the boundaries, it will search for them automatically:
# No --start or --end flags
+cargo bisect-rustc
+
+This will assume the latest nightly is a regression (the end boundary). +It will then search backwards until it can find a nightly that passes to use as the start boundary. +Bisection can usually go faster if you happen to know the start boundary, so that it doesn’t need to search for it.
+--start
and --end
are optional.
+If --start
is not specified, then it will try to find the start range automatically.
+If --end
is not specified, it will assume it is the most recently available.
You can pass a date in the form YYYY-MM-DD to the --start
and --end
flags.
+It will download the nightly corresponding to that date, and then begin bisecting those nightlies.
cargo bisect-rustc --start=2018-08-14 --end=2018-10-11
+
+If the nightly with the regression was within the past 167 days, then it will automatically start bisecting the individual PRs merged on that day using Git commit boundaries.
+You can pass the particular git commit hash of a PR as a boundary. +The Rust project keeps the builds of every merged PR for the last 167 days. +If you happen to know the PR to use as a boundary, you can pass the SHA-1 hash of that PR.
+cargo bisect-rustc \
+ --start=6323d9a45bdf0ac2a9319a6a558537e0a7e6abd1 \
+ --end=866a713258915e6cbb212d135f751a6a8c9e1c0a
+
+There are several ways to determine the SHA-1 hash for a PR.
+rust-lang:master
”.
+You can copy that hash to use as a boundary.
+If the PR was merged as part of a rollup, you will need to use the hash of the rollup instead.
+You’ll need to look through the PR messages to see if the PR was mentioned from a rollup PR.git log --first-parent upstream/master
(where upstream
is your origin name for rust-lang/rust
).
+This will show all the top-level commits.
+You can then search for your PR.++Note: If the PR was merged after the most recent nightly, you’ll need to be sure to also specify the
+--end
range. +Otherwise it will assume the most recent nightly is the end and it won’t work if the start is after the end.
If the regression is found in a rollup PR, then cargo-bisect-rustc
will bisect the individual PRs within the rollup.
+This final bisection is only available for x86_64-unknown-linux-gnu
since it is using the builds made for the rustc performance tracker.
++Note: If you specify date boundaries, then you can use the
+--by-commit
CLI option to force it to use PR commits instead of nightlies.
The boundary can be specified with a git release tag.
+This is useful if you know something works in one release and not another, but you don’t happen to know which nightly this corresponds with.
+When given a tag, cargo-bisect-rustc
will try to find the nightly that corresponds with that release.
+For example:
cargo bisect-rustc --start=1.58.0 --end=1.59.0
+
+When writing your test and picking a bisection range, you should be careful to ensure that the test won’t vary between pass/fail over the bisection range. +It should only transition from good to bad once in the bisection range (it must change +monotonically).
+In the following example, cargo-bisect-rustc
will find one of the transitions, but that may not be the true root cause of the issue you are investigating.
nightly-2023-02-01 baseline **start**
+nightly-2023-02-02 baseline
+nightly-2023-02-03 baseline
+nightly-2023-02-04 regression
+nightly-2023-02-05 regression
+nightly-2023-02-06 baseline
+nightly-2023-02-07 regression
+nightly-2023-02-08 regression **end**
+
+Here it may either find 2023-02-04 or 2023-02-07 as the regression.
+The following are some suggestions for avoiding or dealing with this problem:
+-vv
flag (very verbose) to display the output from the compiler to make sure it is what you expect.--prompt
flag to inspect the output and verify each step.cargo-bisect-rustc
can be used to check for Clippy regressions, too.
+You’ll need to instruct it to download clippy, and run the command correctly:
cargo bisect-rustc --start=1.67.0 --end=1.68.0 -c clippy -- clippy
+
+Note that depending on what you are looking for, this may just find a PR that syncs the rust-clippy
repo to rust-lang/rust
.
+You may be able to scan the list of changes in that PR to discover what you are looking for.
+If the list of changes is too big or nothing is jumping out as a possible culprit, then consider using git bisect
on the clippy repo itself (which will require building clippy).
By default, cargo-bisect-rustc
only fetches rustc
, cargo
, rustdoc
, and the standard library for the host.
+You may need additional Rustup Components to run your test.
+Some examples of when this might be needed are:
x86_64-pc-windows-gnu
host may need the rust-mingw
component.If you are testing cross-compilation, use the --target
option to download the standard library for the target you are using.
The following example shows how to use components to do a bisection with Cargo’s build-std feature.
+cargo-bisect-rustc --start=2022-11-01 --end=2022-11-20 -c rust-src -- build -Zbuild-std
+
+++ +Note: The
+--with-src
option is an alias for-c rust-src
.
+The--with-dev
option is an alias for-c rustc-dev -c llvm-tools
.
The following is an example of checking when the diagnostic output of rustc
changes.
+For example, this can check when either the wording has changed, or a different error or warning is produced.
#109067 is an example of where this is necessary.
+A warning started being emitted, and it is the kind of warning that cannot be turned into an error with deny(warnings)
.
The following script is intended to be used with the --script
option (set the executable flag on the script, chmod u+x
):
#!/bin/sh
+
+OUTPUT=`cargo check 2>&1`
+# Comment out this test if your example is intended to fail.
+if [ $? -ne 0 ]
+then
+ echo "Build unexpectedly failed: $OUTPUT"
+ exit 1
+fi
+# Display the output for debugging purposes.
+# Run `cargo-bisect-rustc` with `-vv` to view the output.
+echo "$OUTPUT"
+# This indicates a regression when the text "non-ASCII" is in the output.
+#
+# If the regression is when the text is *not* in the output, remove the `!` prefix
+# (and customize the `--term-old` and `--term-new` CLI options if you want).
+! echo "$OUTPUT" | grep "non-ASCII"
+
+Then run something like:
+cargo bisect-rustc --start=1.67.0 --end=1.68.0 --script ./test.sh \
+ --term-old="No warning" --term-new="Found non-ASCII warning"
+
+
+ cargo-bisect-rustc
can be used to scan for changes in the documentation shipped with each release.
+This includes all the books and standard library documentation.
+To do this, instruct it to download the component, and use a script that scans for whatever you are looking for.
+You can use rustup doc --path
or rustc --print=sysroot
to find the proper location.
+For example:
test.sh
:
#!/bin/sh
+
+# Exit if any command fails.
+set -e
+
+STD=`dirname $(rustup doc --std --path)`
+
+# Checks if a particular file exists.
+# This could also be `grep` or any other kinds of tests you need.
+if [ -e $STD/io/error/type.RawOsError.html ]
+then
+ echo "found"
+ exit 1
+fi
+
+And run with:
+cargo bisect-rustc --start 1.68.0 --end 1.69.0 -c rust-docs --script ./test.sh \
+ --term-old="Did not find" --term-new="Found"
+
+++ +Note: This may not work on all targets since
+cargo-bisect-rustc
doesn’t properly handle rustup manifests, which alias some targets to other targets. +Use--host x86_64-unknown-linux-gnu
in that situation.
Some tests may fail randomly.
+The following script is an example that will run rustc
repeatedly to check for a failure.
+This example is from #108216 (which requires macOS).
test.sh
:
#!/bin/sh
+
+rm -rf *.o incremental foo
+
+echo "fn main() { let a: i64 = 1 << 64; }" > foo1.rs
+echo "fn main() { let a: i64 = 1 << 63; }" > foo2.rs
+
+ARGS="--crate-name foo -C split-debuginfo=unpacked -C debuginfo=2 -C incremental=incremental"
+
+for i in {1..20}
+do
+ echo run $i
+ rustc foo1.rs $ARGS && { echo "ERROR: first build should have failed"; exit 1; }
+ rustc foo2.rs $ARGS || { echo "ERROR: second build should have passed"; exit 1; }
+ ./foo || { echo "ERROR: executing should have passed"; exit 1; }
+done
+
+This test can be run with:
+cargo bisect-rustc --start=1.57.0 --end=1.58.0 --script=./test.sh
+
+In general, configure the script to perform whichever actions you need in a for
loop that runs enough times that you have a high confidence it has found the regression.
Testing for regressions with incremental compilation may require running a command multiple times. +The following illustrates an example for #87384 which only generates a warning the second time a build is run with incremental. +Previously no warning was emitted.
+foo.rs
:
+#![type_length_limit = "95595489"] + +pub fn main() { + println!("Hello, world!"); +}
Create a script test.sh
:
#!/bin/sh
+
+# Exit if any command fails.
+set -e
+
+rm -rf incremental
+rustc foo.rs --crate-type lib -C incremental=incremental
+echo second
+OUTPUT=`rustc foo.rs --crate-type lib -C incremental=incremental 2>&1`
+echo $OUTPUT
+! echo "$OUTPUT" | grep \
+ "crate-level attribute should be in the root module"
+
+Run this script with:
+cargo-bisect-rustc --start 1.54.0 --end 1.55.0 --script ./test.sh
+
+
+ The following chapters show examples of different ways of using cargo-bisect-rustc
.
You may want to reuse the toolchains downloaded by cargo-bisect-rustc
for doing further analysis or debugging.
+Or, while setting up your regression test, you may need to adjust your test and script several times, and downloading the same toolchains multiple times can be quite slow.
You can do this with the --preserve
option.
cargo bisect-rustc --start=2023-01-01 --end=2023-02-01 --preserve
+
+The toolchains will be kept in your Rustup home directory (typically ~/.rustup/toolchains
).
Toolchains for nightlies will have the form of bisector-nightly-YYYY-MM-DD-<target>
.
+Toolchains for PR artifacts will have the form of bisector-ci-<hash>-<target>
.
You can run these toolchains using a Rustup override, like this:
+cargo +bisector-nightly-2023-03-18-x86_64-unknown-linux-gnu build
+# or...
+cargo +bisector-ci-e187f8871e3d553181c9d2d4ac111197a139ca0d-x86_64-unknown-linux-gnu build
+
+When you are done, you’ll probably want to clean up these directories since they use a lot of space. +The easiest method is to just delete the directories:
+rm -rf ~/.rustup/toolchains/bisector-*
+
+The --install
option can be used to only install a toolchain.
+This won’t do a bisection, it is just for fetching a toolchain for testing.
cargo bisect-rustc --install e187f8871e3d553181c9d2d4ac111197a139ca0d
+
+++ +Note: See also
+rustup-toolchain-install-master
which is specialized for installing CI artifacts.
cargo-bisect-rustc
can be used to check for Rustdoc regressions, too.
+All you need to do is instruct it to use the correct command.
The following example will check to find a regression when cargo doc
suddenly starts to fail.
cargo bisect-rustc --start=2022-08-05 --end=2022-09-09 -- doc
+
+Some rustdoc regressions might be in the generated HTML output. +To scan the output, you can use a script like the following:
+test.sh
:
#!/bin/sh
+
+# Exit if any command fails.
+set -e
+
+cargo doc
+
+grep "some example text" $CARGO_TARGET_DIR/doc/mycrate/fn.foo.html
+
+This can be used with the --script
option:
cargo-bisect-rustc --start=2023-01-22 --end=2023-03-18 --script=./test.sh \
+ --term-old="Found example text" --term-new="Failed, or did not find text"
+
+
+ Some regressions may involve the compiler hanging or taking an unusually long time to run.
+The --timeout
CLI option can be used to check for this.
+Let’s use #89524 as an example.
+A particular combination of factors caused the compiler to start to hang.
Change Cargo.toml
to the following:
[package]
+name = "slow"
+version = "0.1.0"
+
+[dependencies]
+config = "=0.9.3"
+
+[profile.release]
+panic = "abort"
+codegen-units = 1
+
+Then use the timeout option:
+cargo-bisect-rustc --start=2021-09-01 --end=2021-10-02 --timeout 30 -- build --release
+
+You may need to adjust the timeout value based on the speed of your system.
+++ +Note:
+--timeout
is currently not working on macOS. See https://github.com/rust-lang/cargo-bisect-rustc/issues/232.
Using the --script
option on Windows can be cumbersome because Windows does not support #!
scripts like Unix does, and the built-in scripting can also be awkward.
+The following sections show the different ways you can use scripting.
You can use DOS-style .bat
files:
test.bat
:
(cargo check 2>&1) | find "E0642"
+
+This can be executed directly with:
+cargo-bisect-rustc --script ./test.bat
+
+But .bat
can be challenging to do more complex options, or you may not be familiar with it.
You can’t execute .ps1
Powershell files directly, so you will need to use pwsh
to launch them:
test.ps1
:
( cargo check 2>&1 ) | grep E0642
+if ( -Not $? ) {
+ exit 1
+}
+
+This can be run with:
+cargo-bisect-rustc --script pwsh -- -File ./test.ps1
+
+If you have Git-for-Windows installed, then you can use its copy of bash to run bash scripts:
+test.sh
:
#!/bin/bash
+
+cargo check 2>&1 | grep E0642
+
+This can be run with:
+cargo-bisect-rustc --script "C:\\Program Files\\Git\\usr\\bin\\bash.exe" -- ./test.sh
+
+This also works if you have bash from something like msys2 installed.
+ +Some bisections don’t require Cargo.
+You can use the --without-cargo
option to skip installing cargo which can speed up the bisection since it doesn’t need to download cargo, and doesn’t have the overhead of running cargo.
+You will need to pair this with --script
since cargo-bisect-rustc
assumes projects use Cargo.
For example, using a simple rustc
command:
cargo-bisect-rustc --start=2022-11-01 --end=2022-11-20 --without-cargo --script=rustc -- foo.rs
+
+++ +Note: You can use
+--without-cargo
while still using a Cargo project. +Rustup will fall back to usingcargo
from your installed nightly, beta, or stable toolchain. +However, this isn’t recommended sincecargo
is only intended to work with the version it is released with, and can sometimes be incompatible with different versions. +But if you are bisecting a very recent change, then you can probably get away with it.
There are some rare cases where you may need to build rustc
with custom options, or otherwise work around issues with pre-built compilers not being available.
+For this you can use git bisect
to build the compiler locally.
It can be helpful to use the --first-parent
option so that it only bisects the merge commits directly reachable on the master branch.
+Otherwise the bisecting may land on intermediate commits from within a PR which may not build or test correctly.
To start the bisection, specifying the boundaries where the bisection will start:
+git bisect start --first-parent
+git bisect good 96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef
+git bisect bad a00f8ba7fcac1b27341679c51bf5a3271fa82df3
+
+Then, build the compiler as needed and run your tests to check for a regression:
+./x.py build std
+rustc +stage1 foo.rs
+
+You may want to consider running ./x.py clean
if you are running into issues since changes to the internal structures of build artifacts aren’t always versioned, and those changes can be incompatible.
+Incremental caches are particularly susceptible, so you may want to turn that off if you have turned them on.
If you determine the current version is good or bad, run git bisect good
or git bisect bad
to mark that, and then repeat building and marking until finished.
Similar to cargo-bisect-rustc
, git bisect
supports scripting and lots of other goodies.
+Check out its documentation for more.
The cargo-bisect-rustc
tool makes it super easy to find exactly when behavior has regressed in rustc.
+It automatically downloads rustc artifacts and tests them against a project you provide until it finds the regression.
The Installation chapter shows how to install cargo-bisect-rustc
.
+For a quick introduction, see the Tutorial.
+Otherwise, start at the Basic usage chapter to learn how cargo-bisect-rustc
works.