compiler: Recognize -fno-sanitize=<...> in addition to -fsanitize=<...>.

This commit is contained in:
Alex Rønne Petersen 2025-04-03 07:23:23 +02:00
parent 7c5412c7a4
commit c3e88a21fb
No known key found for this signature in database
3 changed files with 11 additions and 5 deletions

View File

@ -7043,7 +7043,7 @@ joinpd1("fmsc-version="),
.{ .{
.name = "fno-sanitize=", .name = "fno-sanitize=",
.syntax = .comma_joined, .syntax = .comma_joined,
.zig_equivalent = .other, .zig_equivalent = .no_sanitize,
.pd1 = true, .pd1 = true,
.pd2 = false, .pd2 = false,
.psl = false, .psl = false,

View File

@ -2217,18 +2217,19 @@ fn buildOutputType(
mod_opts.strip = false; mod_opts.strip = false;
create_module.opts.debug_format = .{ .dwarf = .@"64" }; create_module.opts.debug_format = .{ .dwarf = .@"64" };
}, },
.sanitize => { .sanitize, .no_sanitize => |t| {
const enable = t == .sanitize;
var san_it = std.mem.splitScalar(u8, it.only_arg, ','); var san_it = std.mem.splitScalar(u8, it.only_arg, ',');
var recognized_any = false; var recognized_any = false;
while (san_it.next()) |sub_arg| { while (san_it.next()) |sub_arg| {
if (mem.eql(u8, sub_arg, "undefined")) { if (mem.eql(u8, sub_arg, "undefined")) {
mod_opts.sanitize_c = true; mod_opts.sanitize_c = enable;
recognized_any = true; recognized_any = true;
} else if (mem.eql(u8, sub_arg, "thread")) { } else if (mem.eql(u8, sub_arg, "thread")) {
mod_opts.sanitize_thread = true; mod_opts.sanitize_thread = enable;
recognized_any = true; recognized_any = true;
} else if (mem.eql(u8, sub_arg, "fuzzer") or mem.eql(u8, sub_arg, "fuzzer-no-link")) { } else if (mem.eql(u8, sub_arg, "fuzzer") or mem.eql(u8, sub_arg, "fuzzer-no-link")) {
mod_opts.fuzz = true; mod_opts.fuzz = enable;
recognized_any = true; recognized_any = true;
} }
} }
@ -5904,6 +5905,7 @@ pub const ClangArgIterator = struct {
gdwarf32, gdwarf32,
gdwarf64, gdwarf64,
sanitize, sanitize,
no_sanitize,
linker_script, linker_script,
dry_run, dry_run,
verbose, verbose,

View File

@ -284,6 +284,10 @@ const known_options = [_]KnownOpt{
.name = "fsanitize", .name = "fsanitize",
.ident = "sanitize", .ident = "sanitize",
}, },
.{
.name = "fno-sanitize",
.ident = "no_sanitize",
},
.{ .{
.name = "T", .name = "T",
.ident = "linker_script", .ident = "linker_script",