I have a binary, that contains Rust and C Code and is built using Cargo. In the debug build I want to enable ASAN, especially for the C code. At the moment I do not have any unsafe Rust code, so I do not care that much about instrumenting the Rust code.
How would you do that? I see two ways to do this:
-
via RUSTFLAGS:
I can setRUSTFLAGS="-Z sanitizer=address"
manually when building with Cargo, but then I have to detect this in thebuild.rs
and set the-fsanitize=address
accordingly. I do not know how to achieve this. -
only in the C code:
I can set-fsanitize=address
for all C files, and skip the rust code. Then I would need to pass a flag to the linker. How would I do that in thebuild.rs
?