Use native library name

This commit is contained in:
nora 2023-09-23 15:22:12 +02:00
parent b771e5ad29
commit e622de62ff

View file

@ -96,17 +96,9 @@ impl RustFunction {
std::fs::write(&source_path, full_file).context("writing source")?; std::fs::write(&source_path, full_file).context("writing source")?;
let library_path = file.path().join("libhelper");
let mut rustc = Command::new("rustc"); let mut rustc = Command::new("rustc");
rustc.arg(source_path); rustc.arg(source_path);
rustc.args([ rustc.args(["--crate-type=cdylib", "--crate-name=helper", "--emit=link"]);
"--crate-type=cdylib",
"--crate-name=helper",
"--emit=link",
"-o",
]);
rustc.arg(&library_path);
rustc.current_dir(file.path()); rustc.current_dir(file.path());
let output = rustc.output().context("running rustc")?; let output = rustc.output().context("running rustc")?;
@ -117,7 +109,8 @@ impl RustFunction {
// SAFETY: We are loading a simple rust cdylib, which does not do weird things. But we cannot unload Rust dylibs, so we use MD below. // SAFETY: We are loading a simple rust cdylib, which does not do weird things. But we cannot unload Rust dylibs, so we use MD below.
let dylib = unsafe { let dylib = unsafe {
libloading::Library::new(&library_path).context("loading helper shared library")? libloading::Library::new(file.path().join(libloading::library_filename("helper")))
.context("loading helper shared library")?
}; };
let dylib = ManuallyDrop::new(dylib); let dylib = ManuallyDrop::new(dylib);