-
Notifications
You must be signed in to change notification settings - Fork 89
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
Compilation issues with num
#11
Comments
Hi @tilpner, I had a quick look. With a more recent version of rust (1.34.0) it first worked for me. I could reproduce your problems with (1.32.0). When I did a Sorry, I will have a more systematic look some time later. If you have time to help, you could
|
It still occurs with nix /tmp > rustc -V; cargo -V; crate2nix -V
rustc 1.35.0
cargo 1.35.0
crate2nix 0.5.0-alpha.0 # b24b31ffc0ea437da22a6f75612b2e5ac4b8f016
nix /tmp > cargo new --bin numtest && cd numtest
Created binary (application) `numtest` package
nix /tmp/numtest > echo 'num = "0.2"' >> Cargo.toml
nix /tmp/numtest > crate2nix generate
Prefetching 1/8: https://crates.io/api/v1/crates/autocfg/0.1.5/download
Prefetching 2/8: https://crates.io/api/v1/crates/num/0.2.0/download
Prefetching 3/8: https://crates.io/api/v1/crates/num-bigint/0.2.2/download
Prefetching 4/8: https://crates.io/api/v1/crates/num-complex/0.2.3/download
Prefetching 5/8: https://crates.io/api/v1/crates/num-integer/0.1.41/download
Prefetching 6/8: https://crates.io/api/v1/crates/num-iter/0.1.39/download
Prefetching 7/8: https://crates.io/api/v1/crates/num-rational/0.2.2/download
Prefetching 8/8: https://crates.io/api/v1/crates/num-traits/0.2.8/download
Wrote hashes to ./crate-hashes.json.
Generated ./default.nix successfully.
nix /tmp/numtest > NIX_PATH=nixpkgs=channel:nixos-unstable nix-build --no-out-link -A rootCrate.build
these derivations will be built:
/nix/store/vrb3db4r3is7q8iv81bl37pkv8n4xxxz-rust_num-bigint-0.2.2.drv
/nix/store/767kvzx8lkg3z5s3iwz7ffv1q0yqqnr0-rust_num-rational-0.2.2.drv
/nix/store/5f6lq37afa9mw18vhslpyhmgxjdkch3j-rust_num-0.2.0.drv
/nix/store/9jybmixsni14yc68bhkkndsr69lnphj6-rust_numtest-0.1.0.drv
building '/nix/store/vrb3db4r3is7q8iv81bl37pkv8n4xxxz-rust_num-bigint-0.2.2.drv'...
unpacking sources
unpacking source archive /nix/store/dbbddfhjvlwm1hhllmlb42ilamaalqbd-num-bigint-0.2.2.tar.gz
source root is num-bigint-0.2.2.tar.gz
patching sources
configuring
Building build.rs (num-bigint)
Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=7 --edition 2015 --out-dir target/build/num-bigint --emit=dep-info,link -L dependency=target/buildDeps --cap-lints allow --color always
building
Building src/lib.rs (num-bigint)
Running rustc --crate-name num_bigint src/lib.rs --crate-type lib -C opt-level=3 -C codegen-units=7 --edition 2015 -C metadata=5267052fbf -C extra-filename=-5267052fbf --out-dir target/lib --emit=dep-info,link -L dependency=target/deps --extern num_integer=/nix/store/xqscn9l8a9l4pmr8z7qsy3cjffclh843-rust_num-integer-0.1.41/lib/libnum_integer-92d5248289.rlib --extern num_traits=/nix/store/z7bzsang9k0wzaiszyqinp1bgpc147jn-rust_num-traits-0.2.8/lib/libnum_traits-bc00277194.rlib --cap-lints allow -L /build/num-bigint-0.2.2.tar.gz/target/build/num-bigint.out --cfg has_i128 --color always
error[E0433]: failed to resolve: maybe a missing `extern crate std;`?
--> src/lib.rs:91:5
|
91 | use std::error::Error;
| ^^^ maybe a missing `extern crate std;`?
...
error: aborting due to 497 previous errors
Some errors occurred: E0405, E0412, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0405`.
builder for '/nix/store/vrb3db4r3is7q8iv81bl37pkv8n4xxxz-rust_num-bigint-0.2.2.drv' failed with exit code 1
cannot build derivation '/nix/store/9jybmixsni14yc68bhkkndsr69lnphj6-rust_numtest-0.1.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/9jybmixsni14yc68bhkkndsr69lnphj6-rust_numtest-0.1.0.drv' failed crate2nix (edited):
cargo (edited):
crate2nix (only interesting differences):
cargo (only interesting differences):
num-bigint has the features |
Thanks for the excellent analysis. I am looking at the different feature configuration first. That is weird indeed. Some problems with the feature propagation. If I recreated the numtest crate, I get the following dependency attributes from {
"name": "num",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"req": "^0.2.0",
//...
"optional": false,
"uses_default_features": true,
"features": []
}, "num" itself has the following: "features": {
"default": [
"std"
],
// ...
"std": [
"num-bigint/std",
"num-complex/std",
"num-integer/std",
"num-iter/std",
"num-rational/std",
"num-rational/bigint",
"num-traits/std"
] So it enables "std" by default and std enables the dependency features. The code looks like the intention is to support this behavior but it apparently doesn't. I'll investigate... |
This is fixed on master. Basically, the code didn't enable a dependency if a dependency feature was enabled and not the dependency directly. Sorry, that this was your first experience with crate2nix. |
First time using crate2nix, so user error is likely.
Full error
The text was updated successfully, but these errors were encountered: