Repository: rust
Issue: Invalid metadata for arm64e due to Xcode 15+ on ARM64e macOS
Labels: O-macos,O-Arm,P-high,T-compiler,T-bootstrap,C-bug,regression-untriaged

I tried to compile `arm64e-apple-darwin` on `aarch64` (ARM-based CPU) `macOS`. So, I got the following error

<details><summary>error[E0786]: found invalid metadata files for crate `zerocopy_derive`</summary>
<p>

```sh

  error[E0786]: found invalid metadata files for crate `zerocopy_derive`
     --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:285:9
      |
  285 | pub use zerocopy_derive::Unaligned;
      |         ^^^^^^^^^^^^^^^
      |
      = note: no `.rustc` section in '/Users/runner/work/rust-compiler-builder/rust-compiler-builder/rust/build/aarch64-apple-darwin/stage1-rustc/arm64e-apple-darwin/release/deps/libzerocopy_derive-85cad85f9873b5cd.dylib'
  
  error[E0786]: found invalid metadata files for crate `zerocopy_derive`
     --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:293:9
      |
  293 | pub use zerocopy_derive::KnownLayout;
      |         ^^^^^^^^^^^^^^^
      |
      = note: no `.rustc` section in '/Users/runner/work/rust-compiler-builder/rust-compiler-builder/rust/build/aarch64-apple-darwin/stage1-rustc/arm64e-apple-darwin/release/deps/libzerocopy_derive-85cad85f9873b5cd.dylib'
  
  error[E0786]: found invalid metadata files for crate `zerocopy_derive`
      --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:1118:9
       |
  1118 | pub use zerocopy_derive::FromZeroes;
       |         ^^^^^^^^^^^^^^^
       |
       = note: no `.rustc` section in '/Users/runner/work/rust-compiler-builder/rust-compiler-builder/rust/build/aarch64-apple-darwin/stage1-rustc/arm64e-apple-darwin/release/deps/libzerocopy_derive-85cad85f9873b5cd.dylib'
  
  error[E0786]: found invalid metadata files for crate `zerocopy_derive`
      --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:1733:9
       |
  1733 | pub use zerocopy_derive::FromBytes;
       |         ^^^^^^^^^^^^^^^
       |
       = note: no `.rustc` section in '/Users/runner/work/rust-compiler-builder/rust-compiler-builder/rust/build/aarch64-apple-darwin/stage1-rustc/arm64e-apple-darwin/release/deps/libzerocopy_derive-85cad85f9873b5cd.dylib'
  
  error[E0786]: found invalid metadata files for crate `zerocopy_derive`
      --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:2599:9
       |
  2599 | pub use zerocopy_derive::AsBytes;
       |         ^^^^^^^^^^^^^^^
       |
       = note: no `.rustc` section in '/Users/runner/work/rust-compiler-builder/rust-compiler-builder/rust/build/aarch64-apple-darwin/stage1-rustc/arm64e-apple-darwin/release/deps/libzerocopy_derive-85cad85f9873b5cd.dylib'
  
  error[E0432]: unresolved import `crate::KnownLayout`
    --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/util.rs:21:34
     |
  21 |     use crate::{util::AsAddress, KnownLayout, _CastType};
     |                                  ^^^^^^^^^^^
  
  [RUSTC-TIMING] displaydoc test:false 7.021
     Compiling tracing-attributes v0.1.27
  error[E0277]: the trait bound `byteorder::U16<O>: FromZeroes` is not satisfied
     --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/byteorder.rs:292:49
      |
  236 | / macro_rules! define_type {
  237 | |     ($article:ident,
  238 | |         $name:ident,
  239 | |         $native:ident,
  ...   |
  292 | |             impl_or_verify!(O => FromZeroes for $name<O>);
      | |                                                 ^^^^^^^^ the trait `FromZeroes` is not implemented for `byteorder::U16<O>`
  ...   |
  462 | |     };
  463 | | }
      | |_- in this expansion of `define_type!`
  464 |
  465 | / define_type!(
  466 | |     A,
  467 | |     U16,
  468 | |     u16,
  ...   |
  477 | |     [U32, U64, U128]
  478 | | );
      | |_- in this macro invocation
      |
      = help: the following other types implement trait `FromZeroes`:
                ()
                *const T
                *mut T
                ManuallyDrop<T>
                MaybeUninit<T>
                Option<&T>
                Option<&mut T>
                Option<NonNull<T>>
              and 103 others
  note: required by a bound in `byteorder::_::_::Subtrait`
     --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/macros.rs:323:29
      |
  28  | / macro_rules! safety_comment {
  29  | |     (#[doc = r" SAFETY:"] $($(#[$attr:meta])* $macro:ident!$args:tt;)*) => {
  30  | |         #[allow(clippy::undocumented_unsafe_blocks, unused_attributes)]
  31  | |         const _: () = { $($(#[$attr])* $macro!$args;)* };
      | |                                        ------------ in this macro invocation (#3)
  32  | |     }
  33  | | }
      | |_- in this expansion of `safety_comment!` (#2)
  ...
  279 | / macro_rules! impl_or_verify {
  280 | |     // The following two match arms follow the same pattern as their
  281 | |     // counterparts in `unsafe_impl!`; see the documentation on those arms for
  282 | |     // more details.
  ...   |
  302 | /         impl_or_verify!(@verify $trait, {
  303 |               impl<$($tyvar $(: $(? $optbound +)* $($bound +)*)?),*> Subtrait for $ty {}
  304 | |         });
      | |__________- in this macro invocation (#4)
  ...
  323 | |             trait Subtrait: $trait {}
      | |                             ^^^^^^ required by this bound in `Subtrait`
  ...   |
  326 | |     };
  327 | | }
      | | -
      | |_|
      | |_in this expansion of `impl_or_verify!` (#3)
      |   in this expansion of `impl_or_verify!` (#4)
      |
     ::: /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/byteorder.rs:236:1
      |
  236 | / macro_rules! define_type {
  237 | |     ($article:ident,
  238 | |         $name:ident,
  239 | |         $native:ident,
  ...   |
  287 | /         safety_comment! {
  288 |               /// SAFETY:
  289 |               /// `$name<O>` is `repr(transparent)`, and so it has the same layout
  290 |               /// as its only non-zero field, which is a `u8` array. `u8` arrays
  ...
  295 |               impl_or_verify!(O => Unaligned for $name<O>);
  296 | |         }
      | |_________- in this macro invocation (#2)
  ...
  462 | |     };
  463 | | }
      | |_- in this expansion of `define_type!` (#1)
  464 |
  465 | / define_type!(
  466 | |     A,
  467 | |     U16,
  468 | |     u16,
  ...   |
  477 | |     [U32, U64, U128]
  478 | | );
      | |_- in this macro invocation (#1)
  
  error[E0277]: the trait bound `byteorder::U16<O>: FromBytes` is not satisfied
     --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/byteorder.rs:293:48
      |
  236 | / macro_rules! define_type {
  237 | |     ($article:ident,
  238 | |         $name:ident,
  239 | |         $native:ident,
  ...   |
  293 | |             impl_or_verify!(O => FromBytes for $name<O>);
      | |                                                ^^^^^^^^ the trait `FromBytes` is not implemented for `byteorder::U16<O>`
  ...   |
  462 | |     };
  463 | | }
      | |_- in this expansion of `define_type!`
  464 |
  465 | / define_type!(
  466 | |     A,
  467 | |     U16,
  468 | |     u16,
  ...   |
  477 | |     [U32, U64, U128]
  478 | | );
      | |_- in this macro invocation
      |
      = help: the following other types implement trait `FromBytes`:
                ()
                ManuallyDrop<T>
                MaybeUninit<T>
                Option<NonZero<i128>>
                Option<NonZero<i16>>
                Option<NonZero<i32>>
                Option<NonZero<i64>>
                Option<NonZero<i8>>
              and 69 others
  note: required by a bound in `byteorder::_::_::Subtrait`
     --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/macros.rs:323:29
      |
  28  | / macro_rules! safety_comment {
  29  | |     (#[doc = r" SAFETY:"] $($(#[$attr:meta])* $macro:ident!$args:tt;)*) => {
  30  | |         #[allow(clippy::undocumented_unsafe_blocks, unused_attributes)]
  31  | |         const _: () = { $($(#[$attr])* $macro!$args;)* };
      | |                                        ------------ in this macro invocation (#3)
  32  | |     }
  33  | | }
      | |_- in this expansion of `safety_comment!` (#2)
  ...
  279 | / macro_rules! impl_or_verify {
  280 | |     // The following two match arms follow the same pattern as their
  281 | |     // counterparts in `unsafe_impl!`; see the documentation on those arms for
  282 | |     // more details.
  ...   |
  302 | /         impl_or_verify!(@verify $trait, {
  303 |               impl<$($tyvar $(: $(? $optbound +)* $($bound +)*)?),*> Subtrait for $ty {}
  304 | |         });
      | |__________- in this macro invocation (#4)
  ...
  323 | |             trait Subtrait: $trait {}
      | |                             ^^^^^^ required by this bound in `Subtrait`
  ...   |
  326 | |     };
  327 | | }
      | | -
      | |_|
      | |_in this expansion of `impl_or_verify!` (#3)
      |   in this expansion of `impl_or_verify!` (#4)
      |
     ::: /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/byteorder.rs:236:1
      |
  236 | / macro_rules! define_type {
  237 | |     ($article:ident,
  238 | |         $name:ident,
  239 | |         $native:ident,
  ...   |
  287 | /         safety_comment! {
  288 |               /// SAFETY:
  289 |               /// `$name<O>` is `repr(transparent)`, and so it has the same layout
  290 |               /// as its only non-zero field, which is a `u8` array. `u8` arrays
  ...
  295 |               impl_or_verify!(O => Unaligned for $name<O>);
  296 | |         }
      | |_________- in this macro invocation (#2)
  ...
  462 | |     };
  463 | | }
      | |_- in this expansion of `define_type!` (#1)
  464 |
  465 | / define_type!(
  466 | |     A,
  467 | |     U16,
  468 | |     u16,
  ...   |
  477 | |     [U32, U64, U128]
  478 | | );
      | |_- in this macro invocation (#1)
  
  error[E0277]: the trait bound `byteorder::U16<O>: AsBytes` is not satisfied
     --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/byteorder.rs:294:46
      |
  236 | / macro_rules! define_type {
  237 | |     ($article:ident,
  238 | |         $name:ident,
  239 | |         $native:ident,
  ...   |
  294 | |             impl_or_verify!(O => AsBytes for $name<O>);
      | |                                              ^^^^^^^^ the trait `AsBytes` is not implemented for `byteorder::U16<O>`
  ...   |
  462 | |     };
  463 | | }
      | |_- in this expansion of `define_type!`
  464 |
  465 | / define_type!(
  466 | |     A,
  467 | |     U16,
  468 | |     u16,
  ...   |
  477 | |     [U32, U64, U128]
  478 | | );
      | |_- in this macro invocation
      |

```

</p>
</details>

This issue can be reproduced only on *aarch64* (ARM-based CPU) `macOS`.

See https://github.com/google/zerocopy/issues/1739
See https://github.com/llvm/llvm-project/issues/79543

Blocked by https://github.com/llvm/llvm-project/issues/80200
Relates to https://github.com/rust-lang/rust/issues/130085

<!--
If you know when this regression occurred, please add a line like below, replacing `{channel}` with one of stable, beta, or nightly.

@rustbot modify labels: +regression-from-stable-to-{channel} -regression-untriaged
-->