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

no_std doesn't seem to be transitive #57

Closed
robomancer-or opened this issue Mar 1, 2018 · 28 comments
Closed

no_std doesn't seem to be transitive #57

robomancer-or opened this issue Mar 1, 2018 · 28 comments

Comments

@robomancer-or
Copy link

This might just be me being new to rust, but I'm having a really tough time cross compiling uom for ARM. Starting from a lib crate that builds fine, if I add

[dependencies.uom]
default-features = false
features = [ "si", "usize" ]
version = "*"

to Cargo.toml and then run xargo build it tells me

error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabihf` target may not be installed

error: aborting due to previous error

error: Could not compile `num-traits`.

Caused by:
  process didn't exit successfully: `rustc --crate-name num_traits ~/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.0/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 --cfg feature="default" --cfg feature="std" -C metadata=459f1b7f38ae1057 -C extra-filename=-459f1b7f38ae1057 --out-dir target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=target/thumbv7em-none-eabihf/debug/deps -L dependency=target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=cortex-m-rt-ld -Z linker-flavor=ld -Z thinlto=no --sysroot ~/.xargo` (exit code: 101)

of special note there is the part that says --cfg feature="std". It seems that specifying no_std for uom isn't enforcing that constraint on upstream dependencies.

@iliekturtles
Copy link
Owner

Good catch. Currently uom just depends on the num crate which doesn't have a std feature. Switching to depend on individual num-* crates should be able to fix the issue. num-traits at least has a std feature.

PR welcome if you want to attempt it. Otherwise it's going to be at least until this weekend before I get a chance to take a look.

@robomancer-or
Copy link
Author

robomancer-or commented Mar 1, 2018

https://gist.github.com/robomancer-or/a427335eeb5690e96cb10b2d4c40feed#file-uom-patch What do you think? (I haven't actually tested that it will solve my problem, but it does compile without std and all the tests pass)

@iliekturtles
Copy link
Owner

Pulling in both num and num-traits can have the num-traits crate be included twice because num will include it with the default options. I think we'll have to pull in each individual num-* crate as necessary.

Leave the version as 0.16. I've been meaning to release the current code as 0.17 for a while now and can include these changes.

Could you also investigate re-exporting the num-* crates from a local num module so that all the references elsewhere in the code can still use ::num::....

@robomancer-or
Copy link
Author

So, I've been working on it and I can safely say that I'm not yet good enough at Rust to help you with this. After an hour or so of poking I'm no closer to understanding how your code works.

I tried adding "std" as a dependency for all of the big* and rational* features, and then changing lib.rs to include

#[cfg(std)]
extern crate num;
#[cfg(not(std))]
extern crate num_traits as num;

But it didn't work, I thought I'd be able to fix it by adding #[cfg(std)] whenever the compiler complained about not finding a symbol, but now I'm getting dozens of confusing trait bound not satisfied errors, but it's all macro soup so I can't tell why by looking at the error or the code. So I'm signing off, I wish you luck with this, if you can get it to work without std I'd love to use it in a bootloader I'm writing, but unfortunately I'm not yet good enough to help make it happen.

iliekturtles added a commit that referenced this issue Mar 14, 2018
@robomancer-or
Copy link
Author

Awesome, it's nice to see progress (even if this one isn't done yet), thanks for the new version!

iliekturtles added a commit that referenced this issue Mar 15, 2018
@iliekturtles
Copy link
Owner

Did a bit more work on this today. My new fear is that because num-rational references num-traits/std and doesn't provide it's own std feature as soon as you include a uom feature that references num-rational you get a std dependency that can't be controlled. May require changes to num crates.

@robomancer-or
Copy link
Author

I guess my question is why do non-rational types depend on num-rational? For applications that can accept some degree of rounding errors couldn't floats work to implement the conversion methods? (sorry if I'm missing the point, I still don't totally understand how uom works)

@iliekturtles
Copy link
Owner

Conversion factors for integral types are stored as a ratio of that type. The main reason is that conversion between integral and floating point gets messy. Some integral values can't be represented as a floating point value and of course many floating point values can't be represented as an integral value. Conversion between types also makes it a lot harder to get simple performant code. val * numer / denom becomes something like convert_from(convert_to(val) * conversion).

I'd like to get ratio conversion factors working before investigating using floating point (PRs always welcome). Although I haven't reviewed the num-rational code I don't see any reason why it needs std. Likely no one has gone through to do the necessary work to add a std feature.

@robomancer-or
Copy link
Author

robomancer-or commented Mar 15, 2018

What do you think about https://gist.github.com/robomancer-or/bbbed5cfd458a57ed03bb64e5c934063 ? Should I submit it as a PR to num-rational?

Edit: Got impatient ;-) rust-num/num-rational#23

@iliekturtles
Copy link
Owner

Awesome! I briefly looked over the changes earlier today and Float vs. FloatCore was going to be my suggestion as well.

@robomancer-or
Copy link
Author

... and it's merged! num-rational now supports no_std (in master, hasn't been released to crates.io yet)!

iliekturtles added a commit that referenced this issue Mar 18, 2018
iliekturtles added a commit that referenced this issue Mar 18, 2018
Only include `std`, `rational`, and `bigint` support as necessary based
on `uom` feature selection. Resolves #57.
@iliekturtles
Copy link
Owner

@robomancer-or I just pushed what should be a final version. When you have some time could you try testing the dev-num-std branch in your project and verify that std dependencies are not pulled in (uom = { git = "https://github.com/iliekturtles/uom", branch = "dev-num-std", default-features-false, features = "..." })? This branch is currently using git dependencies on num-rational and num-bigint. Once num-rational is released I'll merge this branch into master, reference the crates.io versions, and release v0.18.0 for uom.

@robomancer-or
Copy link
Author

robomancer-or commented Mar 19, 2018

No such luck, I added

uom = { git = "https://github.com/iliekturtles/uom", branch = "dev-num-std", default-features = false, features = ["si", "f32"] }

and got

error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabihf` target may not be installed

error: aborting due to previous error

error: Could not compile `num-traits`.

Caused by:
  process didn't exit successfully: `rustc --crate-name num_traits /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.2/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 --cfg feature="default" --cfg feature="std" -C metadata=f14dfebabe440ccb -C extra-filename=-f14dfebabe440ccb --out-dir /home/robomancer/optimus/vehicle/vcb/rust/bootloader/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/optimus/vehicle/vcb/rust/bootloader/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/optimus/vehicle/vcb/rust/bootloader/target/debug/deps --cap-lints warn -C link-arg=-Tlink.x -C linker=cortex-m-rt-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed

it may be relevant that the line

Updating registry `https://github.com/rust-lang/crates.io-index` 

is only in the output when I have the uom dependency. Why anything involving crates.io would be involved I'm not sure...

@iliekturtles
Copy link
Owner

I haven't been able to reproduce yet. Try cargo update to ensure you have the latest git version of all the dependencies. From the error message you pasted num_traits is being compiled with --cfg feature="default" --cfg feature="std" for some reason. Could you include cargo clean && cargo build --verbose output, your full Cargo.toml, and the cargo command you're using to run?

@robomancer-or
Copy link
Author

robomancer-or commented Mar 19, 2018

So the trick is I'm cross compiling, so I'm using xargo instead of cargo. I just recreated it via:

cargo new deleteme
cd deleteme
echo "#![no_std]" > src/lib.rs

Then in Xargo.toml:

[dependencies.core]
stage = 0

[dependencies.compiler_builtins]
features = ["mem"]
stage = 1

and in Cargo.toml:

[package]
name = "deleteme"
version = "0.1.0"
authors = ["M@ Dunlap <robomancer@optimusride.com>"]

[dependencies]
uom = { git = "https://github.com/iliekturtles/uom", branch = "dev-num-std", default-features=false, features =["si", "f32"] }

and then I run xargo build -vv to get:

robomancer@bee ~/c/deleteme> xargo build -vv
+ "rustc" "--print" "sysroot"
+ "cargo" "build" "-vv"
    Updating git repository `https://github.com/iliekturtles/uom`
    Updating registry `https://github.com/rust-lang/crates.io-index`            
   Compiling typenum v1.10.0                                                    
   Compiling num-traits v0.2.2
     Running `rustc --crate-name build_script_main /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/typenum-1.10.0/build/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=8b4a508d24d9c349 -C extra-filename=-8b4a508d24d9c349 --out-dir /home/robomancer/code/deleteme/target/debug/build/typenum-8b4a508d24d9c349 -L dependency=/home/robomancer/code/deleteme/target/debug/deps --cap-lints warn --sysroot /home/robomancer/.xargo/HOST`
     Running `rustc --crate-name num_traits /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.2/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=bdaea5e1ee2d18f6 -C extra-filename=-bdaea5e1ee2d18f6 --out-dir /home/robomancer/code/deleteme/target/debug/deps -L dependency=/home/robomancer/code/deleteme/target/debug/deps --cap-lints warn --sysroot /home/robomancer/.xargo/HOST`
error[E0463]: can't find crate for `std`

error: aborting due to previous error

error: Could not compile `typenum`.

Caused by:
  process didn't exit successfully: `rustc --crate-name build_script_main /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/typenum-1.10.0/build/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=8b4a508d24d9c349 -C extra-filename=-8b4a508d24d9c349 --out-dir /home/robomancer/code/deleteme/target/debug/build/typenum-8b4a508d24d9c349 -L dependency=/home/robomancer/code/deleteme/target/debug/deps --cap-lints warn --sysroot /home/robomancer/.xargo/HOST` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed

@iliekturtles
Copy link
Owner

Well, partial success. The new failure is in the build_script_main of Typenum. I'm not sure where to assign blame here. Typenum's build script uses std, which should be fine since it's just generating code. It should be compiled/run on the local architecture and not the target architecture.

Is there some way to choose a different target architecture for build scripts?

@robomancer-or
Copy link
Author

robomancer-or commented Mar 20, 2018

Ugh. Forgot about .cargo/config . Okay, uom just built successfully in the deleteme project, but it's still not building in the project I care about (same num-traits error). I've deleted ~/.cargo/git/ ~/.cargo/registry/ ./target/ and ./Cargo.lock, updated, rustuped and rebuilt but it's still acting as if it doesn't have the git version of your code. Any other caches you can think of that I might need to blow away?

@iliekturtles
Copy link
Owner

I can't think of anywhere else that it would be cached. Could you post the log of clean && build --verbose?

@robomancer-or
Copy link
Author

  • "rustc" "--print" "sysroot"
  • "rustc" "--print" "target-list"
  • RUSTFLAGS="-C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo"
  • "cargo" "build" "--verbose"
    Updating registry https://github.com/rust-lang/crates.io-index
    Updating git repository https://github.com/iliekturtles/uom
    Compiling num-traits v0.2.2
    Compiling cc v1.0.8
    Compiling semver-parser v0.7.0
    Compiling libc v0.2.39
    Compiling cfg-if v0.1.2
    Compiling vcell v0.1.0
    Compiling unicode-xid v0.0.4
    Compiling rustc-demangle v0.1.7
    Running rustc --crate-name num_traits /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.2/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=883d58a6d324b2d1 -C extra-filename=-883d58a6d324b2d1 --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Running rustc --crate-name semver_parser /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/semver-parser-0.7.0/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=7dc1169c76c3d080 -C extra-filename=-7dc1169c76c3d080 --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Running rustc --crate-name cc /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.8/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=beda1d741be816f0 -C extra-filename=-beda1d741be816f0 --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Running rustc --crate-name libc /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.39/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=929d5943f453ee5e -C extra-filename=-929d5943f453ee5e --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Running rustc --crate-name vcell /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/vcell-0.1.0/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=60548130eceb9b1d -C extra-filename=-60548130eceb9b1d --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Running rustc --crate-name cfg_if /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.2/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=cb753478daaa308d -C extra-filename=-cb753478daaa308d --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Running rustc --crate-name unicode_xid /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-xid-0.0.4/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 --cfg 'feature="default"' -C metadata=9f8aa54afc0150e6 -C extra-filename=-9f8aa54afc0150e6 --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Running rustc --crate-name rustc_demangle /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-demangle-0.1.7/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=9cb0c617f10a0112 -C extra-filename=-9cb0c617f10a0112 --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Compiling cortex-m v0.3.1
    Running rustc --crate-name build_script_build /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.3.1/build.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=5f655f6211ae86db -C extra-filename=-5f655f6211ae86db --out-dir /home/robomancer/PATH_EL/target/debug/build/cortex-m-5f655f6211ae86db -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Compiling bare-metal v0.1.1
    Running rustc --crate-name bare_metal /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/bare-metal-0.1.1/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=cedde71bf7724c88 -C extra-filename=-cedde71bf7724c88 --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Compiling quote v0.3.15
    Running rustc --crate-name quote /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-0.3.15/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=a7377682639f5dfe -C extra-filename=-a7377682639f5dfe --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Compiling aligned v0.1.1
    Running rustc --crate-name aligned /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/aligned-0.1.1/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=64a6e0de30b15972 -C extra-filename=-64a6e0de30b15972 --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Compiling cortex-m v0.4.3
    Running rustc --crate-name build_script_build /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.4.3/build.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=b88d0f686546a20b -C extra-filename=-b88d0f686546a20b --out-dir /home/robomancer/PATH_EL/target/debug/build/cortex-m-b88d0f686546a20b -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Compiling untagged-option v0.1.1
    Running rustc --crate-name untagged_option /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/untagged-option-0.1.1/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=5c61e2462053683a -C extra-filename=-5c61e2462053683a --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Compiling typenum v1.10.0
    Running rustc --crate-name build_script_main /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/typenum-1.10.0/build/main.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=a00f6c96586e42c7 -C extra-filename=-a00f6c96586e42c7 --out-dir /home/robomancer/PATH_EL/target/debug/build/typenum-a00f6c96586e42c7 -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Compiling r0 v0.2.2
    Running rustc --crate-name r0 /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/r0-0.2.2/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=88f17a2803bd253a -C extra-filename=-88f17a2803bd253a --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Compiling cortex-m-rtfm v0.3.1
    Running rustc --crate-name build_script_build /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rtfm-0.3.1/build.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=2c82edeb7f49ca45 -C extra-filename=-2c82edeb7f49ca45 --out-dir /home/robomancer/PATH_EL/target/debug/build/cortex-m-rtfm-2c82edeb7f49ca45 -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow
    Compiling byteorder v1.2.1
    Running rustc --crate-name byteorder /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.2.1/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=f4d5f03996fce5c6 -C extra-filename=-f4d5f03996fce5c6 --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Compiling rtfm-core v0.2.0
    Running rustc --crate-name rtfm_core /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/rtfm-core-0.2.0/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=8bf9336d15bf2c66 -C extra-filename=-8bf9336d15bf2c66 --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Running rustc --crate-name num_traits /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.2/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=b156d0c4abc318eb -C extra-filename=-b156d0c4abc318eb --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Compiling volatile-register v0.2.0
    Running rustc --crate-name volatile_register /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/volatile-register-0.2.0/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 -C metadata=3b814acffe113ab4 -C extra-filename=-3b814acffe113ab4 --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --extern vcell=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps/libvcell-60548130eceb9b1d.rlib --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo
    Compiling synom v0.11.3
    Running rustc --crate-name synom /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/synom-0.11.3/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=6582593f1b8acf10 -C extra-filename=-6582593f1b8acf10 --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --extern unicode_xid=/home/robomancer/PATH_EL/target/debug/deps/libunicode_xid-9f8aa54afc0150e6.rlib --cap-lints allow
    Running /home/robomancer/PATH_EL/target/debug/build/cortex-m-5f655f6211ae86db/build-script-build
    Compiling time v0.1.39
    Running rustc --crate-name time /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.39/src/lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 -C metadata=eb43c2e432e334bb -C extra-filename=-eb43c2e432e334bb --out-dir /home/robomancer/PATH_EL/target/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --extern libc=/home/robomancer/PATH_EL/target/debug/deps/liblibc-929d5943f453ee5e.rlib --cap-lints allow
    error[E0463]: can't find crate for std
    |
    = note: the thumbv7em-none-eabihf 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 num-traits.

Caused by:
process didn't exit successfully: rustc --crate-name num_traits /home/robomancer/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.2/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 --cfg feature="default" --cfg feature="std" -C metadata=b156d0c4abc318eb -C extra-filename=-b156d0c4abc318eb --out-dir /home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -L dependency=/home/robomancer/PATH_EL/target/thumbv7em-none-eabihf/debug/deps -L dependency=/home/robomancer/PATH_EL/target/debug/deps --cap-lints allow -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld -Z thinlto=no --sysroot /home/robomancer/.xargo (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed

@robomancer-or
Copy link
Author

robomancer-or commented Mar 20, 2018

Update! One of my transitive build-dependencies is chrono which depends on and old version of num-traits. This is starting to smell like dependency hell... why are my build dependencies interfering with regular dependencies?

Edit: you can recreate the behavior by adding the follwoing to Cargo.toml in the deleteme example

[build-dependencies]
chrono = "*"

which will build fine when uom is not included.

@iliekturtles
Copy link
Owner

The curse of many small dependencies. The "good" news is that the latest chrono code pulls in num-traits without std if you don't mind a git dependency. Not sure why a new version hasn't been released since June last year.

@robomancer-or
Copy link
Author

So it seems the next yak lay yonder... well... wish me luck!

@Nemo157
Copy link
Contributor

Nemo157 commented Mar 28, 2018

I can confirm your linked branch works on a thumbv6m-none-eabi device 👍

Unfortunately it seems floating point operations are being pulled in even when just using u32 storage (really bad for this device because floats are emulated in software). I think that's just caused by quantity! using FromPrimitive::from_f64 for the conversion factors.

I'm not sure if there's any way to avoid this, other than potentially being able to force const evaluation into Ratio at compile time one day in the future. But since that involves something like const trait FromPrimitive it seems to be a very long way off.

I may have an attempt at manually writing out the few implementations I actually need at the moment, hopefully that will give me some idea of how this could be worked around, if you have some suggestions of known work arounds/areas to look at I'd be grateful for them.

@iliekturtles
Copy link
Owner

Just added #60 regarding conversion factors having a run-time cost to access for certain underlying storage types. There is really two parts to the issue: remove the dependency on the conversion factor being represented as f64 and ensure that there is no run-time cost to accessing the conversion factor.

If you're interested in discussing how the Conversion<V> implementations can be improved let's continue discussion under that issue.

@robomancer-or
Copy link
Author

Good news everyone! After updating nightly (according to https://users.rust-lang.org/t/psa-you-no-longer-need-xargo-to-do-arm-cortex-m-development/16703 ) the dev-num-std builds in no_std!! Thanks for all your help and hard work! My final ask is would you mind updating this issue when that branch merges and makes it to crates.io (no rush though, I don't mind the git dependency)?

@iliekturtles
Copy link
Owner

As soon as num-rational and num-bigint 0.2 are released on crates.io I'll merge the dev-num-std branch into master which will close this issue and should notify you. I'll try to do a uom release to crates.io shortly after that.

iliekturtles added a commit that referenced this issue Jun 20, 2018
Only include `std`, `rational`, and `bigint` support as necessary based
on `uom` feature selection. Resolves #57.
@iliekturtles
Copy link
Owner

v0.19.0 just released to crates.io!

@robomancer-or
Copy link
Author

robomancer-or commented Jun 21, 2018 via email

iliekturtles added a commit that referenced this issue Jun 30, 2018
Disable `cbrt`, `mul_add`, and `sqrt` tests unless the `std` feature is
enabled. Changes to reference `num` sub-crates directly in #57
(ff6a331) introduced the issue as these
methods are no available on the `FloatCore` trait that is available when
`no_std` is enabled.
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