Skip to content

Commit f3655ed

Browse files
committed
Frontend: correct -sdk search paths for !Darwin
This adjusts the runtime library import paths to add the OS/architecture subdirectory to the path. This allows the use of `-sdk` with the compiler to target Android and Windows as well (and Linux). The SDK image is identical to that generated by the current CMake setup without the host tools. Ideally, we would change the layout for the modules on other targets to be identical to the Darwin layout which converts to OS/<module>/architecture.<extension> rather than OS/architecture/<module>.<extension>.
1 parent c113db2 commit f3655ed

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
8989
if (!SearchPathOpts.SDKPath.empty()) {
9090
LibPath = SearchPathOpts.SDKPath;
9191
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
92+
if (!Triple.isOSDarwin()) {
93+
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
94+
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
95+
}
9296
SearchPathOpts.RuntimeLibraryImportPaths.push_back(LibPath.str());
9397
}
9498
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -target x86_64-unknown-linux-android -disable-objc-interop -swift-version 5 -O -module-name Swift -parse-stdlib
3+

test/Driver/android-sdk.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// RUN: %swift -target x86_64-unknown-linux-android -sdk %S/Inputs/android.sdk %s -typecheck

0 commit comments

Comments
 (0)