| author | |
| committer | |
| log | a9082b4ec51debdbffc20b56e9b37cb82dd04750 |
| tree | 251eaeee7562ee64757b3a171cd327c4d23a116c |
| parent | 4b403c7eaca50815cae8f2ddde19b4fb476ae8ca |
4 files changed, 44 insertions(+), 2 deletions(-)
BRANCH_TODO-1| ... | @@ -1,4 +1,3 @@ | ... | @@ -1,4 +1,3 @@ |
| 1 | * subsystem | ||
| 2 | * COFF LLD linking | 1 | * COFF LLD linking |
| 3 | * mingw-w64 | 2 | * mingw-w64 |
| 4 | * MachO LLD linking | 3 | * MachO LLD linking |
src/Compilation.zig+7-1| ... | @@ -377,6 +377,7 @@ pub const InitOptions = struct { | ... | @@ -377,6 +377,7 @@ pub const InitOptions = struct { |
| 377 | color: @import("main.zig").Color = .Auto, | 377 | color: @import("main.zig").Color = .Auto, |
| 378 | test_filter: ?[]const u8 = null, | 378 | test_filter: ?[]const u8 = null, |
| 379 | test_name_prefix: ?[]const u8 = null, | 379 | test_name_prefix: ?[]const u8 = null, |
| 380 | subsystem: ?std.Target.SubSystem = null, | ||
| 380 | }; | 381 | }; |
| 381 | 382 | ||
| 382 | pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | 383 | pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| ... | @@ -767,6 +768,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -767,6 +768,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 767 | .is_compiler_rt_or_libc = options.is_compiler_rt_or_libc, | 768 | .is_compiler_rt_or_libc = options.is_compiler_rt_or_libc, |
| 768 | .each_lib_rpath = options.each_lib_rpath orelse false, | 769 | .each_lib_rpath = options.each_lib_rpath orelse false, |
| 769 | .disable_lld_caching = options.disable_lld_caching, | 770 | .disable_lld_caching = options.disable_lld_caching, |
| 771 | .subsystem = options.subsystem, | ||
| 770 | }); | 772 | }); |
| 771 | errdefer bin_file.destroy(); | 773 | errdefer bin_file.destroy(); |
| 772 | comp.* = .{ | 774 | comp.* = .{ |
| ... | @@ -2557,6 +2559,10 @@ fn updateStage1Module(comp: *Compilation) !void { | ... | @@ -2557,6 +2559,10 @@ fn updateStage1Module(comp: *Compilation) !void { |
| 2557 | const stage1_pkg = try createStage1Pkg(arena, "root", mod.root_pkg, null); | 2559 | const stage1_pkg = try createStage1Pkg(arena, "root", mod.root_pkg, null); |
| 2558 | const test_filter = comp.test_filter orelse ""[0..0]; | 2560 | const test_filter = comp.test_filter orelse ""[0..0]; |
| 2559 | const test_name_prefix = comp.test_name_prefix orelse ""[0..0]; | 2561 | const test_name_prefix = comp.test_name_prefix orelse ""[0..0]; |
| 2562 | const subsystem = if (comp.bin_file.options.subsystem) |s| | ||
| 2563 | @intToEnum(stage1.TargetSubsystem, @enumToInt(s)) | ||
| 2564 | else | ||
| 2565 | stage1.TargetSubsystem.Auto; | ||
| 2560 | stage1_module.* = .{ | 2566 | stage1_module.* = .{ |
| 2561 | .root_name_ptr = comp.bin_file.options.root_name.ptr, | 2567 | .root_name_ptr = comp.bin_file.options.root_name.ptr, |
| 2562 | .root_name_len = comp.bin_file.options.root_name.len, | 2568 | .root_name_len = comp.bin_file.options.root_name.len, |
| ... | @@ -2581,7 +2587,7 @@ fn updateStage1Module(comp: *Compilation) !void { | ... | @@ -2581,7 +2587,7 @@ fn updateStage1Module(comp: *Compilation) !void { |
| 2581 | .userdata = @ptrToInt(comp), | 2587 | .userdata = @ptrToInt(comp), |
| 2582 | .root_pkg = stage1_pkg, | 2588 | .root_pkg = stage1_pkg, |
| 2583 | .code_model = @enumToInt(comp.bin_file.options.machine_code_model), | 2589 | .code_model = @enumToInt(comp.bin_file.options.machine_code_model), |
| 2584 | .subsystem = stage1.TargetSubsystem.Auto, | 2590 | .subsystem = subsystem, |
| 2585 | .err_color = @enumToInt(comp.color), | 2591 | .err_color = @enumToInt(comp.color), |
| 2586 | .pic = comp.bin_file.options.pic, | 2592 | .pic = comp.bin_file.options.pic, |
| 2587 | .link_libc = comp.bin_file.options.link_libc, | 2593 | .link_libc = comp.bin_file.options.link_libc, |
src/link.zig+1| ... | @@ -77,6 +77,7 @@ pub const Options = struct { | ... | @@ -77,6 +77,7 @@ pub const Options = struct { |
| 77 | disable_lld_caching: bool, | 77 | disable_lld_caching: bool, |
| 78 | gc_sections: ?bool = null, | 78 | gc_sections: ?bool = null, |
| 79 | allow_shlib_undefined: ?bool = null, | 79 | allow_shlib_undefined: ?bool = null, |
| 80 | subsystem: ?std.Target.SubSystem = null, | ||
| 80 | linker_script: ?[]const u8 = null, | 81 | linker_script: ?[]const u8 = null, |
| 81 | version_script: ?[]const u8 = null, | 82 | version_script: ?[]const u8 = null, |
| 82 | override_soname: ?[]const u8 = null, | 83 | override_soname: ?[]const u8 = null, |
src/main.zig+36| ... | @@ -273,6 +273,7 @@ const usage_build_generic = | ... | @@ -273,6 +273,7 @@ const usage_build_generic = |
| 273 | \\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker | 273 | \\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker |
| 274 | \\ -dynamic Force output to be dynamically linked | 274 | \\ -dynamic Force output to be dynamically linked |
| 275 | \\ -static Force output to be statically linked | 275 | \\ -static Force output to be statically linked |
| 276 | \\ --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n" | ||
| 276 | \\ | 277 | \\ |
| 277 | \\Test Options: | 278 | \\Test Options: |
| 278 | \\ --test-filter [text] Skip tests that do not match filter | 279 | \\ --test-filter [text] Skip tests that do not match filter |
| ... | @@ -439,6 +440,7 @@ fn buildOutputType( | ... | @@ -439,6 +440,7 @@ fn buildOutputType( |
| 439 | var override_lib_dir: ?[]const u8 = null; | 440 | var override_lib_dir: ?[]const u8 = null; |
| 440 | var main_pkg_path: ?[]const u8 = null; | 441 | var main_pkg_path: ?[]const u8 = null; |
| 441 | var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no; | 442 | var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no; |
| 443 | var subsystem: ?std.Target.SubSystem = null; | ||
| 442 | 444 | ||
| 443 | var system_libs = std.ArrayList([]const u8).init(gpa); | 445 | var system_libs = std.ArrayList([]const u8).init(gpa); |
| 444 | defer system_libs.deinit(); | 446 | defer system_libs.deinit(); |
| ... | @@ -575,6 +577,39 @@ fn buildOutputType( | ... | @@ -575,6 +577,39 @@ fn buildOutputType( |
| 575 | } else { | 577 | } else { |
| 576 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); | 578 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); |
| 577 | } | 579 | } |
| 580 | } else if (mem.eql(u8, arg, "--subsystem")) { | ||
| 581 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); | ||
| 582 | i += 1; | ||
| 583 | if (mem.eql(u8, args[i], "console")) { | ||
| 584 | subsystem = .Console; | ||
| 585 | } else if (mem.eql(u8, args[i], "windows")) { | ||
| 586 | subsystem = .Windows; | ||
| 587 | } else if (mem.eql(u8, args[i], "posix")) { | ||
| 588 | subsystem = .Posix; | ||
| 589 | } else if (mem.eql(u8, args[i], "native")) { | ||
| 590 | subsystem = .Native; | ||
| 591 | } else if (mem.eql(u8, args[i], "efi_application")) { | ||
| 592 | subsystem = .EfiApplication; | ||
| 593 | } else if (mem.eql(u8, args[i], "efi_boot_service_driver")) { | ||
| 594 | subsystem = .EfiBootServiceDriver; | ||
| 595 | } else if (mem.eql(u8, args[i], "efi_rom")) { | ||
| 596 | subsystem = .EfiRom; | ||
| 597 | } else if (mem.eql(u8, args[i], "efi_runtime_driver")) { | ||
| 598 | subsystem = .EfiRuntimeDriver; | ||
| 599 | } else { | ||
| 600 | fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{ | ||
| 601 | args[i], | ||
| 602 | \\ console | ||
| 603 | \\ windows | ||
| 604 | \\ posix | ||
| 605 | \\ native | ||
| 606 | \\ efi_application | ||
| 607 | \\ efi_boot_service_driver | ||
| 608 | \\ efi_rom | ||
| 609 | \\ efi_runtime_driver | ||
| 610 | \\ | ||
| 611 | }); | ||
| 612 | } | ||
| 578 | } else if (mem.eql(u8, arg, "-O")) { | 613 | } else if (mem.eql(u8, arg, "-O")) { |
| 579 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); | 614 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); |
| 580 | i += 1; | 615 | i += 1; |
| ... | @@ -1539,6 +1574,7 @@ fn buildOutputType( | ... | @@ -1539,6 +1574,7 @@ fn buildOutputType( |
| 1539 | .test_filter = test_filter, | 1574 | .test_filter = test_filter, |
| 1540 | .test_name_prefix = test_name_prefix, | 1575 | .test_name_prefix = test_name_prefix, |
| 1541 | .disable_lld_caching = !have_enable_cache, | 1576 | .disable_lld_caching = !have_enable_cache, |
| 1577 | .subsystem = subsystem, | ||
| 1542 | }) catch |err| { | 1578 | }) catch |err| { |
| 1543 | fatal("unable to create compilation: {}", .{@errorName(err)}); | 1579 | fatal("unable to create compilation: {}", .{@errorName(err)}); |
| 1544 | }; | 1580 | }; |