authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-18 19:20:23+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-04-18 19:20:23+02:00
log5195b87639a1dc56b90751d0aecc4fcf4f2a1bb0
tree774ce60e408b3357bb71be106d808a1c826875a1
parentf8d2b87fa122a948e2c8e1056e2ec4cfd4cf01bf
parentb2344cc18e9fa5dfa1d19025caa2b0f583498734
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #11396 from wojtekmach/wm-zig-cc-subsystem

zig cc: support --subsystem linker flag

1 files changed, 40 insertions(+), 30 deletions(-)

src/main.zig+40-30
......@@ -849,36 +849,7 @@ fn buildOutputType(
849849 const next_arg = args_iter.next() orelse {
850850 fatal("expected parameter after {s}", .{arg});
851851 };
852 if (mem.eql(u8, next_arg, "console")) {
853 subsystem = .Console;
854 } else if (mem.eql(u8, next_arg, "windows")) {
855 subsystem = .Windows;
856 } else if (mem.eql(u8, next_arg, "posix")) {
857 subsystem = .Posix;
858 } else if (mem.eql(u8, next_arg, "native")) {
859 subsystem = .Native;
860 } else if (mem.eql(u8, next_arg, "efi_application")) {
861 subsystem = .EfiApplication;
862 } else if (mem.eql(u8, next_arg, "efi_boot_service_driver")) {
863 subsystem = .EfiBootServiceDriver;
864 } else if (mem.eql(u8, next_arg, "efi_rom")) {
865 subsystem = .EfiRom;
866 } else if (mem.eql(u8, next_arg, "efi_runtime_driver")) {
867 subsystem = .EfiRuntimeDriver;
868 } else {
869 fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{
870 next_arg,
871 \\ console
872 \\ windows
873 \\ posix
874 \\ native
875 \\ efi_application
876 \\ efi_boot_service_driver
877 \\ efi_rom
878 \\ efi_runtime_driver
879 \\
880 });
881 }
852 subsystem = try parseSubSystem(next_arg);
882853 } else if (mem.eql(u8, arg, "-O")) {
883854 optimize_mode_string = args_iter.next() orelse {
884855 fatal("expected parameter after {s}", .{arg});
......@@ -1610,6 +1581,12 @@ fn buildOutputType(
16101581 fatal("expected linker arg after '{s}'", .{arg});
16111582 }
16121583 try rpath_list.append(linker_args.items[i]);
1584 } else if (mem.eql(u8, arg, "--subsystem")) {
1585 i += 1;
1586 if (i >= linker_args.items.len) {
1587 fatal("expected linker arg after '{s}'", .{arg});
1588 }
1589 subsystem = try parseSubSystem(linker_args.items[i]);
16131590 } else if (mem.eql(u8, arg, "-I") or
16141591 mem.eql(u8, arg, "--dynamic-linker") or
16151592 mem.eql(u8, arg, "-dynamic-linker"))
......@@ -5132,3 +5109,36 @@ fn warnAboutForeignBinaries(
51325109 },
51335110 }
51345111}
5112
5113fn parseSubSystem(next_arg: []const u8) !std.Target.SubSystem {
5114 if (mem.eql(u8, next_arg, "console")) {
5115 return .Console;
5116 } else if (mem.eql(u8, next_arg, "windows")) {
5117 return .Windows;
5118 } else if (mem.eql(u8, next_arg, "posix")) {
5119 return .Posix;
5120 } else if (mem.eql(u8, next_arg, "native")) {
5121 return .Native;
5122 } else if (mem.eql(u8, next_arg, "efi_application")) {
5123 return .EfiApplication;
5124 } else if (mem.eql(u8, next_arg, "efi_boot_service_driver")) {
5125 return .EfiBootServiceDriver;
5126 } else if (mem.eql(u8, next_arg, "efi_rom")) {
5127 return .EfiRom;
5128 } else if (mem.eql(u8, next_arg, "efi_runtime_driver")) {
5129 return .EfiRuntimeDriver;
5130 } else {
5131 fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{
5132 next_arg,
5133 \\ console
5134 \\ windows
5135 \\ posix
5136 \\ native
5137 \\ efi_application
5138 \\ efi_boot_service_driver
5139 \\ efi_rom
5140 \\ efi_runtime_driver
5141 \\
5142 });
5143 }
5144}