| author | |
| committer | |
| log | 3661133f989fefa64c58447dd0073b8c0e8050fc |
| tree | c1cd62ba6278ab912f9fcdbc0b6ea27778b2dc10 |
| parent | c808e546a766192c4a9bd45190d4bcfae61d6f3b |
| parent | bad9efbcc140ce5e9837ef06652610636593c1d0 |
| signature |
mingw: support -municode15 files changed, 231 insertions(+), 26 deletions(-)
lib/libc/mingw/crt/crtexewin.c created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | /** | |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | |
| 3 | * This file is part of the mingw-w64 runtime package. | |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | |
| 5 | */ | |
| 6 | #include <windows.h> | |
| 7 | #include <tchar.h> | |
| 8 | #include <corecrt_startup.h> | |
| 9 | ||
| 10 | #ifndef _UNICODE | |
| 11 | #include <mbctype.h> | |
| 12 | #endif | |
| 13 | ||
| 14 | #define SPACECHAR _T(' ') | |
| 15 | #define DQUOTECHAR _T('\"') | |
| 16 | ||
| 17 | extern IMAGE_DOS_HEADER __ImageBase; | |
| 18 | ||
| 19 | int _tmain (int, _TCHAR **, _TCHAR **); | |
| 20 | int _tmain (int __UNUSED_PARAM(argc), | |
| 21 | _TCHAR ** __UNUSED_PARAM(argv), | |
| 22 | _TCHAR ** __UNUSED_PARAM(envp)) | |
| 23 | { | |
| 24 | HINSTANCE hInstance; | |
| 25 | _TCHAR *lpCmdLine; | |
| 26 | DWORD nShowCmd; | |
| 27 | ||
| 28 | hInstance = (HINSTANCE) &__ImageBase; | |
| 29 | ||
| 30 | #ifdef _UNICODE | |
| 31 | lpCmdLine = _wcmdln; | |
| 32 | #else | |
| 33 | lpCmdLine = _acmdln; | |
| 34 | #endif | |
| 35 | if (lpCmdLine) | |
| 36 | { | |
| 37 | BOOL inDoubleQuote = FALSE; | |
| 38 | while (*lpCmdLine > SPACECHAR || (*lpCmdLine && inDoubleQuote)) | |
| 39 | { | |
| 40 | if (*lpCmdLine == DQUOTECHAR) | |
| 41 | inDoubleQuote = !inDoubleQuote; | |
| 42 | #ifndef _UNICODE | |
| 43 | if (_ismbblead (*lpCmdLine)) | |
| 44 | { | |
| 45 | if (lpCmdLine[1]) | |
| 46 | ++lpCmdLine; | |
| 47 | } | |
| 48 | #endif | |
| 49 | ++lpCmdLine; | |
| 50 | } | |
| 51 | while (*lpCmdLine && (*lpCmdLine <= SPACECHAR)) | |
| 52 | lpCmdLine++; | |
| 53 | } | |
| 54 | else | |
| 55 | lpCmdLine = _TEXT(""); | |
| 56 | ||
| 57 | { | |
| 58 | STARTUPINFO StartupInfo; | |
| 59 | memset (&StartupInfo, 0, sizeof (STARTUPINFO)); | |
| 60 | GetStartupInfo (&StartupInfo); | |
| 61 | if (StartupInfo.dwFlags & STARTF_USESHOWWINDOW) | |
| 62 | nShowCmd = StartupInfo.wShowWindow; | |
| 63 | else | |
| 64 | nShowCmd = SW_SHOWDEFAULT; | |
| 65 | } | |
| 66 | ||
| 67 | return _tWinMain (hInstance, NULL, lpCmdLine, nShowCmd); | |
| 68 | } |
lib/libc/mingw/crt/ucrtexewin.c created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | /** | |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | |
| 3 | * This file is part of the mingw-w64 runtime package. | |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | |
| 5 | */ | |
| 6 | ||
| 7 | #ifndef UNICODE | |
| 8 | #define UNICODE | |
| 9 | #endif | |
| 10 | #ifndef _UNICODE | |
| 11 | #define _UNICODE | |
| 12 | #endif | |
| 13 | ||
| 14 | #include "crtexewin.c" |
lib/std/Build/Step/Compile.zig+7| ... | ... | @@ -161,6 +161,9 @@ dll_export_fns: ?bool = null, |
| 161 | 161 | |
| 162 | 162 | subsystem: ?std.Target.SubSystem = null, |
| 163 | 163 | |
| 164 | /// (Windows) When targeting the MinGW ABI, use the unicode entry point (wmain/wWinMain) | |
| 165 | mingw_unicode_entry_point: bool = false, | |
| 166 | ||
| 164 | 167 | /// How the linker must handle the entry point of the executable. |
| 165 | 168 | entry: Entry = .default, |
| 166 | 169 | |
| ... | ... | @@ -1583,6 +1586,10 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1583 | 1586 | }); |
| 1584 | 1587 | } |
| 1585 | 1588 | |
| 1589 | if (self.mingw_unicode_entry_point) { | |
| 1590 | try zig_args.append("-municode"); | |
| 1591 | } | |
| 1592 | ||
| 1586 | 1593 | if (self.error_limit) |err_limit| try zig_args.appendSlice(&.{ |
| 1587 | 1594 | "--error-limit", |
| 1588 | 1595 | b.fmt("{}", .{err_limit}), |
src/Compilation.zig+5-2| ... | ... | @@ -173,6 +173,7 @@ global_cache_directory: Directory, |
| 173 | 173 | libc_include_dir_list: []const []const u8, |
| 174 | 174 | libc_framework_dir_list: []const []const u8, |
| 175 | 175 | rc_includes: RcIncludes, |
| 176 | mingw_unicode_entry_point: bool, | |
| 176 | 177 | thread_pool: *ThreadPool, |
| 177 | 178 | |
| 178 | 179 | /// Populated when we build the libc++ static library. A Job to build this is placed in the queue |
| ... | ... | @@ -758,7 +759,7 @@ pub const MiscTask = enum { |
| 758 | 759 | |
| 759 | 760 | @"mingw-w64 crt2.o", |
| 760 | 761 | @"mingw-w64 dllcrt2.o", |
| 761 | @"mingw-w64 mingwex.lib", | |
| 762 | @"mingw-w64 mingw32.lib", | |
| 762 | 763 | }; |
| 763 | 764 | |
| 764 | 765 | pub const MiscError = struct { |
| ... | ... | @@ -1101,6 +1102,7 @@ pub const CreateOptions = struct { |
| 1101 | 1102 | test_name_prefix: ?[]const u8 = null, |
| 1102 | 1103 | test_runner_path: ?[]const u8 = null, |
| 1103 | 1104 | subsystem: ?std.Target.SubSystem = null, |
| 1105 | mingw_unicode_entry_point: bool = false, | |
| 1104 | 1106 | /// (Zig compiler development) Enable dumping linker's state as JSON. |
| 1105 | 1107 | enable_link_snapshots: bool = false, |
| 1106 | 1108 | /// (Darwin) Install name of the dylib |
| ... | ... | @@ -1427,6 +1429,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1427 | 1429 | .libc_include_dir_list = libc_dirs.libc_include_dir_list, |
| 1428 | 1430 | .libc_framework_dir_list = libc_dirs.libc_framework_dir_list, |
| 1429 | 1431 | .rc_includes = options.rc_includes, |
| 1432 | .mingw_unicode_entry_point = options.mingw_unicode_entry_point, | |
| 1430 | 1433 | .thread_pool = options.thread_pool, |
| 1431 | 1434 | .clang_passthrough_mode = options.clang_passthrough_mode, |
| 1432 | 1435 | .clang_preprocessor_mode = options.clang_preprocessor_mode, |
| ... | ... | @@ -1768,7 +1771,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1768 | 1771 | |
| 1769 | 1772 | const crt_job: Job = .{ .mingw_crt_file = if (is_dyn_lib) .dllcrt2_o else .crt2_o }; |
| 1770 | 1773 | try comp.work_queue.ensureUnusedCapacity(2); |
| 1771 | comp.work_queue.writeItemAssumeCapacity(.{ .mingw_crt_file = .mingwex_lib }); | |
| 1774 | comp.work_queue.writeItemAssumeCapacity(.{ .mingw_crt_file = .mingw32_lib }); | |
| 1772 | 1775 | comp.work_queue.writeItemAssumeCapacity(crt_job); |
| 1773 | 1776 | |
| 1774 | 1777 | // When linking mingw-w64 there are some import libs we always need. |
src/clang_options_data.zig+8-1| ... | ... | @@ -6895,7 +6895,14 @@ joinpd1("mdouble="), |
| 6895 | 6895 | joinpd1("mfpmath="), |
| 6896 | 6896 | joinpd1("mhwmult="), |
| 6897 | 6897 | joinpd1("mthreads"), |
| 6898 | joinpd1("municode"), | |
| 6898 | .{ | |
| 6899 | .name = "municode", | |
| 6900 | .syntax = .joined, | |
| 6901 | .zig_equivalent = .mingw_unicode_entry_point, | |
| 6902 | .pd1 = true, | |
| 6903 | .pd2 = false, | |
| 6904 | .psl = false, | |
| 6905 | }, | |
| 6899 | 6906 | joinpd1("mwindows"), |
| 6900 | 6907 | .{ |
| 6901 | 6908 | .name = "offload=", |
src/link/Coff/lld.zig+1-1| ... | ... | @@ -409,7 +409,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) |
| 409 | 409 | try argv.append(try comp.get_libc_crt_file(arena, "crt2.obj")); |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib")); | |
| 412 | try argv.append(try comp.get_libc_crt_file(arena, "mingw32.lib")); | |
| 413 | 413 | } else { |
| 414 | 414 | const lib_str = switch (comp.config.link_mode) { |
| 415 | 415 | .dynamic => "", |
src/main.zig+7| ... | ... | @@ -450,6 +450,7 @@ const usage_build_generic = |
| 450 | 450 | \\ -fstructured-cfg (SPIR-V) force SPIR-V kernels to use structured control flow |
| 451 | 451 | \\ -fno-structured-cfg (SPIR-V) force SPIR-V kernels to not use structured control flow |
| 452 | 452 | \\ -mexec-model=[value] (WASI) Execution model |
| 453 | \\ -municode (Windows) Use wmain/wWinMain as entry point | |
| 453 | 454 | \\ |
| 454 | 455 | \\Per-Module Compile Options: |
| 455 | 456 | \\ -target [name] <arch><sub>-<os>-<abi> see the targets command |
| ... | ... | @@ -893,6 +894,7 @@ fn buildOutputType( |
| 893 | 894 | var subsystem: ?std.Target.SubSystem = null; |
| 894 | 895 | var major_subsystem_version: ?u16 = null; |
| 895 | 896 | var minor_subsystem_version: ?u16 = null; |
| 897 | var mingw_unicode_entry_point: bool = false; | |
| 896 | 898 | var enable_link_snapshots: bool = false; |
| 897 | 899 | var debug_incremental: bool = false; |
| 898 | 900 | var install_name: ?[]const u8 = null; |
| ... | ... | @@ -1686,6 +1688,8 @@ fn buildOutputType( |
| 1686 | 1688 | } |
| 1687 | 1689 | } else if (mem.startsWith(u8, arg, "-mexec-model=")) { |
| 1688 | 1690 | create_module.opts.wasi_exec_model = parseWasiExecModel(arg["-mexec-model=".len..]); |
| 1691 | } else if (mem.eql(u8, arg, "-municode")) { | |
| 1692 | mingw_unicode_entry_point = true; | |
| 1689 | 1693 | } else { |
| 1690 | 1694 | fatal("unrecognized parameter: '{s}'", .{arg}); |
| 1691 | 1695 | } |
| ... | ... | @@ -2091,6 +2095,7 @@ fn buildOutputType( |
| 2091 | 2095 | try force_undefined_symbols.put(arena, it.only_arg, {}); |
| 2092 | 2096 | }, |
| 2093 | 2097 | .force_load_objc => force_load_objc = true, |
| 2098 | .mingw_unicode_entry_point => mingw_unicode_entry_point = true, | |
| 2094 | 2099 | .weak_library => try create_module.system_libs.put(arena, it.only_arg, .{ |
| 2095 | 2100 | .needed = false, |
| 2096 | 2101 | .weak = true, |
| ... | ... | @@ -3229,6 +3234,7 @@ fn buildOutputType( |
| 3229 | 3234 | .rc_source_files = create_module.rc_source_files.items, |
| 3230 | 3235 | .manifest_file = manifest_file, |
| 3231 | 3236 | .rc_includes = rc_includes, |
| 3237 | .mingw_unicode_entry_point = mingw_unicode_entry_point, | |
| 3232 | 3238 | .link_objects = create_module.link_objects.items, |
| 3233 | 3239 | .framework_dirs = create_module.framework_dirs.items, |
| 3234 | 3240 | .frameworks = resolved_frameworks.items, |
| ... | ... | @@ -5792,6 +5798,7 @@ pub const ClangArgIterator = struct { |
| 5792 | 5798 | install_name, |
| 5793 | 5799 | undefined, |
| 5794 | 5800 | force_load_objc, |
| 5801 | mingw_unicode_entry_point, | |
| 5795 | 5802 | }; |
| 5796 | 5803 | |
| 5797 | 5804 | const Args = struct { |
src/mingw.zig+18-22| ... | ... | @@ -13,7 +13,7 @@ const Cache = std.Build.Cache; |
| 13 | 13 | pub const CRTFile = enum { |
| 14 | 14 | crt2_o, |
| 15 | 15 | dllcrt2_o, |
| 16 | mingwex_lib, | |
| 16 | mingw32_lib, | |
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | 19 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void { |
| ... | ... | @@ -28,14 +28,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 28 | 28 | .crt2_o => { |
| 29 | 29 | var args = std.ArrayList([]const u8).init(arena); |
| 30 | 30 | try add_cc_args(comp, arena, &args); |
| 31 | try args.appendSlice(&[_][]const u8{ | |
| 32 | // Prevents warning: 'used' attribute ignored on a non-definition declaration | |
| 33 | // pointing at extern _CRTALLOC | |
| 34 | "-Wno-ignored-attributes", | |
| 35 | // Uncommenting this makes mingw-w64 look for wmain instead of main. | |
| 36 | //"-DUNICODE", | |
| 37 | //"-D_UNICODE", | |
| 38 | }); | |
| 31 | if (comp.mingw_unicode_entry_point) { | |
| 32 | try args.appendSlice(&.{ "-DUNICODE", "-D_UNICODE" }); | |
| 33 | } | |
| 39 | 34 | var files = [_]Compilation.CSourceFile{ |
| 40 | 35 | .{ |
| 41 | 36 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -63,12 +58,12 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 63 | 58 | return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", prog_node, &files); |
| 64 | 59 | }, |
| 65 | 60 | |
| 66 | .mingwex_lib => { | |
| 61 | .mingw32_lib => { | |
| 67 | 62 | var args = std.ArrayList([]const u8).init(arena); |
| 68 | 63 | try add_cc_args(comp, arena, &args); |
| 69 | 64 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 70 | 65 | |
| 71 | for (mingwex_generic_src) |dep| { | |
| 66 | for (mingw32_generic_src) |dep| { | |
| 72 | 67 | try c_source_files.append(.{ |
| 73 | 68 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 74 | 69 | "libc", "mingw", dep, |
| ... | ... | @@ -79,7 +74,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 79 | 74 | } |
| 80 | 75 | const target = comp.getTarget(); |
| 81 | 76 | if (target.cpu.arch == .x86 or target.cpu.arch == .x86_64) { |
| 82 | for (mingwex_x86_src) |dep| { | |
| 77 | for (mingw32_x86_src) |dep| { | |
| 83 | 78 | try c_source_files.append(.{ |
| 84 | 79 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 85 | 80 | "libc", "mingw", dep, |
| ... | ... | @@ -89,7 +84,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 89 | 84 | }); |
| 90 | 85 | } |
| 91 | 86 | if (target.cpu.arch == .x86) { |
| 92 | for (mingwex_x86_32_src) |dep| { | |
| 87 | for (mingw32_x86_32_src) |dep| { | |
| 93 | 88 | try c_source_files.append(.{ |
| 94 | 89 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 95 | 90 | "libc", "mingw", dep, |
| ... | ... | @@ -100,7 +95,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 100 | 95 | } |
| 101 | 96 | } |
| 102 | 97 | } else if (target.cpu.arch.isARM()) { |
| 103 | for (mingwex_arm32_src) |dep| { | |
| 98 | for (mingw32_arm32_src) |dep| { | |
| 104 | 99 | try c_source_files.append(.{ |
| 105 | 100 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 106 | 101 | "libc", "mingw", dep, |
| ... | ... | @@ -110,7 +105,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 110 | 105 | }); |
| 111 | 106 | } |
| 112 | 107 | } else if (target.cpu.arch.isAARCH64()) { |
| 113 | for (mingwex_arm64_src) |dep| { | |
| 108 | for (mingw32_arm64_src) |dep| { | |
| 114 | 109 | try c_source_files.append(.{ |
| 115 | 110 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 116 | 111 | "libc", "mingw", dep, |
| ... | ... | @@ -122,7 +117,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 122 | 117 | } else { |
| 123 | 118 | @panic("unsupported arch"); |
| 124 | 119 | } |
| 125 | return comp.build_crt_file("mingwex", .Lib, .@"mingw-w64 mingwex.lib", prog_node, c_source_files.items); | |
| 120 | return comp.build_crt_file("mingw32", .Lib, .@"mingw-w64 mingw32.lib", prog_node, c_source_files.items); | |
| 126 | 121 | }, |
| 127 | 122 | } |
| 128 | 123 | } |
| ... | ... | @@ -389,14 +384,16 @@ fn findDef( |
| 389 | 384 | return error.FileNotFound; |
| 390 | 385 | } |
| 391 | 386 | |
| 392 | const mingwex_generic_src = [_][]const u8{ | |
| 387 | const mingw32_generic_src = [_][]const u8{ | |
| 393 | 388 | // mingw32 |
| 389 | "crt" ++ path.sep_str ++ "crtexewin.c", | |
| 394 | 390 | "crt" ++ path.sep_str ++ "dll_argv.c", |
| 395 | 391 | "crt" ++ path.sep_str ++ "gccmain.c", |
| 396 | 392 | "crt" ++ path.sep_str ++ "natstart.c", |
| 397 | 393 | "crt" ++ path.sep_str ++ "pseudo-reloc-list.c", |
| 398 | 394 | "crt" ++ path.sep_str ++ "wildcard.c", |
| 399 | 395 | "crt" ++ path.sep_str ++ "charmax.c", |
| 396 | "crt" ++ path.sep_str ++ "ucrtexewin.c", | |
| 400 | 397 | "crt" ++ path.sep_str ++ "dllargv.c", |
| 401 | 398 | "crt" ++ path.sep_str ++ "_newmode.c", |
| 402 | 399 | "crt" ++ path.sep_str ++ "tlssup.c", |
| ... | ... | @@ -814,7 +811,7 @@ const mingwex_generic_src = [_][]const u8{ |
| 814 | 811 | "libsrc" ++ path.sep_str ++ "activeds-uuid.c", |
| 815 | 812 | }; |
| 816 | 813 | |
| 817 | const mingwex_x86_src = [_][]const u8{ | |
| 814 | const mingw32_x86_src = [_][]const u8{ | |
| 818 | 815 | // mingwex |
| 819 | 816 | "math" ++ path.sep_str ++ "cbrtl.c", |
| 820 | 817 | "math" ++ path.sep_str ++ "erfl.c", |
| ... | ... | @@ -873,8 +870,7 @@ const mingwex_x86_src = [_][]const u8{ |
| 873 | 870 | "math" ++ path.sep_str ++ "nexttowardf.c", |
| 874 | 871 | }; |
| 875 | 872 | |
| 876 | const mingwex_x86_32_src = [_][]const u8{ | |
| 877 | // ucrtbase | |
| 873 | const mingw32_x86_32_src = [_][]const u8{ | |
| 878 | 874 | "math" ++ path.sep_str ++ "coshf.c", |
| 879 | 875 | "math" ++ path.sep_str ++ "expf.c", |
| 880 | 876 | "math" ++ path.sep_str ++ "log10f.c", |
| ... | ... | @@ -896,7 +892,7 @@ const mingwex_x86_32_src = [_][]const u8{ |
| 896 | 892 | "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanf.c", |
| 897 | 893 | }; |
| 898 | 894 | |
| 899 | const mingwex_arm32_src = [_][]const u8{ | |
| 895 | const mingw32_arm32_src = [_][]const u8{ | |
| 900 | 896 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c", |
| 901 | 897 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "_chgsignl.S", |
| 902 | 898 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c", |
| ... | ... | @@ -905,7 +901,7 @@ const mingwex_arm32_src = [_][]const u8{ |
| 905 | 901 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincosf.S", |
| 906 | 902 | }; |
| 907 | 903 | |
| 908 | const mingwex_arm64_src = [_][]const u8{ | |
| 904 | const mingw32_arm64_src = [_][]const u8{ | |
| 909 | 905 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c", |
| 910 | 906 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "_chgsignl.S", |
| 911 | 907 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c", |
test/standalone.zig+4| ... | ... | @@ -195,6 +195,10 @@ pub const build_cases = [_]BuildCase{ |
| 195 | 195 | .build_root = "test/standalone/windows_resources", |
| 196 | 196 | .import = @import("standalone/windows_resources/build.zig"), |
| 197 | 197 | }, |
| 198 | .{ | |
| 199 | .build_root = "test/standalone/windows_entry_points", | |
| 200 | .import = @import("standalone/windows_entry_points/build.zig"), | |
| 201 | }, | |
| 198 | 202 | .{ |
| 199 | 203 | .build_root = "test/standalone/windows_spawn", |
| 200 | 204 | .import = @import("standalone/windows_spawn/build.zig"), |
test/standalone/windows_entry_points/build.zig created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn build(b: *std.Build) void { | |
| 4 | const test_step = b.step("test", "Test it"); | |
| 5 | b.default_step = test_step; | |
| 6 | ||
| 7 | const target = b.resolveTargetQuery(.{ | |
| 8 | .cpu_arch = .x86_64, | |
| 9 | .os_tag = .windows, | |
| 10 | .abi = .gnu, | |
| 11 | }); | |
| 12 | ||
| 13 | { | |
| 14 | const exe = b.addExecutable(.{ | |
| 15 | .name = "main", | |
| 16 | .target = target, | |
| 17 | .optimize = .Debug, | |
| 18 | .link_libc = true, | |
| 19 | }); | |
| 20 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" } }); | |
| 21 | ||
| 22 | _ = exe.getEmittedBin(); | |
| 23 | test_step.dependOn(&exe.step); | |
| 24 | } | |
| 25 | ||
| 26 | { | |
| 27 | const exe = b.addExecutable(.{ | |
| 28 | .name = "wmain", | |
| 29 | .target = target, | |
| 30 | .optimize = .Debug, | |
| 31 | .link_libc = true, | |
| 32 | }); | |
| 33 | exe.mingw_unicode_entry_point = true; | |
| 34 | exe.addCSourceFile(.{ .file = .{ .path = "wmain.c" } }); | |
| 35 | ||
| 36 | _ = exe.getEmittedBin(); | |
| 37 | test_step.dependOn(&exe.step); | |
| 38 | } | |
| 39 | ||
| 40 | { | |
| 41 | const exe = b.addExecutable(.{ | |
| 42 | .name = "winmain", | |
| 43 | .target = target, | |
| 44 | .optimize = .Debug, | |
| 45 | .link_libc = true, | |
| 46 | }); | |
| 47 | // Note: `exe.subsystem = .Windows;` is not necessary | |
| 48 | exe.addCSourceFile(.{ .file = .{ .path = "winmain.c" } }); | |
| 49 | ||
| 50 | _ = exe.getEmittedBin(); | |
| 51 | test_step.dependOn(&exe.step); | |
| 52 | } | |
| 53 | ||
| 54 | { | |
| 55 | const exe = b.addExecutable(.{ | |
| 56 | .name = "wwinmain", | |
| 57 | .target = target, | |
| 58 | .optimize = .Debug, | |
| 59 | .link_libc = true, | |
| 60 | }); | |
| 61 | exe.mingw_unicode_entry_point = true; | |
| 62 | // Note: `exe.subsystem = .Windows;` is not necessary | |
| 63 | exe.addCSourceFile(.{ .file = .{ .path = "wwinmain.c" } }); | |
| 64 | ||
| 65 | _ = exe.getEmittedBin(); | |
| 66 | test_step.dependOn(&exe.step); | |
| 67 | } | |
| 68 | } |
test/standalone/windows_entry_points/main.c created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | #include <stdio.h> | |
| 2 | ||
| 3 | int main(int argc, char *argv[ ], char *envp[ ]) { | |
| 4 | printf("hello from main\n"); | |
| 5 | return 0; | |
| 6 | } | |
| \ No newline at end of file |
test/standalone/windows_entry_points/winmain.c created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | #include <windows.h> | |
| 2 | #include <stdio.h> | |
| 3 | ||
| 4 | int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) { | |
| 5 | printf("hello from WinMain\n"); | |
| 6 | return 0; | |
| 7 | } | |
| \ No newline at end of file |
test/standalone/windows_entry_points/wmain.c created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | #include <stdio.h> | |
| 2 | #include <windows.h> | |
| 3 | ||
| 4 | int wmain(int argc, wchar_t *argv[ ], wchar_t *envp[ ]) { | |
| 5 | printf("hello from wmain\n"); | |
| 6 | return 0; | |
| 7 | } | |
| \ No newline at end of file |
test/standalone/windows_entry_points/wwinmain.c created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | #include <windows.h> | |
| 2 | #include <stdio.h> | |
| 3 | ||
| 4 | int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PWSTR cmdline, int cmdshow) { | |
| 5 | printf("hello from wWinMain\n"); | |
| 6 | return 0; | |
| 7 | } | |
| \ No newline at end of file |
tools/update_clang_options.zig+4| ... | ... | @@ -532,6 +532,10 @@ const known_options = [_]KnownOpt{ |
| 532 | 532 | .name = "ObjC", |
| 533 | 533 | .ident = "force_load_objc", |
| 534 | 534 | }, |
| 535 | .{ | |
| 536 | .name = "municode", | |
| 537 | .ident = "mingw_unicode_entry_point", | |
| 538 | }, | |
| 535 | 539 | }; |
| 536 | 540 | |
| 537 | 541 | const blacklisted_options = [_][]const u8{}; |