aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-09-19 14:37:46 -0700
committerGitHub <noreply@github.com>2023-09-19 14:37:46 -0700
commita63a1c5cb9fd31a57e8371e6cba5f316bd3f2a65 (patch)
tree86c229e453d1f09734d6c89d172a471675aa7478 /src/Compilation.zig
parentee4ced96833470f9432e6a5dc5b31534457280c0 (diff)
parentf9f9c4a083b4e268caac3feff3a848df7a4f17cb (diff)
downloadzig-a63a1c5cb9fd31a57e8371e6cba5f316bd3f2a65.tar.gz
zig-a63a1c5cb9fd31a57e8371e6cba5f316bd3f2a65.zip
Merge pull request #17202 from ziglang/llvm17
Update to LLVM 17
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 0150d615e3..177c71f4d1 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -4318,6 +4318,9 @@ pub fn addCCArgs(
try argv.append("-D_LIBCPP_HAS_NO_THREADS");
}
+ // See the comment in libcxx.zig for more details about this.
+ try argv.append("-D_LIBCPP_PSTL_CPU_BACKEND_SERIAL");
+
try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
@intFromEnum(comp.libcxx_abi_version),
}));
@@ -4454,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");
}