Skip to content

Features "jpeg" and "dynamic_linking" cause linking error in 0.14-rc.4 on linux #14117

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

Closed
Sorseg opened this issue Jul 3, 2024 · 17 comments
Closed
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Build-System Related to build systems or continuous integration C-Bug An unexpected or incorrect behavior C-Dependencies A change to the crates that Bevy depends on O-Linux Specific to the Linux desktop operating system P-Compile-Failure A failure to compile Bevy apps P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@Sorseg
Copy link
Contributor

Sorseg commented Jul 3, 2024

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

  = note: /usr/bin/ld: __rust_realloc: undefined version: 
          /usr/bin/ld: __rust_no_alloc_shim_is_unstable: undefined version: 
          /usr/bin/ld: __rust_dealloc: undefined version: 
          /usr/bin/ld: __rust_alloc_zeroed: undefined version: 
          /usr/bin/ld: __rust_alloc_error_handler_should_panic: undefined version: 
          /usr/bin/ld: __rust_alloc_error_handler: undefined version: 
          /usr/bin/ld: __rust_alloc: undefined version: 
          /usr/bin/ld: failed to set dynamic section sizes: bad value
          collect2: error: ld returned 1 exit status

and on nightly with lld it is

  = note: rust-lld: error: version script assignment of 'global' to symbol '__rust_alloc' failed: symbol not defined
          rust-lld: error: version script assignment of 'global' to symbol '__rust_alloc_error_handler' failed: symbol not defined
          rust-lld: error: version script assignment of 'global' to symbol '__rust_alloc_error_handler_should_panic' failed: symbol not defined
          rust-lld: error: version script assignment of 'global' to symbol '__rust_alloc_zeroed' failed: symbol not defined
          rust-lld: error: version script assignment of 'global' to symbol '__rust_dealloc' failed: symbol not defined
          rust-lld: error: version script assignment of 'global' to symbol '__rust_no_alloc_shim_is_unstable' failed: symbol not defined
          rust-lld: error: version script assignment of 'global' to symbol '__rust_realloc' failed: symbol not defined
          collect2: error: ld returned 1 exit status
          

error: could not compile `bevy_dylib` (lib) due to 1 previous error

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!

@Sorseg Sorseg added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 3, 2024
@Sorseg Sorseg changed the title Features "jpeg" and "dynamic_linking" cause linking error in 0.14-rc.4 Features "jpeg" and "dynamic_linking" cause linking error in 0.14-rc.4 on linux Jul 3, 2024
@janhohenheim janhohenheim added A-Build-System Related to build systems or continuous integration A-Assets Load files from disk to use for things like images, models, and sounds O-Linux Specific to the Linux desktop operating system P-Regression Functionality that used to work but no longer does. Add a test for this! P-Compile-Failure A failure to compile Bevy apps and removed S-Needs-Triage This issue needs to be labelled labels Jul 3, 2024
@janhohenheim janhohenheim added this to the 0.14 milestone Jul 3, 2024
@BD103 BD103 added the S-Needs-Investigation This issue requires detective work to figure out what's going wrong label Jul 3, 2024
@alice-i-cecile
Copy link
Member

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.

@BD103
Copy link
Member

BD103 commented Jul 3, 2024

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:

  1. Do you use a custom linker? (Perhaps through config_fast_builds.toml?)
  2. If you disable default features for Bevy, does it still fail to link?

@alice-i-cecile
Copy link
Member

I take it this can't be reproduced on 0.13 alone?

@Sorseg
Copy link
Contributor Author

Sorseg commented Jul 3, 2024

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 cleaning 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

@Sorseg
Copy link
Contributor Author

Sorseg commented Jul 3, 2024

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

@AyeTbk
Copy link

AyeTbk commented Jul 3, 2024

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.

@mockersf
Copy link
Member

mockersf commented Jul 3, 2024

the cdylib crate type has been removed from zune-jpeg: etemesi254/zune-image#187

until everything is updated, not much we can do on Bevy side

@mockersf mockersf added C-Dependencies A change to the crates that Bevy depends on S-Blocked This cannot move forward until something else changes and removed S-Needs-Investigation This issue requires detective work to figure out what's going wrong labels Jul 3, 2024
@alice-i-cecile alice-i-cecile removed this from the 0.14 milestone Jul 3, 2024
@TarekAS
Copy link

TarekAS commented Jul 18, 2024

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.

@ironpeak
Copy link

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" }

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 30, 2024

How was this not fixed by rust-lang/rust#113695? That PR should prevent rustc from attempting to link against cdylib's when a rust dependency is expected.

@alice-i-cecile alice-i-cecile removed the S-Blocked This cannot move forward until something else changes label Nov 30, 2024
@alice-i-cecile alice-i-cecile added the S-Needs-Investigation This issue requires detective work to figure out what's going wrong label Nov 30, 2024
@alice-i-cecile
Copy link
Member

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.

@mockersf
Copy link
Member

it should be fixed by etemesi254/zune-image#187, but we're waiting for every dependency to release/update

@Usioumeo
Copy link

Usioumeo commented Dec 5, 2024

If anyone reeealy needs to run bevy 0.15 with this two flags, it is possible to add to cargo.toml:

#patches for zune jpeg
[patch.crates-io]
zune-jpeg = { git = "https://github.com/etemesi254/zune-image", branch = "zune-jpeg-4.12"}

[patch."https://github.com/etemesi254/zune-image"]
zune-core = "0.4.12"

For me this solved the issue.

@BenjaminBrienen
Copy link
Contributor

What dependency are we waiting on to release in order to close this?

@rparrett
Copy link
Contributor

As far as I can tell, this should have been fixed as soon as zune-jpeg 0.4.12 was released (jul 21 2014). I don't think there was ever a published version of image that depended on 0.3, so the zune-jpeg release fixing this has has been semver compatible / cargo update should have been bringing it in.

 cargo tree -i zune-jpeg --features=jpeg
zune-jpeg v0.4.14
└── image v0.25.5
    ├── bevy_image v0.15.0 (/Users/robparrett/src/bevy/crates/bevy_image)

@ironpeak @TarekAS @Usioumeo are you able to confirm that this is fixed without patching?

@ironpeak
Copy link

It has been sorted out for me, I tested checking out a commit from 18-07-2024 in my repository and removing the zune-jpeg patch and it compiled and ran.

@rparrett
Copy link
Contributor

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Build-System Related to build systems or continuous integration C-Bug An unexpected or incorrect behavior C-Dependencies A change to the crates that Bevy depends on O-Linux Specific to the Linux desktop operating system P-Compile-Failure A failure to compile Bevy apps P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests