Skip to content

NoStd No Alloc build failures #173

Description

@AdamKMeller

While working in a no std environment with alloc and I tried building the latest (0.7.6) with various feature flags and found some compilation errors. Namely, the alloc feature is seemingly required for the managed_vec.rs file to compile, erroring out on line 24 when alloc is not present. Adding alloc prevents this error, however, alloc with noStd seems to create some ambiguity in the tracepoints.rs (added in version 0.7.4) which will create a compiler error. I was only able to get a noStd build to work on version 0.7.3 with alloc.

With version "=0.7.6", default-features = false but no alloc, an error would be thrown:

 error[E0004]: non-exhaustive patterns: `&mut &mut ManagedSlice::Owned(_)` not covered
  --> ... /.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/gdbstub-0.7.6/src/util/managed_vec.rs:24:19
   |
24 |             match &mut self.buf {
   |                   ^^^^^^^^^^^^^ pattern `&mut &mut ManagedSlice::Owned(_)` not covered
   |

By adding the alloc feature ( version = "=0.7.6", default-features = false, features = [ "alloc"]) the error would go away but another one would come up in the tracepoints added in version 0.7.4:

error[E0599]: no method named `to_owned` found for enum `ManagedSlice<'_, u8>` in the current scope
   --> .../ .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/gdbstub-0.7.6/src/target/ext/tracepoints.rs:124:51
    |
124 |             bytes: ManagedSlice::Owned(self.bytes.to_owned()),
    |                                                   ^^^^^^^^ method not found in `ManagedSlice<'_, u8>`
    |
    = help: items from traits can only be used if the trait is in scope
help: trait `ToOwned` which provides `to_owned` is implemented but not in scope; perhaps you want to import it
    |
18  + use crate::alloc::borrow::ToOwned;
    |

In order to get a properly compiling version of gdbstub with noStd I had to roll back to version 0.7.3 before tracepoints and include alloc (I also added core_error but this does not have an impact on the compilation as far as I can see).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions