File tree 3 files changed +32
-7
lines changed
3 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,7 @@ extension Toolchain {
26
26
for targetInfo: FrontendTargetInfo ,
27
27
parsedOptions: inout ParsedOptions
28
28
) throws -> VirtualPath {
29
- var platform = targetInfo. target. triple. platformName ( conflatingDarwin: true ) !
30
- // compiler-rt moved these Android sanitizers into `lib/linux/` a couple
31
- // years ago, llvm/llvm-project@a68ccba, so look for them there instead.
32
- if platform == " android " {
33
- platform = " linux "
34
- }
29
+ let platform = targetInfo. target. triple. clangOSLibName
35
30
36
31
// NOTE(compnerd) Windows uses the per-target runtime directory for the
37
32
// Windows runtimes. This should also be done for the other platforms, but
Original file line number Diff line number Diff line change @@ -303,7 +303,28 @@ extension Triple {
303
303
}
304
304
}
305
305
306
- /// The platform name, i.e. the name clang uses to identify this target in its
306
+
307
+ /// The "os" component of the Clang compiler resource library directory (`<ResourceDir>/lib/<OSName>`).
308
+ /// Must be kept in sync with Clang driver:
309
+ /// https://github.com/llvm/llvm-project/blob/llvmorg-20.1.4/clang/lib/Driver/ToolChain.cpp#L690
310
+ @_spi ( Testing) public var clangOSLibName : String {
311
+ guard let os else {
312
+ return osName
313
+ }
314
+ if os. isDarwin {
315
+ return " darwin "
316
+ }
317
+
318
+ switch os {
319
+ case . freeBSD: return " freebsd "
320
+ case . netbsd: return " netbsd "
321
+ case . openbsd: return " openbsd "
322
+ case . aix: return " aix "
323
+ default : return osName
324
+ }
325
+ }
326
+
327
+ /// The platform name, i.e. the name Swift uses to identify this target in its
307
328
/// resource directory.
308
329
///
309
330
/// - Parameter conflatingDarwin: If true, all Darwin platforms will be
Original file line number Diff line number Diff line change @@ -1317,6 +1317,15 @@ final class TripleTests: XCTestCase {
1317
1317
shouldHaveJetPacks: true )
1318
1318
}
1319
1319
1320
+ func testClangOSLibName( ) {
1321
+ XCTAssertEqual ( " darwin " , Triple ( " x86_64-apple-macosx " ) . clangOSLibName)
1322
+ XCTAssertEqual ( " darwin " , Triple ( " arm64-apple-ios13.0 " ) . clangOSLibName)
1323
+ XCTAssertEqual ( " linux " , Triple ( " aarch64-unknown-linux-android24 " ) . clangOSLibName)
1324
+ XCTAssertEqual ( " wasi " , Triple ( " wasm32-unknown-wasi " ) . clangOSLibName)
1325
+ XCTAssertEqual ( " wasip1 " , Triple ( " wasm32-unknown-wasip1-threads " ) . clangOSLibName)
1326
+ XCTAssertEqual ( " none " , Triple ( " arm64-unknown-none " ) . clangOSLibName)
1327
+ }
1328
+
1320
1329
func testToolchainSelection( ) {
1321
1330
let diagnostics = DiagnosticsEngine ( )
1322
1331
struct None { }
You can’t perform that action at this time.
0 commit comments