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

Re-add a hash to the filename at the top level to avoid conflicts with external libs? #1601

Open
mitchmindtree opened this issue May 12, 2015 · 3 comments
Labels
A-configuration Area: cargo config files and env vars S-triage Status: This issue is waiting on initial triage.

Comments

@mitchmindtree
Copy link

This is a follow up to this issue from the rust repo after amazing detective work by @alexcrichton :)

It seems that although 27efa7b correctly points out that it is impossible for conflicts to arise between rust crates, it is still possible for conflicts to arise between external libraries and cargo produced libraries.

This may prove to be a confusing/surprising issue for authors of rust libraries that bind to external / non-cargo produced libraries. It is likely not uncommon for an author to name their crate the same as the external library which they wrap for ease of search-ability. As an example, this is the exact issue we've just run into in the rust-portaudio crate.

Possible solutions:

  1. Alex mentioned that perhaps it's worth suggesting to re-add a hash to the filename at the top level to allow for this use-case to work, which sounds like a nice way of avoiding related linking issues entirely in the future.
  2. An alternative might be for Cargo to check for name conflicts and provide a clear error. One issue with this is that the conflicts do not arise until the crate is depended upon (by i.e another lib or an example). I wonder if it is possible to catch this error in advance while compiling the crate that would produce the error?

Personally I'm in favour of 1, though I'm not familiar enough with cargo to understand entirely what is involved :)

Thanks again Alex for the great job on debugging this one!

@alexcrichton
Copy link
Member

Thanks for opening an issue! My concrete idea here was something like:

[lib]
name = "..."
extra-filename = "-rust"

Where extra-filename is just passed as -C extra-filename to the compiler when this is being compiled as a top-level library.

@stale
Copy link

stale bot commented Sep 20, 2018

As there hasn't been any activity here in a while would someone (the author, a team member, or any interested party) be able to summarise the current state, perhaps making explicit:

  • Is this still relevant?
  • If so, what is blocking it?
  • Is it known what could be done to help move this forward?

Thank you!

(The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.)

If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!

@stale stale bot added the stale label Sep 20, 2018
@MavenRain
Copy link

This is still a relevant issue. Here is my attempt to compile the default hello-world template using the musl target:

cargo build --target=x86_64-unknown-linux-musl
   Compiling statichello v0.1.0 (file:///Users/oobi/Documents/statichello)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-nostdlib" "-Wl,--eh-frame-hdr" "-Wl,-(" "-m64" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/crt1.o" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/crti.o" "-L" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7.1y16o1qfye96o7m0.rcgu.o" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7.3rngp6bm2u2q5z0y.rcgu.o" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7.4fjwfaqmjj8b91za.rcgu.o" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7.4oc10dk278mpk1vy.rcgu.o" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7.4xq48u46a1pwiqn7.rcgu.o" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7.oa3rad818d8sgn4.rcgu.o" "-o" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps/statichello-e5d01fc231a96ca7.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-no-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/Users/oobi/Documents/statichello/target/x86_64-unknown-linux-musl/debug/deps" "-L" "/Users/oobi/Documents/statichello/target/debug/deps" "-L" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc_jemalloc-df3e4031127dce42.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-8d08af64ad431975.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-11e3f8fd4b2ddf53.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-2f81785a80e61513.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc_system-d90fc26763500b3a.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-7fffa1d1569ad749.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-3cc30608bed80fd1.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd_unicode-613611d5c8b34858.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-0683b9c8bb72ea71.rlib" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-e3f5a156e80ff368.rlib" "-static" "-Wl,-Bdynamic" "/Users/oobi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/crtn.o" "-Wl,-)"
  = note: clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
          ld: unknown option: --as-needed
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: aborting due to previous error

error: Could not compile `statichello`.

To learn more, run the command again with --verbose.

@stale stale bot removed the stale label Oct 14, 2018
@weihanglo weihanglo added the S-triage Status: This issue is waiting on initial triage. label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

4 participants