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

Windows warning: output filename collision #41

Open
akesson opened this issue Jan 9, 2023 · 7 comments
Open

Windows warning: output filename collision #41

akesson opened this issue Jan 9, 2023 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@akesson
Copy link
Collaborator

akesson commented Jan 9, 2023

Summary of discord exchange

Full error mesage
PS [project_dir]> cargo leptos watch --release
warning: output filename collision.
The bin target `leptos_start` in package `leptos_start v0.1.0 ([project_dir])` has the same output filename as the lib target `leptos_start` in package `leptos_start v0.1.0 ([project_dir])`.
Colliding filename is: [project_dir]\target/server\release\deps\leptos_start.pdb
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>.
    Finished release [optimized] target(s) in 0.20s
       Cargo finished cargo build --package=leptos_start --bin=leptos_start --target-dir=target/server --no-default-features --features=ssr --release
    Finished release [optimized] target(s) in 0.15s
       Cargo finished cargo build --package=leptos_start --lib --target-dir=target/front --target=wasm32-unknown-unknown --no-default-features --features=hydrate --release
      Notify watching folders .\src, style
2023-01-08T23:22:33.066Z INFO  [leptos_start] serving at http://127.0.0.1:3000
2023-01-08T23:22:33.067Z INFO  [actix_server::builder] Starting 16 workers
2023-01-08T23:22:33.067Z INFO  [actix_server::server] Actix runtime found; starting in Actix runtime
      Leptos ctrl-c received
PS [project_dir]>

file list from a cargo build on linux:

leptos_start
libleptos_start.rlib
libleptos_start.so

file list from a cargo build on windows:

leptos_start.exe
leptos_start.pdb
leptos_start.dll
libleptos_start.rlib

rust-lang/cargo#8519

so the pdb is the debug info for the .exe
and for the .dll
so yeah, confirmed cargo bug
not sure why the linux version outputs lib prefixed files
but the windows one doesn't

@Indrazar
Copy link
Contributor

Indrazar commented Jan 9, 2023

If we attempt to force the linux style naming convention by just adding:

name = "libleptos_start" to [lib] then the output artifacts are:

leptos_start.exe
leptos_start.pdb
libleptos_start.dll
libleptos_start.pdb
liblibleptos_start.rlib

The .rlib ends up with a double prefix and additionally the leptos_start.wasm is named libleptos_start.wasm.

This causes cargo leptos watch to fail to find the wasm file (it is expecting leptos_start.wasm and only libleptos_start.wasm exists).

At this point we just need a way to have only the cdylib library artifact .dll emitted as a specific filename (preferably libleptos_start.dll) without affecting the rlib and the resulting WASM artifact.

@Indrazar
Copy link
Contributor

Indrazar commented Jan 9, 2023

There might be a way around the cargo build collision using workspaces but at that point we should just move the complexity of cargo leptos watch's output style of front/server/site to the Cargo.toml.

To be clear, this problem of colliding filenames does not occur in actual use. The cargo leptos watch build is entirely different from cargo build and the output files when using cargo-leptos correctly are not colliding.

I believe the real solution is not to edit the TOML between platforms, but to skip the default cargo mode build check since we are not using that output format.

@Indrazar
Copy link
Contributor

Indrazar commented Jan 9, 2023

The following cargo command is enough to emit the error despite it creating no colliding files:

cargo build --package=leptos_start --bin=leptos_start --target-dir=target/server --no-default-features --features=ssr

This means the problem is fully outside of cargo-leptos.

@Indrazar
Copy link
Contributor

Indrazar commented Jan 9, 2023

At this point I recommend just waiting until rust-lang/cargo#8519 is resolved. Hopefully before rust-lang/cargo#6313 is elevated to an error from its current status as a warning.

Regarding #8519: this is our use case which emits the error without creating colliding files:

cargo build --package=leptos_start --bin=leptos_start --target-dir=target/server --no-default-features --features=ssr

Unfortunately this use case is not a minimal test case so I don't know how much time they would really be willing to spend on it.

Maybe if we somehow create the lib and the bin with one command, then cargo would be able to inspect that there are no colliding files, but I don't think there is a way to specify --target-dir for --bin and --lib separately in one command.

Here is the lib building command:

cargo build --package=leptos_start --lib --target-dir=target/front --target=wasm32-unknown-unknown --no-default-features --features=hydrate

@akesson akesson added the documentation Improvements or additions to documentation label Jan 12, 2023
@Indrazar
Copy link
Contributor

A possible solution for the PDB collision on windows would be to specify a different binary name (which would generate a different PDB name).
Unfortunately this is currently a nightly only feature being tracked here: rust-lang/cargo#9778

@yokomizor
Copy link

iirc on stable rust you can create bin/leptos_start_bin.rs so binary and lib would have different names.

If there was a way to define the binary name for cargo-leptos, then windows users could avoid the conflicting name issues without using workspaces.

It would also work if there was an option to define the lib name on cargo-leptos, then windows users could use:

[lib]
name = "libleptos_start"
crate-type = ["cdylib", "rlib"]

@DanielJoyce
Copy link
Contributor

Dug around in related-issues, and saw a suggestion of having cargo call rustc with an explicit -o some_binary_name to rustc as a way to fix the issue on windows.

Cargo leptos controls the build, so we could simply pass it on there.

rust-lang/cargo#1706

rust-lang/cargo#1706 (comment)

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

No branches or pull requests

4 participants