File tree Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,7 @@ extension Toolchain {
2626 for targetInfo: FrontendTargetInfo ,
2727 parsedOptions: inout ParsedOptions
2828 ) 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
3530
3631 // NOTE(compnerd) Windows uses the per-target runtime directory for the
3732 // 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 {
303303 }
304304 }
305305
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
307328 /// resource directory.
308329 ///
309330 /// - 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 {
13171317 shouldHaveJetPacks: true )
13181318 }
13191319
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+
13201329 func testToolchainSelection( ) {
13211330 let diagnostics = DiagnosticsEngine ( )
13221331 struct None { }
You can’t perform that action at this time.
0 commit comments