cmake: add -g to existing RUSTFLAGS if required

Makes it possible to use the sanitizers again.

Note that this requires RUSTFLAGS to be set when running CMake, and will not be
updated when running the build system if the environment variable changes.
This commit is contained in:
David Adam 2024-02-08 00:28:28 +08:00
parent 7768952749
commit 2bc197fe74
2 changed files with 3 additions and 2 deletions

View file

@ -102,7 +102,6 @@ add_custom_command(
OUTPUT ${rust_target_dir}/${rust_profile}/libfish.rlib
COMMAND ${CMAKE_COMMAND} -E env
${VARS_FOR_CARGO}
$<$<CONFIG:Debug,RelWithDebInfo>:RUSTFLAGS=-g>
${Rust_CARGO} ARGS
build --lib
$<$<CONFIG:Release,RelWithDebInfo>:--release>
@ -122,7 +121,6 @@ function(FISH_LINK_DEPS_AND_SIGN target)
OUTPUT ${rust_target_dir}/${rust_profile}/${target}
COMMAND ${CMAKE_COMMAND} -E env
${VARS_FOR_CARGO}
$<$<CONFIG:Debug,RelWithDebInfo>:RUSTFLAGS=-g>
${Rust_CARGO} ARGS build --bin ${target}
$<$<CONFIG:Release,RelWithDebInfo>:--release>
--target ${Rust_CARGO_TARGET}

View file

@ -19,6 +19,8 @@ else()
endif()
set(rust_profile $<IF:$<CONFIG:Debug>,debug,release>)
set(rust_debugflags "$<$<CONFIG:Debug,RelWithDebInfo>:-g>")
# Temporary hack to propogate CMake flags/options to build.rs. We need to get CMake to evaluate the
# truthiness of the strings if they are set.
@ -56,4 +58,5 @@ set(VARS_FOR_CARGO
"CARGO_TARGET_DIR=${FISH_RUST_BUILD_DIR}"
"CARGO_BUILD_RUSTC=${RUSTC_EXECUTABLE}"
"${FISH_PCRE2_BUILDFLAG}"
"RUSTFLAGS=$ENV{RUSTFLAGS} ${rust_debugflags}"
)