From 6ce66f691a96f890c539abb39042af96c70547fa Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Wed, 8 May 2024 01:23:25 +0200 Subject: [PATCH] Force `strip = false` for the current profile Fixes #87. --- src/main.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9e016c9..18a7447 100644 --- a/src/main.rs +++ b/src/main.rs @@ -681,16 +681,23 @@ fn process_crate(args: &Args) -> Result { Err(Error::UnsupportedCrateType) } -fn get_cargo_envs(args: &Args, target_triple: &str) - -> Vec<(impl AsRef, impl AsRef)> { +fn get_cargo_envs( + args: &Args, + target_triple: &str +) -> Vec<(impl AsRef, impl AsRef)> { let mut list = Vec::new(); let profile = args.get_profile() .to_ascii_uppercase() .replace('-', "_"); - // When targeting MSVC, symbols data will be stored in PDB files, - // so always generate debug info + // No matter which profile we are building for, never strip the binary + // because we need the symbols. + list.push((format!("CARGO_PROFILE_{}_STRIP", profile), "false")); + + // When targeting MSVC, symbols data will be stored in PDB files. + // Because of that, the Release build would not have any useful information + // even if not stripped. Therefore, force the debug info for MSVC target. if target_triple.contains("msvc") { list.push((format!("CARGO_PROFILE_{}_DEBUG", profile), "true")); }