Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

backtrace-sys still compiled when the backtrace feature is turned off #161

Open
Michael-F-Bryan opened this issue Jun 25, 2017 · 4 comments

Comments

@Michael-F-Bryan
Copy link

Apparently the backtrace-sys dependency is always compiled, regardless of whether the backtrace feature is present. This bit me because when compiling for the x86_64-unknown-linux-musl target and the musl C library isn't installed, backtrace-sys can't be compiled.

My question is, why is error-chain depending on backtrace-sys even when the backtrace feature isn't activated?


This is roughly what I was doing to replicate a failed travis build for my mdbook PR, azerupi/mdbook#361.

$ rustup target add x86_64-unknown-linux-musl
$ cargo build --target x86_64-unknown-linux-musl
   Compiling rustc-demangle v0.1.4
   Compiling backtrace-sys v0.1.11
error: failed to run custom build command for `backtrace-sys v0.1.11`
...
--- stderr
configure: error: in `/home/michael/Documents/forks/mdBook/target/x86_64-unknown-linux-musl/debug/build/backtrace-sys-9b035f64636a9441/out':
configure: error: C compiler cannot create executables

I then thought I could work around this by telling error-chain to not use the backtrace feature. With the backtrace feature removed this shouldn't try to compile anything related to backtraces.

// Cargo.toml
- error-chain = "0.10.0"
+ error-chain = { version = "0.10.0", features = [] }

Recompiling then gives you the same error.

The build succeeds if you install musl gcc wrapper (pacman -S musl), but that means you are still building the backtrace-sys crate even when the backtrace feature isn't enabled.

@Yamakaky
Copy link
Contributor

I think you have to add default-features = false.

@Michael-F-Bryan
Copy link
Author

I tried that too and it still compiles backtrace-sys regardless of whether I specify default-features = false and/or features = [].

error-chain declares backtrace as an optional dependency which is only meant to be compiled when the backtrace feature is enabled, do you know why cargo would still be compiling an optional dependency even when it is told not to?

@Yamakaky
Copy link
Contributor

Hum, did you try the dependency syntax from http://doc.crates.io/manifest.html (search dependencies.awesome)?

@Paspartout
Copy link

Paspartout commented Jul 7, 2017

I ran into the same issue but as @Yamakaky suggested this fixed it:

[dependencies.error-chain]
version = "0.10.0"
default-features = false

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants