diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-04-18 19:20:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 19:20:23 +0200 |
| commit | 5195b87639a1dc56b90751d0aecc4fcf4f2a1bb0 (patch) | |
| tree | 774ce60e408b3357bb71be106d808a1c826875a1 /src | |
| parent | f8d2b87fa122a948e2c8e1056e2ec4cfd4cf01bf (diff) | |
| parent | b2344cc18e9fa5dfa1d19025caa2b0f583498734 (diff) | |
| download | zig-5195b87639a1dc56b90751d0aecc4fcf4f2a1bb0.tar.gz zig-5195b87639a1dc56b90751d0aecc4fcf4f2a1bb0.zip | |
Merge pull request #11396 from wojtekmach/wm-zig-cc-subsystem
zig cc: support --subsystem linker flag
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/src/main.zig b/src/main.zig index a647216b05..e341a10f99 100644 --- a/src/main.zig +++ b/src/main.zig @@ -849,36 +849,7 @@ fn buildOutputType( const next_arg = args_iter.next() orelse { fatal("expected parameter after {s}", .{arg}); }; - if (mem.eql(u8, next_arg, "console")) { - subsystem = .Console; - } else if (mem.eql(u8, next_arg, "windows")) { - subsystem = .Windows; - } else if (mem.eql(u8, next_arg, "posix")) { - subsystem = .Posix; - } else if (mem.eql(u8, next_arg, "native")) { - subsystem = .Native; - } else if (mem.eql(u8, next_arg, "efi_application")) { - subsystem = .EfiApplication; - } else if (mem.eql(u8, next_arg, "efi_boot_service_driver")) { - subsystem = .EfiBootServiceDriver; - } else if (mem.eql(u8, next_arg, "efi_rom")) { - subsystem = .EfiRom; - } else if (mem.eql(u8, next_arg, "efi_runtime_driver")) { - subsystem = .EfiRuntimeDriver; - } else { - fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{ - next_arg, - \\ console - \\ windows - \\ posix - \\ native - \\ efi_application - \\ efi_boot_service_driver - \\ efi_rom - \\ efi_runtime_driver - \\ - }); - } + subsystem = try parseSubSystem(next_arg); } else if (mem.eql(u8, arg, "-O")) { optimize_mode_string = args_iter.next() orelse { fatal("expected parameter after {s}", .{arg}); @@ -1610,6 +1581,12 @@ fn buildOutputType( fatal("expected linker arg after '{s}'", .{arg}); } try rpath_list.append(linker_args.items[i]); + } else if (mem.eql(u8, arg, "--subsystem")) { + i += 1; + if (i >= linker_args.items.len) { + fatal("expected linker arg after '{s}'", .{arg}); + } + subsystem = try parseSubSystem(linker_args.items[i]); } else if (mem.eql(u8, arg, "-I") or mem.eql(u8, arg, "--dynamic-linker") or mem.eql(u8, arg, "-dynamic-linker")) @@ -5132,3 +5109,36 @@ fn warnAboutForeignBinaries( }, } } + +fn parseSubSystem(next_arg: []const u8) !std.Target.SubSystem { + if (mem.eql(u8, next_arg, "console")) { + return .Console; + } else if (mem.eql(u8, next_arg, "windows")) { + return .Windows; + } else if (mem.eql(u8, next_arg, "posix")) { + return .Posix; + } else if (mem.eql(u8, next_arg, "native")) { + return .Native; + } else if (mem.eql(u8, next_arg, "efi_application")) { + return .EfiApplication; + } else if (mem.eql(u8, next_arg, "efi_boot_service_driver")) { + return .EfiBootServiceDriver; + } else if (mem.eql(u8, next_arg, "efi_rom")) { + return .EfiRom; + } else if (mem.eql(u8, next_arg, "efi_runtime_driver")) { + return .EfiRuntimeDriver; + } else { + fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{ + next_arg, + \\ console + \\ windows + \\ posix + \\ native + \\ efi_application + \\ efi_boot_service_driver + \\ efi_rom + \\ efi_runtime_driver + \\ + }); + } +} |
