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

Installing without --locked fails to compile, errors related to FromBytes / AsBytes / Unaligned #341

Open
vvuk opened this issue Aug 21, 2024 · 7 comments

Comments

@vvuk
Copy link
Collaborator

vvuk commented Aug 21, 2024

This is probably pe-unwind-info breakage, but trying to cargo install samply (or direct from source):

   Compiling pe-unwind-info v0.2.3
error[E0252]: the name `FromBytes` is defined multiple times
  --> /home/vladimir/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pe-unwind-info-0.2.3/src/x86_64.rs:10:23
   |
9  | use zerocopy::{FromBytes, Ref, Unaligned, LE};
   |                --------- previous import of the macro `FromBytes` here
10 | use zerocopy_derive::{FromBytes, FromZeroes, Unaligned};
   |                       ^^^^^^^^^--
   |                       |
   |                       `FromBytes` reimported here
   |                       help: remove unnecessary import
   |
   = note: `FromBytes` must be defined only once in the macro namespace of this module

error[E0252]: the name `Unaligned` is defined multiple times
  --> /home/vladimir/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pe-unwind-info-0.2.3/src/x86_64.rs:10:46
   |
9  | use zerocopy::{FromBytes, Ref, Unaligned, LE};
   |                                --------- previous import of the macro `Unaligned` here
10 | use zerocopy_derive::{FromBytes, FromZeroes, Unaligned};
   |                                              ^^^^^^^^^ `Unaligned` reimported here
   |
   = note: `Unaligned` must be defined only once in the macro namespace of this module

For more information about this error, try `rustc --explain E0252`.
@vvuk
Copy link
Collaborator Author

vvuk commented Aug 22, 2024

Actually no. cargo build builds fine, cargo install --path samply does not.

@javierhonduco
Copy link

javierhonduco commented Sep 3, 2024

I'm also experiencing this issue, currently running this if it helps

$ rustc --version
rustc 1.79.0-nightly (ef8b9dcf2 2024-04-24)
$ cargo --version
cargo 1.79.0-nightly (c93926759 2024-04-23)

I could also compile it directly with a local clone of the repo

@mstange
Copy link
Owner

mstange commented Sep 3, 2024

The following pattern only compiles when the derive feature of the zerocopy crate is not enabled:

use zerocopy::FromBytes;
use zerocopy_derive::FromBytes;

It breaks as soon as any dependency in the workspace enables the derive feature. In this case, it happened because version 0.2.20 of ppv-lite86 enabled that feature - interestingly, they enabled it to fix the same kind of build failure as we're dealing with here. cryptocorrosion/cryptocorrosion#77

This feels like a bit of a footgun in zerocopy.

I will need to re-release multiple crates to fix this.

For now, you can work around this by passing --locked to cargo install.

@mstange mstange changed the title main broken on linux due to pe-unwind-info Installing without --locked fails to compile, errors related to FromBytes / AsBytes / Unaligned Sep 3, 2024
@najtin
Copy link

najtin commented Nov 2, 2024

I just want to add, that the current lock file has yanked dependencies and cargo advices not to install with --locked:

warning: package `bytes v1.6.0` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked
warning: package `futures-util v0.3.30` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked

@najtin
Copy link

najtin commented Nov 2, 2024

pe-unwind-info on the main branch has since been updated and does not have multiple definition of FromBytes / AsBytes Unaligned anymore. See mozilla/pe-unwind-info@7825141

Updating pe-unwind-info to 0.3.X should fix this issue.

@jct-tympanon
Copy link

i landed here using wholesym 0.7.0 as a library, independently of samply (thanks for the crate btw!). I get a related compile error in samply-symbols:

Compiling samply-symbols v0.23.0
error[E0252]: the name `AsBytes` is defined multiple times
  --> /XXXX/.cargo/registry/src/index.crates.io-6f17d22bba15001f/samply-symbols-0.23.0/src/breakpad/index.rs:15:23
   |
14 | use zerocopy::{AsBytes, LittleEndian, Ref, U32, U64};
   |                ------- previous import of the macro `AsBytes` here
15 | use zerocopy_derive::{AsBytes, FromBytes, FromZeroes, Unaligned};
   |                       ^^^^^^^--
   |                       |
   |                       `AsBytes` reimported here
   |                       help: remove unnecessary import
   |
   = note: `AsBytes` must be defined only once in the macro namespace of this module

For more information about this error, try `rustc --explain E0252`.

i can confirm that this error is also fixed by your dep upgrades in HEAD. zerocopy does have a related bug report, which they considered to be a documentation problem: google/zerocopy#1587

it might be a good idea to update breakpad/index.rs to follow their recommendation though? otherwises this might creep back in via other dependencies in the closure.

i tried a patch against wholesym-v0.7.0 in my workspace and it also fixed the error. i can send a PR if you like (it's just a one-liner).

@mstange
Copy link
Owner

mstange commented Dec 6, 2024

it might be a good idea to update breakpad/index.rs to follow their recommendation though? otherwises this might creep back in via other dependencies in the closure.

Ah, thanks, I've put up a PR to do this in #437.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants