mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
clang: -fno-sanitize=function workaround
It is very common, and well-defined, for a pointer on one side of a C ABI to have a different but compatible element type. Examples include: - `char*` vs `uint8_t*` on a system with 8-bit bytes - `const char*` vs `char*` - `char*` vs `unsigned char*` Without this flag, Clang would invoke UBSAN when such an extern function was called. Might be nice to file an upstream issue and find out if there is a more precise way to disable the problematic check. `-fsanitize-cfi-icall-generalize-pointers` looks promising according to the documentation, but empirically it does not work.
This commit is contained in:
parent
75b8b21cc1
commit
66312c0b51
1 changed files with 9 additions and 0 deletions
|
|
@ -4457,9 +4457,18 @@ pub fn addCCArgs(
|
|||
if (comp.sanitize_c and !comp.bin_file.options.tsan) {
|
||||
try argv.append("-fsanitize=undefined");
|
||||
try argv.append("-fsanitize-trap=undefined");
|
||||
// It is very common, and well-defined, for a pointer on one side of a C ABI
|
||||
// to have a different but compatible element type. Examples include:
|
||||
// `char*` vs `uint8_t*` on a system with 8-bit bytes
|
||||
// `const char*` vs `char*`
|
||||
// `char*` vs `unsigned char*`
|
||||
// Without this flag, Clang would invoke UBSAN when such an extern
|
||||
// function was called.
|
||||
try argv.append("-fno-sanitize=function");
|
||||
} else if (comp.sanitize_c and comp.bin_file.options.tsan) {
|
||||
try argv.append("-fsanitize=undefined,thread");
|
||||
try argv.append("-fsanitize-trap=undefined");
|
||||
try argv.append("-fno-sanitize=function");
|
||||
} else if (!comp.sanitize_c and comp.bin_file.options.tsan) {
|
||||
try argv.append("-fsanitize=thread");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue