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

If you build the library and the executable at the same time, embed-resource will fail #42

Closed
byeblack opened this issue Feb 27, 2022 · 8 comments
Labels

Comments

@byeblack
Copy link

embed-resource fails when lib.rs exists in the project, or [lib] is in Cargo.toml

Windows 10
Rust Version is 1.59.0
embed-resource Version is 1.6.5

@noe132
Copy link

noe132 commented Feb 27, 2022

Happened to me as well, when lib.rs presents, the executable built was the same as if embed-resource wasn't used, and no error messages.

@nabijaczleweli
Copy link
Owner

Do you have a log or an example that reproduces this? I don't really see a reason this shouldn't work, and AFAIK it has done so far?

@noe132
Copy link

noe132 commented Feb 28, 2022

@nabijaczleweli
https://github.com/noe132/rust-embed-resource-lib-bug
run cargo build -r the exe would have no icon
delete src/lib.rs and run cargo build -r again the exe would have icon as expected.

Video_2022-02-28_112132

on windows 10 and rust 1.59.0

@nabijaczleweli
Copy link
Owner

nabijaczleweli commented Mar 2, 2022

Thanks for the repro!

T:\>git diff withlib nolib
diff --git a/withlib b/nolib
index 095dcfb..26f749f 100644
--- a/withlib
+++ b/nolib
@@ -1,11 +1,10 @@
-T:\rust-embed-resource-lib-bug>cargo build -v > withlib
+T:\rust-embed-resource-lib-bug>cargo build -v > nolib
    Compiling embed-resource v1.6.5
      Running `rustc --crate-name embed_resource D:\Users\nabijaczleweli\.cargo\registry\src\github.com-1ecc6299db9ec823\embed-resource-1.6.5\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=9adc43b206abdea4 -C extra-filename=-9adc43b206abdea4 --out-dir T:\rust-embed-resource-lib-bug\target\debug\deps -L dependency=T:\rust-embed-resource-lib-bug\target\debug\deps --cap-lints allow`
    Compiling rust-demo v0.1.0 (T:\rust-embed-resource-lib-bug)
      Running `rustc --crate-name build_script_build --edition=2018 build.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=2e23cacad8a689e2 -C extra-filename=-2e23cacad8a689e2 --out-dir T:\rust-embed-resource-lib-bug\target\debug\build\rust-demo-2e23cacad8a689e2 -C incremental=T:\rust-embed-resource-lib-bug\target\debug\incremental -L dependency=T:\rust-embed-resource-lib-bug\target\debug\deps --extern embed_resource=T:\rust-embed-resource-lib-bug\target\debug\deps\libembed_resource-9adc43b206abdea4.rlib`
      Running `T:\rust-embed-resource-lib-bug\target\debug\build\rust-demo-2e23cacad8a689e2\build-script-build`
-     Running `rustc --crate-name rust_demo --edition=2018 src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=d71b703fa29c9940 -C extra-filename=-d71b703fa29c9940 --out-dir T:\rust-embed-resource-lib-bug\target\debug\deps -C incremental=T:\rust-embed-resource-lib-bug\target\debug\incremental -L dependency=T:\rust-embed-resource-lib-bug\target\debug\deps -L native=T:\rust-embed-resource-lib-bug\target\debug\build\rust-demo-433fe507bd489039\out -l dylib=icon`
      Running `rustc --crate-name rust_demo --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=904f042c82b0f1c9 -C extra-filename=-904f042c82b0f1c9 --out-dir T:\rust-embed-resource-lib-bug\target\debug\deps -C incremental=T:\rust-embed-resource-lib-bug\target\debug\incremental -L dependency=T:\rust-embed-resource-lib-bug\target\debug\deps
-     --extern rust_demo=T:\rust-embed-resource-lib-bug\target\debug\deps\librust_demo-d71b703fa29c9940.rlib
      -L native=T:\rust-embed-resource-lib-bug\target\debug\build\rust-demo-433fe507bd489039\out
+     -l dylib=icon
     Finished dev [unoptimized + debuginfo] target(s) in s

yeah, confirmed. i thought this would carry over transitively but it .. doesn't (or, maybe, it used to, but doesn't anymore?) – only the library is linked with the resource. hm.

@nabijaczleweli
Copy link
Owner

nabijaczleweli commented Mar 2, 2022

Can you try with latest master branch (at least e895286)? Your PoC worked for me, but I'd be much happier with a confirmation from a real use-case (do note that you need rustc >= 1.50.0, there's no way to fix this in earlier toolchains).

@byeblack
Copy link
Author

byeblack commented Mar 3, 2022

Can you try with latest master branch (at least e895286)? Your PoC worked for me, but I'd be much happier with a confirmation from a real use-case (do note that you need rustc >= 1.50.0, there's no way to fix this in earlier toolchains).

Thanks a lot, it worked successfully in my project

Windows 10
rustc 1.59.0
MSVC v143

Cargo.toml

[build-dependencies]
embed-resource = { git = "https://github.com/nabijaczleweli/rust-embed-resource", branch = "master" }

[[bin]]
name = "test_bin"
path = "src/main.rs"

[lib]
name = "test"
crate-type = ["staticlib", "cdylib"]
path = "src/lib.rs"

@noe132
Copy link

noe132 commented Mar 3, 2022

Works for me too on master 👍

@nabijaczleweli
Copy link
Owner

Great! Released in v1.6.6.

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

No branches or pull requests

3 participants