From dd98022ecacdf2421357215ce9f0e2f317924038 Mon Sep 17 00:00:00 2001 From: itsjunetime Date: Sat, 27 Jun 2026 15:35:06 -0500 Subject: [PATCH] Maybe link correct msvcrt on debug vs non-debug? --- Cargo.lock | 6 ++++-- Cargo.toml | 2 +- build.rs | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index 715eedd..780a6ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1624,7 +1624,8 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libmimalloc-sys" version = "0.1.49" -source = "git+https://github.com/itsjunetime/mimalloc_rust.git?rev=3b0dda87caa5fbf4df1f60063a32b1462ddb5a85#3b0dda87caa5fbf4df1f60063a32b1462ddb5a85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9" dependencies = [ "cc", ] @@ -1750,7 +1751,8 @@ dependencies = [ [[package]] name = "mimalloc" version = "0.1.52" -source = "git+https://github.com/itsjunetime/mimalloc_rust.git?rev=3b0dda87caa5fbf4df1f60063a32b1462ddb5a85#3b0dda87caa5fbf4df1f60063a32b1462ddb5a85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862" dependencies = [ "libmimalloc-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 0d751a6..04903cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] } futures-util = { version = "0.3.30", default-features = false } flume = { version = "0.12.0", default-features = false, features = ["async"] } xflags = "0.4.0-pre.2" -mimalloc = { git = "https://github.com/itsjunetime/mimalloc_rust.git", rev = "3b0dda87caa5fbf4df1f60063a32b1462ddb5a85", features = [ "debug_in_debug" ] } +mimalloc = { version = "0.1", features = [ "debug_in_debug" ] } nix = { version = "0.31.0", features = ["signal"] } mupdf = { git = "https://github.com/messense/mupdf-rs.git", rev = "d7441b9998c92135e329559c0aa71d9dc92cf4de", default-features = false, features = ["svg", "system-fonts", "img"] } rayon = { version = "1", default-features = false } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..b36305d --- /dev/null +++ b/build.rs @@ -0,0 +1,14 @@ +// Working around https://github.com/purpleprotocol/mimalloc_rust/pull/167 while all the cc, rust, +// msvc, etc stuff is still being worked on. Kinda unfortunate that we need a build.rs for all +// targets, but at least it should be quick. + +fn main() { + if std::env::var("TARGET").is_ok_and(|s| s.contains("windows-msvc")) + && std::env::var("PROFILE").is_ok_and(|p| p == "debug") + { + // Don't link the default CRT + println!("cargo::rustc-link-arg=/nodefaultlib:msvcrt"); + // Link the debug CRT instead + println!("cargo::rustc-link-arg=/defaultlib:msvcrtd"); + } +}