Commit 6af0eeb58d

cod1r <jasonho353@gmail.com>
2022-09-18 16:47:24
adding `static` and `dynamic` ZigEquivalent enums so that we can branch to set `link_mode` properly when we iterate over the clang arguments. also replaced `dynamic` flag in clang_options_data.zig with proper definition similarly to `static`.
1 parent d987bf8
src/clang_options_data.zig
@@ -2480,7 +2480,14 @@ flagpd1("dwarf-ext-refs"),
 },
 sepd1("dylib_file"),
 flagpd1("dylinker"),
-flagpd1("dynamic"),
+.{
+    .name = "dynamic",
+    .syntax = .flag,
+    .zig_equivalent = .dynamic,
+    .pd1 = true,
+    .pd2 = false,
+    .psl = false,
+},
 .{
     .name = "dynamiclib",
     .syntax = .flag,
@@ -4028,7 +4035,7 @@ flagpd1("menable-unsafe-fp-math"),
 m("menqcmd"),
 m("mexception-handling"),
 m("mexecute-only"),
-flagpd1("mextended-const"),
+m("mextended-const"),
 flagpd1("mextern-sdata"),
 m("mf16c"),
 flagpd1("mfancy-math-387"),
@@ -4037,7 +4044,7 @@ flagpd1("mfix4300"),
 flagpd1("mfix-and-continue"),
 m("mfix-cmse-cve-2021-35465"),
 m("mfix-cortex-a53-835769"),
-flagpd1("mfix-cortex-a57-aes-1742098"),
+m("mfix-cortex-a57-aes-1742098"),
 flagpd1("mfix-cortex-a72-aes-1655431"),
 m("mfloat128"),
 sepd1("mfloat-abi"),
@@ -4188,12 +4195,12 @@ m("mno-enqcmd"),
 m("mno-exception-handling"),
 flagpd1("mnoexecstack"),
 m("mno-execute-only"),
-flagpd1("mno-extended-const"),
+m("mno-extended-const"),
 flagpd1("mno-extern-sdata"),
 m("mno-f16c"),
 m("mno-fix-cmse-cve-2021-35465"),
 m("mno-fix-cortex-a53-835769"),
-flagpd1("mno-fix-cortex-a57-aes-1742098"),
+m("mno-fix-cortex-a57-aes-1742098"),
 flagpd1("mno-fix-cortex-a72-aes-1655431"),
 m("mno-float128"),
 m("mno-fma"),
@@ -4272,7 +4279,7 @@ m("mno-prfchw"),
 m("mno-ptwrite"),
 flagpd1("mno-pure-code"),
 m("mno-rdpid"),
-flagpd1("mno-rdpru"),
+m("mno-rdpru"),
 m("mno-rdrnd"),
 m("mno-rdseed"),
 .{
@@ -4382,7 +4389,7 @@ m("mptwrite"),
 flagpd1("mpure-code"),
 flagpd1("mqdsp6-compat"),
 m("mrdpid"),
-flagpd1("mrdpru"),
+m("mrdpru"),
 m("mrdrnd"),
 m("mrdseed"),
 flagpd1("mreassociate"),
@@ -5034,7 +5041,7 @@ sepd1("stack-usage-file"),
 .{
     .name = "static",
     .syntax = .flag,
-    .zig_equivalent = .other,
+    .zig_equivalent = .static,
     .pd1 = true,
     .pd2 = true,
     .psl = false,
src/main.zig
@@ -1649,6 +1649,8 @@ fn buildOutputType(
                             };
                         }
                     },
+                    .dynamic => link_mode = .Dynamic,
+                    .static => link_mode = .Static,
                 }
             }
             // Parse linker args.
@@ -4678,6 +4680,8 @@ pub const ClangArgIterator = struct {
         weak_framework,
         headerpad_max_install_names,
         compress_debug_sections,
+        dynamic,
+        static,
     };
 
     const Args = struct {
tools/update_clang_options.zig
@@ -492,6 +492,14 @@ const known_options = [_]KnownOpt{
         .name = "compress-debug-sections=",
         .ident = "compress_debug_sections",
     },
+    .{
+        .name = "dynamic",
+        .ident = "dynamic",
+    },
+    .{
+        .name = "static",
+        .ident = "static",
+    },
 };
 
 const blacklisted_options = [_][]const u8{};
@@ -798,7 +806,7 @@ fn objSyntax(obj: *json.ObjectMap) ?Syntax {
         } else if (std.mem.eql(u8, superclass, "CLRemainingArgsJoined")) {
             return .remaining_args_joined;
         } else if (std.mem.eql(u8, superclass, "MultiArg")) {
-            return .{ .multi_arg = num_args };
+            return Syntax{ .multi_arg = num_args };
         }
     }
     const name = obj.get("Name").?.String;