Skip to content

defmt-0.3.9 failed to build #2679

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

Closed
jonathanpallant opened this issue Nov 28, 2024 · 24 comments
Closed

defmt-0.3.9 failed to build #2679

jonathanpallant opened this issue Nov 28, 2024 · 24 comments

Comments

@jonathanpallant
Copy link

Crate name

defmt

Build failure link

https://docs.rs/crate/defmt/0.3.9/builds/1566395

Additional details

I don't think we changed anything substantial since defmt-0.3.8, which built OK.

@syphar
Copy link
Member

syphar commented Nov 28, 2024

there wasn't any related change in docs.rs, though I can only imagine it's either related to your code, or perhaps that the new nightly version changed something.

@GuillaumeGomez
Copy link
Member

Maybe -Zbuild-std is the one in fault here?

@syphar
Copy link
Member

syphar commented Nov 28, 2024

this is the diff: knurling-rs/defmt@defmt-v0.3.8...defmt-v0.3.9

@syphar
Copy link
Member

syphar commented Nov 28, 2024

ah, I remember there is also diff.rs: https://diff.rs/defmt/0.3.8/defmt/0.3.9/Cargo.toml

@jonathanpallant
Copy link
Author

Do you use -Zbuild-std? Because I don't think we do. And yes, on thumbv6m-none-eabi for example, I'm pretty sure you have to say -Zbuild-std=core

defmt git:(release-defmt-0.3.10) rustc +nightly --version
rustc 1.83.0-nightly (06bb8364a 2024-10-01)defmt git:(release-defmt-0.3.10) cargo +nightly build --target=thumbv6m-none-eabi
   Compiling bitflags v1.3.2
   Compiling defmt v0.3.9 (/Users/jonathan/Documents/knurling-rs/defmt/defmt)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23sdefmt git:(release-defmt-0.3.10) cargo +nightly build --target=thumbv6m-none-eabi -Zbuild-std
   Compiling gimli v0.29.0
error[E0432]: unresolved import `alloc::sync`
 --> /Users/jonathan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gimli-0.29.0/src/read/dwarf.rs:2:12
  |
2 | use alloc::sync::Arc;
  |            ^^^^ could not find `sync` in `alloc`

error[E0432]: unresolved import `alloc::sync`
 --> /Users/jonathan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gimli-0.29.0/src/read/abbrev.rs:4:12
  |
4 | use alloc::sync::Arc;
  |            ^^^^ could not find `sync` in `alloc`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `gimli` (lib) due to 2 previous errorsdefmt git:(release-defmt-0.3.10) cargo +nightly build --target=thumbv6m-none-eabi -Zbuild-std=core
   Compiling bitflags v1.3.2
   Compiling defmt v0.3.9 (/Users/jonathan/Documents/knurling-rs/defmt/defmt)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.25sdefmt git:(release-defmt-0.3.10)

@jonathanpallant
Copy link
Author

@jonathanpallant
Copy link
Author

Which was added last week: rust-lang/cargo@5e4a1db

@jonathanpallant
Copy link
Author

Yup:

defmt git:(release-defmt-0.3.10) RUSTC=~/Downloads/rust-nightly/rust-nightly-aarch64-apple-darwin/rustc/bin/rustc  ~/Downloads/rust-nightly/rust-nightly-aarch64-apple-darwin/cargo/bin/cargo build --target=thumbv6m-none-eabi -Zbuild-std
error: building std is not supported on the following targets: thumbv6m-none-eabi
defmt git:(release-defmt-0.3.10) RUSTC=~/Downloads/rust-nightly/rust-nightly-aarch64-apple-darwin/rustc/bin/rustc  ~/Downloads/rust-nightly/rust-nightly-aarch64-apple-darwin/cargo/bin/cargo build --target=thumbv6m-none-eabi -Zbuild-std=core
error: "/Users/jonathan/Downloads/rust-nightly/rust-nightly-aarch64-apple-darwin/rustc/lib/rustlib/src/rust/library/Cargo.lock" does not exist, unable to build with the standard library, try:
        rustup component add rust-src

No idea how to add rust-src to a tarball installation, but that's the error.

@jonathanpallant
Copy link
Author

I sent https://crates.io/crates/thejpster-test-docs-target down the line, which is an inoffensive test crate. If you can't build it then I'm pretty sure it's a docs.rs but and not a defmt bug.

@syphar
Copy link
Member

syphar commented Nov 28, 2024

Maybe -Zbuild-std is the one in fault here?

@GuillaumeGomez you mean we need add it do the docs.rs metadata to use #2107 ?

I sent https://crates.io/crates/thejpster-test-docs-target down the line, which is an inoffensive test crate. If you can't build it then I'm pretty sure it's a docs.rs but and not a defmt bug.

there was no docs.rs change that might cause this, so I imagine the nighty version changes you linked could cause the error.

If you have a test crate that errors too (and IMO it likely will with the targets) we might try it with cargo-args=["-Zbuild-std"]

@GuillaumeGomez
Copy link
Member

It's not clear when it's needed. Also, I'm surprised it worked without using -Zbuild-std (I thought we used it but we don't).

@jonathanpallant
Copy link
Author

AFAIK will need -Zbuild-std=core when building for a target that doesn't have libstd. I guess most of your crates build for the host machine, but the docs.rs metadata for this one forces you to build it for thumbv6m-none-eabi and thumbv7em-none-eabihf, because it's known to not work on Windows/macOS/Linux.

@jonathanpallant
Copy link
Author

https://crates.io/crates/thejpster-test-docs-target is perpetually stuck at the back of the queue, perhaps because you've rated as a crate of low value (it is, it's terrible).

@syphar
Copy link
Member

syphar commented Nov 28, 2024

https://crates.io/crates/thejpster-test-docs-target is perpetually stuck at the back of the queue, perhaps because you've rated as a crate of low value (it is, it's terrible).

it's not deprioritized, so has the same prio as normal releases (deprioritized is shown in braces after the crate, if we do it, like (priority: -1))

@jonathanpallant
Copy link
Author

jonathanpallant commented Nov 28, 2024

So why is everything else being added to the queue in front of it? It was one-from-last and 27th and is now one-from-last and 63rd.

@syphar
Copy link
Member

syphar commented Nov 28, 2024

I can't Check the logs right now, my guess is build-attempts.

For a certain type of build errors ( like the one from the original crate) we actually try the build up to 5 times with a delay in between.

@jonathanpallant
Copy link
Author

Ah, it did build but it went back in the queue!!

and it failed: https://docs.rs/crate/thejpster-test-docs-target/0.1.0/builds/1567394

error: building std is not supported on the following targets: thumbv7em-none-eabihf, thumbv6m-none-eabi

So yup, not defmt's fault.

@syphar
Copy link
Member

syphar commented Nov 29, 2024

so, I don't know enough about the build process around these targets to be able to judge where the problem lies, in the cargo change, in how docs.rs builds docs, of if we're missing a build arg (build-std?) and we were just lucky until now.

What I know is that before the mentioned cargo change, the doc build works.

So I froze the nightly version docs.rs uses to nightly-2024-11-21. A rebuild for thejpster-test-docs-target then succeeds, so did the rebuild for defmt 0.3.9.

@syphar
Copy link
Member

syphar commented Nov 29, 2024

I want to create a bug-report for cargo, @jonathanpallant could you push the test crate to github so I can include it?

@syphar
Copy link
Member

syphar commented Nov 29, 2024

I wonder if cargo-args = ["-Zbuild-std=core"] in the metadata might help...

@syphar
Copy link
Member

syphar commented Nov 29, 2024

I started with a zulip thread

@jonathanpallant
Copy link
Author

https://github.com/jonathanpallant/thejpster-test-docs-target

@syphar
Copy link
Member

syphar commented Dec 16, 2024

the final fix is still in progress, but since there were some other releases that needed a newer version I un-froze the nightly version.

Feel free to ping me if you need to build another release, and we can handle it together. It might also be worth trying to add Zbuild-std=core as done here

@syphar
Copy link
Member

syphar commented Dec 20, 2024

coming from the zulip discussion I would say this is fixed now.

Feel free to reopen if it breaks again, if it fails please first try adding -Zbuild-std=core or -Zbuild-std to the docs.rs metadata

@syphar syphar closed this as completed Dec 20, 2024
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

3 participants