From ea5fb6e4baad9fbe7c217499bcbbf65c210bb693 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 23 Sep 2023 15:22:12 +0200 Subject: [PATCH] Use native library name --- src/dylib_flag.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/dylib_flag.rs b/src/dylib_flag.rs index fcc65a8..229ea6d 100644 --- a/src/dylib_flag.rs +++ b/src/dylib_flag.rs @@ -96,17 +96,9 @@ impl RustFunction { std::fs::write(&source_path, full_file).context("writing source")?; - let library_path = file.path().join("libhelper"); - let mut rustc = Command::new("rustc"); rustc.arg(source_path); - rustc.args([ - "--crate-type=cdylib", - "--crate-name=helper", - "--emit=link", - "-o", - ]); - rustc.arg(&library_path); + rustc.args(["--crate-type=cdylib", "--crate-name=helper", "--emit=link"]); rustc.current_dir(file.path()); 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. 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);