Open Sorseg opened 5 months ago
Thanks a ton for the minimal reproduction: this saves us a ton of time and grief. I'll try and reproduce tomorrow, but I think the odds are high that this doesn't make the 0.14 release. This sort of problem can be quite involved to troubleshoot and dynamic_linking isn't a must-have feature IMO.
I can't seem to reproduce this locally on MacOS. The jpeg
feature enables image/jpeg
, which adds a dependency on zune-core
and zune-jpeg
. This is the repository, though with a quick search I can't seem to find anything. Two questions:
config_fast_builds.toml
?)I take it this can't be reproduced on 0.13 alone?
I agree that this is not a high priority issue, I posted it here mostly for other people running into this linking issue to figure out the cause, as it took me a couple of hours.
I am using this linker.
$ ld --version
GNU ld (GNU Binutils for Ubuntu) 2.38
The only thing in my .cargo/config.toml
is rustc-wrapper=sccache
, but I've added it there after running into the issue, to speed up investigating since I was cargo clean
ing a lot.
Building with bevy 0.13.2
succeeds.
Building with default-features=false
fails the same way, updated the repro repo to disable default features
I was able to reproduce it in the repro repo with docker
sudo docker run -it -v $PWD:/usr/src --workdir /usr/src rust:1.79.0 cargo build
I get the same problem on Arch Linux.
I managed to make a minimal reproduction of the underlying linking error here. The gist of it seems to be: bevy uses image
version 0.25, which uses zune-jpeg
version 4.11, which has a crate-type of "cdylib"
. Either removing the crate-type or changing it to "dylib"
(without the c) makes the linking succeed. I have tested this with Sorseg's repo, patching zune-jpeg locally.
Interesting to note: the latest version of zune-jpeg (0.5.0-rc1) doesn't have the crate-type anymore.
the cdylib crate type has been removed from zune-jpeg: https://github.com/etemesi254/zune-image/pull/187
until everything is updated, not much we can do on Bevy side
This is happening in a GitHub Action for me as well, if I run my tests with dynamic linking enabled to save on build time. Will disable dynamic linking until this is fixed.
I forked the zune-jpeg
repository and made the latest code compatible with bevy so that I could use dynamic linking.
It works in my project although I'm not using many jpegs.
Cargo.toml
# https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
[patch.crates-io]
zune-jpeg = { git = "https://github.com/ironpeak/zune-image", rev = "eebb01b72c07aaf8b00200d9d87d4cba6f01651f" }
How was this not fixed by https://github.com/rust-lang/rust/pull/113695? That PR should prevent rustc from attempting to link against cdylib's when a rust dependency is expected.
I don't see an upstream issue about the cdylib. If this can be reproduced, we should open an issue there, and on the Rust repo itself.
it should be fixed by https://github.com/etemesi254/zune-image/pull/187, but we're waiting for every dependency to release/update
Bevy version
0.14.0-rc.4
Relevant system information
Linux host 6.9.3-76060903-generic #202405300957~1718348209~22.04~7817b67 SMP PREEMPT_DYNAMIC Mon J x86_64 x86_64 x86_64 GNU/Linux
rustc 1.79.0 (129f3b996 2024-06-10)
What you did
I've updated to new bevy rc on my project and started getting compilation errors after running a cargo clean once. I've made a repro repo that is a hello world project, with only bevy as the dependency and it also fails to link.
What went wrong
Linking error on stable is
and on nightly with lld it is
Additional information
A workaround in my case was to get rid of the
jpeg
feature as I don't use it anymore.Thank you for maintaining this amazing engine!