From fdf5ded3605fad0ec68963fe068487e429d5194e Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 15 Dec 2023 16:15:12 -0700 Subject: [PATCH 1/4] Add debug info if Rust code is compiled with debug assertions --- sys/build.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/build.rs b/sys/build.rs index 9545b61..a3c6a0f 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -138,6 +138,10 @@ fn main() { config.define("WHISPER_METAL", "OFF"); } + if cfg!(debug_assertions) { + config.define("CMAKE_BUILD_TYPE", "Debug"); + } + let destination = config.build(); if env::var("TARGET").unwrap().contains("window") { From 755d9e590fb57a00fc2939966ec04210556a9c2d Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 15 Dec 2023 21:09:04 -0700 Subject: [PATCH 2/4] Switch from Debug to RelWithDebugInfo Debug builds are simply too slow to be remotely usable even on a 13700K, or with an Intel Arc A770 GPU (both tested to be unusable for anything approaching realtime) --- sys/build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/build.rs b/sys/build.rs index a3c6a0f..2dc3d45 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -139,7 +139,9 @@ fn main() { } if cfg!(debug_assertions) { - config.define("CMAKE_BUILD_TYPE", "Debug"); + // debug builds are too slow to even remotely be usable, + // so we build with optimizations even in debug mode + config.define("CMAKE_BUILD_TYPE", "RelWithDebugInfo"); } let destination = config.build(); From b5cddefcfa441ae8b43e0874d09b187e6b1e16fd Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 15 Dec 2023 21:20:39 -0700 Subject: [PATCH 3/4] Add flag to force debug mode --- sys/Cargo.toml | 3 +++ sys/build.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/Cargo.toml b/sys/Cargo.toml index b429860..90a2183 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -41,11 +41,14 @@ include = [ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] +default = ["force-debug"] + coreml = [] cuda = [] opencl = [] openblas = [] metal = [] +force-debug = [] [build-dependencies] cmake = "0.1" diff --git a/sys/build.rs b/sys/build.rs index 2dc3d45..1628bf5 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -138,10 +138,10 @@ fn main() { config.define("WHISPER_METAL", "OFF"); } - if cfg!(debug_assertions) { + if cfg!(debug_assertions) || cfg!(feature = "force-debug") { // debug builds are too slow to even remotely be usable, // so we build with optimizations even in debug mode - config.define("CMAKE_BUILD_TYPE", "RelWithDebugInfo"); + config.define("CMAKE_BUILD_TYPE", "RelWithDebInfo"); } let destination = config.build(); From 5061acff43e6144a1c96ce079a275601c63235e7 Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 15 Dec 2023 21:23:14 -0700 Subject: [PATCH 4/4] Don't enable force-debug by default --- sys/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/Cargo.toml b/sys/Cargo.toml index 90a2183..1966542 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -41,8 +41,6 @@ include = [ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["force-debug"] - coreml = [] cuda = [] opencl = []