dhardy / rand

http://doc.rust-lang.org/rand
Other
2 stars 2 forks source link

Fix no_std CI test #47

Closed dhardy closed 6 years ago

dhardy commented 6 years ago

46 (now #50) adds a Travis test on a bare-metal target (no std).

As expected, this initially failed with a "can't find std" message, because the libc and rand_core dependencies inadvertently depended on default features (including std). The second commit fixed this.

But now, the build fails with:

error[E0463]: can't find crate for core | = note: the thumbv6m-none-eabi target may not be installed

Why?

vks commented 6 years ago

Why do we need libc?

dhardy commented 6 years ago

Some of the OS random impls use it. Possibly not needed on all platforms. And shouldn't be needed with no_std — good point!

src/os.rs
102:    extern crate libc;
117:    fn getrandom(buf: &mut [u8]) -> libc::c_long {
119:            fn syscall(number: libc::c_long, ...) -> libc::c_long;
123:        const NR_GETRANDOM: libc::c_long = 318;
125:        const NR_GETRANDOM: libc::c_long = 355;
127:        const NR_GETRANDOM: libc::c_long = 384;
129:        const NR_GETRANDOM: libc::c_long = 278;
131:        const NR_GETRANDOM: libc::c_long = 384;
133:        const GRND_NONBLOCK: libc::c_uint = 0x0001;
146:    fn getrandom(_buf: &mut [u8]) -> libc::c_long { -1 }
195:                err != Some(libc::ENOSYS)
249:    extern crate libc;
254:    use self::libc::{c_int, size_t};
292:    extern crate libc;
306:            let mib = [libc::CTL_KERN, libc::KERN_ARND];
311:                    libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint,
330:    extern crate libc;
347:                    libc::getentropy(s.as_mut_ptr() as *mut libc::c_void, s.len())