-
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
Panic when use ruby-static feature #54
Comments
So that error is coming from Lines 79 to 81 in ddebce7
The So next we call That value is passed to The final step would be to pass the non-error value to I do not know why I just pushed a commit swapping to You could try pointing your Magnus dependency to this git repo and give that a try and see if the error is something actionable. Another approach would be to add rb-sys to your project and call |
After updating to use the new commit, the error message is interesting 🤔
P.S. use |
Oh, I wonder if (despite the slightly different error message) that's the same issue that is described in the Troubleshooting - Issues with static linking section of the readme. Have you given that a go? |
Yes, I had tested with extra config. The dynamic library grows from 7MB to 37MB, I think it should bundle it. |
I've added |
After setting the revision to use The Godot freezes when I run the game to test, but using
|
can you post a small repo with the all the code that shows this so I can take a look? |
I create a repo that included my test code: |
I noticed in the gdn config that it may be trying to load libruby.so. If you are linking ruby statically, it shouldn’t be necessary. Does Godot expect dylibs? I ask because having Ruby expects one and only one VM to be setup, and having multiple versions loaded would break assumptions Ruby will make about the location of thread locals, etc |
Godot expect dylibs because we didn't compile the extension into the game engine. We are creating a dynamic library and using gdn config to define where to load it. My project is loaded ruby in this way: Godot -> libruby.so (the extension bundled ruby) P.S. the rust godot SDK does not support "singleton" mode for now. When I start a new process it is panic therefore I guess it breaks the first time. |
Still a bit confused on this. It seems like you want both libruby.so and to link ruby statically (which is not possible). Is that right? |
Ahh I see, you named to crate "ruby" so I was getting confused. One thing you should add as well is a First, add diff --git i/Cargo.toml w/Cargo.toml
index 46d4e99..582d6c9 100644
--- i/Cargo.toml
+++ w/Cargo.toml
@@ -8,5 +8,8 @@ gdnative = "0.11"
rb-sys = "0.9.56"
magnus = { git = "https://github.com/matsadler/magnus.git", rev = "52eeaad", features = ["embed", "ruby-static"] }
+[build-dependencies]
+rb-sys-env = "0.1.2"
+
[lib]
crate-type = ["cdylib"] Then: // build.rs
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let _ = rb_sys_env::activate()?;
Ok(())
} This gets us to the point where we have linked up all of the libruby-static symbols: ❯ nm --defined-only /tmp/godot-with-ruby_poc/target/debug/libruby.dylib | grep ' _rb_str_new'
00000000001e6448 t _rb_str_new
00000000001e677c t _rb_str_new_cstr
00000000001e7b10 t _rb_str_new_frozen
00000000001e7a9c t _rb_str_new_shared
00000000001e6914 t _rb_str_new_static
00000000001e80cc t _rb_str_new_with_class |
And for good measure, let's specify the features of rb-sys: diff --git i/Cargo.toml w/Cargo.toml
index 46d4e99..857089b 100644
--- i/Cargo.toml
+++ w/Cargo.toml
@@ -5,8 +5,11 @@ edition = "2021"
[dependencies]
gdnative = "0.11"
-rb-sys = "0.9.56"
+rb-sys = { version = "0.9.65", features = ["link-ruby", "ruby-static"] }
magnus = { git = "https://github.com/matsadler/magnus.git", rev = "52eeaad", features = ["embed", "ruby-static"] }
+[build-dependencies]
+rb-sys-env = "0.1.2"
+
[lib]
crate-type = ["cdylib"] |
Played around with it and got the basic demo working. I know nothing about godot, but noticed things broke when Another solution for this problem would be to spawn a tokio runtime with a single thread, and ensure all calls to ruby happen inside of a |
Thanks for your demo. I put the The The newer Godot is changing the extension system design, I want to identify the issues caused by magnus or godot-rust's first (e.g. godot-rust cannot support singleton mode and call the |
I am trying to use magnus with godot-rust but got some errors that are hard to track.
The init code in the godot-rust
And I got this error
The
lib.rs:27
is points togodot_init!(init);
and the panic is raised byembed::init()
If I remove the
ruby-static
feature everything works correctly.Command to build the library on macOS (Ventura 13.1)
RUBY=~/Downloads/ruby-3.2.0/dist/bin/ruby cargo build
P.S. if didn't use
godot-rust
run as a standalone binary instead of dylib, it works correctly.Other information
nm -gU target/debug/libexample.dylib
otool -L target/debug/libexample.dylib
The text was updated successfully, but these errors were encountered: