Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize catch_unwind to match C++ try/catch #67502

Merged
merged 16 commits into from
Mar 14, 2020

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Dec 22, 2019

This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown.

https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is exactly the same if -Cpanic=abort is passed, which is clearly not great.

This PR, on the other hand, generates the following assembly:

# -Cpanic=unwind:
	push   rbx
	mov    ebx,0x2a
	call   QWORD PTR [rip+0x1c53c]        # <happy>
	mov    eax,ebx
	pop    rbx
	ret
	mov    rdi,rax
	call   QWORD PTR [rip+0x1c537]        # cleanup function call
	call   QWORD PTR [rip+0x1c539]        # <unfortunate>
	mov    ebx,0xd
	mov    eax,ebx
	pop    rbx
	ret

# -Cpanic=abort:
	push   rax
	call   QWORD PTR [rip+0x20a1]        # <happy>
	mov    eax,0x2a
	pop    rcx
	ret

Fixes #64224, and resolves #64222.

@rust-highfive
Copy link
Collaborator

r? @shepmaster

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 22, 2019
@Mark-Simulacrum
Copy link
Member Author

I suspect that the best reviewer here is r? @alexcrichton.

I am not sure whether we want to accept this. I created this patch while trying to investigate #64224; it is a slight simplification of the generated assembly, but not really anything too major (as might be expected).

@bors

This comment has been minimized.

@Mark-Simulacrum Mark-Simulacrum changed the title Overlap caught panic with closure data Optimize catch_unwind to match C++ try/catch Dec 26, 2019
src/libpanic_unwind/emcc.rs Outdated Show resolved Hide resolved
src/libstd/panicking.rs Outdated Show resolved Hide resolved
src/libstd/panicking.rs Outdated Show resolved Hide resolved
src/libstd/panicking.rs Outdated Show resolved Hide resolved
src/libpanic_unwind/lib.rs Outdated Show resolved Hide resolved
src/libstd/panicking.rs Outdated Show resolved Hide resolved
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member Author

I believe the test failure here is because we treat -Zno-landing-pads and -Cpanic=abort equivalently today, which has worked so far because -Zno-landing-pads was never passed to the libpanic_unwind compiler. These two options mean different things though: -Zno-landing-pads means that a panic will not run destructors, but will still unwind, whereas -Cpanic=abort will just immediately abort.

I'm not actually sure if there's much use to -Zno-landing-pads -- is there a situation where you want to unwind but not actually run destructors and so forth? I think the answer is no, or at least, it doesn't make much sense to me. I would suggest that we drop that flag entirely.

That would mean that the test in question would also be deleted; we do not expect that a crate with -Cpanic=abort can catch panics (even at thread boundaries).

@Mark-Simulacrum
Copy link
Member Author

@bors try for easier testing

@bors
Copy link
Contributor

bors commented Dec 28, 2019

⌛ Trying commit ba58f6421d4c5598f16479b0b2e5a1357917bac0 with merge d19982ed64d76225c52b773a53d593e6e96282e8...

@bors
Copy link
Contributor

bors commented Dec 28, 2019

☀️ Try build successful - checks-azure
Build commit: d19982ed64d76225c52b773a53d593e6e96282e8 (d19982ed64d76225c52b773a53d593e6e96282e8)

@Amanieu
Copy link
Member

Amanieu commented Dec 29, 2019

Should be good to merge at this point. I moved some unrelated commits fixing some memory leaks to a separate PR (#67711).

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'm worried about here is that this PR changes the standard library to unconditionally use the try intrinsic no matter what panic mode is selected. Previously the try intrinsic was only codegen'd into the panic_unwind crate, but now it'll also be codegen'd when using panic=abort.

I don't think that this is a huge huge problem but I do think that we very much want to avoid any invoke instructions at all in panic=abort mode. Some targets in LLVM die really quickly on the invoke instruction I think. Could you double check the raw IR output in debug mode in panic=abort mode to make sure no invoke instruction exists?

This may require updating the codegen of the try intrinsic to just be call in panic=abort mode which I suspect would be a relatively simple change. It may also already be done, I'm not sure!

@@ -29,6 +28,31 @@ use crate::io::set_panic;
#[cfg(test)]
use realstd::io::set_panic;

// This must be kept in sync with the implementations in libpanic_unwind.
//
// This is *not* checked in anyway; the compiler does not allow us to use a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/anyway/any way/

// type/macro/anything from panic_unwind, since we're then linking in the
// panic_unwind runtime even during -Cpanic=abort.
//
// Essentially this must be the type of `imp::Payload` in libpanic_unwind.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to extract the definition of Payload to a foo.rs file which we could include with #[path] here?

@Amanieu
Copy link
Member

Amanieu commented Jan 6, 2020

This may require updating the codegen of the try intrinsic to just be call in panic=abort mode which I suspect would be a relatively simple change. It may also already be done, I'm not sure!

This is already the case: try lowers to call with -Z no-landing-pads (which panic=abort enables).

@alexcrichton
Copy link
Member

Great! That's perfect

@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-07T15:54:02.4589818Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-07T15:54:02.4675058Z ##[command]git config gc.auto 0
2020-01-07T15:54:02.4759986Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-07T15:54:02.4829368Z ##[command]git config --get-all http.proxy
2020-01-07T15:54:02.4970119Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67502/merge:refs/remotes/pull/67502/merge
---
2020-01-07T15:58:40.4496895Z     Checking alloc v0.0.0 (/checkout/src/liballoc)
2020-01-07T15:58:40.7700380Z     Checking cfg-if v0.1.8
2020-01-07T15:58:40.8156581Z     Checking rustc-demangle v0.1.16
2020-01-07T15:58:41.2595695Z     Checking panic_abort v0.0.0 (/checkout/src/libpanic_abort)
2020-01-07T15:58:41.2967617Z error: couldn't read src/libpanic_abort/../libpanic_unwind/payload.rs: No such file or directory (os error 2)
2020-01-07T15:58:41.2967972Z   --> src/libpanic_abort/lib.rs:24:1
2020-01-07T15:58:41.2968240Z    |
2020-01-07T15:58:41.2968501Z 24 | include!("../libpanic_unwind/payload.rs");
2020-01-07T15:58:41.2969002Z    | 
2020-01-07T15:58:41.2969233Z   ::: <::core::macros::builtin::include macros>:1:1
2020-01-07T15:58:41.2969418Z    |
2020-01-07T15:58:41.2969418Z    |
2020-01-07T15:58:41.2969716Z 1  | ($ file : expr) => { { } } ; ($ file : expr,) => { { } } ;
2020-01-07T15:58:41.2970035Z    | ---------------------------------------------------------- in this expansion of `include!`
2020-01-07T15:58:41.2990782Z error: aborting due to previous error
2020-01-07T15:58:41.2996142Z 
2020-01-07T15:58:41.3048740Z error: could not compile `panic_abort`.
2020-01-07T15:58:41.3049040Z warning: build failed, waiting for other jobs to finish...
---
2020-01-07T15:58:42.8482419Z   local time: Tue Jan  7 15:58:42 UTC 2020
2020-01-07T15:58:43.1308741Z   network time: Tue, 07 Jan 2020 15:58:43 GMT
2020-01-07T15:58:43.1314377Z == end clock drift check ==
2020-01-07T15:58:44.4231747Z 
2020-01-07T15:58:44.4340624Z ##[error]Bash exited with code '1'.
2020-01-07T15:58:44.4370787Z ##[section]Starting: Checkout
2020-01-07T15:58:44.4373469Z ==============================================================================
2020-01-07T15:58:44.4373544Z Task         : Get sources
2020-01-07T15:58:44.4373593Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Mar 14, 2020

☀️ Test successful - checks-azure
Approved by: Mark-Simulacrum
Pushing be055d9 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 14, 2020
@bors bors merged commit be055d9 into rust-lang:master Mar 14, 2020
@@ -274,27 +269,59 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the "2." comment above is no longer accurate? The code now does ManuallyDrop::into_inner(data.p) in the "panicked" case, which looks very symmetric to the "didn't panic case": in both cases we move "it out of data and return it", it's just a different thing we move out.

@RalfJung
Copy link
Member

RalfJung commented Mar 14, 2020

r=Mark-Simulacrum

Now Mark is both author and reviewer of this PR. ;)

EDIT: Ah, most commits are authored by @Amanieu, looks like Mark just submitted it. I see.

bors added a commit that referenced this pull request Mar 14, 2020
adjust Miri to needs of changed unwinding strategy

As expected, #67502 broke unwinding in Miri. To fix it we have to adjust parts of the engine and the panic runtime, which this PR does. The Miri-side changes are in rust-lang/miri#1227.

Cc @oli-obk @Aaron1011 @Mark-Simulacrum @Amanieu
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2020
Remove -Z no-landing-pads flag

Since rust-lang#67502, `-Z no-landing-pads` will cause all attempted unwinds to abort since we don't generate a `try` / `catch`. This previously worked because `__rust_try` was located in libpanic_unwind which is always compiled with `-C panic=unwind`, but `__rust_try` is now directly inline into the crate that uses `catch_unwind`.

As such, `-Z no-landing-pads` is now mostly useless and people should use `-C panic=abort` instead.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jun 8, 2020
Pkgsrc changes:
 * Remove a couple diffs which are now integrated upstream.
 * Adjust cargo checksums after upstream upgrades.
 * Belatedly bump the curl dependency
 * Unset DESTDIR during the build phase, to work around a mysterious
   build bug deep in the bowels of llvm.
 * Bump nearly all bootstraps to 1.43.1.

Upstream changes:

Version 1.44.0 (2020-06-04)
==========================

Language
--------
- [You can now use `async/.await` with `#[no_std]` enabled.][69033]
- [Added the `unused_braces` lint.][70081]

**Syntax-only changes**

- [Expansion-driven outline module parsing][69838]
```rust
#[cfg(FALSE)]
mod foo {
    mod bar {
        mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
    }
}
```

These are still rejected semantically, so you will likely receive an error but
these changes can be seen and parsed by macros and conditional compilation.

Compiler
--------
- [Rustc now respects the `-C codegen-units` flag in incremental mode.][70156]
  Additionally when in incremental mode rustc defaults to 256 codegen units.
- [Refactored `catch_unwind`, to have zero-cost unless unwinding is enabled and
  a panic is thrown.][67502]
- [Added tier 3\* support for the `aarch64-unknown-none` and
  `aarch64-unknown-none-softfloat` targets.][68334]
- [Added tier 3 support for `arm64-apple-tvos` and
  `x86_64-apple-tvos` targets.][68191]

Libraries
---------
- [Special cased `vec![]` to map directly to `Vec::new()`.][70632] This allows
  `vec![]` to be able to be used in `const` contexts.
- [`convert::Infallible` now implements `Hash`.][70281]
- [`OsString` now implements `DerefMut` and `IndexMut` returning
  a `&mut OsStr`.][70048]
- [Unicode 13 is now supported.][69929]
- [`String` now implements `From<&mut str>`.][69661]
- [`IoSlice` now implements `Copy`.][69403]
- [`Vec<T>` now implements `From<[T; N]>`.][68692] Where `N` is less than 32.
- [`proc_macro::LexError` now implements `fmt::Display` and `Error`.][68899]
- [`from_le_bytes`, `to_le_bytes`, `from_be_bytes`, `to_be_bytes`,
  `from_ne_bytes`, and `to_ne_bytes` methods are now `const` for all
  integer types.][69373]

Stabilized APIs
---------------
- [`PathBuf::with_capacity`]
- [`PathBuf::capacity`]
- [`PathBuf::clear`]
- [`PathBuf::reserve`]
- [`PathBuf::reserve_exact`]
- [`PathBuf::shrink_to_fit`]
- [`f32::to_int_unchecked`]
- [`f64::to_int_unchecked`]
- [`Layout::align_to`]
- [`Layout::pad_to_align`]
- [`Layout::array`]
- [`Layout::extend`]

Cargo
-----
- [Added the `cargo tree` command which will print a tree graph of
  your dependencies.][cargo/8062] E.g.
  ```
    mdbook v0.3.2 (/Users/src/rust/mdbook)
  +-- ammonia v3.0.0
  |   +-- html5ever v0.24.0
  |   |   +-- log v0.4.8
  |   |   |   +-- cfg-if v0.1.9
  |   |   +-- mac v0.1.1
  |   |   +-- markup5ever v0.9.0
  |   |       +-- log v0.4.8 (*)
  |   |       +-- phf v0.7.24
  |   |       |   +-- phf_shared v0.7.24
  |   |       |       +-- siphasher v0.2.3
  |   |       |       +-- unicase v1.4.2
  |   |       |           [build-dependencies]
  |   |       |           +-- version_check v0.1.5
  ...
  ```
  You can also display dependencies on multiple versions of the same crate with
  `cargo tree -d` (short for `cargo tree --duplicates`).

Misc
----
- [Rustdoc now allows you to specify `--crate-version` to have rustdoc include
  the version in the sidebar.][69494]

Compatibility Notes
-------------------
- [Rustc now correctly generates static libraries on Windows GNU targets with
  the `.a` extension, rather than the previous `.lib`.][70937]
- [Removed the `-C no_integrated_as` flag from rustc.][70345]
- [The `file_name` property in JSON output of macro errors now points the actual
  source file rather than the previous format of `<NAME macros>`.][70969]
  **Note:** this may not point a file that actually exists on the user's system.
- [The minimum required external LLVM version has been bumped to LLVM 8.][71147]
- [`mem::{zeroed, uninitialised}` will now panic when used with types that do
  not allow zero initialization such as `NonZeroU8`.][66059] This was
  previously a warning.
- [In 1.45.0 (the next release) converting a `f64` to `u32` using the `as`
  operator has been defined as a saturating operation.][71269] This was
  previously undefined behaviour, you can use the `{f64, f32}::to_int_unchecked`
  methods to continue using the current behaviour which may desirable in rare
  performance sensitive situations.

Internal Only
-------------
These changes provide no direct user facing benefits, but represent significant
improvements to the internals and overall performance of rustc and
related tools.

- [dep_graph Avoid allocating a set on when the number reads are small.][69778]
- [Replace big JS dict with JSON parsing.][71250]

[69373]: rust-lang/rust#69373
[66059]: rust-lang/rust#66059
[68191]: rust-lang/rust#68191
[68899]: rust-lang/rust#68899
[71147]: rust-lang/rust#71147
[71250]: rust-lang/rust#71250
[70937]: rust-lang/rust#70937
[70969]: rust-lang/rust#70969
[70632]: rust-lang/rust#70632
[70281]: rust-lang/rust#70281
[70345]: rust-lang/rust#70345
[70048]: rust-lang/rust#70048
[70081]: rust-lang/rust#70081
[70156]: rust-lang/rust#70156
[71269]: rust-lang/rust#71269
[69838]: rust-lang/rust#69838
[69929]: rust-lang/rust#69929
[69661]: rust-lang/rust#69661
[69778]: rust-lang/rust#69778
[69494]: rust-lang/rust#69494
[69403]: rust-lang/rust#69403
[69033]: rust-lang/rust#69033
[68692]: rust-lang/rust#68692
[68334]: rust-lang/rust#68334
[67502]: rust-lang/rust#67502
[cargo/8062]: rust-lang/cargo#8062
[`PathBuf::with_capacity`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.with_capacity
[`PathBuf::capacity`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.capacity
[`PathBuf::clear`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.clear
[`PathBuf::reserve`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.reserve
[`PathBuf::reserve_exact`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.reserve_exact
[`PathBuf::shrink_to_fit`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.shrink_to_fit
[`f32::to_int_unchecked`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_int_unchecked
[`f64::to_int_unchecked`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_int_unchecked
[`Layout::align_to`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.align_to
[`Layout::pad_to_align`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.pad_to_align
[`Layout::array`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.array
[`Layout::extend`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.extend
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jun 9, 2020
Version 1.44.0 (2020-06-04)
==========================

Language
--------
- [You can now use `async/.await` with `#[no_std]` enabled.][69033]
- [Added the `unused_braces` lint.][70081]

**Syntax-only changes**

- [Expansion-driven outline module parsing][69838]
```rust
#[cfg(FALSE)]
mod foo {
    mod bar {
        mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
    }
}
```

These are still rejected semantically, so you will likely receive an error but
these changes can be seen and parsed by macros and conditional compilation.

Compiler
--------
- [Rustc now respects the `-C codegen-units` flag in incremental mode.][70156]
  Additionally when in incremental mode rustc defaults to 256 codegen units.
- [Refactored `catch_unwind` to have zero-cost, unless unwinding is enabled and
  a panic is thrown.][67502]
- [Added tier 3\* support for the `aarch64-unknown-none` and
  `aarch64-unknown-none-softfloat` targets.][68334]
- [Added tier 3 support for `arm64-apple-tvos` and
  `x86_64-apple-tvos` targets.][68191]


Libraries
---------
- [Special cased `vec![]` to map directly to `Vec::new()`.][70632] This allows
  `vec![]` to be able to be used in `const` contexts.
- [`convert::Infallible` now implements `Hash`.][70281]
- [`OsString` now implements `DerefMut` and `IndexMut` returning
  a `&mut OsStr`.][70048]
- [Unicode 13 is now supported.][69929]
- [`String` now implements `From<&mut str>`.][69661]
- [`IoSlice` now implements `Copy`.][69403]
- [`Vec<T>` now implements `From<[T; N]>`.][68692] Where `N` is at most 32.
- [`proc_macro::LexError` now implements `fmt::Display` and `Error`.][68899]
- [`from_le_bytes`, `to_le_bytes`, `from_be_bytes`, `to_be_bytes`,
  `from_ne_bytes`, and `to_ne_bytes` methods are now `const` for all
  integer types.][69373]

Stabilized APIs
---------------
- [`PathBuf::with_capacity`]
- [`PathBuf::capacity`]
- [`PathBuf::clear`]
- [`PathBuf::reserve`]
- [`PathBuf::reserve_exact`]
- [`PathBuf::shrink_to_fit`]
- [`f32::to_int_unchecked`]
- [`f64::to_int_unchecked`]
- [`Layout::align_to`]
- [`Layout::pad_to_align`]
- [`Layout::array`]
- [`Layout::extend`]

Cargo
-----
- [Added the `cargo tree` command which will print a tree graph of
  your dependencies.][cargo/8062] E.g.
  ```
    mdbook v0.3.2 (/Users/src/rust/mdbook)
  ├── ammonia v3.0.0
  │   ├── html5ever v0.24.0
  │   │   ├── log v0.4.8
  │   │   │   └── cfg-if v0.1.9
  │   │   ├── mac v0.1.1
  │   │   └── markup5ever v0.9.0
  │   │       ├── log v0.4.8 (*)
  │   │       ├── phf v0.7.24
  │   │       │   └── phf_shared v0.7.24
  │   │       │       ├── siphasher v0.2.3
  │   │       │       └── unicase v1.4.2
  │   │       │           [build-dependencies]
  │   │       │           └── version_check v0.1.5
  ...
  ```
  You can also display dependencies on multiple versions of the same crate with
  `cargo tree -d` (short for `cargo tree --duplicates`).

Misc
----
- [Rustdoc now allows you to specify `--crate-version` to have rustdoc include
  the version in the sidebar.][69494]

Compatibility Notes
-------------------
- [Rustc now correctly generates static libraries on Windows GNU targets with
  the `.a` extension, rather than the previous `.lib`.][70937]
- [Removed the `-C no_integrated_as` flag from rustc.][70345]
- [The `file_name` property in JSON output of macro errors now points the actual
  source file rather than the previous format of `<NAME macros>`.][70969]
  **Note:** this may not point to a file that actually exists on the user's system.
- [The minimum required external LLVM version has been bumped to LLVM 8.][71147]
- [`mem::{zeroed, uninitialised}` will now panic when used with types that do
  not allow zero initialization such as `NonZeroU8`.][66059] This was
  previously a warning.
- [In 1.45.0 (the next release) converting a `f64` to `u32` using the `as`
  operator has been defined as a saturating operation.][71269] This was previously
  undefined behaviour, but you can use the `{f64, f32}::to_int_unchecked` methods to
  continue using the current behaviour, which may be desirable in rare performance
  sensitive situations.

Internal Only
-------------
These changes provide no direct user facing benefits, but represent significant
improvements to the internals and overall performance of rustc and
related tools.

- [dep_graph Avoid allocating a set on when the number reads are small.][69778]
- [Replace big JS dict with JSON parsing.][71250]

[69373]: rust-lang/rust#69373
[66059]: rust-lang/rust#66059
[68191]: rust-lang/rust#68191
[68899]: rust-lang/rust#68899
[71147]: rust-lang/rust#71147
[71250]: rust-lang/rust#71250
[70937]: rust-lang/rust#70937
[70969]: rust-lang/rust#70969
[70632]: rust-lang/rust#70632
[70281]: rust-lang/rust#70281
[70345]: rust-lang/rust#70345
[70048]: rust-lang/rust#70048
[70081]: rust-lang/rust#70081
[70156]: rust-lang/rust#70156
[71269]: rust-lang/rust#71269
[69838]: rust-lang/rust#69838
[69929]: rust-lang/rust#69929
[69661]: rust-lang/rust#69661
[69778]: rust-lang/rust#69778
[69494]: rust-lang/rust#69494
[69403]: rust-lang/rust#69403
[69033]: rust-lang/rust#69033
[68692]: rust-lang/rust#68692
[68334]: rust-lang/rust#68334
[67502]: rust-lang/rust#67502
[cargo/8062]: rust-lang/cargo#8062
[`PathBuf::with_capacity`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.with_capacity
[`PathBuf::capacity`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.capacity
[`PathBuf::clear`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.clear
[`PathBuf::reserve`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.reserve
[`PathBuf::reserve_exact`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.reserve_exact
[`PathBuf::shrink_to_fit`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.shrink_to_fit
[`f32::to_int_unchecked`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_int_unchecked
[`f64::to_int_unchecked`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_int_unchecked
[`Layout::align_to`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.align_to
[`Layout::pad_to_align`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.pad_to_align
[`Layout::array`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.array
[`Layout::extend`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.extend
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jul 6, 2020
Pkgsrc changes:
 * Remove the clutter caused by the cross-compile setup from Makefile
   (Now consigned to my own private cross.mk file.)
 * Remove a couple of patches which are now integrated upstream.
 * Minor adjustments to a couple of other patches.
 * Adjust cargo checksums after upstream upgrades.
 * Belatedly bump the curl dependency
 * If doing a "dist" build, unset DESTDIR during the build phase,
   to work around a mysterious build bug deep in the bowels of llvm,
   causing llvm tools to be installed to a directory unexpecetd by
   the rest of the rust build, ref.
   rust-lang/rust#73132
   A "dist" build is not expected to be followed by an "install".
 * Bump nearly all bootstraps to 1.43.1; NetBSD earmv7hf bootstrap
   bumped to 1.44.0, as that one now finally builds and works.

Upstream changes:

Version 1.44.0 (2020-06-04)
==========================

Language
--------
- [You can now use `async/.await` with `#[no_std]` enabled.][69033]
- [Added the `unused_braces` lint.][70081]

**Syntax-only changes**

- [Expansion-driven outline module parsing][69838]
```rust
#[cfg(FALSE)]
mod foo {
    mod bar {
        mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
    }
}
```

These are still rejected semantically, so you will likely receive an error but
these changes can be seen and parsed by macros and conditional compilation.

Compiler
--------
- [Rustc now respects the `-C codegen-units` flag in incremental mode.][70156]
  Additionally when in incremental mode rustc defaults to 256 codegen units.
- [Refactored `catch_unwind`, to have zero-cost unless unwinding is enabled and
  a panic is thrown.][67502]
- [Added tier 3\* support for the `aarch64-unknown-none` and
  `aarch64-unknown-none-softfloat` targets.][68334]
- [Added tier 3 support for `arm64-apple-tvos` and
  `x86_64-apple-tvos` targets.][68191]

Libraries
---------
- [Special cased `vec![]` to map directly to `Vec::new()`.][70632] This allows
  `vec![]` to be able to be used in `const` contexts.
- [`convert::Infallible` now implements `Hash`.][70281]
- [`OsString` now implements `DerefMut` and `IndexMut` returning
  a `&mut OsStr`.][70048]
- [Unicode 13 is now supported.][69929]
- [`String` now implements `From<&mut str>`.][69661]
- [`IoSlice` now implements `Copy`.][69403]
- [`Vec<T>` now implements `From<[T; N]>`.][68692] Where `N` is less than 32.
- [`proc_macro::LexError` now implements `fmt::Display` and `Error`.][68899]
- [`from_le_bytes`, `to_le_bytes`, `from_be_bytes`, `to_be_bytes`,
  `from_ne_bytes`, and `to_ne_bytes` methods are now `const` for all
  integer types.][69373]

Stabilized APIs
---------------
- [`PathBuf::with_capacity`]
- [`PathBuf::capacity`]
- [`PathBuf::clear`]
- [`PathBuf::reserve`]
- [`PathBuf::reserve_exact`]
- [`PathBuf::shrink_to_fit`]
- [`f32::to_int_unchecked`]
- [`f64::to_int_unchecked`]
- [`Layout::align_to`]
- [`Layout::pad_to_align`]
- [`Layout::array`]
- [`Layout::extend`]

Cargo
-----
- [Added the `cargo tree` command which will print a tree graph of
  your dependencies.][cargo/8062] E.g.
  ```
    mdbook v0.3.2 (/Users/src/rust/mdbook)
  +-- ammonia v3.0.0
  |   +-- html5ever v0.24.0
  |   |   +-- log v0.4.8
  |   |   |   +-- cfg-if v0.1.9
  |   |   +-- mac v0.1.1
  |   |   +-- markup5ever v0.9.0
  |   |       +-- log v0.4.8 (*)
  |   |       +-- phf v0.7.24
  |   |       |   +-- phf_shared v0.7.24
  |   |       |       +-- siphasher v0.2.3
  |   |       |       +-- unicase v1.4.2
  |   |       |           [build-dependencies]
  |   |       |           +-- version_check v0.1.5
  ...
  ```
  You can also display dependencies on multiple versions of the same crate with
  `cargo tree -d` (short for `cargo tree --duplicates`).

Misc
----
- [Rustdoc now allows you to specify `--crate-version` to have rustdoc include
  the version in the sidebar.][69494]

Compatibility Notes
-------------------
- [Rustc now correctly generates static libraries on Windows GNU targets with
  the `.a` extension, rather than the previous `.lib`.][70937]
- [Removed the `-C no_integrated_as` flag from rustc.][70345]
- [The `file_name` property in JSON output of macro errors now points the actual
  source file rather than the previous format of `<NAME macros>`.][70969]
  **Note:** this may not point a file that actually exists on the user's system.
- [The minimum required external LLVM version has been bumped to LLVM 8.][71147]
- [`mem::{zeroed, uninitialised}` will now panic when used with types that do
  not allow zero initialization such as `NonZeroU8`.][66059] This was
  previously a warning.
- [In 1.45.0 (the next release) converting a `f64` to `u32` using the `as`
  operator has been defined as a saturating operation.][71269] This was
  previously undefined behaviour, you can use the `{f64, f32}::to_int_unchecked`
  methods to continue using the current behaviour which may desirable in rare
  performance sensitive situations.

Internal Only
-------------
These changes provide no direct user facing benefits, but represent significant
improvements to the internals and overall performance of rustc and
related tools.

- [dep_graph Avoid allocating a set on when the number reads are small.][69778]
- [Replace big JS dict with JSON parsing.][71250]

[69373]: rust-lang/rust#69373
[66059]: rust-lang/rust#66059
[68191]: rust-lang/rust#68191
[68899]: rust-lang/rust#68899
[71147]: rust-lang/rust#71147
[71250]: rust-lang/rust#71250
[70937]: rust-lang/rust#70937
[70969]: rust-lang/rust#70969
[70632]: rust-lang/rust#70632
[70281]: rust-lang/rust#70281
[70345]: rust-lang/rust#70345
[70048]: rust-lang/rust#70048
[70081]: rust-lang/rust#70081
[70156]: rust-lang/rust#70156
[71269]: rust-lang/rust#71269
[69838]: rust-lang/rust#69838
[69929]: rust-lang/rust#69929
[69661]: rust-lang/rust#69661
[69778]: rust-lang/rust#69778
[69494]: rust-lang/rust#69494
[69403]: rust-lang/rust#69403
[69033]: rust-lang/rust#69033
[68692]: rust-lang/rust#68692
[68334]: rust-lang/rust#68334
[67502]: rust-lang/rust#67502
[cargo/8062]: rust-lang/cargo#8062
[`PathBuf::with_capacity`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.with_capacity
[`PathBuf::capacity`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.capacity
[`PathBuf::clear`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.clear
[`PathBuf::reserve`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.reserve
[`PathBuf::reserve_exact`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.reserve_exact
[`PathBuf::shrink_to_fit`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.shrink_to_fit
[`f32::to_int_unchecked`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_int_unchecked
[`f64::to_int_unchecked`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_int_unchecked
[`Layout::align_to`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.align_to
[`Layout::pad_to_align`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.pad_to_align
[`Layout::array`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.array
[`Layout::extend`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.extend
@mati865 mati865 mentioned this pull request Sep 25, 2020
yuulive pushed a commit to planet-s/uefi_std that referenced this pull request Mar 21, 2021
The eh_unwind_resume lang item has been removed [1], which prevents
using uefi_std with newer toolchains.

[1]: rust-lang/rust#67502
#[no_mangle]
#[cfg(all(target_os = "windows", target_env = "gnu"))]
#[rustc_std_internal_symbol]
#[cfg(all(bootstrap, target_os = "windows", target_env = "gnu"))]
pub extern "C" fn rust_eh_unwind_resume() {}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This additional requirement on #cfg(bootstrap)] looks as though it may be responsible for #79609 ... not sure I understand why it was required, however ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler used to emit references to rust_eh_unwind_resume from codegen. But it doesn't do that any more and rust_eh_unwind_resume doesn't exist any more.

@Mark-Simulacrum Mark-Simulacrum deleted the opt-catch branch February 13, 2022 18:17
jackpot51 pushed a commit to redox-os/uefi that referenced this pull request Mar 2, 2022
The eh_unwind_resume lang item has been removed [1], which prevents
using uefi_std with newer toolchains.

[1]: rust-lang/rust#67502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet