mstange / samply

Command-line sampling profiler for macOS and Linux
Apache License 2.0
1.96k stars 48 forks source link

0.12.0 fails to compile: wholesym trait bounds not satisfied #271

Closed cdown closed 1 week ago

cdown commented 1 week ago

Didn't have time to look into what's going on here yet, but I thought you'd like to know. From cargo install samply:

   Compiling samply v0.12.0
error[E0277]: the trait bound `object::File<'_, R>: wholesym::samply_symbols::object::Object<'_>` is not satisfied
    --> /home/cdown/.cargo/registry/src/index.crates.io-6f17d22bba15001f/samply-0.12.0/src/linux_shared/converter.rs:1130:44
     |
1130 |         let debug_id = debug_id_for_object(file)?;
     |                        ------------------- ^^^^ the trait `wholesym::samply_symbols::object::Object<'_>` is not implemented for `object::File<'_, R>`
     |                        |
     |                        required by a bound introduced by this call
     |
     = help: the following other types implement trait `wholesym::samply_symbols::object::Object<'data>`:
               wholesym::samply_symbols::object::File<'data, R>
               wholesym::samply_symbols::object::coff::CoffFile<'data, R, Coff>
               wholesym::samply_symbols::object::read::elf::ElfFile<'data, Elf, R>
               wholesym::samply_symbols::object::read::macho::MachOFile<'data, Mach, R>
               wholesym::samply_symbols::object::read::pe::PeFile<'data, Pe, R>
note: required by a bound in `debug_id_for_object`
    --> /home/cdown/.cargo/registry/src/index.crates.io-6f17d22bba15001f/samply-symbols-0.22.1/src/debugid_util.rs:69:46
     |
69   | pub fn debug_id_for_object<'data>(obj: &impl Object<'data>) -> Option<DebugId> {
     |                                              ^^^^^^^^^^^^^ required by this bound in `debug_id_for_object`

error[E0277]: the trait bound `object::File<'_, R>: wholesym::samply_symbols::object::Object<'_>` is not satisfied
    --> /home/cdown/.cargo/registry/src/index.crates.io-6f17d22bba15001f/samply-0.12.0/src/linux_shared/converter.rs:1169:63
     |
1169 |         let base_svma = samply_symbols::relative_address_base(file);
     |                         ------------------------------------- ^^^^ the trait `wholesym::samply_symbols::object::Object<'_>` is not implemented for `object::File<'_, R>`
     |                         |
     |                         required by a bound introduced by this call
     |
     = help: the following other types implement trait `wholesym::samply_symbols::object::Object<'data>`:
               wholesym::samply_symbols::object::File<'data, R>
               wholesym::samply_symbols::object::coff::CoffFile<'data, R, Coff>
               wholesym::samply_symbols::object::read::elf::ElfFile<'data, Elf, R>
               wholesym::samply_symbols::object::read::macho::MachOFile<'data, Mach, R>
               wholesym::samply_symbols::object::read::pe::PeFile<'data, Pe, R>
note: required by a bound in `wholesym::samply_symbols::relative_address_base`
    --> /home/cdown/.cargo/registry/src/index.crates.io-6f17d22bba15001f/samply-symbols-0.22.1/src/shared.rs:646:56
     |
646  | pub fn relative_address_base<'data>(object_file: &impl object::Object<'data>) -> u64 {
     |                                                        ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `relative_address_base`

error[E0277]: the trait bound `O: wholesym::samply_symbols::object::Object<'_>` is not satisfied
    --> /home/cdown/.cargo/registry/src/index.crates.io-6f17d22bba15001f/samply-0.12.0/src/linux_shared/converter.rs:1301:71
     |
1301 |                 let base_svma = samply_symbols::relative_address_base(file);
     |                                 ------------------------------------- ^^^^ the trait `wholesym::samply_symbols::object::Object<'_>` is not implemented for `O`
     |                                 |
     |                                 required by a bound introduced by this call
     |
note: required by a bound in `wholesym::samply_symbols::relative_address_base`
    --> /home/cdown/.cargo/registry/src/index.crates.io-6f17d22bba15001f/samply-symbols-0.22.1/src/shared.rs:646:56
     |
646  | pub fn relative_address_base<'data>(object_file: &impl object::Object<'data>) -> u64 {
     |                                                        ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `relative_address_base`
help: consider further restricting this bound
     |
1282 |     pub fn compute_base_avma<'data, O: Object<'data> + wholesym::samply_symbols::object::Object<'_>>(
     |                                                      ++++++++++++++++++++++++++++++++++++++++++++++

For more information about this error, try `rustc --explain E0277`.
error: could not compile `samply` (bin "samply") due to 3 previous errors
cdown commented 1 week ago

--locked works, so it seems like then somewhere some versioning or version ranges are not restrictive enough.

mstange commented 1 week ago

Ugh, thanks for reporting! I may need to yank the recent dot release of samply-symbols.

mstange commented 1 week ago

I'm working on this now.

mstange commented 1 week ago

Here's the dependency chains as written down in each released crate's Cargo.toml:

samply 0.12.0 -> wholesym 0.5.0 -> samply-symbols 0.22.0 -> object 0.35 samply 0.12.0 -> wholesym 0.5.0 -> object 0.35

samply-symbols has a public API which expects a type from object.

I recently released samply-symbols 0.22.1 which depends on object 0.36. This was a mistake, because it is a breaking change to the public API debug_id_for_object. Now wholesym 0.5.0 can no longer pass its object 0.35 types to debug_id_for_object.

I'm planning to release samply-symbols 0.22.2 with the same code as samply-symbols 0.22.0. Then I will yank samply-symbols 0.22.1.

mstange commented 1 week ago

Done. cargo install samply works for me locally again.

mstange commented 1 week ago

cargo semver-checks missed this breaking change, I think that's https://github.com/obi1kenobi/cargo-semver-checks/issues/638 .