Index: lib/Support/Host.cpp =================================================================== --- lib/Support/Host.cpp +++ lib/Support/Host.cpp @@ -1486,7 +1486,9 @@ #endif std::string sys::getProcessTriple() { - Triple PT(Triple::normalize(LLVM_HOST_TRIPLE)); + std::string TargetTripleString(LLVM_HOST_TRIPLE); + updateTripleOSVersion(TargetTripleString); + Triple PT(Triple::normalize(TargetTripleString)); if (sizeof(void *) == 8 && PT.isArch32Bit()) PT = PT.get64BitArchVariant(); Index: lib/Support/Unix/Host.inc =================================================================== --- lib/Support/Unix/Host.inc +++ lib/Support/Unix/Host.inc @@ -34,18 +34,30 @@ return info.release; } -std::string sys::getDefaultTargetTriple() { - std::string TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE); - - // On darwin, we want to update the version to match that of the - // target. +static void updateTripleOSVersion(std::string &TargetTripleString) { + // On darwin, we want to update the version to match that of the target. std::string::size_type DarwinDashIdx = TargetTripleString.find("-darwin"); if (DarwinDashIdx != std::string::npos) { TargetTripleString.resize(DarwinDashIdx + strlen("-darwin")); TargetTripleString += getOSVersion(); + return; + } + std::string::size_type MacOSDashIdx = TargetTripleString.find("-macos"); + if (MacOSDashIdx != std::string::npos) { + TargetTripleString.resize(MacOSDashIdx); + // Reset the OS to darwin as the OS version from `uname` doesn't use the + // macOS version scheme. + TargetTripleString += "-darwin"; + TargetTripleString += getOSVersion(); } +} + +std::string sys::getDefaultTargetTriple() { + std::string TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE); + updateTripleOSVersion(TargetTripleString); - // Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV. + // Override the default target with an environment variable named by + // LLVM_TARGET_TRIPLE_ENV. #if defined(LLVM_TARGET_TRIPLE_ENV) if (const char *EnvTriple = std::getenv(LLVM_TARGET_TRIPLE_ENV)) TargetTripleString = EnvTriple; Index: lib/Support/Windows/Host.inc =================================================================== --- lib/Support/Windows/Host.inc +++ lib/Support/Windows/Host.inc @@ -17,6 +17,10 @@ using namespace llvm; +static void updateTripleOSVersion(std::string &) { + // Do nothing. +} + std::string sys::getDefaultTargetTriple() { const char *Triple = LLVM_DEFAULT_TARGET_TRIPLE;