FaultyRAM / windres-rs

Compiles Windows resource files (.rc) into a Rust program.
Apache License 2.0
21 stars 4 forks source link

Linker Error on Rust 1.50.0 #15

Closed bmarcaur closed 3 years ago

bmarcaur commented 3 years ago

windres-rs version: 0.2.1 rust version: 1.50.0

Hello!

I have a simple build.rs file which contains:

        Build::new()
            .compile("bitmap.rc")
            .expect("Failed to set Windows resources");

where bitmap.rc is simply:

1 BITMAP "company-logo.bmp"

I am upgrading from 1.41.1 where this compiles without issue. After upgrading to 1.50.0 I am not getting something along the lines of:

= note: LINK : fatal error LNK1356: cannot find library `C:\...\target\i686-pc-windows-msvc\debug\build\APPLICATION-HASH\out\bitmap.res.lib' specified to be whole archived

Yet... that file does indeed exist in the location that is logged. If you look higher up in the logs you will see:

# These arguments
... "bitmap.res.lib" "/WHOLEARCHIVE:bitmap.res.lib" ... 
# And a libpath with this entry
... "/LIBPATH:C:\\...\\target\\i686-pc-windows-msvc\\debug\\build\\APPLICATION-HASH\\out" ...

Doing some light searching I found this thread, https://users.rust-lang.org/t/linking-on-windows-without-wholearchive/49846, which seems to suggest removing static from the build.rs when linking lib's. However, this seems to be baked in to windres here, https://github.com/FaultyRAM/windres-rs/blob/master/src/msvc.rs#L99.

I am not sure that I fully understand the issue and I was wondering if you have any thoughts.

Sorry for the terse logs, this is in support of company work and I don't feel comfortable dumping more complete logs, but if it will help I can try to do some more scrubbing.

I am hesitant to do a PR that "just removes this" because it lacks understanding on my part, but I can do that as well if you think that is the right course of action.

Thank you, and LMK how I can facilitate.

bmarcaur commented 3 years ago

I am gonna try and bisect exactly which version of rust this regressed as I do not think it is unique to 1.50.0.

bmarcaur commented 3 years ago

Yeah seems to have regressed between 1.45.2 and 1.46.0.

Edit: I am kinda shocked that this behavior was left in the MSVC build chain as it really seems like it is a breaking change. The comments in this, https://github.com/rust-lang/rust/pull/72785, seem to indicate that they are aware of cases where it might break and that the fix is outlined in an RFC where you can control this explicitly, yet... the actual implementation of that has yet to be started.

FaultyRAM commented 3 years ago

Sorry for the notification spam, bors broke my PR 😞

Anyway, I published 0.2.2 which removes =static as suggested in the forum thread you linked. I haven't really looked into why whole archive linking breaks things on MSVC targets, I just hope that this is an edge case and it didn't silently break a ton of crates.

bmarcaur commented 3 years ago

and it didn't silently break a ton of crates

I hope that as well 👀

Thank you for the prompt fix!