Skip to content

Build fails due to std crate in kernel binding while std/lib.rs specifies #![no_std] attribute #27

@dipanjan

Description

@dipanjan

The project doesn't get compiled out of the box with rustc 1.20.0-nightly (bf0a9e0b4 2017-07-10). Instead of the forked version of bindgen (which doesn't get compiled), I used the original one which generates a kernel binding that uses std crate everywhere. A snippet looks like:

pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
impl <T> __IncompleteArrayField<T> {
    #[inline]
    pub fn new() -> Self {
        __IncompleteArrayField(::std::marker::PhantomData)
    }
    #[inline]
    pub unsafe fn as_ptr(&self) -> *const T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut_ptr(&mut self) -> *mut T {
        ::std::mem::transmute(self)
    }
    #[inline]
    pub unsafe fn as_slice(&self, len: usize) -> &[T] {
        ::std::slice::from_raw_parts(self.as_ptr(), len)
    }
    #[inline]
    pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
        ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
    }
}

While compiling, I get the following errors (a lot of similar ones because of use of std crate).

error[E0433]: failed to resolve. Could not find `marker` in `std`
 --> std/src/os/kernel.rs:5:38
  |
5 | pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
  |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `marker` in `std`

I wonder how the original project was even compiled. Any idea how can I get around the issue?

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