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

warning: file found to be present in multiple build targets #5930

Closed
gnzlbg opened this issue Aug 23, 2018 · 7 comments
Closed

warning: file found to be present in multiple build targets #5930

gnzlbg opened this issue Aug 23, 2018 · 7 comments

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Aug 23, 2018

In the cargo-asm project cargo produces the warning:

warning: file found to be present in multiple build targets: cargo-asm/src/main.rs

Since it is a warning, I assume that I must be doing something wrong / not as good as possible there, and that there is something that I can do to silence it.

I have no idea what that can be: cargo-asm produces two binaries, cargo-asm and cargo-llvm-ir, both are identical. Ideally, I'd just produce one, and then create a link with a different name to it, or a copy. I have no idea how to do any of that with cargo.

If there is nothing that users can do about this warning, then it shouldn't be a warning until there is something that users can do.

@alexcrichton
Copy link
Member

This can happen when there are two targets (like two [[bin]] sections) which point to path = "cargo-asm/src/main.rs", is that present in your project?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 23, 2018

Yes that's exactly the case.

@donbright
Copy link

i have this same warning but a different situation. im trying to build a library with tests... and a build script so i can generate tests from a list of files, at compile time.

tests/integration_tests.rs
tests/build.rs
tests/generated_tests.rs
tests/testfiles/data1.txt
tests/testfiles/data2.txt
src/lib.rs

Cargo.toml
[package]
name = "blargh"
version = "0.1.0"
authors = [me]
build = "tests/build.rs"

this layout is based on paholg's post here https://stackoverflow.com/questions/34662713/how-can-i-create-parameterized-tests-in-rust

thanks

@alexcrichton
Copy link
Member

Oh oops I meant to close this earlier as @gnzlbg's original bug was discovered and presumably fixed. @donbright mind actually opening a new issue for that as I think it's a new use case we haven't seen before!

@liuchong
Copy link

This can happen when there are two targets (like two [[bin]] sections) which point to path = "cargo-asm/src/main.rs", is that present in your project?

This is exactly what I want, could I disable this warning? Or this better way to generate multiple binaries with same source file?

Maybe I should create a section

[lib]
name = "my_lib"
path = "src/lib.rs"

And then create two file with different name but same content in src/bin/ directory?

@alexcrichton
Copy link
Member

Yeah @liuchong we'd recommend either using a library or a mod foo; pointing to the same location. If you use a shared library crate then you'll get better compile times though!

@liuchong
Copy link

Thanks! @alexcrichton

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

4 participants