diff options
| author | bors <bors@rust-lang.org> | 2024-09-25 18:19:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-25 18:19:08 +0000 |
| commit | 0399709cdc3c5cc22327e9f657dc7956546a0457 (patch) | |
| tree | 5191d6d23da893ab9075ea155625c9651e25c754 /compiler/rustc_codegen_ssa/src | |
| parent | b5117538e934f81e39eb9c326fdcc6574d144cb7 (diff) | |
| parent | e805182fcc0daf1c0d7b9a1c5b42322b9263ded3 (diff) | |
| download | rust-0399709cdc3c5cc22327e9f657dc7956546a0457.tar.gz rust-0399709cdc3c5cc22327e9f657dc7956546a0457.zip | |
Auto merge of #130847 - matthiaskrgr:rollup-f0n80bw, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #130735 (Simple validation for unsize coercion in MIR validation) - #130781 (Fix up setting strip = true in Cargo.toml makes build scripts fail in…) - #130811 (add link from random() helper fn to extensive DefaultRandomSource docs) - #130819 (Add `must_use` attribute to `len_utf8` and `len_utf16`.) - #130832 (fix some cfg logic around optimize_for_size and 16-bit targets) - #130842 (Add tracking issue for io_error_inprogress) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/base.rs | 24 |
2 files changed, 26 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 892dfb91201..69693230ce0 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1087,16 +1087,17 @@ fn link_natively( let strip = sess.opts.cg.strip; if sess.target.is_like_osx { + let stripcmd = "/usr/bin/strip"; match (strip, crate_type) { (Strip::Debuginfo, _) => { - strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-S")) + strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S")) } // Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988) (Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => { - strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-x")) + strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x")) } (Strip::Symbols, _) => { - strip_symbols_with_external_utility(sess, "strip", out_filename, None) + strip_symbols_with_external_utility(sess, stripcmd, out_filename, None) } (Strip::None, _) => {} } diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index fcf48d3e4a3..5c67600e4ee 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -125,8 +125,28 @@ fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let old_info = old_info.expect("unsized_info: missing old info for trait upcasting coercion"); if data_a.principal_def_id() == data_b.principal_def_id() { - // A NOP cast that doesn't actually change anything, should be allowed even with - // invalid vtables. + // Codegen takes advantage of the additional assumption, where if the + // principal trait def id of what's being casted doesn't change, + // then we don't need to adjust the vtable at all. This + // corresponds to the fact that `dyn Tr<A>: Unsize<dyn Tr<B>>` + // requires that `A = B`; we don't allow *upcasting* objects + // between the same trait with different args. If we, for + // some reason, were to relax the `Unsize` trait, it could become + // unsound, so let's assert here that the trait refs are *equal*. + // + // We can use `assert_eq` because the binders should have been anonymized, + // and because higher-ranked equality now requires the binders are equal. + debug_assert_eq!( + data_a.principal(), + data_b.principal(), + "NOP unsize vtable changed principal trait ref: {data_a} -> {data_b}" + ); + + // A NOP cast that doesn't actually change anything, let's avoid any + // unnecessary work. This relies on the assumption that if the principal + // traits are equal, then the associated type bounds (`dyn Trait<Assoc=T>`) + // are also equal, which is ensured by the fact that normalization is + // a function and we do not allow overlapping impls. return old_info; } |
