authorgravatar for linux@nebulae.onlinenebulaeonline <linux@nebulae.online> 2018-12-23 22:21:32-05:00
committergravatar for linux@nebulae.onlinenebulaeonline <linux@nebulae.online> 2018-12-23 22:21:32-05:00
log39d32ee40a53deb99a3683fed4574adceca95afe
tree188727bf439ab172dd0428ba64368ff2235c96c5
parent280187031a68c577e84c72add037271153d27c62

Altered SUBSYSTEM option handling when linking in msvc mode; Added preliminary UEFI support.


18 files changed, 154 insertions(+), 52 deletions(-)

CMakeLists.txt+1
......@@ -590,6 +590,7 @@ set(ZIG_STD_FILES
590590 "os/freebsd/x86_64.zig"
591591 "os/path.zig"
592592 "os/time.zig"
593 "os/uefi/index.zig"
593594 "os/windows/advapi32.zig"
594595 "os/windows/error.zig"
595596 "os/windows/index.zig"
src-self-hosted/target.zig+1-1
......@@ -520,7 +520,7 @@ pub const Target = union(enum) {
520520 => return 64,
521521 },
522522
523 builtin.Os.windows => switch (id) {
523 builtin.Os.windows, builtin.Os.uefi => switch (id) {
524524 CInt.Id.Short,
525525 CInt.Id.UShort,
526526 => return 16,
src/all_types.hpp+1-2
......@@ -1754,8 +1754,7 @@ struct CodeGen {
17541754 bool strip_debug_symbols;
17551755 bool is_test_build;
17561756 bool is_native_target;
1757 bool windows_subsystem_windows;
1758 bool windows_subsystem_console;
1757 ZigLLVM_MSVCSubsystemType msvc_subsystem;
17591758 bool linker_rdynamic;
17601759 bool no_rosegment_workaround;
17611760 bool each_lib_rpath;
src/analyze.cpp+6-6
......@@ -3203,24 +3203,25 @@ void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLi
32033203 if (ccc) {
32043204 if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) {
32053205 g->have_c_main = true;
3206 g->windows_subsystem_windows = false;
3207 g->windows_subsystem_console = true;
3206 g->msvc_subsystem = ZigLLVM_MSVC_CONSOLE;
32083207 } else if (buf_eql_str(symbol_name, "WinMain") &&
32093208 g->zig_target.os == OsWindows)
32103209 {
32113210 g->have_winmain = true;
3212 g->windows_subsystem_windows = true;
3213 g->windows_subsystem_console = false;
3211 g->msvc_subsystem = ZigLLVM_MSVC_WINDOWS;
32143212 } else if (buf_eql_str(symbol_name, "WinMainCRTStartup") &&
32153213 g->zig_target.os == OsWindows)
32163214 {
32173215 g->have_winmain_crt_startup = true;
3216 g->msvc_subsystem = ZigLLVM_MSVC_WINDOWS;
32183217 } else if (buf_eql_str(symbol_name, "DllMainCRTStartup") &&
32193218 g->zig_target.os == OsWindows)
32203219 {
32213220 g->have_dllmain_crt_startup = true;
3221 g->msvc_subsystem = ZigLLVM_MSVC_WINDOWS;
32223222 }
32233223 }
3224
32243225 FnExport *fn_export = fn_table_entry->export_list.add_one();
32253226 memset(fn_export, 0, sizeof(FnExport));
32263227 buf_init_from_buf(&fn_export->name, symbol_name);
......@@ -4376,8 +4377,7 @@ ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *r
43764377 if (is_pub && ok_cc) {
43774378 if (buf_eql_str(proto_name, "main")) {
43784379 g->have_pub_main = true;
4379 g->windows_subsystem_windows = false;
4380 g->windows_subsystem_console = true;
4380 g->msvc_subsystem = ZigLLVM_MSVC_CONSOLE;
43814381 } else if (buf_eql_str(proto_name, "panic")) {
43824382 g->have_pub_panic = true;
43834383 }
src/codegen.cpp+3-8
......@@ -291,11 +291,6 @@ void codegen_add_framework(CodeGen *g, const char *framework) {
291291 g->darwin_frameworks.append(buf_create_from_str(framework));
292292}
293293
294void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole) {
295 g->windows_subsystem_windows = mwindows;
296 g->windows_subsystem_console = mconsole;
297}
298
299294void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min) {
300295 g->mmacosx_version_min = mmacosx_version_min;
301296}
......@@ -7273,7 +7268,7 @@ static void init(CodeGen *g) {
72737268 // LLVM creates invalid binaries on Windows sometimes.
72747269 // See https://github.com/ziglang/zig/issues/508
72757270 // As a workaround we do not use target native features on Windows.
7276 if (g->zig_target.os == OsWindows) {
7271 if (g->zig_target.os == OsWindows || g->zig_target.os == OsUefi) {
72777272 target_specific_cpu_args = "";
72787273 target_specific_features = "";
72797274 } else {
......@@ -7519,6 +7514,7 @@ static void gen_root_source(CodeGen *g) {
75197514 report_errors_and_maybe_exit(g);
75207515
75217516 if (!g->is_test_build && g->zig_target.os != OsFreestanding &&
7517 g->zig_target.os != OsZen && g->zig_target.os != OsUefi &&
75227518 !g->have_c_main && !g->have_winmain && !g->have_winmain_crt_startup &&
75237519 ((g->have_pub_main && g->out_type == OutTypeObj) || g->out_type == OutTypeExe))
75247520 {
......@@ -8079,8 +8075,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
80798075 cache_bool(ch, g->strip_debug_symbols);
80808076 cache_bool(ch, g->is_test_build);
80818077 cache_bool(ch, g->is_native_target);
8082 cache_bool(ch, g->windows_subsystem_windows);
8083 cache_bool(ch, g->windows_subsystem_console);
8078 cache_int(ch, g->msvc_subsystem);
80848079 cache_bool(ch, g->linker_rdynamic);
80858080 cache_bool(ch, g->no_rosegment_workaround);
80868081 cache_bool(ch, g->each_lib_rpath);
src/codegen.hpp-1
......@@ -33,7 +33,6 @@ void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir);
3333void codegen_set_msvc_lib_dir(CodeGen *g, Buf *msvc_lib_dir);
3434void codegen_set_kernel32_lib_dir(CodeGen *codegen, Buf *kernel32_lib_dir);
3535void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker);
36void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole);
3736void codegen_add_lib_dir(CodeGen *codegen, const char *dir);
3837void codegen_add_forbidden_lib(CodeGen *codegen, Buf *lib);
3938LinkLib *codegen_add_link_lib(CodeGen *codegen, Buf *lib);
src/ir.cpp+7-1
......@@ -17872,7 +17872,13 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct
1787217872 if (type_is_invalid(cimport_result->value.type))
1787317873 return ira->codegen->invalid_instruction;
1787417874
17875 find_libc_include_path(ira->codegen);
17875 if (ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_APPLICATION &&
17876 ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER &&
17877 ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_ROM &&
17878 ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_RUNTIME_DRIVER) {
17879
17880 find_libc_include_path(ira->codegen);
17881 }
1787617882
1787717883 ImportTableEntry *child_import = allocate<ImportTableEntry>(1);
1787817884 child_import->decls_scope = create_decls_scope(ira->codegen, node, nullptr, nullptr, child_import);
src/link.cpp+58-20
......@@ -455,7 +455,7 @@ static void construct_linker_job_coff(LinkJob *lj) {
455455
456456 lj->args.append("-NOLOGO");
457457
458 if (!g->strip_debug_symbols) {
458 if (!g->strip_debug_symbols && g->zig_target.os != Os::OsUefi) {
459459 lj->args.append("-DEBUG");
460460 }
461461
......@@ -466,11 +466,6 @@ static void construct_linker_job_coff(LinkJob *lj) {
466466
467467 coff_append_machine_arg(g, &lj->args);
468468
469 if (g->windows_subsystem_windows) {
470 lj->args.append("/SUBSYSTEM:windows");
471 } else if (g->windows_subsystem_console) {
472 lj->args.append("/SUBSYSTEM:console");
473 }
474469 // The commented out stuff is from when we linked with MinGW
475470 // Now that we're linking with LLD it remains to be determined
476471 // how to handle --target-environ gnu
......@@ -499,18 +494,47 @@ static void construct_linker_job_coff(LinkJob *lj) {
499494 // }
500495 //}
501496
502 lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&g->output_file_path))));
503
504 if (g->libc_link_lib != nullptr) {
505 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->msvc_lib_dir))));
506 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->kernel32_lib_dir))));
507
508 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_lib_dir))));
509 if (g->libc_static_lib_dir != nullptr) {
510 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_static_lib_dir))));
511 }
512 }
513497
498 // These are n actual command lines from LINK.EXE UEFI builds (app & driver) to be used as guidance cleaning
499 // up a bit for building the COFF linker args:
500 // /OUT:"J:\coding\nebulae\k\x64\Release\k.efi" /LTCG:incremental /Driver /PDB:"J:\coding\nebulae\k\x64\Release\k.pdb" "UefiApplicationEntryPoint.lib" "UefiRuntimeLib.lib" "UefiHiiLib.lib" "UefiHiiServicesLib.lib" "UefiSortLib.lib" "UefiShellLib.lib" "GlueLib.lib" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiBootServicesTableLib.lib" "UefiRuntimeServicesTableLib.lib" "UefiDevicePathLibDevicePathProtocol.lib" "UefiDebugLibConOut.lib" "UefiMemoryLib.lib" "UefiMemoryAllocationLib.lib" "BaseSynchronizationLib.lib" "UefiFileHandleLib.lib" /IMPLIB:"J:\coding\nebulae\k\x64\Release\k.lib" /DEBUG:FASTLINK /BASE:"0" /MACHINE:X64 /ENTRY:"EfiMain" /OPT:REF /SAFESEH:NO /SUBSYSTEM:EFI_APPLICATION /MERGE:".rdata=.data" /NOLOGO /ALIGN:32 /NODEFAULTLIB /SECTION:".xdata,D"
501 // /OUT:"J:\coding\VisualUefi\samples\x64\Release\UefiDriver.efi" /LTCG:incremental /Driver /PDB:"J:\coding\VisualUefi\samples\x64\Release\UefiDriver.pdb" "UefiDriverEntryPoint.lib" "UefiHiiLib.lib" "UefiHiiServicesLib.lib" "UefiSortLib.lib" "UefiShellLib.lib" "GlueLib.lib" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiBootServicesTableLib.lib" "UefiRuntimeServicesTableLib.lib" "UefiDevicePathLibDevicePathProtocol.lib" "UefiDebugLibConOut.lib" "UefiMemoryLib.lib" "UefiMemoryAllocationLib.lib" "BaseSynchronizationLib.lib" "UefiFileHandleLib.lib" /IMPLIB:"J:\coding\VisualUefi\samples\x64\Release\UefiDriver.lib" /DEBUG:FASTLINK /BASE:"0" /MACHINE:X64 /ENTRY:"EfiMain" /OPT:REF /SAFESEH:NO /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MERGE:".rdata=.data" /NOLOGO /ALIGN:32 /NODEFAULTLIB /SECTION:".xdata,D"
502
503 // Sorry for the goto(s) :)
504 switch (g->msvc_subsystem) {
505 case ZigLLVM_MSVC_CONSOLE:
506 lj->args.append("/SUBSYSTEM:console");
507 goto building_nt;
508 case ZigLLVM_MSVC_EFI_APPLICATION:
509 lj->args.append("/SUBSYSTEM:efi_application");
510 goto building_uefi;
511 case ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER:
512 lj->args.append("/SUBSYSTEM:efi_boot_service_driver");
513 goto building_uefi;
514 case ZigLLVM_MSVC_EFI_ROM:
515 lj->args.append("/SUBSYSTEM:efi_rom");
516 goto building_uefi;
517 case ZigLLVM_MSVC_EFI_RUNTIME_DRIVER:
518 lj->args.append("/SUBSYSTEM:efi_runtime_driver");
519 goto building_uefi;
520 case ZigLLVM_MSVC_NATIVE:
521 lj->args.append("/SUBSYSTEM:native");
522 goto building_nt;
523 case ZigLLVM_MSVC_POSIX:
524 lj->args.append("/SUBSYSTEM:posix");
525 goto building_nt;
526 case ZigLLVM_MSVC_WINDOWS:
527 lj->args.append("/SUBSYSTEM:windows");
528 goto building_nt;
529 case ZigLLVM_MSVC_NONE:
530 goto continuing_build;
531 }
532
533building_uefi:
534 lj->args.append("/BASE:\"0\" /ENTRY:\"EfiMain\" /OPT:REF /SAFESEH:NO /MERGE:\".rdata=.data\" /ALIGN:32 /NODEFAULTLIB /SECTION:\".xdata,D\"");
535 goto continuing_build;
536
537building_nt:
514538 if (lj->link_in_crt) {
515539 const char *lib_str = g->is_static ? "lib" : "";
516540 const char *d_str = (g->build_mode == BuildModeDebug) ? "d" : "";
......@@ -547,16 +571,30 @@ static void construct_linker_job_coff(LinkJob *lj) {
547571 // msvcrt depends on kernel32
548572 lj->args.append("kernel32.lib");
549573 } else {
550 lj->args.append("-NODEFAULTLIB");
574 lj->args.append("/NODEFAULTLIB");
551575 if (!is_library) {
552576 if (g->have_winmain) {
553 lj->args.append("-ENTRY:WinMain");
577 lj->args.append("/ENTRY:WinMain");
554578 } else {
555 lj->args.append("-ENTRY:WinMainCRTStartup");
579 lj->args.append("/ENTRY:WinMainCRTStartup");
556580 }
557581 }
558582 }
559583
584continuing_build:
585
586 lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&g->output_file_path))));
587
588 if (g->libc_link_lib != nullptr) {
589 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->msvc_lib_dir))));
590 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->kernel32_lib_dir))));
591
592 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_lib_dir))));
593 if (g->libc_static_lib_dir != nullptr) {
594 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_static_lib_dir))));
595 }
596 }
597
560598 if (is_library && !g->is_static) {
561599 lj->args.append("-DLL");
562600 }
src/main.cpp+30-4
......@@ -90,9 +90,7 @@ static int print_full_usage(const char *arg0) {
9090 " -rdynamic add all symbols to the dynamic symbol table\n"
9191 " -rpath [path] add directory to the runtime library search path\n"
9292 " --no-rosegment compromise security to workaround valgrind bug\n"
93 " -mconsole (windows) --subsystem console to the linker\n"
94 " -mwindows (windows) --subsystem windows to the linker\n"
95 " -framework [name] (darwin) link against framework\n"
93 " --msvc-subsystem [subsystem] (windows/uefi) /SUBSYSTEM:<subsystem> to the linker\n" " -framework [name] (darwin) link against framework\n"
9694 " -mios-version-min [ver] (darwin) set iOS deployment target\n"
9795 " -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n"
9896 " --ver-major [ver] dynamic library semver major version\n"
......@@ -395,6 +393,7 @@ int main(int argc, char **argv) {
395393 int runtime_args_start = -1;
396394 bool no_rosegment_workaround = false;
397395 bool system_linker_hack = false;
396 ZigLLVM_MSVCSubsystemType msvc_subsystem_type = ZigLLVM_MSVC_NONE;
398397
399398 if (argc >= 2 && strcmp(argv[1], "build") == 0) {
400399 Buf zig_exe_path_buf = BUF_INIT;
......@@ -540,6 +539,32 @@ int main(int argc, char **argv) {
540539 verbose_llvm_ir = true;
541540 } else if (strcmp(arg, "--verbose-cimport") == 0) {
542541 verbose_cimport = true;
542 } else if (strcmp(arg, "--msvc-subsystem") == 0) {
543 if (i + 1 >= argc) {
544 fprintf(stderr, "Expected 1 argument after --msvc-subsystem\n");
545 return print_error_usage(arg0);
546 }
547 i += 1;
548 if (stricmp(argv[i], "CONSOLE") == 0) {
549 msvc_subsystem_type = ZigLLVM_MSVC_CONSOLE;
550 } else if (stricmp(argv[i], "WINDOWS") == 0) {
551 msvc_subsystem_type = ZigLLVM_MSVC_WINDOWS;
552 } else if (stricmp(argv[i], "POSIX") == 0) {
553 msvc_subsystem_type = ZigLLVM_MSVC_POSIX;
554 } else if (stricmp(argv[i], "NATIVE") == 0) {
555 msvc_subsystem_type = ZigLLVM_MSVC_NATIVE;
556 } else if (stricmp(argv[i], "EFI_APPLICATION") == 0) {
557 msvc_subsystem_type = ZigLLVM_MSVC_EFI_APPLICATION;
558 } else if (stricmp(argv[i], "EFI_BOOT_SERVICE_DRIVER") == 0) {
559 msvc_subsystem_type = ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER;
560 } else if (stricmp(argv[i], "EFI_ROM") == 0) {
561 msvc_subsystem_type = ZigLLVM_MSVC_EFI_ROM;
562 } else if (stricmp(argv[i], "EFI_RUNTIME_DRIVER") == 0) {
563 msvc_subsystem_type = ZigLLVM_MSVC_EFI_RUNTIME_DRIVER;
564 } else {
565 fprintf(stderr, "Unknown format %s for --msvc-subsystem argument\n", argv[i]);
566 return EXIT_FAILURE;
567 }
543568 } else if (strcmp(arg, "-mwindows") == 0) {
544569 mwindows = true;
545570 } else if (strcmp(arg, "-mconsole") == 0) {
......@@ -849,6 +874,8 @@ int main(int argc, char **argv) {
849874 buf_out_name = buf_create_from_str("run");
850875 }
851876 CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, get_zig_lib_dir());
877 g->msvc_subsystem = msvc_subsystem_type;
878
852879 if (disable_pic) {
853880 if (out_type != OutTypeLib || !is_static) {
854881 fprintf(stderr, "--disable-pic only applies to static libraries");
......@@ -909,7 +936,6 @@ int main(int argc, char **argv) {
909936 codegen_add_rpath(g, rpath_list.at(i));
910937 }
911938
912 codegen_set_windows_subsystem(g, mwindows, mconsole);
913939 codegen_set_rdynamic(g, rdynamic);
914940 g->no_rosegment_workaround = no_rosegment_workaround;
915941 if (mmacosx_version_min && mios_version_min) {
src/target.cpp+8-2
......@@ -174,6 +174,7 @@ static const Os os_list[] = {
174174 OsContiki,
175175 OsAMDPAL,
176176 OsZen,
177 OsUefi,
177178};
178179
179180// Coordinate with zig_llvm.h
......@@ -315,6 +316,8 @@ ZigLLVM_OSType get_llvm_os_type(Os os_type) {
315316 return ZigLLVM_Contiki;
316317 case OsAMDPAL:
317318 return ZigLLVM_AMDPAL;
319 case OsUefi:
320 return ZigLLVM_Uefi;
318321 }
319322 zig_unreachable();
320323}
......@@ -756,6 +759,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
756759 case CIntTypeCount:
757760 zig_unreachable();
758761 }
762 case OsUefi:
759763 case OsWindows:
760764 switch (id) {
761765 case CIntTypeShort:
......@@ -803,7 +807,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
803807}
804808
805809const char *target_o_file_ext(ZigTarget *target) {
806 if (target->env_type == ZigLLVM_MSVC || target->os == OsWindows) {
810 if (target->env_type == ZigLLVM_MSVC || (target->os == OsWindows || target->os == OsUefi)) {
807811 return ".obj";
808812 } else {
809813 return ".o";
......@@ -821,13 +825,15 @@ const char *target_llvm_ir_file_ext(ZigTarget *target) {
821825const char *target_exe_file_ext(ZigTarget *target) {
822826 if (target->os == OsWindows) {
823827 return ".exe";
828 } else if (target->os == OsUefi) {
829 return ".efi";
824830 } else {
825831 return "";
826832 }
827833}
828834
829835const char *target_lib_file_ext(ZigTarget *target, bool is_static, size_t version_major, size_t version_minor, size_t version_patch) {
830 if (target->os == OsWindows) {
836 if (target->os == OsWindows || target->os == OsUefi) {
831837 if (is_static) {
832838 return ".lib";
833839 } else {
src/target.hpp+2
......@@ -51,6 +51,7 @@ enum Os {
5151 OsContiki,
5252 OsAMDPAL,
5353 OsZen,
54 OsUefi,
5455};
5556
5657struct ZigTarget {
......@@ -59,6 +60,7 @@ struct ZigTarget {
5960 Os os;
6061 ZigLLVM_EnvironmentType env_type;
6162 ZigLLVM_ObjectFormatType oformat;
63 ZigLLVM_MSVCSubsystemType msvc_subsystem = ZigLLVM_MSVC_NONE;
6264};
6365
6466enum CIntType {
src/translate_c.cpp+4-2
......@@ -4749,8 +4749,10 @@ Error parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const
47494749 clang_argv.append("-isystem");
47504750 clang_argv.append(buf_ptr(codegen->zig_c_headers_dir));
47514751
4752 clang_argv.append("-isystem");
4753 clang_argv.append(buf_ptr(codegen->libc_include_dir));
4752 if (codegen->libc_include_dir) {
4753 clang_argv.append("-isystem");
4754 clang_argv.append(buf_ptr(codegen->libc_include_dir));
4755 }
47544756
47554757 // windows c runtime requires -D_DEBUG if using debug libraries
47564758 if (codegen->build_mode == BuildModeDebug) {
src/zig_llvm.cpp+8-1
......@@ -690,7 +690,14 @@ const char *ZigLLVMGetVendorTypeName(ZigLLVM_VendorType vendor) {
690690}
691691
692692const char *ZigLLVMGetOSTypeName(ZigLLVM_OSType os) {
693 return (const char*)Triple::getOSTypeName((Triple::OSType)os).bytes_begin();
693 switch (os) {
694 case ZigLLVM_Zen:
695 return "unknown";
696 case ZigLLVM_Uefi:
697 return "windows";
698 default:
699 return (const char*)Triple::getOSTypeName((Triple::OSType)os).bytes_begin();
700 }
694701}
695702
696703const char *ZigLLVMGetEnvironmentTypeName(ZigLLVM_EnvironmentType env_type) {
src/zig_llvm.h+16-2
......@@ -10,6 +10,7 @@
1010
1111#include <stdbool.h>
1212#include <stddef.h>
13#include <stdint.h>
1314#include <llvm-c/Core.h>
1415#include <llvm-c/Analysis.h>
1516#include <llvm-c/Target.h>
......@@ -357,8 +358,8 @@ enum ZigLLVM_OSType {
357358 ZigLLVM_Mesa3D,
358359 ZigLLVM_Contiki,
359360 ZigLLVM_AMDPAL, // AMD PAL Runtime
360
361 ZigLLVM_LastOSType = ZigLLVM_AMDPAL
361 ZigLLVM_Uefi,
362 ZigLLVM_LastOSType = ZigLLVM_Uefi
362363};
363364
364365// Synchronize with target.cpp::environ_list
......@@ -397,6 +398,19 @@ enum ZigLLVM_ObjectFormatType {
397398 ZigLLVM_Wasm,
398399};
399400
401// For MSVC-supported subsystems
402enum ZigLLVM_MSVCSubsystemType {
403 ZigLLVM_MSVC_NONE,
404 ZigLLVM_MSVC_CONSOLE,
405 ZigLLVM_MSVC_WINDOWS,
406 ZigLLVM_MSVC_POSIX,
407 ZigLLVM_MSVC_NATIVE,
408 ZigLLVM_MSVC_EFI_APPLICATION,
409 ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER,
410 ZigLLVM_MSVC_EFI_ROM,
411 ZigLLVM_MSVC_EFI_RUNTIME_DRIVER,
412};
413
400414ZIG_EXTERN_C const char *ZigLLVMGetArchTypeName(enum ZigLLVM_ArchType arch);
401415ZIG_EXTERN_C const char *ZigLLVMGetSubArchTypeName(enum ZigLLVM_SubArchType sub_arch);
402416ZIG_EXTERN_C const char *ZigLLVMGetVendorTypeName(enum ZigLLVM_VendorType vendor);
std/debug/index.zig+1-1
......@@ -1135,7 +1135,7 @@ pub const DebugInfo = switch (builtin.os) {
11351135 return self.ofiles.allocator;
11361136 }
11371137 },
1138 builtin.Os.windows => struct {
1138 builtin.Os.uefi, builtin.Os.windows => struct {
11391139 pdb: pdb.Pdb,
11401140 coff: *coff.Coff,
11411141 sect_contribs: []pdb.SectionContribEntry,
std/os/index.zig+7
......@@ -18,6 +18,7 @@ test "std.os" {
1818 _ = @import("test.zig");
1919 _ = @import("time.zig");
2020 _ = @import("windows/index.zig");
21 _ = @import("uefi/index.zig");
2122 _ = @import("get_app_data_dir.zig");
2223}
2324
......@@ -26,6 +27,8 @@ pub const darwin = @import("darwin.zig");
2627pub const linux = @import("linux/index.zig");
2728pub const freebsd = @import("freebsd/index.zig");
2829pub const zen = @import("zen.zig");
30pub const uefi = @import("uefi/index.zig");
31
2932pub const posix = switch (builtin.os) {
3033 Os.linux => linux,
3134 Os.macosx, Os.ios => darwin,
......@@ -33,6 +36,7 @@ pub const posix = switch (builtin.os) {
3336 Os.zen => zen,
3437 else => @compileError("Unsupported OS"),
3538};
39
3640pub const net = @import("net.zig");
3741
3842pub const ChildProcess = @import("child_process.zig").ChildProcess;
......@@ -187,6 +191,9 @@ pub fn abort() noreturn {
187191 }
188192 windows.ExitProcess(3);
189193 },
194 Os.uefi => {
195 while (true) {}
196 },
190197 else => @compileError("Unsupported OS"),
191198 }
192199}
std/os/uefi/index.zig created
std/special/panic.zig+1-1
......@@ -10,7 +10,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn
1010 @setCold(true);
1111 switch (builtin.os) {
1212 // TODO: fix panic in zen.
13 builtin.Os.freestanding, builtin.Os.zen => {
13 builtin.Os.freestanding, builtin.Os.zen, builtin.Os.uefi => {
1414 while (true) {}
1515 },
1616 else => {