diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b64bcca8..7b31f9656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -590,6 +590,7 @@ set(ZIG_STD_FILES "os/freebsd/x86_64.zig" "os/path.zig" "os/time.zig" + "os/uefi/index.zig" "os/windows/advapi32.zig" "os/windows/error.zig" "os/windows/index.zig" diff --git a/src-self-hosted/target.zig b/src-self-hosted/target.zig index 218353c9d..36381b820 100644 --- a/src-self-hosted/target.zig +++ b/src-self-hosted/target.zig @@ -520,7 +520,7 @@ pub const Target = union(enum) { => return 64, }, - builtin.Os.windows => switch (id) { + builtin.Os.windows, builtin.Os.uefi => switch (id) { CInt.Id.Short, CInt.Id.UShort, => return 16, diff --git a/src/all_types.hpp b/src/all_types.hpp index 11304e536..26e9edbab 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1754,8 +1754,7 @@ struct CodeGen { bool strip_debug_symbols; bool is_test_build; bool is_native_target; - bool windows_subsystem_windows; - bool windows_subsystem_console; + ZigLLVM_MSVCSubsystemType msvc_subsystem; bool linker_rdynamic; bool no_rosegment_workaround; bool each_lib_rpath; diff --git a/src/analyze.cpp b/src/analyze.cpp index 9c24f3cc8..48d473fb3 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3203,24 +3203,25 @@ void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLi if (ccc) { if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) { g->have_c_main = true; - g->windows_subsystem_windows = false; - g->windows_subsystem_console = true; + g->msvc_subsystem = ZigLLVM_MSVC_CONSOLE; } else if (buf_eql_str(symbol_name, "WinMain") && g->zig_target.os == OsWindows) { g->have_winmain = true; - g->windows_subsystem_windows = true; - g->windows_subsystem_console = false; + g->msvc_subsystem = ZigLLVM_MSVC_WINDOWS; } else if (buf_eql_str(symbol_name, "WinMainCRTStartup") && g->zig_target.os == OsWindows) { g->have_winmain_crt_startup = true; + g->msvc_subsystem = ZigLLVM_MSVC_WINDOWS; } else if (buf_eql_str(symbol_name, "DllMainCRTStartup") && g->zig_target.os == OsWindows) { g->have_dllmain_crt_startup = true; + g->msvc_subsystem = ZigLLVM_MSVC_WINDOWS; } } + FnExport *fn_export = fn_table_entry->export_list.add_one(); memset(fn_export, 0, sizeof(FnExport)); buf_init_from_buf(&fn_export->name, symbol_name); @@ -4376,8 +4377,7 @@ ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *r if (is_pub && ok_cc) { if (buf_eql_str(proto_name, "main")) { g->have_pub_main = true; - g->windows_subsystem_windows = false; - g->windows_subsystem_console = true; + g->msvc_subsystem = ZigLLVM_MSVC_CONSOLE; } else if (buf_eql_str(proto_name, "panic")) { g->have_pub_panic = true; } diff --git a/src/codegen.cpp b/src/codegen.cpp index e37703d5f..b76bbfb49 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -291,11 +291,6 @@ void codegen_add_framework(CodeGen *g, const char *framework) { g->darwin_frameworks.append(buf_create_from_str(framework)); } -void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole) { - g->windows_subsystem_windows = mwindows; - g->windows_subsystem_console = mconsole; -} - void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min) { g->mmacosx_version_min = mmacosx_version_min; } @@ -7273,7 +7268,7 @@ static void init(CodeGen *g) { // LLVM creates invalid binaries on Windows sometimes. // See https://github.com/ziglang/zig/issues/508 // As a workaround we do not use target native features on Windows. - if (g->zig_target.os == OsWindows) { + if (g->zig_target.os == OsWindows || g->zig_target.os == OsUefi) { target_specific_cpu_args = ""; target_specific_features = ""; } else { @@ -7519,6 +7514,7 @@ static void gen_root_source(CodeGen *g) { report_errors_and_maybe_exit(g); if (!g->is_test_build && g->zig_target.os != OsFreestanding && + g->zig_target.os != OsZen && g->zig_target.os != OsUefi && !g->have_c_main && !g->have_winmain && !g->have_winmain_crt_startup && ((g->have_pub_main && g->out_type == OutTypeObj) || g->out_type == OutTypeExe)) { @@ -8079,8 +8075,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { cache_bool(ch, g->strip_debug_symbols); cache_bool(ch, g->is_test_build); cache_bool(ch, g->is_native_target); - cache_bool(ch, g->windows_subsystem_windows); - cache_bool(ch, g->windows_subsystem_console); + cache_int(ch, g->msvc_subsystem); cache_bool(ch, g->linker_rdynamic); cache_bool(ch, g->no_rosegment_workaround); cache_bool(ch, g->each_lib_rpath); diff --git a/src/codegen.hpp b/src/codegen.hpp index 1d39e4bf5..6f1cdfb67 100644 --- a/src/codegen.hpp +++ b/src/codegen.hpp @@ -33,7 +33,6 @@ void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir); void codegen_set_msvc_lib_dir(CodeGen *g, Buf *msvc_lib_dir); void codegen_set_kernel32_lib_dir(CodeGen *codegen, Buf *kernel32_lib_dir); void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker); -void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole); void codegen_add_lib_dir(CodeGen *codegen, const char *dir); void codegen_add_forbidden_lib(CodeGen *codegen, Buf *lib); LinkLib *codegen_add_link_lib(CodeGen *codegen, Buf *lib); diff --git a/src/ir.cpp b/src/ir.cpp index 83960f2ee..a1432c7b1 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -17872,7 +17872,13 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct if (type_is_invalid(cimport_result->value.type)) return ira->codegen->invalid_instruction; - find_libc_include_path(ira->codegen); + if (ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_APPLICATION && + ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER && + ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_ROM && + ira->codegen->msvc_subsystem != ZigLLVM_MSVC_EFI_RUNTIME_DRIVER) { + + find_libc_include_path(ira->codegen); + } ImportTableEntry *child_import = allocate(1); child_import->decls_scope = create_decls_scope(ira->codegen, node, nullptr, nullptr, child_import); diff --git a/src/link.cpp b/src/link.cpp index 188f976a8..52ca2f2cd 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -455,7 +455,7 @@ static void construct_linker_job_coff(LinkJob *lj) { lj->args.append("-NOLOGO"); - if (!g->strip_debug_symbols) { + if (!g->strip_debug_symbols && g->zig_target.os != Os::OsUefi) { lj->args.append("-DEBUG"); } @@ -466,11 +466,6 @@ static void construct_linker_job_coff(LinkJob *lj) { coff_append_machine_arg(g, &lj->args); - if (g->windows_subsystem_windows) { - lj->args.append("/SUBSYSTEM:windows"); - } else if (g->windows_subsystem_console) { - lj->args.append("/SUBSYSTEM:console"); - } // The commented out stuff is from when we linked with MinGW // Now that we're linking with LLD it remains to be determined // how to handle --target-environ gnu @@ -499,18 +494,47 @@ static void construct_linker_job_coff(LinkJob *lj) { // } //} - lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&g->output_file_path)))); - if (g->libc_link_lib != nullptr) { - lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->msvc_lib_dir)))); - lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->kernel32_lib_dir)))); - - lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_lib_dir)))); - if (g->libc_static_lib_dir != nullptr) { - lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_static_lib_dir)))); - } + // These are n actual command lines from LINK.EXE UEFI builds (app & driver) to be used as guidance cleaning + // up a bit for building the COFF linker args: + // /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" + // /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" + + // Sorry for the goto(s) :) + switch (g->msvc_subsystem) { + case ZigLLVM_MSVC_CONSOLE: + lj->args.append("/SUBSYSTEM:console"); + goto building_nt; + case ZigLLVM_MSVC_EFI_APPLICATION: + lj->args.append("/SUBSYSTEM:efi_application"); + goto building_uefi; + case ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER: + lj->args.append("/SUBSYSTEM:efi_boot_service_driver"); + goto building_uefi; + case ZigLLVM_MSVC_EFI_ROM: + lj->args.append("/SUBSYSTEM:efi_rom"); + goto building_uefi; + case ZigLLVM_MSVC_EFI_RUNTIME_DRIVER: + lj->args.append("/SUBSYSTEM:efi_runtime_driver"); + goto building_uefi; + case ZigLLVM_MSVC_NATIVE: + lj->args.append("/SUBSYSTEM:native"); + goto building_nt; + case ZigLLVM_MSVC_POSIX: + lj->args.append("/SUBSYSTEM:posix"); + goto building_nt; + case ZigLLVM_MSVC_WINDOWS: + lj->args.append("/SUBSYSTEM:windows"); + goto building_nt; + case ZigLLVM_MSVC_NONE: + goto continuing_build; } +building_uefi: + lj->args.append("/BASE:\"0\" /ENTRY:\"EfiMain\" /OPT:REF /SAFESEH:NO /MERGE:\".rdata=.data\" /ALIGN:32 /NODEFAULTLIB /SECTION:\".xdata,D\""); + goto continuing_build; + +building_nt: if (lj->link_in_crt) { const char *lib_str = g->is_static ? "lib" : ""; const char *d_str = (g->build_mode == BuildModeDebug) ? "d" : ""; @@ -547,16 +571,30 @@ static void construct_linker_job_coff(LinkJob *lj) { // msvcrt depends on kernel32 lj->args.append("kernel32.lib"); } else { - lj->args.append("-NODEFAULTLIB"); + lj->args.append("/NODEFAULTLIB"); if (!is_library) { if (g->have_winmain) { - lj->args.append("-ENTRY:WinMain"); + lj->args.append("/ENTRY:WinMain"); } else { - lj->args.append("-ENTRY:WinMainCRTStartup"); + lj->args.append("/ENTRY:WinMainCRTStartup"); } } } +continuing_build: + + lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&g->output_file_path)))); + + if (g->libc_link_lib != nullptr) { + lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->msvc_lib_dir)))); + lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->kernel32_lib_dir)))); + + lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_lib_dir)))); + if (g->libc_static_lib_dir != nullptr) { + lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_static_lib_dir)))); + } + } + if (is_library && !g->is_static) { lj->args.append("-DLL"); } diff --git a/src/main.cpp b/src/main.cpp index 078dfb25f..469ec448e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,9 +90,7 @@ static int print_full_usage(const char *arg0) { " -rdynamic add all symbols to the dynamic symbol table\n" " -rpath [path] add directory to the runtime library search path\n" " --no-rosegment compromise security to workaround valgrind bug\n" - " -mconsole (windows) --subsystem console to the linker\n" - " -mwindows (windows) --subsystem windows to the linker\n" - " -framework [name] (darwin) link against framework\n" + " --msvc-subsystem [subsystem] (windows/uefi) /SUBSYSTEM: to the linker\n" " -framework [name] (darwin) link against framework\n" " -mios-version-min [ver] (darwin) set iOS deployment target\n" " -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n" " --ver-major [ver] dynamic library semver major version\n" @@ -395,6 +393,7 @@ int main(int argc, char **argv) { int runtime_args_start = -1; bool no_rosegment_workaround = false; bool system_linker_hack = false; + ZigLLVM_MSVCSubsystemType msvc_subsystem_type = ZigLLVM_MSVC_NONE; if (argc >= 2 && strcmp(argv[1], "build") == 0) { Buf zig_exe_path_buf = BUF_INIT; @@ -540,6 +539,32 @@ int main(int argc, char **argv) { verbose_llvm_ir = true; } else if (strcmp(arg, "--verbose-cimport") == 0) { verbose_cimport = true; + } else if (strcmp(arg, "--msvc-subsystem") == 0) { + if (i + 1 >= argc) { + fprintf(stderr, "Expected 1 argument after --msvc-subsystem\n"); + return print_error_usage(arg0); + } + i += 1; + if (stricmp(argv[i], "CONSOLE") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_CONSOLE; + } else if (stricmp(argv[i], "WINDOWS") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_WINDOWS; + } else if (stricmp(argv[i], "POSIX") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_POSIX; + } else if (stricmp(argv[i], "NATIVE") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_NATIVE; + } else if (stricmp(argv[i], "EFI_APPLICATION") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_EFI_APPLICATION; + } else if (stricmp(argv[i], "EFI_BOOT_SERVICE_DRIVER") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER; + } else if (stricmp(argv[i], "EFI_ROM") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_EFI_ROM; + } else if (stricmp(argv[i], "EFI_RUNTIME_DRIVER") == 0) { + msvc_subsystem_type = ZigLLVM_MSVC_EFI_RUNTIME_DRIVER; + } else { + fprintf(stderr, "Unknown format %s for --msvc-subsystem argument\n", argv[i]); + return EXIT_FAILURE; + } } else if (strcmp(arg, "-mwindows") == 0) { mwindows = true; } else if (strcmp(arg, "-mconsole") == 0) { @@ -849,6 +874,8 @@ int main(int argc, char **argv) { buf_out_name = buf_create_from_str("run"); } CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, get_zig_lib_dir()); + g->msvc_subsystem = msvc_subsystem_type; + if (disable_pic) { if (out_type != OutTypeLib || !is_static) { fprintf(stderr, "--disable-pic only applies to static libraries"); @@ -909,7 +936,6 @@ int main(int argc, char **argv) { codegen_add_rpath(g, rpath_list.at(i)); } - codegen_set_windows_subsystem(g, mwindows, mconsole); codegen_set_rdynamic(g, rdynamic); g->no_rosegment_workaround = no_rosegment_workaround; if (mmacosx_version_min && mios_version_min) { diff --git a/src/target.cpp b/src/target.cpp index 5a4b5252f..6992f86ca 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -174,6 +174,7 @@ static const Os os_list[] = { OsContiki, OsAMDPAL, OsZen, + OsUefi, }; // Coordinate with zig_llvm.h @@ -315,6 +316,8 @@ ZigLLVM_OSType get_llvm_os_type(Os os_type) { return ZigLLVM_Contiki; case OsAMDPAL: return ZigLLVM_AMDPAL; + case OsUefi: + return ZigLLVM_Uefi; } zig_unreachable(); } @@ -756,6 +759,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { case CIntTypeCount: zig_unreachable(); } + case OsUefi: case OsWindows: switch (id) { case CIntTypeShort: @@ -803,7 +807,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { } const char *target_o_file_ext(ZigTarget *target) { - if (target->env_type == ZigLLVM_MSVC || target->os == OsWindows) { + if (target->env_type == ZigLLVM_MSVC || (target->os == OsWindows || target->os == OsUefi)) { return ".obj"; } else { return ".o"; @@ -821,13 +825,15 @@ const char *target_llvm_ir_file_ext(ZigTarget *target) { const char *target_exe_file_ext(ZigTarget *target) { if (target->os == OsWindows) { return ".exe"; + } else if (target->os == OsUefi) { + return ".efi"; } else { return ""; } } const char *target_lib_file_ext(ZigTarget *target, bool is_static, size_t version_major, size_t version_minor, size_t version_patch) { - if (target->os == OsWindows) { + if (target->os == OsWindows || target->os == OsUefi) { if (is_static) { return ".lib"; } else { diff --git a/src/target.hpp b/src/target.hpp index 04652179d..62cc20711 100644 --- a/src/target.hpp +++ b/src/target.hpp @@ -51,6 +51,7 @@ enum Os { OsContiki, OsAMDPAL, OsZen, + OsUefi, }; struct ZigTarget { @@ -59,6 +60,7 @@ struct ZigTarget { Os os; ZigLLVM_EnvironmentType env_type; ZigLLVM_ObjectFormatType oformat; + ZigLLVM_MSVCSubsystemType msvc_subsystem = ZigLLVM_MSVC_NONE; }; enum CIntType { diff --git a/src/translate_c.cpp b/src/translate_c.cpp index f6bc9cd68..0e56e2981 100644 --- a/src/translate_c.cpp +++ b/src/translate_c.cpp @@ -4749,8 +4749,10 @@ Error parse_h_file(ImportTableEntry *import, ZigList *errors, const clang_argv.append("-isystem"); clang_argv.append(buf_ptr(codegen->zig_c_headers_dir)); - clang_argv.append("-isystem"); - clang_argv.append(buf_ptr(codegen->libc_include_dir)); + if (codegen->libc_include_dir) { + clang_argv.append("-isystem"); + clang_argv.append(buf_ptr(codegen->libc_include_dir)); + } // windows c runtime requires -D_DEBUG if using debug libraries if (codegen->build_mode == BuildModeDebug) { diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index bda8fa0ad..e12ece919 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -690,7 +690,14 @@ const char *ZigLLVMGetVendorTypeName(ZigLLVM_VendorType vendor) { } const char *ZigLLVMGetOSTypeName(ZigLLVM_OSType os) { - return (const char*)Triple::getOSTypeName((Triple::OSType)os).bytes_begin(); + switch (os) { + case ZigLLVM_Zen: + return "unknown"; + case ZigLLVM_Uefi: + return "windows"; + default: + return (const char*)Triple::getOSTypeName((Triple::OSType)os).bytes_begin(); + } } const char *ZigLLVMGetEnvironmentTypeName(ZigLLVM_EnvironmentType env_type) { diff --git a/src/zig_llvm.h b/src/zig_llvm.h index 551a4a744..bb7cb5c5f 100644 --- a/src/zig_llvm.h +++ b/src/zig_llvm.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -357,8 +358,8 @@ enum ZigLLVM_OSType { ZigLLVM_Mesa3D, ZigLLVM_Contiki, ZigLLVM_AMDPAL, // AMD PAL Runtime - - ZigLLVM_LastOSType = ZigLLVM_AMDPAL + ZigLLVM_Uefi, + ZigLLVM_LastOSType = ZigLLVM_Uefi }; // Synchronize with target.cpp::environ_list @@ -397,6 +398,19 @@ enum ZigLLVM_ObjectFormatType { ZigLLVM_Wasm, }; +// For MSVC-supported subsystems +enum ZigLLVM_MSVCSubsystemType { + ZigLLVM_MSVC_NONE, + ZigLLVM_MSVC_CONSOLE, + ZigLLVM_MSVC_WINDOWS, + ZigLLVM_MSVC_POSIX, + ZigLLVM_MSVC_NATIVE, + ZigLLVM_MSVC_EFI_APPLICATION, + ZigLLVM_MSVC_EFI_BOOT_SERVICE_DRIVER, + ZigLLVM_MSVC_EFI_ROM, + ZigLLVM_MSVC_EFI_RUNTIME_DRIVER, +}; + ZIG_EXTERN_C const char *ZigLLVMGetArchTypeName(enum ZigLLVM_ArchType arch); ZIG_EXTERN_C const char *ZigLLVMGetSubArchTypeName(enum ZigLLVM_SubArchType sub_arch); ZIG_EXTERN_C const char *ZigLLVMGetVendorTypeName(enum ZigLLVM_VendorType vendor); diff --git a/std/debug/index.zig b/std/debug/index.zig index 73c6ea7b5..93d6a60a0 100644 --- a/std/debug/index.zig +++ b/std/debug/index.zig @@ -1135,7 +1135,7 @@ pub const DebugInfo = switch (builtin.os) { return self.ofiles.allocator; } }, - builtin.Os.windows => struct { + builtin.Os.uefi, builtin.Os.windows => struct { pdb: pdb.Pdb, coff: *coff.Coff, sect_contribs: []pdb.SectionContribEntry, diff --git a/std/os/index.zig b/std/os/index.zig index b19679c96..ce6566715 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -18,6 +18,7 @@ test "std.os" { _ = @import("test.zig"); _ = @import("time.zig"); _ = @import("windows/index.zig"); + _ = @import("uefi/index.zig"); _ = @import("get_app_data_dir.zig"); } @@ -26,6 +27,8 @@ pub const darwin = @import("darwin.zig"); pub const linux = @import("linux/index.zig"); pub const freebsd = @import("freebsd/index.zig"); pub const zen = @import("zen.zig"); +pub const uefi = @import("uefi/index.zig"); + pub const posix = switch (builtin.os) { Os.linux => linux, Os.macosx, Os.ios => darwin, @@ -33,6 +36,7 @@ pub const posix = switch (builtin.os) { Os.zen => zen, else => @compileError("Unsupported OS"), }; + pub const net = @import("net.zig"); pub const ChildProcess = @import("child_process.zig").ChildProcess; @@ -187,6 +191,9 @@ pub fn abort() noreturn { } windows.ExitProcess(3); }, + Os.uefi => { + while (true) {} + }, else => @compileError("Unsupported OS"), } } diff --git a/std/os/uefi/index.zig b/std/os/uefi/index.zig new file mode 100644 index 000000000..e69de29bb diff --git a/std/special/panic.zig b/std/special/panic.zig index ca1caea73..fe1e02060 100644 --- a/std/special/panic.zig +++ b/std/special/panic.zig @@ -10,7 +10,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn @setCold(true); switch (builtin.os) { // TODO: fix panic in zen. - builtin.Os.freestanding, builtin.Os.zen => { + builtin.Os.freestanding, builtin.Os.zen, builtin.Os.uefi => { while (true) {} }, else => {