Skip to content

Commit 95bb536

Browse files
alexrpandrewrk
authored andcommitted
zig cc: Support -rtlib=none for disabling compiler-rt.
1 parent de8cece commit 95bb536

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/clang_options_data.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ flagpsl("MT"),
19841984
.{
19851985
.name = "rtlib",
19861986
.syntax = .separate,
1987-
.zig_equivalent = .other,
1987+
.zig_equivalent = .rtlib,
19881988
.pd1 = false,
19891989
.pd2 = true,
19901990
.psl = false,
@@ -7331,7 +7331,7 @@ jspd1("iquote"),
73317331
.{
73327332
.name = "rtlib=",
73337333
.syntax = .joined,
7334-
.zig_equivalent = .other,
7334+
.zig_equivalent = .rtlib,
73357335
.pd1 = true,
73367336
.pd2 = true,
73377337
.psl = false,

src/main.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,19 @@ fn buildOutputType(
21802180
fatal("unsupported -undefined option '{s}'", .{it.only_arg});
21812181
}
21822182
},
2183+
.rtlib => {
2184+
// Unlike Clang, we support `none` for explicitly omitting compiler-rt.
2185+
if (mem.eql(u8, "none", it.only_arg)) {
2186+
want_compiler_rt = false;
2187+
} else if (mem.eql(u8, "compiler-rt", it.only_arg) or
2188+
mem.eql(u8, "libgcc", it.only_arg))
2189+
{
2190+
want_compiler_rt = true;
2191+
} else {
2192+
// Note that we don't support `platform`.
2193+
fatal("unsupported -rtlib option '{s}'", .{it.only_arg});
2194+
}
2195+
},
21832196
}
21842197
}
21852198
// Parse linker args.
@@ -5810,6 +5823,7 @@ pub const ClangArgIterator = struct {
58105823
san_cov_trace_pc_guard,
58115824
san_cov,
58125825
no_san_cov,
5826+
rtlib,
58135827
};
58145828

58155829
const Args = struct {

tools/update_clang_options.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,14 @@ const known_options = [_]KnownOpt{
548548
.name = "fno-sanitize-coverage",
549549
.ident = "no_san_cov",
550550
},
551+
.{
552+
.name = "rtlib",
553+
.ident = "rtlib",
554+
},
555+
.{
556+
.name = "rtlib=",
557+
.ident = "rtlib",
558+
},
551559
};
552560

553561
const blacklisted_options = [_][]const u8{};

0 commit comments

Comments
 (0)