mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Frontend: allow directory layout for Swift on non-Darwin platforms
Adjust the serialized module loader to allow directory layouts for the Swift module on non-Darwin targets, unifying the layout across all the platforms. It also eases cross-architecture and cross-platform development by having the same layout, which can enable more similar flag usage.
This commit is contained in:
@@ -586,17 +586,17 @@ SerializedModuleLoaderBase::findModule(ImportPath::Element moduleID,
|
||||
case SearchPathKind::RuntimeLibrary: {
|
||||
isFramework = false;
|
||||
|
||||
bool checkTargetSpecificModule;
|
||||
if (Kind == SearchPathKind::RuntimeLibrary) {
|
||||
// Apple platforms always use target-specific files within a
|
||||
// .swiftmodule directory for the stdlib; non-Apple platforms
|
||||
// always use single-architecture swiftmodules.
|
||||
checkTargetSpecificModule = Ctx.LangOpts.Target.isOSDarwin();
|
||||
} else {
|
||||
// On Apple platforms, we can assume that the runtime libraries use
|
||||
// target-specifi module files wihtin a `.swiftmodule` directory.
|
||||
// This was not always true on non-Apple platforms, and in order to
|
||||
// ease the transition, check both layouts.
|
||||
bool checkTargetSpecificModule = true;
|
||||
if (Kind != SearchPathKind::RuntimeLibrary ||
|
||||
!Ctx.LangOpts.Target.isOSDarwin()) {
|
||||
auto modulePath = currPath;
|
||||
llvm::sys::path::append(modulePath, genericModuleFileName);
|
||||
|
||||
llvm::ErrorOr<llvm::vfs::Status> statResult = fs.status(modulePath);
|
||||
|
||||
// Even if stat fails, we can't just return the error; the path
|
||||
// we're looking for might not be "Foo.swiftmodule".
|
||||
checkTargetSpecificModule = statResult && statResult->isDirectory();
|
||||
|
||||
Reference in New Issue
Block a user