diff options
| author | Wojtek Mach <wojtek@wojtekmach.pl> | 2022-04-06 22:48:07 +0200 |
|---|---|---|
| committer | Wojtek Mach <wojtek@wojtekmach.pl> | 2022-04-06 22:48:07 +0200 |
| commit | 5eee8f70d1bff5504760f7080e1d50b91be4dc1c (patch) | |
| tree | d67722282940f3be112784dfcde6827dbd054cf2 /src/main.zig | |
| parent | 289ba5dfc2dbd5f6f179c49e974b0332f16604a6 (diff) | |
| download | zig-5eee8f70d1bff5504760f7080e1d50b91be4dc1c.tar.gz zig-5eee8f70d1bff5504760f7080e1d50b91be4dc1c.zip | |
zig cc: support --subsystem linker flag
Example:
$ zig cc -o main.exe main.cpp -target x86_64-windows -Wl,--subsystem,windows
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/src/main.zig b/src/main.zig index a647216b05..aec88c1175 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}); @@ -1467,6 +1438,11 @@ fn buildOutputType( mem.eql(u8, linker_arg, "-static")) { force_static_libs = true; + } else if (mem.eql(u8, linker_arg, "--subsystem")) { + const next_arg = split_it.next() orelse { + fatal("expected parameter after {s}", .{linker_arg}); + }; + subsystem = try parseSubSystem(next_arg); } else { try linker_args.append(linker_arg); } @@ -5132,3 +5108,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 + \\ + }); + } +} |
