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

extra-link-arg-etc: support all link types (credit @davidhewitt) #10274

Merged
merged 1 commit into from
Jan 30, 2022

Conversation

aviramha
Copy link
Contributor

@aviramha aviramha commented Jan 8, 2022

This commit adds support for the remaining link types to -Zextra-link-arg-etc:
rustc-link-arg-tests rustc-link-arg-benches rustc-link-arg-examples
This would be useful in PyO3, where users writing Python extension modules (which do link against libpython) want to run cargo tests for extension module. As executables, these tests need to link against libpython.

This is a follow up of #9416 by @davidhewitt

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2022
@aviramha aviramha force-pushed the extra-link-args branch 2 times, most recently from 9f0d443 to 575282d Compare January 8, 2022 15:49
@ehuss
Copy link
Contributor

ehuss commented Jan 15, 2022

Thanks for the PR! I'll try to get to review this when I can, but my queue is quite large right now.

A question though: Can you explain the use case in a little more detail? I'm curious why cargo:rustc-link-arg is not sufficient. Why do you need independent control over the different target types?

@aviramha
Copy link
Contributor Author

The use case originates from PyO3's issue: PyO3/pyo3#1123
We want to be able to set link arguments when compiling tests specifically so cargo test would work correctly.

@ehuss
Copy link
Contributor

ehuss commented Jan 15, 2022

Can you summarize why you need different link settings for tests? From a quick peek at that PR, I have no idea what it is doing. Please assume I don't know what PyO3 is or what you are trying to accomplish.

@aviramha
Copy link
Contributor Author

aviramha commented Jan 15, 2022

Sorry for being vague. I wasn't sure how deep to go with the explanation.

PyO3 is a library and framework to write and build native Python extensions using Rust.

When building a library/extension (cdylib/so), we need to use dynamic linking to the library, so it would work on any environment.
When building tests/binaries, we need to link statically to libpython so those can run.

@ehuss
Copy link
Contributor

ehuss commented Jan 18, 2022

Sounds good. I think this should be fine to add without the unstable flag. Would you mind removing that, and just updating the Build scripts chapter for the new options?

@aviramha
Copy link
Contributor Author

@ehuss Done.

@aviramha aviramha force-pushed the extra-link-args branch 2 times, most recently from c9077b8 to 246c654 Compare January 18, 2022 18:37
Comment on lines 646 to 647
"rustc-link-arg-tests" => {
linker_args.push((LinkType::Test, value));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these include validation that the package actually has a test or bench or example? Similar to rustc-link-arg-bins, this is intended to help the developer know that the instruction isn't valid. And if you can share the code between the bins/tests/benches/examples cases, that would be great!

@@ -169,6 +169,30 @@ The optional `KIND` may be one of `dylib`, `static`, or `framework`. See the
[option-link]: ../../rustc/command-line-arguments.md#option-l-link-lib
[FFI]: ../../nomicon/ffi.md


<a id="rustc-link-arg-tests"></a>
#### `cargo:rustc-link-arg-tests=FLAG`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add these to the list at the top of the chapter?

link-arg=FLAG` option][link-arg] to the compiler, but only when building a
tests target.

[link-arg]: ../../rustc/codegen-options/index.md#link-arg
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this [link-arg] definition can be removed. There only needs to be one in the file (Markdown only looks at one of them, ignoring the rest). Probably can remove the other duplicates, too.

.build();

p.cargo("test -v")
.masquerade_as_nightly_cargo()
Copy link
Contributor

Choose a reason for hiding this comment

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

These calls to masquerade_as_nightly_cargo can be removed.

@aviramha
Copy link
Contributor Author

@ehuss I've done the requested changes. I'm a bit "macrophobic' so any enhancements there would be welcome.

@davidhewitt
Copy link

Hey, just wanted to say thanks @aviramha for writing this and @ehuss / @joshtriplett for reviewing! PyO3's build model is somewhat complex thanks to Python, so having these flags will be a game-changer for downstream projects!

The explanation above wasn't quite right, so for posterity here's my understanding:

  • When building a Python native extension (cdylib/so), we're not allowed to link to libpython; instead the Python interpreter provides the symbols we need at link load time.
  • When building tests/binaries, we need to link dynamically to libpython so those can run their main. (or statically, but linking the interpreter statically is hard for other reasons not worth elaborating on here)

The fact that native extensions aren't allowed to link at all has been the gotcha for us in PyO3 - we have to resort to not linking any artifacts to libpython if users are building a native extension. This creates problems for users trying to cargo run or cargo test accompanying binaries in such a project, as they end up with unresolved symbols. With these flags we will have a mechanism to enable linking to libpython for these accompanying binaries, which will improve the experience of users we have using PyO3 (often Python users writing their first Rust).

@ehuss ehuss added the T-cargo Team: Cargo label Jan 19, 2022
@ehuss
Copy link
Contributor

ehuss commented Jan 19, 2022

Thanks!

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Jan 19, 2022

Team member @ehuss has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge labels Jan 19, 2022
@@ -17,6 +17,22 @@ use std::sync::{Arc, Mutex};

const CARGO_WARNING: &str = "cargo:warning=";

macro_rules! check_and_add_target {
Copy link
Member

Choose a reason for hiding this comment

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

Could this perhaps be a function instead of a macro?

(it'd be great to avoid 9-argument things with closures that close over outer values too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose macro over function as it might be a tedious to pass all the required parameters to it. I understand your concern though. If you think it's better as function I'll change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder what you'd expect the function to do and what would be it's signature? We can't pass the check function (as it's bound to a single instance?)

Copy link
Member

Choose a reason for hiding this comment

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

Without being the one writing this I don't know precisely what it would look like. I find myself very rarely needing 9-parameter things and often in need of a refactoring of such a need arises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried playing with it a bit. Couldn't think of any better way to avoid the code duplication.
If you think it's better to revert to the old style (a bit of repetition) then I'm okay with it.

@rfcbot rfcbot added the final-comment-period FCP — a period for last comments before action is taken label Jan 19, 2022
@rfcbot rfcbot removed the proposed-final-comment-period An FCP proposal has started, but not yet signed off. label Jan 19, 2022
@rfcbot
Copy link
Collaborator

rfcbot commented Jan 19, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@aviramha
Copy link
Contributor Author

Erm.. I'm not quite sure what's the state right now? @ehuss

@ehuss
Copy link
Contributor

ehuss commented Jan 27, 2022

I think it would be good to simplify it some.

Macros can capture from their local environment. If it is defined within the loop, I think it could be something like this:

diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs
index bc8167633..a89984dd0 100644
--- a/src/cargo/core/compiler/custom_build.rs
+++ b/src/cargo/core/compiler/custom_build.rs
@@ -17,22 +17,6 @@ use std::sync::{Arc, Mutex};

 const CARGO_WARNING: &str = "cargo:warning=";

-macro_rules! check_and_add_target {
-    ($targets:ident, $func: ident, $key: ident, $whence: ident, $pkg_descr: ident, $link_type: expr, $value: ident, $type_name: literal, $linker_args: ident) => {
-        if !$targets.iter().any(|target| target.$func()) {
-            bail!(
-                "invalid instruction `cargo:{}` from {}\n\
-                    The package {} does not have a {} target.",
-                $key,
-                $whence,
-                $pkg_descr,
-                $type_name
-            );
-        }
-        $linker_args.push(($link_type, $value));
-    };
-}
-
 /// Contains the parsed output of a custom build script.
 #[derive(Clone, Debug, Hash, Default)]
 pub struct BuildOutput {
@@ -595,6 +579,22 @@ impl BuildOutput {
                 script_out_dir.to_str().unwrap(),
             );

+            macro_rules! check_and_add {
+                ($target_kind: expr, $is_target_kind: expr, $link_type: expr) => {
+                    if !targets.iter().any(|target| $is_target_kind(target)) {
+                        bail!(
+                            "invalid instruction `cargo:{}` from {}\n\
+                                The package {} does not have a {} target.",
+                            key,
+                            whence,
+                            pkg_descr,
+                            $target_kind
+                        );
+                    }
+                    linker_args.push(($link_type, value));
+                };
+            }
+
             // Keep in sync with TargetConfig::parse_links_overrides.
             match key {
                 "rustc-flags" => {
@@ -620,17 +620,7 @@ impl BuildOutput {
                     linker_args.push((LinkType::Cdylib, value))
                 }
                 "rustc-link-arg-bins" => {
-                    check_and_add_target!(
-                        targets,
-                        is_bin,
-                        key,
-                        whence,
-                        pkg_descr,
-                        LinkType::Bin,
-                        value,
-                        "bin",
-                        linker_args
-                    );
+                    check_and_add!("bin", Target::is_bin, LinkType::Bin);
                 }
                 "rustc-link-arg-bin" => {
                     let mut parts = value.splitn(2, '=');
@@ -661,43 +651,13 @@ impl BuildOutput {
                     linker_args.push((LinkType::SingleBin(bin_name), arg.to_string()));
                 }
                 "rustc-link-arg-tests" => {
-                    check_and_add_target!(
-                        targets,
-                        is_test,
-                        key,
-                        whence,
-                        pkg_descr,
-                        LinkType::Test,
-                        value,
-                        "test",
-                        linker_args
-                    );
+                    check_and_add!("test", Target::is_test, LinkType::Test);
                 }
                 "rustc-link-arg-benches" => {
-                    check_and_add_target!(
-                        targets,
-                        is_bench,
-                        key,
-                        whence,
-                        pkg_descr,
-                        LinkType::Bench,
-                        value,
-                        "benchmark",
-                        linker_args
-                    );
+                    check_and_add!("benchmark", Target::is_bench, LinkType::Bench);
                 }
                 "rustc-link-arg-examples" => {
-                    check_and_add_target!(
-                        targets,
-                        is_example,
-                        key,
-                        whence,
-                        pkg_descr,
-                        LinkType::Example,
-                        value,
-                        "example",
-                        linker_args
-                    );
+                    check_and_add!("example", Target::is_example, LinkType::Example);
                 }
                 "rustc-link-arg" => {
                     linker_args.push((LinkType::All, value));

Generally I would prefer using a closure. However, in this case that would require passing a few more things in due to the way closures capture things. Overall the macro seems a little simpler, though not as elegant.

@aviramha
Copy link
Contributor Author

@ehuss I've applied your change. Thanks!
I wasn't sure if macro can be defined in function scope, apparently it can.

@rfcbot rfcbot added finished-final-comment-period FCP complete and removed final-comment-period FCP — a period for last comments before action is taken labels Jan 29, 2022
@rfcbot
Copy link
Collaborator

rfcbot commented Jan 29, 2022

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@ehuss
Copy link
Contributor

ehuss commented Jan 30, 2022

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jan 30, 2022

📌 Commit 541c908 has been approved by ehuss

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2022
@bors
Copy link
Contributor

bors commented Jan 30, 2022

⌛ Testing commit 541c908 with merge b2496f0...

@bors
Copy link
Contributor

bors commented Jan 30, 2022

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing b2496f0 to master...

@bors bors merged commit b2496f0 into rust-lang:master Jan 30, 2022
ehuss added a commit to ehuss/rust that referenced this pull request Feb 1, 2022
Update cargo

10 commits in 1c034752de0df744fcd7788fcbca158830b8bf85..25fcb135d02ea897ce894b67ae021f48107d522b
2022-01-25 22:36:53 +0000 to 2022-02-01 01:32:48 +0000
- fix(install): Keep v1 file formatting the same (rust-lang/cargo#10349)
- fix(vendor): Use tables for sample config (rust-lang/cargo#10348)
- Add bash completion for `cargo clippy` (rust-lang/cargo#10347)
- Do not ignore `--features` when `--all-features` is present (rust-lang/cargo#10337)
- test: Fix compatibilty with new toml_edit (rust-lang/cargo#10350)
- extra-link-arg-etc: support all link types (credit `@davidhewitt)` (rust-lang/cargo#10274)
- Make clippy happy (rust-lang/cargo#10340)
- Update publishing link for semver rules. (rust-lang/cargo#10338)
- Normalize --path when install bin outside current workspace (rust-lang/cargo#10335)
- Bump clap to v3.0.13 (rust-lang/cargo#10336)
@ehuss ehuss added this to the 1.60.0 milestone Feb 14, 2022
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request Apr 15, 2022
Pkgsrc changes:
 * Bump available bootstraps to 1.59.0.
 * Delete one patch which no longer applies,
   adjust another.

Upstream changes:

Version 1.60.0 (2022-04-07)
==========================

Language
--------
- [Stabilize `#[cfg(panic = "...")]` for either `"unwind"` or `"abort"`.]
  [93658]
- [Stabilize `#[cfg(target_has_atomic = "...")]` for each integer
  size and `"ptr"`.][93824]

Compiler
--------
- [Enable combining `+crt-static` and `relocation-model=pic` on
  `x86_64-unknown-linux-gnu`][86374]
- [Fixes wrong `unreachable_pub` lints on nested and glob public
  reexport][87487]
- [Stabilize `-Z instrument-coverage` as `-C instrument-coverage`][90132]
- [Stabilize `-Z print-link-args` as `--print link-args`][91606]
- [Add new Tier 3 target `mips64-openwrt-linux-musl`\*][92300]
- [Add new Tier 3 target `armv7-unknown-linux-uclibceabi` (softfloat)\*][92383]
- [Fix invalid removal of newlines from doc comments][92357]
- [Add kernel target for RustyHermit][92670]
- [Deny mixing bin crate type with lib crate types][92933]
- [Make rustc use `RUST_BACKTRACE=full` by default][93566]
- [Upgrade to LLVM 14][93577]

\* Refer to Rust's [platform support page][platform-support-doc] for more
   information on Rust's tiered platform support.

Libraries
---------
- [Guarantee call order for `sort_by_cached_key`][89621]
- [Improve `Duration::try_from_secs_f32`/`f64` accuracy by directly
  processing exponent and mantissa][90247]
- [Make `Instant::{duration_since, elapsed, sub}` saturating][89926]
- [Remove non-monotonic clocks workarounds in `Instant::now`][89926]
- [Make `BuildHasherDefault`, `iter::Empty` and `future::Pending`
  covariant][92630]

Stabilized APIs
---------------
- [`Arc::new_cyclic`][arc_new_cyclic]
- [`Rc::new_cyclic`][rc_new_cyclic]
- [`slice::EscapeAscii`][slice_escape_ascii]
- [`<[u8]>::escape_ascii`][slice_u8_escape_ascii]
- [`u8::escape_ascii`][u8_escape_ascii]
- [`Vec::spare_capacity_mut`][vec_spare_capacity_mut]
- [`MaybeUninit::assume_init_drop`][assume_init_drop]
- [`MaybeUninit::assume_init_read`][assume_init_read]
- [`i8::abs_diff`][i8_abs_diff]
- [`i16::abs_diff`][i16_abs_diff]
- [`i32::abs_diff`][i32_abs_diff]
- [`i64::abs_diff`][i64_abs_diff]
- [`i128::abs_diff`][i128_abs_diff]
- [`isize::abs_diff`][isize_abs_diff]
- [`u8::abs_diff`][u8_abs_diff]
- [`u16::abs_diff`][u16_abs_diff]
- [`u32::abs_diff`][u32_abs_diff]
- [`u64::abs_diff`][u64_abs_diff]
- [`u128::abs_diff`][u128_abs_diff]
- [`usize::abs_diff`][usize_abs_diff]
- [`Display for io::ErrorKind`][display_error_kind]
- [`From<u8> for ExitCode`][from_u8_exit_code]
- [`Not for !` (the "never" type)][not_never]
- [_Op_`Assign<$t> for Wrapping<$t>`][wrapping_assign_ops]
- [`arch::is_aarch64_feature_detected!`][is_aarch64_feature_detected]

Cargo
-----
- [Port cargo from `toml-rs` to `toml_edit`][cargo/10086]
- [Stabilize `-Ztimings` as `--timings`][cargo/10245]
- [Stabilize namespaced and weak dependency features.][cargo/10269]
- [Accept more `cargo:rustc-link-arg-*` types from build script
  output.][cargo/10274]
- [cargo-new should not add ignore rule on Cargo.lock inside
  subdirs][cargo/10379]

Misc
----
- [Ship docs on Tier 2 platforms by reusing the closest Tier 1
  platform docs][92800]
- [Drop rustc-docs from complete profile][93742]
- [bootstrap: tidy up flag handling for llvm build][93918]

Compatibility Notes
-------------------
- [Remove compiler-rt linking hack on Android][83822]
- [Mitigations for platforms with non-monotonic clocks have been removed from
  `Instant::now`][89926]. On platforms that don't provide monotonic clocks, an
  instant is not guaranteed to be greater than an earlier instant anymore.
- [`Instant::{duration_since, elapsed, sub}` do not panic anymore on underflow,
  saturating to `0` instead][89926]. In the real world the panic happened mostly
  on platforms with buggy monotonic clock implementations rather than catching
  programming errors like reversing the start and end times. Such programming
  errors will now results in `0` rather than a panic.
- In a future release we're planning to increase the baseline requirements for
  the Linux kernel to version 3.2, and for glibc to version 2.17. We'd love
  your feedback in [PR #95026][95026].

Internal Changes
----------------

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

- [Switch all libraries to the 2021 edition][92068]

[83822]: rust-lang/rust#83822
[86374]: rust-lang/rust#86374
[87487]: rust-lang/rust#87487
[89621]: rust-lang/rust#89621
[89926]: rust-lang/rust#89926
[90132]: rust-lang/rust#90132
[90247]: rust-lang/rust#90247
[91606]: rust-lang/rust#91606
[92068]: rust-lang/rust#92068
[92300]: rust-lang/rust#92300
[92357]: rust-lang/rust#92357
[92383]: rust-lang/rust#92383
[92630]: rust-lang/rust#92630
[92670]: rust-lang/rust#92670
[92800]: rust-lang/rust#92800
[92933]: rust-lang/rust#92933
[93566]: rust-lang/rust#93566
[93577]: rust-lang/rust#93577
[93658]: rust-lang/rust#93658
[93742]: rust-lang/rust#93742
[93824]: rust-lang/rust#93824
[93918]: rust-lang/rust#93918
[95026]: rust-lang/rust#95026

[cargo/10086]: rust-lang/cargo#10086
[cargo/10245]: rust-lang/cargo#10245
[cargo/10269]: rust-lang/cargo#10269
[cargo/10274]: rust-lang/cargo#10274
[cargo/10379]: rust-lang/cargo#10379

[arc_new_cyclic]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.new_cyclic
[rc_new_cyclic]: https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.new_cyclic
[slice_escape_ascii]: https://doc.rust-lang.org/stable/std/slice/struct.EscapeAscii.html
[slice_u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.escape_ascii
[u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.escape_ascii
[vec_spare_capacity_mut]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.spare_capacity_mut
[assume_init_drop]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_drop
[assume_init_read]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_read
[i8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.abs_diff
[i16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.abs_diff
[i32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.abs_diff
[i64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.abs_diff
[i128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.abs_diff
[isize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.abs_diff
[u8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.abs_diff
[u16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.abs_diff
[u32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.abs_diff
[u64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.abs_diff
[u128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.abs_diff
[usize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.abs_diff
[display_error_kind]: https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#impl-Display
[from_u8_exit_code]: https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html#impl-From%3Cu8%3E
[not_never]: https://doc.rust-lang.org/stable/std/primitive.never.html#impl-Not
[wrapping_assign_ops]: https://doc.rust-lang.org/stable/std/num/struct.Wrapping.html#trait-implementations
[is_aarch64_feature_detected]: https://doc.rust-lang.org/stable/std/arch/macro.is_aarch64_feature_detected.html
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request May 25, 2022
Pkgsrc changes:
 * Bump available bootstraps to 1.59.0.
 * Adjust line number in patches which had non-zero offsets.

Upstream changes:

Version 1.60.0 (2022-04-07)
===========================

Language
--------
- [Stabilize `#[cfg(panic = "...")]` for either `"unwind"` or `"abort"`.]
  [93658]
- [Stabilize `#[cfg(target_has_atomic = "...")]` for each integer
  size and `"ptr"`.][93824]

Compiler
--------
- [Enable combining `+crt-static` and `relocation-model=pic` on
  `x86_64-unknown-linux-gnu`][86374]
- [Fixes wrong `unreachable_pub` lints on nested and glob public
  reexport][87487]
- [Stabilize `-Z instrument-coverage` as `-C instrument-coverage`][90132]
- [Stabilize `-Z print-link-args` as `--print link-args`][91606]
- [Add new Tier 3 target `mips64-openwrt-linux-musl`\*][92300]
- [Add new Tier 3 target `armv7-unknown-linux-uclibceabi` (softfloat)\*][92383]
- [Fix invalid removal of newlines from doc comments][92357]
- [Add kernel target for RustyHermit][92670]
- [Deny mixing bin crate type with lib crate types][92933]
- [Make rustc use `RUST_BACKTRACE=full` by default][93566]
- [Upgrade to LLVM 14][93577]

\* Refer to Rust's [platform support page][platform-support-doc] for more
   information on Rust's tiered platform support.

Libraries
---------
- [Guarantee call order for `sort_by_cached_key`][89621]
- [Improve `Duration::try_from_secs_f32`/`f64` accuracy by directly
  processing exponent and mantissa][90247]
- [Make `Instant::{duration_since, elapsed, sub}` saturating][89926]
- [Remove non-monotonic clocks workarounds in `Instant::now`][89926]
- [Make `BuildHasherDefault`, `iter::Empty` and `future::Pending`
  covariant][92630]

Stabilized APIs
---------------
- [`Arc::new_cyclic`][arc_new_cyclic]
- [`Rc::new_cyclic`][rc_new_cyclic]
- [`slice::EscapeAscii`][slice_escape_ascii]
- [`<[u8]>::escape_ascii`][slice_u8_escape_ascii]
- [`u8::escape_ascii`][u8_escape_ascii]
- [`Vec::spare_capacity_mut`][vec_spare_capacity_mut]
- [`MaybeUninit::assume_init_drop`][assume_init_drop]
- [`MaybeUninit::assume_init_read`][assume_init_read]
- [`i8::abs_diff`][i8_abs_diff]
- [`i16::abs_diff`][i16_abs_diff]
- [`i32::abs_diff`][i32_abs_diff]
- [`i64::abs_diff`][i64_abs_diff]
- [`i128::abs_diff`][i128_abs_diff]
- [`isize::abs_diff`][isize_abs_diff]
- [`u8::abs_diff`][u8_abs_diff]
- [`u16::abs_diff`][u16_abs_diff]
- [`u32::abs_diff`][u32_abs_diff]
- [`u64::abs_diff`][u64_abs_diff]
- [`u128::abs_diff`][u128_abs_diff]
- [`usize::abs_diff`][usize_abs_diff]
- [`Display for io::ErrorKind`][display_error_kind]
- [`From<u8> for ExitCode`][from_u8_exit_code]
- [`Not for !` (the "never" type)][not_never]
- [_Op_`Assign<$t> for Wrapping<$t>`][wrapping_assign_ops]
- [`arch::is_aarch64_feature_detected!`][is_aarch64_feature_detected]

Cargo
-----
- [Port cargo from `toml-rs` to `toml_edit`][cargo/10086]
- [Stabilize `-Ztimings` as `--timings`][cargo/10245]
- [Stabilize namespaced and weak dependency features.][cargo/10269]
- [Accept more `cargo:rustc-link-arg-*` types from build script
  output.][cargo/10274]
- [cargo-new should not add ignore rule on Cargo.lock inside
  subdirs][cargo/10379]

Misc
----
- [Ship docs on Tier 2 platforms by reusing the closest Tier 1
  platform docs][92800]
- [Drop rustc-docs from complete profile][93742]
- [bootstrap: tidy up flag handling for llvm build][93918]

Compatibility Notes
-------------------
- [Remove compiler-rt linking hack on Android][83822]
- [Mitigations for platforms with non-monotonic clocks have been removed from
  `Instant::now`][89926]. On platforms that don't provide monotonic clocks, an
  instant is not guaranteed to be greater than an earlier instant anymore.
- [`Instant::{duration_since, elapsed, sub}` do not panic anymore on underflow,
  saturating to `0` instead][89926]. In the real world the panic happened mostly
  on platforms with buggy monotonic clock implementations rather than catching
  programming errors like reversing the start and end times. Such programming
  errors will now results in `0` rather than a panic.
- In a future release we're planning to increase the baseline requirements for
  the Linux kernel to version 3.2, and for glibc to version 2.17. We'd love
  your feedback in [PR #95026][95026].

Internal Changes
----------------

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

- [Switch all libraries to the 2021 edition][92068]

[83822]: rust-lang/rust#83822
[86374]: rust-lang/rust#86374
[87487]: rust-lang/rust#87487
[89621]: rust-lang/rust#89621
[89926]: rust-lang/rust#89926
[90132]: rust-lang/rust#90132
[90247]: rust-lang/rust#90247
[91606]: rust-lang/rust#91606
[92068]: rust-lang/rust#92068
[92300]: rust-lang/rust#92300
[92357]: rust-lang/rust#92357
[92383]: rust-lang/rust#92383
[92630]: rust-lang/rust#92630
[92670]: rust-lang/rust#92670
[92800]: rust-lang/rust#92800
[92933]: rust-lang/rust#92933
[93566]: rust-lang/rust#93566
[93577]: rust-lang/rust#93577
[93658]: rust-lang/rust#93658
[93742]: rust-lang/rust#93742
[93824]: rust-lang/rust#93824
[93918]: rust-lang/rust#93918
[95026]: rust-lang/rust#95026

[cargo/10086]: rust-lang/cargo#10086
[cargo/10245]: rust-lang/cargo#10245
[cargo/10269]: rust-lang/cargo#10269
[cargo/10274]: rust-lang/cargo#10274
[cargo/10379]: rust-lang/cargo#10379

[arc_new_cyclic]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.new_cyclic
[rc_new_cyclic]: https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.new_cyclic
[slice_escape_ascii]: https://doc.rust-lang.org/stable/std/slice/struct.EscapeAscii.html
[slice_u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.escape_ascii
[u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.escape_ascii
[vec_spare_capacity_mut]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.spare_capacity_mut
[assume_init_drop]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_drop
[assume_init_read]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_read
[i8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.abs_diff
[i16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.abs_diff
[i32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.abs_diff
[i64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.abs_diff
[i128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.abs_diff
[isize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.abs_diff
[u8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.abs_diff
[u16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.abs_diff
[u32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.abs_diff
[u64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.abs_diff
[u128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.abs_diff
[usize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.abs_diff
[display_error_kind]: https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#impl-Display
[from_u8_exit_code]: https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html#impl-From%3Cu8%3E
[not_never]: https://doc.rust-lang.org/stable/std/primitive.never.html#impl-Not
[wrapping_assign_ops]: https://doc.rust-lang.org/stable/std/num/struct.Wrapping.html#trait-implementations
[is_aarch64_feature_detected]: https://doc.rust-lang.org/stable/std/arch/macro.is_aarch64_feature_detected.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge FCP with intent to merge finished-final-comment-period FCP complete S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-cargo Team: Cargo to-announce
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants