| author | |
| committer | |
| log | 74d2536715c4d4c27d7075b9675fa330e5be02cf |
| tree | f0d213d829e1f6236a1974ecd078d21863837d51 |
| parent | bf15c791faa7bf5a029ec58432b3e8e16c691dff |
| parent | 54f2a7c833bf2ca0b370ebe2470bb0dd71206cba |
| signature |
Misc. Windows subsystem refactorings11 files changed, 75 insertions(+), 147 deletions(-)
lib/std/Build/Step/Compile.zig+2-11| ... | @@ -171,7 +171,7 @@ lto: ?std.zig.LtoMode = null, | ... | @@ -171,7 +171,7 @@ lto: ?std.zig.LtoMode = null, |
| 171 | 171 | ||
| 172 | dll_export_fns: ?bool = null, | 172 | dll_export_fns: ?bool = null, |
| 173 | 173 | ||
| 174 | subsystem: ?std.Target.SubSystem = null, | 174 | subsystem: ?std.zig.Subsystem = null, |
| 175 | 175 | ||
| 176 | /// (Windows) When targeting the MinGW ABI, use the unicode entry point (wmain/wWinMain) | 176 | /// (Windows) When targeting the MinGW ABI, use the unicode entry point (wmain/wWinMain) |
| 177 | mingw_unicode_entry_point: bool = false, | 177 | mingw_unicode_entry_point: bool = false, |
| ... | @@ -1764,16 +1764,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { | ... | @@ -1764,16 +1764,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { |
| 1764 | 1764 | ||
| 1765 | if (compile.subsystem) |subsystem| { | 1765 | if (compile.subsystem) |subsystem| { |
| 1766 | try zig_args.append("--subsystem"); | 1766 | try zig_args.append("--subsystem"); |
| 1767 | try zig_args.append(switch (subsystem) { | 1767 | try zig_args.append(@tagName(subsystem)); |
| 1768 | .Console => "console", | ||
| 1769 | .Windows => "windows", | ||
| 1770 | .Posix => "posix", | ||
| 1771 | .Native => "native", | ||
| 1772 | .EfiApplication => "efi_application", | ||
| 1773 | .EfiBootServiceDriver => "efi_boot_service_driver", | ||
| 1774 | .EfiRom => "efi_rom", | ||
| 1775 | .EfiRuntimeDriver => "efi_runtime_driver", | ||
| 1776 | }); | ||
| 1777 | } | 1768 | } |
| 1778 | 1769 | ||
| 1779 | if (compile.mingw_unicode_entry_point) { | 1770 | if (compile.mingw_unicode_entry_point) { |
lib/std/Target.zig+2-10| ... | @@ -1138,16 +1138,8 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE { | ... | @@ -1138,16 +1138,8 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE { |
| 1138 | }; | 1138 | }; |
| 1139 | } | 1139 | } |
| 1140 | 1140 | ||
| 1141 | pub const SubSystem = enum { | 1141 | /// Deprecated; use 'std.zig.Subsystem' instead. To be removed after 0.16.0 is tagged. |
| 1142 | Console, | 1142 | pub const SubSystem = std.zig.Subsystem; |
| 1143 | Windows, | ||
| 1144 | Posix, | ||
| 1145 | Native, | ||
| 1146 | EfiApplication, | ||
| 1147 | EfiBootServiceDriver, | ||
| 1148 | EfiRom, | ||
| 1149 | EfiRuntimeDriver, | ||
| 1150 | }; | ||
| 1151 | 1143 | ||
| 1152 | pub const Cpu = struct { | 1144 | pub const Cpu = struct { |
| 1153 | /// Architecture | 1145 | /// Architecture |
lib/std/builtin.zig-26| ... | @@ -6,32 +6,6 @@ const root = @import("root"); | ... | @@ -6,32 +6,6 @@ const root = @import("root"); |
| 6 | 6 | ||
| 7 | pub const assembly = @import("builtin/assembly.zig"); | 7 | pub const assembly = @import("builtin/assembly.zig"); |
| 8 | 8 | ||
| 9 | /// `explicit_subsystem` is missing when the subsystem is automatically detected, | ||
| 10 | /// so Zig standard library has the subsystem detection logic here. This should generally be | ||
| 11 | /// used rather than `explicit_subsystem`. | ||
| 12 | /// On non-Windows targets, this is `null`. | ||
| 13 | pub const subsystem: ?std.Target.SubSystem = blk: { | ||
| 14 | if (@hasDecl(builtin, "explicit_subsystem")) break :blk builtin.explicit_subsystem; | ||
| 15 | switch (builtin.os.tag) { | ||
| 16 | .windows => { | ||
| 17 | if (builtin.is_test) { | ||
| 18 | break :blk std.Target.SubSystem.Console; | ||
| 19 | } | ||
| 20 | if (@hasDecl(root, "main") or | ||
| 21 | @hasDecl(root, "WinMain") or | ||
| 22 | @hasDecl(root, "wWinMain") or | ||
| 23 | @hasDecl(root, "WinMainCRTStartup") or | ||
| 24 | @hasDecl(root, "wWinMainCRTStartup")) | ||
| 25 | { | ||
| 26 | break :blk std.Target.SubSystem.Windows; | ||
| 27 | } else { | ||
| 28 | break :blk std.Target.SubSystem.Console; | ||
| 29 | } | ||
| 30 | }, | ||
| 31 | else => break :blk null, | ||
| 32 | } | ||
| 33 | }; | ||
| 34 | |||
| 35 | /// This data structure is used by the Zig language code generation and | 9 | /// This data structure is used by the Zig language code generation and |
| 36 | /// therefore must be kept in sync with the compiler implementation. | 10 | /// therefore must be kept in sync with the compiler implementation. |
| 37 | pub const StackTrace = struct { | 11 | pub const StackTrace = struct { |
lib/std/start.zig+9-12| ... | @@ -734,24 +734,21 @@ pub fn call_wWinMain() std.os.windows.INT { | ... | @@ -734,24 +734,21 @@ pub fn call_wWinMain() std.os.windows.INT { |
| 734 | // - u32 in PEB.ProcessParameters.dwShowWindow | 734 | // - u32 in PEB.ProcessParameters.dwShowWindow |
| 735 | // Since STARTUPINFO is the bottleneck for the allowed values, we use `u16` as the | 735 | // Since STARTUPINFO is the bottleneck for the allowed values, we use `u16` as the |
| 736 | // type which can coerce into i32/c_int/u32 depending on how the user defines their wWinMain | 736 | // type which can coerce into i32/c_int/u32 depending on how the user defines their wWinMain |
| 737 | // (the Win32 docs show wWinMain with `int` as the type for nCmdShow). | 737 | // (the Win32 docs show wWinMain with `int` as the type for nShowCmd). |
| 738 | const nCmdShow: u16 = nCmdShow: { | 738 | const nShowCmd: u16 = nShowCmd: { |
| 739 | // This makes Zig match the nCmdShow behavior of a C program with a WinMain symbol: | 739 | // This makes Zig match the nShowCmd behavior of a C program with a WinMain symbol: |
| 740 | // - With STARTF_USESHOWWINDOW set in STARTUPINFO.dwFlags of the CreateProcess call: | 740 | // - With STARTF_USESHOWWINDOW set in STARTUPINFO.dwFlags of the CreateProcess call: |
| 741 | // - Compiled with subsystem:console -> nCmdShow is always SW_SHOWDEFAULT | 741 | // - nShowCmd is STARTUPINFO.wShowWindow from the parent CreateProcess call |
| 742 | // - Compiled with subsystem:windows -> nCmdShow is STARTUPINFO.wShowWindow from | ||
| 743 | // the parent CreateProcess call | ||
| 744 | // - With STARTF_USESHOWWINDOW unset: | 742 | // - With STARTF_USESHOWWINDOW unset: |
| 745 | // - nCmdShow is always SW_SHOWDEFAULT | 743 | // - nShowCmd is always SW_SHOWDEFAULT |
| 746 | const SW_SHOWDEFAULT = 10; | 744 | const SW_SHOWDEFAULT = 10; |
| 747 | const STARTF_USESHOWWINDOW = 1; | 745 | const STARTF_USESHOWWINDOW = 1; |
| 748 | // root having a wWinMain means that std.builtin.subsystem will always have a non-null value. | 746 | if (peb.ProcessParameters.dwFlags & STARTF_USESHOWWINDOW != 0) { |
| 749 | if (std.builtin.subsystem.? == .Windows and peb.ProcessParameters.dwFlags & STARTF_USESHOWWINDOW != 0) { | 747 | break :nShowCmd @truncate(peb.ProcessParameters.dwShowWindow); |
| 750 | break :nCmdShow @truncate(peb.ProcessParameters.dwShowWindow); | ||
| 751 | } | 748 | } |
| 752 | break :nCmdShow SW_SHOWDEFAULT; | 749 | break :nShowCmd SW_SHOWDEFAULT; |
| 753 | }; | 750 | }; |
| 754 | 751 | ||
| 755 | // second parameter hPrevInstance, MSDN: "This parameter is always NULL" | 752 | // second parameter hPrevInstance, MSDN: "This parameter is always NULL" |
| 756 | return root.wWinMain(hInstance, null, lpCmdLine, nCmdShow); | 753 | return root.wWinMain(hInstance, null, lpCmdLine, nShowCmd); |
| 757 | } | 754 | } |
lib/std/zig.zig+28| ... | @@ -349,6 +349,34 @@ pub const BuildId = union(enum) { | ... | @@ -349,6 +349,34 @@ pub const BuildId = union(enum) { |
| 349 | 349 | ||
| 350 | pub const LtoMode = enum { none, full, thin }; | 350 | pub const LtoMode = enum { none, full, thin }; |
| 351 | 351 | ||
| 352 | pub const Subsystem = enum { | ||
| 353 | console, | ||
| 354 | windows, | ||
| 355 | posix, | ||
| 356 | native, | ||
| 357 | efi_application, | ||
| 358 | efi_boot_service_driver, | ||
| 359 | efi_rom, | ||
| 360 | efi_runtime_driver, | ||
| 361 | |||
| 362 | /// Deprecated; use '.console' instead. To be removed after 0.16.0 is tagged. | ||
| 363 | pub const Console: Subsystem = .console; | ||
| 364 | /// Deprecated; use '.windows' instead. To be removed after 0.16.0 is tagged. | ||
| 365 | pub const Windows: Subsystem = .windows; | ||
| 366 | /// Deprecated; use '.posix' instead. To be removed after 0.16.0 is tagged. | ||
| 367 | pub const Posix: Subsystem = .posix; | ||
| 368 | /// Deprecated; use '.native' instead. To be removed after 0.16.0 is tagged. | ||
| 369 | pub const Native: Subsystem = .native; | ||
| 370 | /// Deprecated; use '.efi_application' instead. To be removed after 0.16.0 is tagged. | ||
| 371 | pub const EfiApplication: Subsystem = .efi_application; | ||
| 372 | /// Deprecated; use '.efi_boot_service_driver' instead. To be removed after 0.16.0 is tagged. | ||
| 373 | pub const EfiBootServiceDriver: Subsystem = .efi_boot_service_driver; | ||
| 374 | /// Deprecated; use '.efi_rom' instead. To be removed after 0.16.0 is tagged. | ||
| 375 | pub const EfiRom: Subsystem = .efi_rom; | ||
| 376 | /// Deprecated; use '.efi_runtime_driver' instead. To be removed after 0.16.0 is tagged. | ||
| 377 | pub const EfiRuntimeDriver: Subsystem = .efi_runtime_driver; | ||
| 378 | }; | ||
| 379 | |||
| 352 | /// Renders a `std.Target.Cpu` value into a textual representation that can be parsed | 380 | /// Renders a `std.Target.Cpu` value into a textual representation that can be parsed |
| 353 | /// via the `-mcpu` flag passed to the Zig compiler. | 381 | /// via the `-mcpu` flag passed to the Zig compiler. |
| 354 | /// Appends the result to `buffer`. | 382 | /// Appends the result to `buffer`. |
src/Compilation.zig+1-1| ... | @@ -1766,7 +1766,7 @@ pub const CreateOptions = struct { | ... | @@ -1766,7 +1766,7 @@ pub const CreateOptions = struct { |
| 1766 | reference_trace: ?u32 = null, | 1766 | reference_trace: ?u32 = null, |
| 1767 | test_filters: []const []const u8 = &.{}, | 1767 | test_filters: []const []const u8 = &.{}, |
| 1768 | test_runner_path: ?[]const u8 = null, | 1768 | test_runner_path: ?[]const u8 = null, |
| 1769 | subsystem: ?std.Target.SubSystem = null, | 1769 | subsystem: ?std.zig.Subsystem = null, |
| 1770 | mingw_unicode_entry_point: bool = false, | 1770 | mingw_unicode_entry_point: bool = false, |
| 1771 | /// (Zig compiler development) Enable dumping linker's state as JSON. | 1771 | /// (Zig compiler development) Enable dumping linker's state as JSON. |
| 1772 | enable_link_snapshots: bool = false, | 1772 | enable_link_snapshots: bool = false, |
src/link.zig+1-1| ... | @@ -448,7 +448,7 @@ pub const File = struct { | ... | @@ -448,7 +448,7 @@ pub const File = struct { |
| 448 | allow_shlib_undefined: ?bool, | 448 | allow_shlib_undefined: ?bool, |
| 449 | allow_undefined_version: bool, | 449 | allow_undefined_version: bool, |
| 450 | enable_new_dtags: ?bool, | 450 | enable_new_dtags: ?bool, |
| 451 | subsystem: ?std.Target.SubSystem, | 451 | subsystem: ?std.zig.Subsystem, |
| 452 | linker_script: ?[]const u8, | 452 | linker_script: ?[]const u8, |
| 453 | version_script: ?[]const u8, | 453 | version_script: ?[]const u8, |
| 454 | soname: ?[]const u8, | 454 | soname: ?[]const u8, |
src/link/Lld.zig+22-59| ... | @@ -19,7 +19,7 @@ const Coff = struct { | ... | @@ -19,7 +19,7 @@ const Coff = struct { |
| 19 | minor_subsystem_version: u16, | 19 | minor_subsystem_version: u16, |
| 20 | lib_directories: []const Cache.Directory, | 20 | lib_directories: []const Cache.Directory, |
| 21 | module_definition_file: ?[]const u8, | 21 | module_definition_file: ?[]const u8, |
| 22 | subsystem: ?std.Target.SubSystem, | 22 | subsystem: ?std.zig.Subsystem, |
| 23 | /// These flags are populated by `codegen.llvm.updateExports` to allow us to guess the subsystem. | 23 | /// These flags are populated by `codegen.llvm.updateExports` to allow us to guess the subsystem. |
| 24 | lld_export_flags: struct { | 24 | lld_export_flags: struct { |
| 25 | c_main: bool, | 25 | c_main: bool, |
| ... | @@ -554,7 +554,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -554,7 +554,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 554 | try argv.append(try allocPrint(arena, "-DEF:{s}", .{def})); | 554 | try argv.append(try allocPrint(arena, "-DEF:{s}", .{def})); |
| 555 | } | 555 | } |
| 556 | 556 | ||
| 557 | const resolved_subsystem: ?std.Target.SubSystem = blk: { | 557 | const resolved_subsystem: ?std.zig.Subsystem = blk: { |
| 558 | if (coff.subsystem) |explicit| break :blk explicit; | 558 | if (coff.subsystem) |explicit| break :blk explicit; |
| 559 | switch (target.os.tag) { | 559 | switch (target.os.tag) { |
| 560 | .windows => { | 560 | .windows => { |
| ... | @@ -565,13 +565,13 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -565,13 +565,13 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 565 | coff.lld_export_flags.winmain_crt_startup or | 565 | coff.lld_export_flags.winmain_crt_startup or |
| 566 | coff.lld_export_flags.wwinmain_crt_startup) | 566 | coff.lld_export_flags.wwinmain_crt_startup) |
| 567 | { | 567 | { |
| 568 | break :blk .Console; | 568 | break :blk .console; |
| 569 | } | 569 | } |
| 570 | if (coff.lld_export_flags.winmain or coff.lld_export_flags.wwinmain) | 570 | if (coff.lld_export_flags.winmain or coff.lld_export_flags.wwinmain) |
| 571 | break :blk .Windows; | 571 | break :blk .windows; |
| 572 | } | 572 | } |
| 573 | }, | 573 | }, |
| 574 | .uefi => break :blk .EfiApplication, | 574 | .uefi => break :blk .efi_application, |
| 575 | else => {}, | 575 | else => {}, |
| 576 | } | 576 | } |
| 577 | break :blk null; | 577 | break :blk null; |
| ... | @@ -580,60 +580,23 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -580,60 +580,23 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 580 | const Mode = enum { uefi, win32 }; | 580 | const Mode = enum { uefi, win32 }; |
| 581 | const mode: Mode = mode: { | 581 | const mode: Mode = mode: { |
| 582 | if (resolved_subsystem) |subsystem| { | 582 | if (resolved_subsystem) |subsystem| { |
| 583 | const subsystem_suffix = try allocPrint(arena, ",{d}.{d}", .{ | 583 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:{s},{d}.{d}", .{ |
| 584 | coff.major_subsystem_version, coff.minor_subsystem_version, | 584 | @tagName(subsystem), |
| 585 | }); | 585 | coff.major_subsystem_version, |
| 586 | 586 | coff.minor_subsystem_version, | |
| 587 | switch (subsystem) { | 587 | })); |
| 588 | .Console => { | 588 | break :mode switch (subsystem) { |
| 589 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:console{s}", .{ | 589 | .console, |
| 590 | subsystem_suffix, | 590 | .windows, |
| 591 | })); | 591 | .posix, |
| 592 | break :mode .win32; | 592 | .native, |
| 593 | }, | 593 | => .win32, |
| 594 | .EfiApplication => { | 594 | .efi_application, |
| 595 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:efi_application{s}", .{ | 595 | .efi_boot_service_driver, |
| 596 | subsystem_suffix, | 596 | .efi_rom, |
| 597 | })); | 597 | .efi_runtime_driver, |
| 598 | break :mode .uefi; | 598 | => .uefi, |
| 599 | }, | 599 | }; |
| 600 | .EfiBootServiceDriver => { | ||
| 601 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:efi_boot_service_driver{s}", .{ | ||
| 602 | subsystem_suffix, | ||
| 603 | })); | ||
| 604 | break :mode .uefi; | ||
| 605 | }, | ||
| 606 | .EfiRom => { | ||
| 607 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:efi_rom{s}", .{ | ||
| 608 | subsystem_suffix, | ||
| 609 | })); | ||
| 610 | break :mode .uefi; | ||
| 611 | }, | ||
| 612 | .EfiRuntimeDriver => { | ||
| 613 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:efi_runtime_driver{s}", .{ | ||
| 614 | subsystem_suffix, | ||
| 615 | })); | ||
| 616 | break :mode .uefi; | ||
| 617 | }, | ||
| 618 | .Native => { | ||
| 619 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:native{s}", .{ | ||
| 620 | subsystem_suffix, | ||
| 621 | })); | ||
| 622 | break :mode .win32; | ||
| 623 | }, | ||
| 624 | .Posix => { | ||
| 625 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:posix{s}", .{ | ||
| 626 | subsystem_suffix, | ||
| 627 | })); | ||
| 628 | break :mode .win32; | ||
| 629 | }, | ||
| 630 | .Windows => { | ||
| 631 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:windows{s}", .{ | ||
| 632 | subsystem_suffix, | ||
| 633 | })); | ||
| 634 | break :mode .win32; | ||
| 635 | }, | ||
| 636 | } | ||
| 637 | } else if (target.os.tag == .uefi) { | 600 | } else if (target.os.tag == .uefi) { |
| 638 | break :mode .uefi; | 601 | break :mode .uefi; |
| 639 | } else { | 602 | } else { |
src/main.zig+7-24| ... | @@ -893,7 +893,7 @@ fn buildOutputType( | ... | @@ -893,7 +893,7 @@ fn buildOutputType( |
| 893 | var override_global_cache_dir: ?[]const u8 = try EnvVar.ZIG_GLOBAL_CACHE_DIR.get(arena); | 893 | var override_global_cache_dir: ?[]const u8 = try EnvVar.ZIG_GLOBAL_CACHE_DIR.get(arena); |
| 894 | var override_lib_dir: ?[]const u8 = try EnvVar.ZIG_LIB_DIR.get(arena); | 894 | var override_lib_dir: ?[]const u8 = try EnvVar.ZIG_LIB_DIR.get(arena); |
| 895 | var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no; | 895 | var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no; |
| 896 | var subsystem: ?std.Target.SubSystem = null; | 896 | var subsystem: ?std.zig.Subsystem = null; |
| 897 | var major_subsystem_version: ?u16 = null; | 897 | var major_subsystem_version: ?u16 = null; |
| 898 | var minor_subsystem_version: ?u16 = null; | 898 | var minor_subsystem_version: ?u16 = null; |
| 899 | var mingw_unicode_entry_point: bool = false; | 899 | var mingw_unicode_entry_point: bool = false; |
| ... | @@ -1135,7 +1135,7 @@ fn buildOutputType( | ... | @@ -1135,7 +1135,7 @@ fn buildOutputType( |
| 1135 | } | 1135 | } |
| 1136 | n_jobs = num; | 1136 | n_jobs = num; |
| 1137 | } else if (mem.eql(u8, arg, "--subsystem")) { | 1137 | } else if (mem.eql(u8, arg, "--subsystem")) { |
| 1138 | subsystem = try parseSubSystem(args_iter.nextOrFatal()); | 1138 | subsystem = try parseSubsystem(args_iter.nextOrFatal()); |
| 1139 | } else if (mem.eql(u8, arg, "-O")) { | 1139 | } else if (mem.eql(u8, arg, "-O")) { |
| 1140 | mod_opts.optimize_mode = parseOptimizeMode(args_iter.nextOrFatal()); | 1140 | mod_opts.optimize_mode = parseOptimizeMode(args_iter.nextOrFatal()); |
| 1141 | } else if (mem.cutPrefix(u8, arg, "-fentry=")) |rest| { | 1141 | } else if (mem.cutPrefix(u8, arg, "-fentry=")) |rest| { |
| ... | @@ -2415,7 +2415,7 @@ fn buildOutputType( | ... | @@ -2415,7 +2415,7 @@ fn buildOutputType( |
| 2415 | } else if (mem.eql(u8, arg, "-rpath") or mem.eql(u8, arg, "--rpath") or mem.eql(u8, arg, "-R")) { | 2415 | } else if (mem.eql(u8, arg, "-rpath") or mem.eql(u8, arg, "--rpath") or mem.eql(u8, arg, "-R")) { |
| 2416 | try create_module.rpath_list.append(arena, linker_args_it.nextOrFatal()); | 2416 | try create_module.rpath_list.append(arena, linker_args_it.nextOrFatal()); |
| 2417 | } else if (mem.eql(u8, arg, "--subsystem")) { | 2417 | } else if (mem.eql(u8, arg, "--subsystem")) { |
| 2418 | subsystem = try parseSubSystem(linker_args_it.nextOrFatal()); | 2418 | subsystem = try parseSubsystem(linker_args_it.nextOrFatal()); |
| 2419 | } else if (mem.eql(u8, arg, "-I") or | 2419 | } else if (mem.eql(u8, arg, "-I") or |
| 2420 | mem.eql(u8, arg, "--dynamic-linker") or | 2420 | mem.eql(u8, arg, "--dynamic-linker") or |
| 2421 | mem.eql(u8, arg, "-dynamic-linker")) | 2421 | mem.eql(u8, arg, "-dynamic-linker")) |
| ... | @@ -2743,7 +2743,7 @@ fn buildOutputType( | ... | @@ -2743,7 +2743,7 @@ fn buildOutputType( |
| 2743 | try symbol_wrap_set.put(arena, next_arg, {}); | 2743 | try symbol_wrap_set.put(arena, next_arg, {}); |
| 2744 | } else if (mem.startsWith(u8, arg, "/subsystem:")) { | 2744 | } else if (mem.startsWith(u8, arg, "/subsystem:")) { |
| 2745 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); | 2745 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); |
| 2746 | subsystem = try parseSubSystem(split_it.first()); | 2746 | subsystem = try parseSubsystem(split_it.first()); |
| 2747 | } else if (mem.startsWith(u8, arg, "/implib:")) { | 2747 | } else if (mem.startsWith(u8, arg, "/implib:")) { |
| 2748 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); | 2748 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); |
| 2749 | emit_implib = .{ .yes = split_it.first() }; | 2749 | emit_implib = .{ .yes = split_it.first() }; |
| ... | @@ -6657,26 +6657,10 @@ fn warnAboutForeignBinaries( | ... | @@ -6657,26 +6657,10 @@ fn warnAboutForeignBinaries( |
| 6657 | } | 6657 | } |
| 6658 | } | 6658 | } |
| 6659 | 6659 | ||
| 6660 | fn parseSubSystem(next_arg: []const u8) !std.Target.SubSystem { | 6660 | fn parseSubsystem(arg: []const u8) !std.zig.Subsystem { |
| 6661 | if (mem.eql(u8, next_arg, "console")) { | 6661 | return std.meta.stringToEnum(std.zig.Subsystem, arg) orelse |
| 6662 | return .Console; | ||
| 6663 | } else if (mem.eql(u8, next_arg, "windows")) { | ||
| 6664 | return .Windows; | ||
| 6665 | } else if (mem.eql(u8, next_arg, "posix")) { | ||
| 6666 | return .Posix; | ||
| 6667 | } else if (mem.eql(u8, next_arg, "native")) { | ||
| 6668 | return .Native; | ||
| 6669 | } else if (mem.eql(u8, next_arg, "efi_application")) { | ||
| 6670 | return .EfiApplication; | ||
| 6671 | } else if (mem.eql(u8, next_arg, "efi_boot_service_driver")) { | ||
| 6672 | return .EfiBootServiceDriver; | ||
| 6673 | } else if (mem.eql(u8, next_arg, "efi_rom")) { | ||
| 6674 | return .EfiRom; | ||
| 6675 | } else if (mem.eql(u8, next_arg, "efi_runtime_driver")) { | ||
| 6676 | return .EfiRuntimeDriver; | ||
| 6677 | } else { | ||
| 6678 | fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{ | 6662 | fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{ |
| 6679 | next_arg, | 6663 | arg, |
| 6680 | \\ console | 6664 | \\ console |
| 6681 | \\ windows | 6665 | \\ windows |
| 6682 | \\ posix | 6666 | \\ posix |
| ... | @@ -6687,7 +6671,6 @@ fn parseSubSystem(next_arg: []const u8) !std.Target.SubSystem { | ... | @@ -6687,7 +6671,6 @@ fn parseSubSystem(next_arg: []const u8) !std.Target.SubSystem { |
| 6687 | \\ efi_runtime_driver | 6671 | \\ efi_runtime_driver |
| 6688 | \\ | 6672 | \\ |
| 6689 | }); | 6673 | }); |
| 6690 | } | ||
| 6691 | } | 6674 | } |
| 6692 | 6675 | ||
| 6693 | /// Model a header searchlist as a group. | 6676 | /// Model a header searchlist as a group. |
test/standalone/issue_5825/build.zig+1-1| ... | @@ -31,7 +31,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -31,7 +31,7 @@ pub fn build(b: *std.Build) void { |
| 31 | .target = target, | 31 | .target = target, |
| 32 | }), | 32 | }), |
| 33 | }); | 33 | }); |
| 34 | exe.subsystem = .Console; | 34 | exe.subsystem = .console; |
| 35 | exe.root_module.linkSystemLibrary("kernel32", .{}); | 35 | exe.root_module.linkSystemLibrary("kernel32", .{}); |
| 36 | exe.root_module.linkSystemLibrary("ntdll", .{}); | 36 | exe.root_module.linkSystemLibrary("ntdll", .{}); |
| 37 | exe.root_module.addObject(obj); | 37 | exe.root_module.addObject(obj); |
test/standalone/windows_entry_points/build.zig+2-2| ... | @@ -53,7 +53,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -53,7 +53,7 @@ pub fn build(b: *std.Build) void { |
| 53 | .link_libc = true, | 53 | .link_libc = true, |
| 54 | }), | 54 | }), |
| 55 | }); | 55 | }); |
| 56 | // Note: `exe.subsystem = .Windows;` is not necessary | 56 | // Note: `exe.subsystem = .windows;` is not necessary |
| 57 | exe.root_module.addCSourceFile(.{ .file = b.path("winmain.c") }); | 57 | exe.root_module.addCSourceFile(.{ .file = b.path("winmain.c") }); |
| 58 | 58 | ||
| 59 | _ = exe.getEmittedBin(); | 59 | _ = exe.getEmittedBin(); |
| ... | @@ -71,7 +71,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -71,7 +71,7 @@ pub fn build(b: *std.Build) void { |
| 71 | }), | 71 | }), |
| 72 | }); | 72 | }); |
| 73 | exe.mingw_unicode_entry_point = true; | 73 | exe.mingw_unicode_entry_point = true; |
| 74 | // Note: `exe.subsystem = .Windows;` is not necessary | 74 | // Note: `exe.subsystem = .windows;` is not necessary |
| 75 | exe.root_module.addCSourceFile(.{ .file = b.path("wwinmain.c") }); | 75 | exe.root_module.addCSourceFile(.{ .file = b.path("wwinmain.c") }); |
| 76 | 76 | ||
| 77 | _ = exe.getEmittedBin(); | 77 | _ = exe.getEmittedBin(); |