mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Driver/Frontend] Add Driver support for macCatalyst and library search paths
Add support in the driver and frontend for macCatalyst target targets and library search paths. The compiler now adds two library search paths for overlays when compiling for macCatalyst: one for macCatalyst libraries and one for zippered macOS libraries. The macCatalyst path must take priority over the normal macOS path so that in the case of 'unzippered twins' the macCatalyst library is found instead of the macOS library. To support 'zippered' builds, also add support for a new -target-variant flag. For zippered libraries, the driver invocation takes both a -target and a -target-variant flag passes them along to the frontend. We support builds both when the target is a macOS triple and the target variant is macCatalyst and also the 'reverse zippered' configuration where the target is macCatalyst and the target-variant is macOS.
This commit is contained in:
@@ -73,7 +73,14 @@ static void setDefaultPrebuiltCacheIfNecessary(
|
||||
return;
|
||||
|
||||
SmallString<64> defaultPrebuiltPath{searchPathOpts.RuntimeResourcePath};
|
||||
StringRef platform = getPlatformNameForTriple(triple);
|
||||
StringRef platform;
|
||||
if (tripleIsMacCatalystEnvironment(triple)) {
|
||||
// The prebuilt cache for macCatalyst is the same as the one for macOS, not iOS
|
||||
// or a separate location of its own.
|
||||
platform = "macosx";
|
||||
} else {
|
||||
platform = getPlatformNameForTriple(triple);
|
||||
}
|
||||
llvm::sys::path::append(defaultPrebuiltPath, platform, "prebuilt-modules");
|
||||
frontendOpts.PrebuiltModuleCachePath = defaultPrebuiltPath.str();
|
||||
}
|
||||
@@ -82,7 +89,11 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
|
||||
llvm::Triple &Triple) {
|
||||
llvm::SmallString<128> LibPath(SearchPathOpts.RuntimeResourcePath);
|
||||
|
||||
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
|
||||
StringRef LibSubDir = getPlatformNameForTriple(Triple);
|
||||
if (tripleIsMacCatalystEnvironment(Triple))
|
||||
LibSubDir = "maccatalyst";
|
||||
|
||||
llvm::sys::path::append(LibPath, LibSubDir);
|
||||
SearchPathOpts.RuntimeLibraryPaths.clear();
|
||||
SearchPathOpts.RuntimeLibraryPaths.push_back(LibPath.str());
|
||||
if (Triple.isOSDarwin())
|
||||
@@ -101,6 +112,13 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
|
||||
SearchPathOpts.RuntimeLibraryImportPaths.push_back(LibPath.str());
|
||||
|
||||
if (!SearchPathOpts.SDKPath.empty()) {
|
||||
if (tripleIsMacCatalystEnvironment(Triple)) {
|
||||
LibPath = SearchPathOpts.SDKPath;
|
||||
llvm::sys::path::append(LibPath, "System", "iOSSupport");
|
||||
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
|
||||
SearchPathOpts.RuntimeLibraryImportPaths.push_back(LibPath.str());
|
||||
}
|
||||
|
||||
LibPath = SearchPathOpts.SDKPath;
|
||||
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
|
||||
if (!Triple.isOSDarwin()) {
|
||||
@@ -520,6 +538,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
TargetArg = A->getValue();
|
||||
}
|
||||
|
||||
if (const Arg *A = Args.getLastArg(OPT_target_variant)) {
|
||||
Opts.TargetVariant = llvm::Triple(A->getValue());
|
||||
}
|
||||
|
||||
Opts.EnableCXXInterop |= Args.hasArg(OPT_enable_cxx_interop);
|
||||
Opts.EnableObjCInterop =
|
||||
Args.hasFlag(OPT_enable_objc_interop, OPT_disable_objc_interop,
|
||||
|
||||
Reference in New Issue
Block a user