From 2bc197fe74e40de35be5ef5abe021162f9851368 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 8 Feb 2024 00:28:28 +0800 Subject: [PATCH] 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. --- CMakeLists.txt | 2 -- cmake/Rust.cmake | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 048a05537..a3891058a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,6 @@ add_custom_command( OUTPUT ${rust_target_dir}/${rust_profile}/libfish.rlib COMMAND ${CMAKE_COMMAND} -E env ${VARS_FOR_CARGO} - $<$:RUSTFLAGS=-g> ${Rust_CARGO} ARGS build --lib $<$:--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} - $<$:RUSTFLAGS=-g> ${Rust_CARGO} ARGS build --bin ${target} $<$:--release> --target ${Rust_CARGO_TARGET} diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index 2f30c3782..fe97ec68e 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -19,6 +19,8 @@ else() endif() set(rust_profile $,debug,release>) +set(rust_debugflags "$<$:-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}" )