From 4a0b928b72411d5c2703ae35e5d11eb089264b29 Mon Sep 17 00:00:00 2001 From: hl Date: Thu, 23 Jul 2026 09:02:09 +0800 Subject: [PATCH 1/2] fix Windows MSVC jemalloc target triple --- jemalloc-sys/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index 845b9d43f..cfc9ba1d4 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -448,8 +448,8 @@ fn execute(cmd: &mut Command, on_fail: impl FnOnce()) { fn gnu_target(target: &str) -> String { match target { - "i686-pc-windows-msvc" => "i686-pc-win32".to_string(), - "x86_64-pc-windows-msvc" => "x86_64-pc-win32".to_string(), + "i686-pc-windows-msvc" => "i686-pc-mingw32".to_string(), + "x86_64-pc-windows-msvc" => "x86_64-pc-mingw32".to_string(), "i686-pc-windows-gnu" | "i686-pc-windows-gnullvm" => "i686-w64-mingw32".to_string(), "x86_64-pc-windows-gnu" | "x86_64-pc-windows-gnullvm" => "x86_64-w64-mingw32".to_string(), "aarch64-pc-windows-gnullvm" => "aarch64-w64-mingw32".to_string(), From 40226a3d96bb7224be41476c9bc10667d4c9f1f3 Mon Sep 17 00:00:00 2001 From: hl Date: Thu, 23 Jul 2026 09:31:53 +0800 Subject: [PATCH 2/2] fix MSVC static jemalloc library linkage --- jemalloc-sys/build.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index cfc9ba1d4..c238ceb0e 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -352,8 +352,11 @@ fn main() { .arg("install_lib_static") .arg("install_include")); - // Try to remove the build directory to avoid it wasting disk space in the target directory - let _ = fs::remove_dir_all(build_dir); + // The MSVC build installs a differently named library, so keep its build + // directory and link the archive directly from there. + if !target.contains("windows") { + let _ = fs::remove_dir_all(&build_dir); + } println!("cargo:root={}", out_dir.display()); @@ -365,11 +368,12 @@ fn main() { // intrinsics that are libgcc specific (e.g. those intrinsics aren't present in // libcompiler-rt), so link that in to get that support. if target.contains("windows") { - println!("cargo:rustc-link-lib=static=jemalloc"); + println!("cargo:rustc-link-lib=static=jemalloc_s"); + println!("cargo:rustc-link-search=native={}/lib", build_dir.display()); } else { println!("cargo:rustc-link-lib=static=jemalloc_pic"); + println!("cargo:rustc-link-search=native={}/lib", out_dir.display()); } - println!("cargo:rustc-link-search=native={}/lib", out_dir.display()); if target.contains("android") { println!("cargo:rustc-link-lib=gcc"); } else if !target.contains("windows") {