Commit 95bb53653d

Alex Rønne Petersen <alex@alexrp.com>
2024-09-08 01:38:44
zig cc: Support `-rtlib=none` for disabling compiler-rt.
1 parent de8cece
src/clang_options_data.zig
@@ -1984,7 +1984,7 @@ flagpsl("MT"),
 .{
     .name = "rtlib",
     .syntax = .separate,
-    .zig_equivalent = .other,
+    .zig_equivalent = .rtlib,
     .pd1 = false,
     .pd2 = true,
     .psl = false,
@@ -7331,7 +7331,7 @@ jspd1("iquote"),
 .{
     .name = "rtlib=",
     .syntax = .joined,
-    .zig_equivalent = .other,
+    .zig_equivalent = .rtlib,
     .pd1 = true,
     .pd2 = true,
     .psl = false,
src/main.zig
@@ -2180,6 +2180,19 @@ fn buildOutputType(
                             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.
@@ -5810,6 +5823,7 @@ pub const ClangArgIterator = struct {
         san_cov_trace_pc_guard,
         san_cov,
         no_san_cov,
+        rtlib,
     };
 
     const Args = struct {
tools/update_clang_options.zig
@@ -548,6 +548,14 @@ const known_options = [_]KnownOpt{
         .name = "fno-sanitize-coverage",
         .ident = "no_san_cov",
     },
+    .{
+        .name = "rtlib",
+        .ident = "rtlib",
+    },
+    .{
+        .name = "rtlib=",
+        .ident = "rtlib",
+    },
 };
 
 const blacklisted_options = [_][]const u8{};