Skip to content

Commit f6b910f

Browse files
committed
Auto merge of #157433 - JonathanBrouwer:rollup-d3I87zR, r=JonathanBrouwer
Rollup of 5 pull requests Successful merges: - rust-lang/rust#154586 (Record failed tests with `--record`, and rerun them with `--rerun`) - rust-lang/rust#157296 (delegation: split resolution and lowering) - rust-lang/rust#156171 (Fix a coroutine UI test which is missing `#[coroutine]`) - rust-lang/rust#157249 (tests: codegen-llvm: Update bpf-alu32 with the new LLVM attributes) - rust-lang/rust#157426 (rustc-dev-guide subtree update)
2 parents faaa421 + 464d14b commit f6b910f

18 files changed

Lines changed: 112 additions & 121 deletions

ci/sembr/Cargo.lock

Lines changed: 7 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f2b291d902bfde7d7f209fc3a64908134bcef201
1+
49b19d32b9f01a5aa606f3bf2e90e6e0aa462c03

src/autodiff/debugging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The actual numbers will depend on your code.
2828
To confirm that your previous step worked, we will use llvm's `opt` tool. Find your path to the opt binary, with a path similar to `<some_dir>/rust/build/<x86/arm/...-target-triple>/ci-llvm/bin/opt`. If you build LLVM from source, you'll likely need to replace `ci-llvm` with `build`. Also find `llvmenzyme-21.<so/dll/dylib>` path, similar to `/rust/build/target-triple/enzyme/build/enzyme/llvmenzyme-21`. Please keep in mind that llvm frequently updates it's llvm backend, so the version number might be higher (20, 21, ...). Once you have both, run the following command:
2929

3030
```sh
31-
<path/to/opt> out.ll -load-pass-plugin=/path/to/build/<target-triple>/stage1/lib/libEnzyme-21.so -passes="enzyme" -enzyme-strict-aliasing=0 -s
31+
<path/to/opt> out.ll -load-pass-plugin=/path/to/build/<target-triple>/stage1/lib/libEnzyme-21.so -passes="enzyme" -enzyme-strict-aliasing=0 -S
3232
```
3333
This command might fail for future versions or on your system, in which case you should replace libEnzyme-21.so with LLVMEnzyme-21.so. Look at the Enzyme docs for instructions on how to build it. You might need to also adjust how to build your LLVM version.
3434

@@ -41,7 +41,7 @@ If you fail to get the same error, please open an issue in the rust repository.
4141
First find your `llvm-extract` binary, it's in the same folder as your opt binary. then run:
4242

4343
```sh
44-
<path/to/llvm-extract> -s --func=<name> --recursive --rfunc="enzyme_autodiff*" --rfunc="enzyme_fwddiff*" --rfunc=<fnc_called_by_enzyme> out.ll -o mwe.ll
44+
<path/to/llvm-extract> -S --func=<name> --recursive --rfunc="enzyme_autodiff*" --rfunc="enzyme_fwddiff*" --rfunc=<fnc_called_by_enzyme> out.ll -o mwe.ll
4545
```
4646

4747
This command creates `mwe.ll`, a minimal working example.

src/autodiff/installation.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ Please open an issue if you want to help enabling automatic builds for your pref
1313

1414
## Installation guide
1515

16-
If you want to use `std::autodiff` and don't plan to contribute PR's to the project, then we recommend to just use your existing nightly installation and download the missing component.
17-
In the future, rustup will be able to do it for you.
18-
For now, you'll have to manually download and copy it.
19-
20-
1) On our github repository, find the last merged PR: [`Repo`]
21-
2) Scroll down to the lower end of the PR, where you'll find a rust-bors message saying `Test successful` with a `CI` link.
22-
3) Click on the `CI` link, and grep for your target. E.g. `dist-x86_64-linux` or `dist-aarch64-llvm-mingw` and click `Load summary`.
23-
4) Under the `CI artifacts` section, find the `enzyme-nightly` artifact, download, and unpack it.
24-
5) Copy the artifact (libEnzyme-22.so for linux, libEnzyme-22.dylib for apple, etc.), which should be in a folder named `enzyme-preview`, to your rust toolchain directory. E.g. for linux: `cp ~/Downloads/enzyme-nightly-x86_64-unknown-linux-gnu/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib`
25-
26-
Apple support was temporarily reverted, due to downstream breakages.
27-
Please (currently) build it from source.
16+
If you want to use `std::autodiff` on Linux or Windows and don't plan to contribute PR's to the project, then we recommend to just use your existing nightly installation and download the missing component. Please run:
17+
18+
```console
19+
rustup +nightly component add enzyme
20+
```
21+
22+
Apple support was temporarily reverted, due to downstream breakages. Please build it from source till we can re-enable it.
2823

2924
## Installation guide for Nix user.
3025

src/autodiff/internals.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
}
1616
```
1717

18-
The detailed documentation for the `std::autodiff` module is available at [std::autodiff](https://doc.rust-lang.org/std/autodiff/index.html).
18+
The detailed documentation for the `std::autodiff` module is available at [std::autodiff](https://doc.rust-lang.org/nightly/std/autodiff/index.html).
1919

2020
Differentiable programming is used in various fields like numerical computing, [solid mechanics][ratel], [computational chemistry][molpipx], [fluid dynamics][waterlily] or for Neural Network training via Backpropagation, [ODE solver][diffsol], [differentiable rendering][libigl], [quantum computing][catalyst], and climate simulations.
2121

@@ -25,3 +25,12 @@ Differentiable programming is used in various fields like numerical computing, [
2525
[diffsol]: https://github.com/martinjrobins/diffsol
2626
[libigl]: https://github.com/alecjacobson/libigl-enzyme-example?tab=readme-ov-file#run
2727
[catalyst]: https://github.com/PennyLaneAI/catalyst
28+
29+
30+
`std::autodiff` is currently based on Enzyme, an LLVM based tool for automatic differentation. There are three main reasons for relying on compiler based autodiff:
31+
32+
- **Usability**: Current autodiff crates do not support normal Rust programs. They either enforce a custom DSL, require the usage of library provided types (instead of e.g. slices or arrays), or are limited to scalar functions. Compiler based autodiff allows users to write normal Rust code, including arrays, slices, user-defined structs and enums, control flow, and more.
33+
- **Performance**: Most existing Rust autodiff approaches have a constant overhead per operation. This can easily be amortized for ML applications which have few expensive operations on large tensors. It is, however, often unacceptable for applications in the HPC or scientific computing field. By working on (optimized) LLVM IR, compiler based autodiff can achieve [significantly][Enzyme] better performance in those cases.
34+
- **Features**: By operating on such a low level and sharing the implementation with other LLVM based languages, we can leverage the large amount of work already done in the Enzyme project. For example, we can support Rust code calling MPI routines, or GPU code, including libraries like CuBLAS.
35+
36+
[Enzyme]: https://dl.acm.org/doi/10.5555/3495724.3496770

src/building/how-to-build-and-run.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ git clone https://github.com/rust-lang/rust.git
4545
cd rust
4646
```
4747

48+
> **NOTE**: On Windows, antivirus scanning can make Git and build commands
49+
> noticeably slower in a large checkout. If that happens, consider adding only
50+
> the Rust checkout directory to the
51+
> [Windows Security exclusion list][windows-security-exclusions].
52+
> Avoid adding broader exclusions than needed.
53+
4854
### Partial clone the repository
4955

5056
Due to the size of the repository, cloning on a slower internet connection can take a long time,
@@ -97,6 +103,7 @@ This chapter focuses on the basics to be productive, but
97103
if you want to learn more about `x.py`, [read this chapter][bootstrap].
98104

99105
[bootstrap]: ./bootstrapping/intro.md
106+
[windows-security-exclusions]: https://support.microsoft.com/windows/add-an-exclusion-to-windows-security-811816c0-4dfd-af4a-47e4-c301afe13b26
100107

101108
Also, using `x` rather than `x.py` is recommended as:
102109

@@ -279,6 +286,16 @@ Instead, you can build a specific component by providing its name, like this:
279286
If you choose the `library` profile when running `x setup`, you can omit `--stage 1` (it's the
280287
default).
281288

289+
If you want to build a tool, you can use:
290+
291+
```bash
292+
./x build src/tools/cargo
293+
```
294+
295+
You can also check the [the section on tool tests][tool-tests-link].
296+
297+
[tool-tests-link]: ../tests/intro.md#tool-tests
298+
282299
## Creating a rustup toolchain
283300

284301
Once you have successfully built `rustc`, you will have created a bunch

src/building/quickstart.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ compiler toolchain. You can use it with rustup by linking it.
4040
rustup toolchain link stage1 build/host/stage1
4141
```
4242

43+
**NOTE**: If you use `./x setup tools`, the default stage will be set to 2 instead of 1.
44+
Adjust your command accordingly:
45+
```sh
46+
rustup toolchain link stage2 build/host/stage2
47+
```
48+
4349
Now you have a toolchain called `stage1` linked to your build. You can use it to
4450
test the compiler.
4551

src/contributing.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ It is also perfectly fine
255255
(and even encouraged!) to use the CI to test your changes if it can help your productivity.
256256
In particular, we don't recommend running the full `./x test` suite locally,
257257
since it takes a very long time to execute.
258+
See the [Testing with CI] chapter for using Rust's CI to test your changes.
259+
260+
[Testing with CI]: https://rustc-dev-guide.rust-lang.org/tests/ci.html#testing-with-ci
258261

259262
### r+
260263

src/implementing-new-features.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- date-check: Jul 2025 -->
21

32
# Implementing new language features
43

@@ -191,7 +190,7 @@ The below steps needs to be followed in order to implement a new unstable featur
191190
If the feature gate is not set,
192191
you should either maintain the pre-feature behavior or raise an error,
193192
depending on what makes sense.
194-
Errors should generally use [`rustc_session::parse::feature_err`].
193+
Errors should generally use [`rustc_session::errors::feature_err`].
195194
For an example of adding an error, see [#81015].
196195

197196
For features introducing new syntax, pre-expansion gating should be used instead.
@@ -221,7 +220,7 @@ The below steps needs to be followed in order to implement a new unstable featur
221220

222221
[`GatedSpans`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/parse/struct.GatedSpans.html
223222
[#81015]: https://github.com/rust-lang/rust/pull/81015
224-
[`rustc_session::parse::feature_err`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/parse/fn.feature_err.html
223+
[`rustc_session::errors::feature_err`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/errors/fn.feature_err.html
225224
[`rustc_ast_passes::feature_gate::check_crate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_passes/feature_gate/fn.check_crate.html
226225
[value the stability of Rust]: https://github.com/rust-lang/rfcs/blob/master/text/1122-language-semver.md
227226
[stability in code]: #stability-in-code

src/macro-expansion.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,21 @@ If we can't make progress in an iteration, this represents a compile error.
7676
an AST, which may produce parse errors.
7777
- During expansion, we create [`SyntaxContext`]s (hierarchy 2) (see
7878
[Hygiene][hybelow] below).
79-
- These three passes happen one after another on every AST fragment
79+
- These two passes happen one after another on every AST fragment
8080
freshly expanded from a macro:
8181
- [`NodeId`]s are assigned by [`InvocationCollector`].
8282
This also collects new macro calls from this new AST piece and
8383
adds them to the queue.
84-
- ["Def paths"][defpath] are created and [`DefId`]s are
85-
assigned to them by [`DefCollector`].
86-
- Names are put into modules (from the resolver's point of
87-
view) by [`BuildReducedGraphVisitor`].
84+
- [`DefCollector`] creates ["Def paths"][defpath], assigns the
85+
corresponding [`DefId`]s, and also builds the reduced graph
86+
(putting names into modules from the resolver's point of view).
8887
3. After expanding a single macro and integrating its output, continue
8988
to the next iteration of [`fully_expand_fragment`][fef].
9089
5. If it's not resolved:
9190
1. Put the macro back in the queue.
9291
2. Continue to next iteration...
9392

9493
[`AstFragment`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/expand/enum.AstFragment.html
95-
[`BuildReducedGraphVisitor`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/build_reduced_graph/struct.BuildReducedGraphVisitor.html
9694
[`DefCollector`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/def_collector/struct.DefCollector.html
9795
[`DefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html
9896
[`ExpnId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/hygiene/struct.ExpnId.html

0 commit comments

Comments
 (0)