fix(windows): link memset_shim object directly and suppress dead_code warning
Some checks failed
Test / frontend-tests (pull_request) Successful in 1m42s
Test / frontend-typecheck (pull_request) Successful in 1m51s
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Successful in 12m47s
Test / rust-clippy (pull_request) Successful in 14m27s
Test / rust-tests (pull_request) Successful in 16m50s
Some checks failed
Test / frontend-tests (pull_request) Successful in 1m42s
Test / frontend-typecheck (pull_request) Successful in 1m51s
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Successful in 12m47s
Test / rust-clippy (pull_request) Successful in 14m27s
Test / rust-tests (pull_request) Successful in 16m50s
- Use rustc-link-arg to directly link memset_shim.o object file instead of -l flag, ensuring symbol is available regardless of link order with libsodium_sys - Add #[allow(dead_code)] to find_ollama_binary() which is only used inside cfg(target_os = "macos") and cfg(target_os = "linux") blocks, causing false positive warning when cross-compiling for Windows
This commit is contained in:
parent
036af81147
commit
e2e7b02a0e
@ -9,17 +9,22 @@ fn main() {
|
||||
// libsodium-sys-stable uses memset_explicit which isn't available in MinGW
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
|
||||
|
||||
|
||||
if target_os == "windows" && target_env == "gnu" {
|
||||
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||
let obj_path = format!("{}/memset_shim.o", out_dir);
|
||||
|
||||
cc::Build::new()
|
||||
.file("memset_s_shim.c")
|
||||
.define("WIN32", None)
|
||||
.define("__WIN32__", None)
|
||||
.out_dir(&out_dir)
|
||||
.compile("memset_shim");
|
||||
|
||||
println!("cargo:rerun-if-changed=memset_s_shim.c");
|
||||
// Link the shim library - must be before libsodium in link order
|
||||
// The shim provides memset_explicit which libsodium expects
|
||||
println!("cargo:rustc-link-lib=static=memset_shim");
|
||||
// Directly link the object file instead of using -l flag
|
||||
// This ensures the symbol is available regardless of link order
|
||||
println!("cargo:rustc-link-arg={}", obj_path);
|
||||
}
|
||||
|
||||
tauri_build::build()
|
||||
|
||||
@ -52,6 +52,7 @@ pub async fn check_ollama() -> anyhow::Result<OllamaStatus> {
|
||||
}
|
||||
|
||||
/// Find the full path to the ollama binary
|
||||
#[allow(dead_code)]
|
||||
fn find_ollama_binary() -> Option<std::path::PathBuf> {
|
||||
// Try which/where command first
|
||||
let which_cmd = if cfg!(target_os = "windows") {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user