| author | |
| committer | |
| log | 54f2a7c833bf2ca0b370ebe2470bb0dd71206cba |
| tree | bad5322f30fbc01a0b842d8128659d43d947f82e |
| parent | 075d300342afa72f5328c0ee4232151dd0968264 |
Also updates the field names to conform with the rest of std.9 files changed, 66 insertions(+), 109 deletions(-)
lib/std/Build/Step/Compile.zig+2-11| ... | ... | @@ -171,7 +171,7 @@ lto: ?std.zig.LtoMode = null, |
| 171 | 171 | |
| 172 | 172 | dll_export_fns: ?bool = null, |
| 173 | 173 | |
| 174 | subsystem: ?std.Target.SubSystem = null, | |
| 174 | subsystem: ?std.zig.Subsystem = null, | |
| 175 | 175 | |
| 176 | 176 | /// (Windows) When targeting the MinGW ABI, use the unicode entry point (wmain/wWinMain) |
| 177 | 177 | mingw_unicode_entry_point: bool = false, |
| ... | ... | @@ -1764,16 +1764,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { |
| 1764 | 1764 | |
| 1765 | 1765 | if (compile.subsystem) |subsystem| { |
| 1766 | 1766 | try zig_args.append("--subsystem"); |
| 1767 | try zig_args.append(switch (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 | }); | |
| 1767 | try zig_args.append(@tagName(subsystem)); | |
| 1777 | 1768 | } |
| 1778 | 1769 | |
| 1779 | 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 | 1138 | }; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | pub const SubSystem = enum { | |
| 1142 | Console, | |
| 1143 | Windows, | |
| 1144 | Posix, | |
| 1145 | Native, | |
| 1146 | EfiApplication, | |
| 1147 | EfiBootServiceDriver, | |
| 1148 | EfiRom, | |
| 1149 | EfiRuntimeDriver, | |
| 1150 | }; | |
| 1141 | /// Deprecated; use 'std.zig.Subsystem' instead. To be removed after 0.16.0 is tagged. | |
| 1142 | pub const SubSystem = std.zig.Subsystem; | |
| 1151 | 1143 | |
| 1152 | 1144 | pub const Cpu = struct { |
| 1153 | 1145 | /// Architecture |
lib/std/zig.zig+28| ... | ... | @@ -349,6 +349,34 @@ pub const BuildId = union(enum) { |
| 349 | 349 | |
| 350 | 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 | 380 | /// Renders a `std.Target.Cpu` value into a textual representation that can be parsed |
| 353 | 381 | /// via the `-mcpu` flag passed to the Zig compiler. |
| 354 | 382 | /// Appends the result to `buffer`. |
src/Compilation.zig+1-1| ... | ... | @@ -1766,7 +1766,7 @@ pub const CreateOptions = struct { |
| 1766 | 1766 | reference_trace: ?u32 = null, |
| 1767 | 1767 | test_filters: []const []const u8 = &.{}, |
| 1768 | 1768 | test_runner_path: ?[]const u8 = null, |
| 1769 | subsystem: ?std.Target.SubSystem = null, | |
| 1769 | subsystem: ?std.zig.Subsystem = null, | |
| 1770 | 1770 | mingw_unicode_entry_point: bool = false, |
| 1771 | 1771 | /// (Zig compiler development) Enable dumping linker's state as JSON. |
| 1772 | 1772 | enable_link_snapshots: bool = false, |
src/link.zig+1-1| ... | ... | @@ -448,7 +448,7 @@ pub const File = struct { |
| 448 | 448 | allow_shlib_undefined: ?bool, |
| 449 | 449 | allow_undefined_version: bool, |
| 450 | 450 | enable_new_dtags: ?bool, |
| 451 | subsystem: ?std.Target.SubSystem, | |
| 451 | subsystem: ?std.zig.Subsystem, | |
| 452 | 452 | linker_script: ?[]const u8, |
| 453 | 453 | version_script: ?[]const u8, |
| 454 | 454 | soname: ?[]const u8, |
src/link/Lld.zig+22-59| ... | ... | @@ -19,7 +19,7 @@ const Coff = struct { |
| 19 | 19 | minor_subsystem_version: u16, |
| 20 | 20 | lib_directories: []const Cache.Directory, |
| 21 | 21 | module_definition_file: ?[]const u8, |
| 22 | subsystem: ?std.Target.SubSystem, | |
| 22 | subsystem: ?std.zig.Subsystem, | |
| 23 | 23 | /// These flags are populated by `codegen.llvm.updateExports` to allow us to guess the subsystem. |
| 24 | 24 | lld_export_flags: struct { |
| 25 | 25 | c_main: bool, |
| ... | ... | @@ -554,7 +554,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 554 | 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 | 558 | if (coff.subsystem) |explicit| break :blk explicit; |
| 559 | 559 | switch (target.os.tag) { |
| 560 | 560 | .windows => { |
| ... | ... | @@ -565,13 +565,13 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 565 | 565 | coff.lld_export_flags.winmain_crt_startup or |
| 566 | 566 | coff.lld_export_flags.wwinmain_crt_startup) |
| 567 | 567 | { |
| 568 | break :blk .Console; | |
| 568 | break :blk .console; | |
| 569 | 569 | } |
| 570 | 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 | 575 | else => {}, |
| 576 | 576 | } |
| 577 | 577 | break :blk null; |
| ... | ... | @@ -580,60 +580,23 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 580 | 580 | const Mode = enum { uefi, win32 }; |
| 581 | 581 | const mode: Mode = mode: { |
| 582 | 582 | if (resolved_subsystem) |subsystem| { |
| 583 | const subsystem_suffix = try allocPrint(arena, ",{d}.{d}", .{ | |
| 584 | coff.major_subsystem_version, coff.minor_subsystem_version, | |
| 585 | }); | |
| 586 | ||
| 587 | switch (subsystem) { | |
| 588 | .Console => { | |
| 589 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:console{s}", .{ | |
| 590 | subsystem_suffix, | |
| 591 | })); | |
| 592 | break :mode .win32; | |
| 593 | }, | |
| 594 | .EfiApplication => { | |
| 595 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:efi_application{s}", .{ | |
| 596 | subsystem_suffix, | |
| 597 | })); | |
| 598 | break :mode .uefi; | |
| 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 | } | |
| 583 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:{s},{d}.{d}", .{ | |
| 584 | @tagName(subsystem), | |
| 585 | coff.major_subsystem_version, | |
| 586 | coff.minor_subsystem_version, | |
| 587 | })); | |
| 588 | break :mode switch (subsystem) { | |
| 589 | .console, | |
| 590 | .windows, | |
| 591 | .posix, | |
| 592 | .native, | |
| 593 | => .win32, | |
| 594 | .efi_application, | |
| 595 | .efi_boot_service_driver, | |
| 596 | .efi_rom, | |
| 597 | .efi_runtime_driver, | |
| 598 | => .uefi, | |
| 599 | }; | |
| 637 | 600 | } else if (target.os.tag == .uefi) { |
| 638 | 601 | break :mode .uefi; |
| 639 | 602 | } else { |
src/main.zig+7-24| ... | ... | @@ -893,7 +893,7 @@ fn buildOutputType( |
| 893 | 893 | var override_global_cache_dir: ?[]const u8 = try EnvVar.ZIG_GLOBAL_CACHE_DIR.get(arena); |
| 894 | 894 | var override_lib_dir: ?[]const u8 = try EnvVar.ZIG_LIB_DIR.get(arena); |
| 895 | 895 | var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no; |
| 896 | var subsystem: ?std.Target.SubSystem = null; | |
| 896 | var subsystem: ?std.zig.Subsystem = null; | |
| 897 | 897 | var major_subsystem_version: ?u16 = null; |
| 898 | 898 | var minor_subsystem_version: ?u16 = null; |
| 899 | 899 | var mingw_unicode_entry_point: bool = false; |
| ... | ... | @@ -1135,7 +1135,7 @@ fn buildOutputType( |
| 1135 | 1135 | } |
| 1136 | 1136 | n_jobs = num; |
| 1137 | 1137 | } else if (mem.eql(u8, arg, "--subsystem")) { |
| 1138 | subsystem = try parseSubSystem(args_iter.nextOrFatal()); | |
| 1138 | subsystem = try parseSubsystem(args_iter.nextOrFatal()); | |
| 1139 | 1139 | } else if (mem.eql(u8, arg, "-O")) { |
| 1140 | 1140 | mod_opts.optimize_mode = parseOptimizeMode(args_iter.nextOrFatal()); |
| 1141 | 1141 | } else if (mem.cutPrefix(u8, arg, "-fentry=")) |rest| { |
| ... | ... | @@ -2415,7 +2415,7 @@ fn buildOutputType( |
| 2415 | 2415 | } else if (mem.eql(u8, arg, "-rpath") or mem.eql(u8, arg, "--rpath") or mem.eql(u8, arg, "-R")) { |
| 2416 | 2416 | try create_module.rpath_list.append(arena, linker_args_it.nextOrFatal()); |
| 2417 | 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 | 2419 | } else if (mem.eql(u8, arg, "-I") or |
| 2420 | 2420 | mem.eql(u8, arg, "--dynamic-linker") or |
| 2421 | 2421 | mem.eql(u8, arg, "-dynamic-linker")) |
| ... | ... | @@ -2743,7 +2743,7 @@ fn buildOutputType( |
| 2743 | 2743 | try symbol_wrap_set.put(arena, next_arg, {}); |
| 2744 | 2744 | } else if (mem.startsWith(u8, arg, "/subsystem:")) { |
| 2745 | 2745 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); |
| 2746 | subsystem = try parseSubSystem(split_it.first()); | |
| 2746 | subsystem = try parseSubsystem(split_it.first()); | |
| 2747 | 2747 | } else if (mem.startsWith(u8, arg, "/implib:")) { |
| 2748 | 2748 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); |
| 2749 | 2749 | emit_implib = .{ .yes = split_it.first() }; |
| ... | ... | @@ -6657,26 +6657,10 @@ fn warnAboutForeignBinaries( |
| 6657 | 6657 | } |
| 6658 | 6658 | } |
| 6659 | 6659 | |
| 6660 | fn parseSubSystem(next_arg: []const u8) !std.Target.SubSystem { | |
| 6661 | if (mem.eql(u8, next_arg, "console")) { | |
| 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 { | |
| 6660 | fn parseSubsystem(arg: []const u8) !std.zig.Subsystem { | |
| 6661 | return std.meta.stringToEnum(std.zig.Subsystem, arg) orelse | |
| 6678 | 6662 | fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{ |
| 6679 | next_arg, | |
| 6663 | arg, | |
| 6680 | 6664 | \\ console |
| 6681 | 6665 | \\ windows |
| 6682 | 6666 | \\ posix |
| ... | ... | @@ -6687,7 +6671,6 @@ fn parseSubSystem(next_arg: []const u8) !std.Target.SubSystem { |
| 6687 | 6671 | \\ efi_runtime_driver |
| 6688 | 6672 | \\ |
| 6689 | 6673 | }); |
| 6690 | } | |
| 6691 | 6674 | } |
| 6692 | 6675 | |
| 6693 | 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 | 31 | .target = target, |
| 32 | 32 | }), |
| 33 | 33 | }); |
| 34 | exe.subsystem = .Console; | |
| 34 | exe.subsystem = .console; | |
| 35 | 35 | exe.root_module.linkSystemLibrary("kernel32", .{}); |
| 36 | 36 | exe.root_module.linkSystemLibrary("ntdll", .{}); |
| 37 | 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 | 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 | 57 | exe.root_module.addCSourceFile(.{ .file = b.path("winmain.c") }); |
| 58 | 58 | |
| 59 | 59 | _ = exe.getEmittedBin(); |
| ... | ... | @@ -71,7 +71,7 @@ pub fn build(b: *std.Build) void { |
| 71 | 71 | }), |
| 72 | 72 | }); |
| 73 | 73 | exe.mingw_unicode_entry_point = true; |
| 74 | // Note: `exe.subsystem = .Windows;` is not necessary | |
| 74 | // Note: `exe.subsystem = .windows;` is not necessary | |
| 75 | 75 | exe.root_module.addCSourceFile(.{ .file = b.path("wwinmain.c") }); |
| 76 | 76 | |
| 77 | 77 | _ = exe.getEmittedBin(); |