Skip to content

Multiple --crate-type=X (--crate-type=staticlib --crate-type=staticlib) leads to a warning and then to assertion #15312

Closed
@azat

Description

@azat

Repro

$ cargo --version
cargo 1.87.0-nightly (ab1463d63 2025-03-08)
$ rustc --version
rustc 1.87.0-nightly (cbfdf0b01 2025-03-13)

$ cargo new my_staticlib --lib

$ cargo rustc --lib --crate-type=staticlib --crate-type=staticlib
warning: output filename collision.
The lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)` has the same output filename as the lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)`.
Colliding filename is: /tmp/rust-test/my_staticlib/target/debug/deps/libmy_staticlib-6e3dfca3ee62c788.a
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
warning: output filename collision.
The lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)` has the same output filename as the lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)`.
Colliding filename is: /tmp/rust-test/my_staticlib/target/debug/libmy_staticlib.a
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
   Compiling my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s

$ cargo rustc --lib --crate-type=staticlib --crate-type=staticlib
warning: output filename collision.
The lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)` has the same output filename as the lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)`.
Colliding filename is: /tmp/rust-test/my_staticlib/target/debug/deps/libmy_staticlib-6e3dfca3ee62c788.a
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
warning: output filename collision.
The lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)` has the same output filename as the lib target `my_staticlib` in package `my_staticlib v0.1.0 (/tmp/rust-test/my_staticlib)`.
Colliding filename is: /tmp/rust-test/my_staticlib/target/debug/libmy_staticlib.a
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.

thread 'main' panicked at src/tools/cargo/src/cargo/core/compiler/fingerprint/mod.rs:1180:13:
assertion failed: mtimes.insert(output.clone(), mtime).is_none()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

So first it prints warning, second time - crash with assertion

Maybe duplicated --crate-type should be ignored? Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Command-rustcE-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions