diff --git a/build.rs b/build.rs index a90c73a..c2bbcc5 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,6 @@ use std::{env, path::PathBuf, process::Command}; fn main() { + println!("cargo:rustc-link-arg=-rdynamic"); println!("cargo:rustc-link-lib=z"); // TODO: if features Ruby } diff --git a/src/runtimes/ruby.rs b/src/runtimes/ruby.rs index 399d58e..e9ee8e7 100644 --- a/src/runtimes/ruby.rs +++ b/src/runtimes/ruby.rs @@ -72,17 +72,18 @@ impl RubyThread { let (sender, receiver) = crossbeam_channel::unbounded::>(); let handle = thread::spawn(move || { - let argc: i32 = 0; - let argv = vec![CString::new("ruby").unwrap(), CString::new("-e").unwrap()]; - let mut argv = argv - .iter() - .map(|cs| cs.as_ptr() as *mut _) - .collect::>(); + let argc: i32 = 3; + let mut argv = vec![ + CString::new("ruby").unwrap().into_raw(), + CString::new("-e").unwrap().into_raw(), + CString::new("").unwrap().into_raw(), + ]; unsafe { let mut variable_in_this_stack_frame: VALUE = 0; ruby_init_stack(&mut variable_in_this_stack_frame as *mut VALUE as *mut _); rb_sys::ruby_init(); + rb_sys::ruby_init_loadpath(); rb_sys::ruby_options(argc, argv.as_mut_ptr()); }; while let Ok(f) = receiver.recv() { @@ -90,7 +91,7 @@ impl RubyThread { f(ruby); } unsafe { - ruby_finalize(); + rb_sys::ruby_finalize(); } });