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

cargo check --examples shouldn't link binaries #4529

Closed
japaric opened this issue Sep 22, 2017 · 3 comments
Closed

cargo check --examples shouldn't link binaries #4529

japaric opened this issue Sep 22, 2017 · 3 comments

Comments

@japaric
Copy link
Member

japaric commented Sep 22, 2017

I believe.

cargo check on a binary crate doesn't do the linking step so I think examples shouldn't be linked either.

STR

$ cargo new --bin hello && cd $_

$ mkdir .cargo && cat >.cargo/config <<EOF
[target.x86_64-unknown-linux-gnu]
linker = "false"
EOF

$ cargo check -v && echo OK
   Compiling hello v0.1.0 (file:///home/arch/tmp/hello)
     Running `rustc --crate-name hello src/main.rs --crate-type bin --emit=dep-info,metadata -C debuginfo=2 -C metadata=20d2e2d706bd0a6e -C extra-filename=-20d2e2d706bd0a6e --out-dir /home/arch/tmp/hello/target/debug/deps -C linker=false -L dependency=/home/arch/tmp/hello/target/debug/deps`
    Finished dev [unoptimized + debuginfo] target(s) in 0.28 secs
OK

$ mkdir examples && cp src/main.rs examples/foo.rs

$ cargo check --examples -v
   Compiling hello v0.1.0 (file:///home/arch/tmp/hello)
     Running `rustc --crate-name foo examples/foo.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=774cc6e534532462 -C extra-filename=-774cc6e534532462 --out-dir /home/arch/tmp/hello/target/debug/examples -C linker=false -L dependency=/home/arch/tmp/hello/target/debug/deps`
error: linking with `false` failed: exit code: 1

That example is contrived. My use case is cross cargo checking: cargo check --examples --target arm-unknown-linux-gnueabi.

Meta

$ rustc -V
rustc 1.22.0-nightly (0701b37d9 2017-09-18)

(Apologies if this has already been reported / fixed; I didn't look too hard)

@ehuss
Copy link
Contributor

ehuss commented Oct 8, 2017

This is related to #4059 and is fixed by PR #4592.

@cyplo
Copy link

cyplo commented Feb 25, 2018

Both the linked issue and the PR are now closed - I also tried running the example given and it returns no error with (cargo 0.25.0 (8c93e08 2018-02-01) and rustc 1.24.0 (4d90ac38c 2018-02-12)).
Would it be okay to close this issue as well ?
thanks !

@alexcrichton
Copy link
Member

Yay!

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

No branches or pull requests

4 participants