On Apple platforms, use swiftmodule directories for the stdlib (#21797)

This changes the Swift resource directory from looking like

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          x86_64/
            Swift.swiftmodule
            Swift.swiftdoc
            Darwin.swiftmodule
            Darwin.swiftdoc

to

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          Swift.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc
          Darwin.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc

matching the layout we use for multi-architecture swiftmodules
everywhere else (particularly frameworks).

There's no change in this commit to how Linux swiftmodules are
packaged. There's been past interest in going the /opposite/ direction
for Linux, since there's not standard support for fat
(multi-architecture) .so libraries. Moving the .so search path /down/
to an architecture-specific directory on Linux would allow the same
resource directory to be used for both host-compiling and
cross-compiling.

rdar://problem/43545560
This commit is contained in:
Jordan Rose
2019-02-19 14:47:21 -08:00
committed by GitHub
parent f87960746c
commit 43feb9cbe1
33 changed files with 235 additions and 118 deletions

View File

@@ -301,10 +301,21 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
// Search the runtime import path.
isFramework = false;
return !findModuleFilesInDirectory(
moduleID, Ctx.SearchPathOpts.RuntimeLibraryImportPath,
moduleFilename.str(), moduleDocFilename.str(), moduleBuffer,
moduleDocBuffer);
currPath = Ctx.SearchPathOpts.RuntimeLibraryImportPath;
if (Ctx.LangOpts.Target.isOSDarwin()) {
// Apple platforms always use architecture-specific files within a
// .swiftmodule directory for the stdlib.
llvm::sys::path::append(currPath, moduleFilename.str());
return !findModuleFilesInDirectory(moduleID, currPath,
archFileNames.first,
archFileNames.second,
moduleBuffer, moduleDocBuffer);
}
// Non-Apple platforms always use single-architecture swiftmodules.
return !findModuleFilesInDirectory(moduleID, currPath,
moduleFilename.str(),
moduleDocFilename.str(),
moduleBuffer, moduleDocBuffer);
}
static std::pair<StringRef, clang::VersionTuple>