diff --git a/lib/Serialization/SerializedModuleLoader.cpp b/lib/Serialization/SerializedModuleLoader.cpp index 59e2d019faa1c..032b1f8c56623 100644 --- a/lib/Serialization/SerializedModuleLoader.cpp +++ b/lib/Serialization/SerializedModuleLoader.cpp @@ -49,14 +49,10 @@ void forEachTargetModuleBasename(const ASTContext &Ctx, // names checked in "#if arch(...)". Fall back to that name in the one case // where it's different from what Swift 4.2 supported: // - 32-bit ARM platforms (formerly "arm") - // - arm64e (formerly shared with "arm64") // We should be able to drop this once there's an Xcode that supports the // new names. - if (Ctx.LangOpts.Target.getArch() == llvm::Triple::ArchType::arm) + if (Ctx.LangOpts.Target.getArch() == llvm::Triple::ArchType::arm) { body("arm"); - else if (Ctx.LangOpts.Target.getSubArch() == - llvm::Triple::SubArchType::AArch64SubArch_E) { - body("arm64"); } } @@ -409,8 +405,12 @@ bool SerializedModuleLoader::maybeDiagnoseTargetMismatch( return false; StringRef filePath = directoryIterator->path(); StringRef extension = llvm::sys::path::extension(filePath); - if (file_types::lookupTypeForExtension(extension) == - file_types::TY_SwiftModuleFile) { + auto fileType = file_types::lookupTypeForExtension(extension); + // We also check for interfaces here, because the SerializedModuleLoader + // is invoked after the ModuleInterfaceLoader; if the ModuleInterfaceLoader + // handled interfaces separately, we could get duplicate diagnostics. + if (fileType == file_types::TY_SwiftModuleFile + || fileType == file_types::TY_SwiftModuleInterfaceFile) { if (!foundArchs.empty()) foundArchs += ", "; foundArchs += llvm::sys::path::stem(filePath).str(); @@ -418,7 +418,7 @@ bool SerializedModuleLoader::maybeDiagnoseTargetMismatch( } if (foundArchs.empty()) { - // Maybe this swiftmodule directory only contains swiftinterfaces, or + // It is strange that there were no swiftmodules or swiftinterfaces here; // maybe something else is going on. Regardless, we shouldn't emit a // possibly incorrect diagnostic. return false; diff --git a/test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64-apple-ios.swiftinterface b/test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64-apple-ios.swiftinterface new file mode 100644 index 0000000000000..cf71c2f1a1e21 --- /dev/null +++ b/test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64-apple-ios.swiftinterface @@ -0,0 +1,4 @@ +// swift-interface-format-version: 1.0 +// swift-compiler-version: Apple Swift version 5.2 +// swift-module-flags: -target arm64-apple-ios13.0 -enable-library-evolution -swift-version 5 -module-name DummyFramework +import Swift diff --git a/test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64.swiftinterface b/test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64.swiftinterface new file mode 100644 index 0000000000000..cf71c2f1a1e21 --- /dev/null +++ b/test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64.swiftinterface @@ -0,0 +1,4 @@ +// swift-interface-format-version: 1.0 +// swift-compiler-version: Apple Swift version 5.2 +// swift-module-flags: -target arm64-apple-ios13.0 -enable-library-evolution -swift-version 5 -module-name DummyFramework +import Swift diff --git a/test/ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift b/test/ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift index 280b1a82aa273..34c87a5841a16 100644 --- a/test/ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift +++ b/test/ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift @@ -14,7 +14,7 @@ // RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s // RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s // RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s -// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH-2 -DARCH=%module-target-triple -DTARGET_CPU=%target-cpu %s // (default) // RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s @@ -82,19 +82,19 @@ // 8. Only the interface is present but for the wrong architecture. // (Diagnostics for the module only are tested elsewhere.) -// FIXME: We should improve this to not just say NO-SUCH-MODULE. // RUN: rm %t/Lib.swiftmodule/garbage.swiftmodule -// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s -// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s // RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s -// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s // (default) -// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s import Lib // NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib' // BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule // WRONG-ARCH: [[@LINE-3]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: garbage +// WRONG-ARCH-2: [[@LINE-4]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: [[TARGET_CPU]] struct X {} let _: X = Lib.testValue diff --git a/test/ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift b/test/ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift index cd2a43d5f7fec..4722b6dfb3cfb 100644 --- a/test/ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift +++ b/test/ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift @@ -14,7 +14,7 @@ // RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s // RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s // RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s -// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH-2 -DARCH=%module-target-triple -DTARGET_CPU=%target-cpu %s // (default) // RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s @@ -83,19 +83,19 @@ // 8. Only the interface is present but for the wrong architecture. // (Diagnostics for the module only are tested elsewhere.) -// FIXME: We should improve this to not just say NO-SUCH-MODULE. // RUN: rm %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftmodule -// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s -// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s // RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s -// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s // (default) -// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s +// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s import Lib // NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib' // BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule // WRONG-ARCH: [[@LINE-3]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: garbage +// WRONG-ARCH-2: [[@LINE-4]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: [[TARGET_CPU]] struct X {} let _: X = Lib.testValue diff --git a/test/ModuleInterface/arm64e-fallback.swift b/test/ModuleInterface/arm64e-fallback.swift new file mode 100644 index 0000000000000..d60ccb5e6898c --- /dev/null +++ b/test/ModuleInterface/arm64e-fallback.swift @@ -0,0 +1,6 @@ +// RUN: not %target-typecheck-verify-swift -target arm64e-apple-ios13.0 -F %S/Inputs 2>&1 | %FileCheck %s + +// REQUIRES: OS=ios + +import DummyFramework +// CHECK: could not find module 'DummyFramework' for target 'arm64e-apple-ios'; found: arm64-apple-ios, arm64