diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -139,12 +139,35 @@ return None; } +static bool checkSimulatedPlatform(PlatformKind lhs, PlatformKind rhs) { + // Mapping of platform to simulator and vice-versa. + static std::map *platformMap = []() { + auto *ret = new std::map(); + + ret->insert({PlatformKind::iOS, PlatformKind::iOSSimulator}); + ret->insert({PlatformKind::iOSSimulator, PlatformKind::iOS}); + + ret->insert({PlatformKind::tvOS, PlatformKind::tvOSSimulator}); + ret->insert({PlatformKind::tvOSSimulator, PlatformKind::tvOS}); + + ret->insert({PlatformKind::watchOS, PlatformKind::watchOSSimulator}); + ret->insert({PlatformKind::watchOSSimulator, PlatformKind::watchOS}); + + return ret; + }(); + + auto iter = platformMap->find(lhs); + return iter != platformMap->end() && iter->second == rhs; +} + static bool checkCompatibility(const InputFile *input) { Optional platformInfo = getPlatformInfo(input); if (!platformInfo) return true; // TODO: Correctly detect simulator platforms or relax this check. - if (config->platform() != platformInfo->target.Platform) { + if (config->platform() != platformInfo->target.Platform && + !checkSimulatedPlatform(config->platform(), + platformInfo->target.Platform)) { error(toString(input) + " has platform " + getPlatformName(platformInfo->target.Platform) + Twine(", which is different from target platform ") +