From c1ae9f40c728e769e804eabfcab0b40d6c0f67f2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 26 Oct 2020 15:48:48 -0700 Subject: [PATCH] stage1: support "native" as the OS string in -target This should help for bootstrapping purposes, intending to fix the macOS CI. --- src/stage1/target.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/stage1/target.cpp b/src/stage1/target.cpp index 433c988a0..6dc3dbdb7 100644 --- a/src/stage1/target.cpp +++ b/src/stage1/target.cpp @@ -357,6 +357,33 @@ Error target_parse_arch(ZigLLVM_ArchType *out_arch, const char *arch_ptr, size_t } Error target_parse_os(Os *out_os, const char *os_ptr, size_t os_len) { + if (mem_eql_str(os_ptr, os_len, "native")) { +#if defined(ZIG_OS_DARWIN) + *out_os = OsMacOSX; + return ErrorNone; +#elif defined(ZIG_OS_WINDOWS) + *out_os = OsWindows; + return ErrorNone; +#elif defined(ZIG_OS_LINUX) + *out_os = OsLinux; + return ErrorNone; +#elif defined(ZIG_OS_FREEBSD) + *out_os = OsFreeBSD; + return ErrorNone; +#elif defined(ZIG_OS_NETBSD) + *out_os = OsNetBSD; + return ErrorNone; +#elif defined(ZIG_OS_DRAGONFLY) + *out_os = OsDragonFly; + return ErrorNone; +#elif defined(ZIG_OS_OPENBSD) + *out_os = OsOpenBSD; + return ErrorNone; +#else + zig_panic("stage1 is unable to detect native target for this OS"); +#endif + } + for (size_t i = 0; i < array_length(os_list); i += 1) { Os os = os_list[i]; const char *os_name = target_os_name(os);