Use cargo build -Z build-std for ASAN

This is recommended and increases coverage.
This commit is contained in:
Mahmoud Al-Qudsi 2023-03-07 12:47:30 -06:00
parent ce5686edc7
commit 1bdb7dffaf
3 changed files with 14 additions and 2 deletions

View file

@ -89,6 +89,8 @@ jobs:
with:
# All -Z options require running nightly
rust-version: nightly
# ASAN uses `cargo build -Zbuild-std` which requires the rust-src component
components: rust-src
- name: Install deps
run: |
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux

View file

@ -15,9 +15,19 @@ set(fish_rust_target "fish-rust")
set(fish_autocxx_gen_dir "${CMAKE_BINARY_DIR}/fish-autocxx-gen/")
if(NOT DEFINED CARGO_FLAGS)
# Corrosion doesn't like an empty string as FLAGS. This is basically a no-op alternative.
# See https://github.com/corrosion-rs/corrosion/issues/356
set(CARGO_FLAGS "--config" "foo=0")
endif()
if(DEFINED ASAN)
list(APPEND CARGO_FLAGS "-Z" "build-std")
endif()
corrosion_import_crate(
MANIFEST_PATH "${CMAKE_SOURCE_DIR}/fish-rust/Cargo.toml"
FEATURES "fish-ffi-tests"
FLAGS "${CARGO_FLAGS}"
)
# We need the build dir because cxx puts our headers in there.

View file

@ -193,7 +193,7 @@ endif()
if(NOT DEFINED ASAN)
add_test(
NAME "cargo-test"
COMMAND cargo test --target-dir target ${cargo_target_opt}
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust"
)
set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
@ -202,7 +202,7 @@ endif()
add_test(
NAME "cargo-test-widestring"
COMMAND cargo test --target-dir target ${cargo_target_opt}
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust/widestring-suffix/"
)
add_test_target("cargo-test-widestring")