Skip to content
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

Musl / no_std support #10

Open
leonardohn opened this issue Aug 10, 2018 · 2 comments
Open

Musl / no_std support #10

leonardohn opened this issue Aug 10, 2018 · 2 comments

Comments

@leonardohn
Copy link

I'm trying to use this crate to control some light bulbs with my wireless router through SSH. My wireless router currently runs OpenWRT which uses Musl as default library. However, I'm facing some problems trying to compile the current version using the target triple "mips-unknown-linux-musl":

error[E0425]: cannot find value `SOL_BLUETOOTH` in module `libc`
   --> /home/leonardohn/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/adapter/peripheral.rs:348:40
    |
348 |             libc::setsockopt(fd, libc::SOL_BLUETOOTH, 4, opt.as_mut_ptr() as *mut libc::c_void, 2)
    |                                        ^^^^^^^^^^^^^ did you mean `AF_BLUETOOTH`?

error[E0308]: mismatched types
  --> /home/leonardohn/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/manager/mod.rs:75:35
   |
75 |                 libc::ioctl(*ctl, HCI_GET_DEV_LIST_MAGIC as libc::c_ulong, dl as (*mut c_void)))?;
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32

error[E0308]: mismatched types
   --> /home/leonardohn/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/adapter/mod.rs:468:43
    |
468 |             handle_error(libc::ioctl(ctl, HCI_GET_DEV_MAGIC as libc::c_ulong,
    |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32

error: aborting due to 3 previous errors

Some errors occurred: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.
error: Could not compile `rumble`.

When I try to compile to my computer architecture it works fine, so, the problem seems to be with using Musl instead of Glibc.

By the way, I'm currently using rust standard library with the project, but it would be nice to move to no_std as it could save some space into the binary file, considering my router has only 8mb in space.

Are you planning to support Musl and no_std implementations?

@jmagnuson
Copy link
Contributor

SOL_BLUETOOTH is defined in mainline linux so should not be a platform-specific issue. I opened rust-lang/libc#1169 (now merged) to get that fixed for musl and others.

Cross-platforming for HCI_GET_DEV_MAGIC, on the other hand, should be handled by rumble. Further-embracing nix's ioctl macros would be a good solution-- I opened #18 with the intent of going down that path. Otherwise, platform cfg flagging (example) is another common approach.

@mwylde
Copy link
Owner

mwylde commented Dec 12, 2018

Great to see the SOL_BLUETOOTH fix merged. I'd be happy to accept a PR that defines the constant internally as well in the meantime (as well as any other fixes needed for no_std).

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