zig cc: Support -rtlib=none for disabling compiler-rt.

This commit is contained in:
Alex Rønne Petersen 2024-09-08 01:38:44 +02:00 committed by Andrew Kelley
parent de8cece6e7
commit 95bb53653d
3 changed files with 24 additions and 2 deletions

View file

@ -1984,7 +1984,7 @@ flagpsl("MT"),
.{ .{
.name = "rtlib", .name = "rtlib",
.syntax = .separate, .syntax = .separate,
.zig_equivalent = .other, .zig_equivalent = .rtlib,
.pd1 = false, .pd1 = false,
.pd2 = true, .pd2 = true,
.psl = false, .psl = false,
@ -7331,7 +7331,7 @@ jspd1("iquote"),
.{ .{
.name = "rtlib=", .name = "rtlib=",
.syntax = .joined, .syntax = .joined,
.zig_equivalent = .other, .zig_equivalent = .rtlib,
.pd1 = true, .pd1 = true,
.pd2 = true, .pd2 = true,
.psl = false, .psl = false,

View file

@ -2180,6 +2180,19 @@ fn buildOutputType(
fatal("unsupported -undefined option '{s}'", .{it.only_arg}); fatal("unsupported -undefined option '{s}'", .{it.only_arg});
} }
}, },
.rtlib => {
// Unlike Clang, we support `none` for explicitly omitting compiler-rt.
if (mem.eql(u8, "none", it.only_arg)) {
want_compiler_rt = false;
} else if (mem.eql(u8, "compiler-rt", it.only_arg) or
mem.eql(u8, "libgcc", it.only_arg))
{
want_compiler_rt = true;
} else {
// Note that we don't support `platform`.
fatal("unsupported -rtlib option '{s}'", .{it.only_arg});
}
},
} }
} }
// Parse linker args. // Parse linker args.
@ -5810,6 +5823,7 @@ pub const ClangArgIterator = struct {
san_cov_trace_pc_guard, san_cov_trace_pc_guard,
san_cov, san_cov,
no_san_cov, no_san_cov,
rtlib,
}; };
const Args = struct { const Args = struct {

View file

@ -548,6 +548,14 @@ const known_options = [_]KnownOpt{
.name = "fno-sanitize-coverage", .name = "fno-sanitize-coverage",
.ident = "no_san_cov", .ident = "no_san_cov",
}, },
.{
.name = "rtlib",
.ident = "rtlib",
},
.{
.name = "rtlib=",
.ident = "rtlib",
},
}; };
const blacklisted_options = [_][]const u8{}; const blacklisted_options = [_][]const u8{};