-
Notifications
You must be signed in to change notification settings - Fork 35
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
Enabling the "embed" feature causes undefined reference to 'uncompress'
on Linux
#84
Comments
I'm not really sure what's happing here. The error is referencing this code in Ruby: https://github.com/ruby/ruby/blob/v3_2_2/addr2line.c#L1978 which references a function from It's likely it doesn't cause a problem on macOS because that code is inside an I think what has happened is that the statically compiled Ruby isn't 100% static, and still has a reference to a dynamic library (zlib). Then when cargo is trying to link your program it can't find where that function is coming from. This is hitting the edge of my knowledge about static compilation and linking, so I don't know enough to fix it or test if my theory is right. |
I experimented a little bit over the last 2 days and now have a different error :D
Can you help me with this one too? To get to this error I followed your hunch of this being a linking error to zlib caused by the At first I tried to disable compression of debug headers by adding Then I tried adding I tried passing In the end I tried to dynamically link zlib by adding Once I figured out that linking to zlib from rust was a step forward I changed the linking to be static, which still produces the same error. Here is the final [build]
# Without this flag, when linking static libruby, the linker removes symbols
# (such as `_rb_ext_ractor_safe`) which it thinks are dead code... but they are
# not, and they need to be included for the `embed` feature to work with static
# Ruby.
rustflags = ["-C", "link-dead-code=on", "-L", "/usr/lib/", "-l", "static=z"] Ruby was built with this command
|
Hi, I was playing around with embedding Ruby into an app and ran into an issue on Linux where
cargo run
fails during compilation due to the following error:Full error message
When I try to compile and run the same code on a Mac it compiles and runs just fine. This error only pops up, for me, on Linux.
I'm unsure if this is user error on my part or a Linux specific issue. Any help is much appreciated.
What I've already tried
At first this seemed to be an issue with my Linux install, so I tried compiling and running my app inside the rb-sys dev Docker container and got the same error.
Dockerfile, build and run instructions
To build the container, and execute
cargo run
inside it I ran the following:Adding a
.cargo/config.toml
file to the project's dir and instructing rustc to keep unused symbols didn't help.Contents of the config.toml file
Different versions of magnus - from version 0.4 to 0.6 - all produce the same error.
Project
There is just one file -
src/main.rs
- that contains the embedding example from the docsthis is the project's
cargo.toml
fileRuby is built using
RUBY_CONFIGURE_OPTS="--disable-shared --disable-install-doc --disable-install-rdoc" ruby-build "3.2.2" "$HOME/Desktop/crazy_idea/ruby"
The project is compiled and ran using
RUBY=$PWD/ruby/bin/ruby cargo run
The text was updated successfully, but these errors were encountered: