Skip to content

Commit 9e58b2c

Browse files
committed
[Backtracing] Make this macOS only for now.
The Linux Swift compiler is ICEing when building _Backtracing, while Windows still needs some tweaks. In order to land this sooner, disable this code except for macOS.
1 parent eb38d80 commit 9e58b2c

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

stdlib/public/Backtracing/Context.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ extension arm_gprs {
219219

220220
public static var registerCount: Int { return 56 }
221221

222-
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && arch(x86_64)
222+
#if os(macOS) && arch(x86_64)
223223
init?(from thread: thread_t) {
224224
var state = darwin_x86_64_thread_state()
225225
let kr = mach_thread_get_state(thread, x86_THREAD_STATE64, &state)
@@ -580,7 +580,7 @@ extension arm_gprs {
580580

581581
public static var registerCount: Int { return 40 }
582582

583-
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && arch(arm64)
583+
#if os(macOS) && arch(arm64)
584584
init?(from thread: thread_t) {
585585
var state = darwin_arm64_thread_state()
586586
let kr = mach_thread_get_state(thread, ARM_THREAD_STATE64, &state)
@@ -629,7 +629,7 @@ extension arm_gprs {
629629
public static func withCurrentContext<T>(fn: (ARM64Context) throws -> T) throws -> T {
630630
throw NotYetImplemented()
631631
}
632-
#elseif arch(arm64)
632+
#elseif arch(arm64) || arch(arm64_32)
633633
@_silgen_name("_swift_get_cpu_context")
634634
static func _swift_get_cpu_context() -> ARM64Context
635635

@@ -851,7 +851,7 @@ extension arm_gprs {
851851

852852
// .. Darwin specifics .........................................................
853853

854-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
854+
#if os(macOS)
855855
private func mach_thread_get_state<T>(_ thread: thread_t,
856856
_ flavor: CInt,
857857
_ result: inout T) -> kern_return_t {
@@ -878,7 +878,7 @@ private func mach_thread_get_state<T>(_ thread: thread_t,
878878
@_spi(Contexts) public typealias HostContext = X86_64Context
879879
#elseif arch(i386)
880880
@_spi(Contexts) public typealias HostContext = I386Context
881-
#elseif arch(arm64)
881+
#elseif arch(arm64) || arch(arm64_32)
882882
@_spi(Contexts) public typealias HostContext = ARM64Context
883883
#elseif arch(arm)
884884
@_spi(Contexts) public typealias HostContext = ARMContext

stdlib/public/Backtracing/MemoryReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extension MemoryReader {
7272
}
7373
}
7474

75-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
75+
#if os(macOS)
7676
@_implementationOnly import Darwin.Mach
7777

7878
@_spi(MemoryReaders) public struct MachError: Error {

stdlib/public/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ if(SWIFT_BUILD_STDLIB)
159159
add_subdirectory(Observation)
160160
endif()
161161

162-
add_subdirectory(Backtracing)
162+
# Make this macOS only for now.
163+
if(OSX IN_LIST SWIFT_SDKS)
164+
add_subdirectory(Backtracing)
165+
endif()
163166
endif()
164167

165168
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)

stdlib/public/libexec/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# Make this macOS only for now.
2+
if(OSX IN_LIST SWIFT_SDKS)
13
add_subdirectory(swift-backtrace)
4+
endif()

stdlib/public/libexec/swift-backtrace/Target.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//
1616
//===----------------------------------------------------------------------===//
1717

18-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
18+
#if os(macOS)
1919

2020
import Darwin
2121
import Darwin.Mach
@@ -345,4 +345,4 @@ private func mach_thread_info<T>(_ thread: thread_t,
345345
}
346346
}
347347

348-
#endif // os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
348+
#endif // os(macOS)

0 commit comments

Comments
 (0)