Does zig support address sanitizer?

If you’re using Zig to compile the C, then this should work (to instrument the C code, that is):

  • If using zig build-exe, then add -cflags -fsanitize=address --
  • If using zig cc, then just -fsanitize=address
  • If using build.zig, then add "-fsanitize=address" to the flags field of the addCSourceFiles options.
  • If the C code is in a dependency, then the dependency might need to expose an option

(I’ve not tested to confirm, though)

3 Likes