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

Add #[no_std] support. (Closes #3) #10

Closed
wants to merge 24 commits into from
Closed

Add #[no_std] support. (Closes #3) #10

wants to merge 24 commits into from

Conversation

mre
Copy link
Owner

@mre mre commented Oct 25, 2018

This makes the necessary changes to make this crate running with #[no_std].
I'm a bit surprised that it was that easy and it feels like I'm missing something here.
It was simply replacing std with core.

If you wonder about the dependency to the log crate, that one is #[no_std] by default since 0.4 (2017-12-24 🎄).

@thejpster, any comments before merging?

@mre
Copy link
Owner Author

mre commented Oct 25, 2018

Oh, one note I just found could serve as a word of caution:

Adding #![no_std] to a crate doesn't mean it doesn't depend on std. If a dependency depends on
std (i.e. it's not #![no_std]) then the top crates does as well. The only way to be really
sure is to compile the crate for a target that doesn't have std in its sysroot (e.g. using
Xargo).

See here.
Looks like we gotta do some more testing using Xargo, and maybe adding that to the travis build targets as well?

@thejpster
Copy link

LGTM. You can test easily by building for a no_std target, such as thumbv7em-none-eabi. Just add that target with rustup and specify with --target.

@thejpster
Copy link

Looks like a dep is using std somewhere.

$ rustup target add thumbv7em-none-eabi
info: downloading component 'rust-std' for 'thumbv7em-none-eabi'
info: installing component 'rust-std' for 'thumbv7em-none-eabi'
$ cargo build --target thumbv7em-none-eabi
    Updating crates.io index
 Downloading num v0.1.42
 Downloading num-bigint v0.1.44
 Downloading num-complex v0.1.43
 Downloading cargo_metadata v0.5.8
 Downloading bytecount v0.3.2
 Downloading syn v0.15.14
   Compiling proc-macro2 v0.4.20
   Compiling unicode-xid v0.1.0
   Compiling winapi v0.3.6
   Compiling serde v1.0.80
   Compiling ryu v0.2.6
   Compiling num-traits v0.2.6
   Compiling cfg-if v0.1.6
   Compiling rustc-demangle v0.1.9
   Compiling pulldown-cmark v0.1.2
   Compiling itoa v0.4.3
   Compiling num-integer v0.1.39
   Compiling semver-parser v0.7.0
   Compiling bitflags v0.9.1
   Compiling rustc-serialize v0.3.24
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabi` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rustc-serialize`.
warning: build failed, waiting for other jobs to finish...
error: build failed

@thejpster
Copy link

thejpster commented Nov 4, 2018

I think as long as the library is no_std, the examples don't have to be, which will make them simpler. If you want some code that runs on an embedded target, I'd put it in a different crate and use cortex-m-quickstart. You should also be able to use the built in targets.

@mre mre mentioned this pull request Nov 4, 2018
@mre
Copy link
Owner Author

mre commented Nov 4, 2018

@thejpster thanks for your advice. I merged the changes for no_std support in #15.
Have no device to try that on, but will create a sub-crate for the cortex-m stuff. 🤞

@mre mre closed this Nov 4, 2018
@mre mre mentioned this pull request Nov 4, 2018
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

Successfully merging this pull request may close these issues.

2 participants