Factor adding sanitizer linker flags into a separate function and make it less OS-specific