Skip to content

Commit 4ad0a40

Browse files
committed
[Backtracing] Disable assembly language on ARM Windows.
On ARM Windows, we need MARMASM to assemble the context capture code, but CMake doesn't support MARMASM until version 3.26, which isn't yet released. (Confusingly it appears to have partial but non-working support in the present versions.) rdar://106284325
1 parent ac72084 commit 4ad0a40

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

Diff for: CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,24 @@ enable_language(CXX)
4949
# On Windows, use MASM or MARMASM
5050
set(SWIFT_ASM_DIALECT ASM)
5151
set(SWIFT_ASM_EXT S)
52+
set(SWIFT_ASM_AVAILABLE YES)
5253
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
5354
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64")
54-
set(SWIFT_ASM_DIALECT ASM_MARMASM)
55+
if(CMAKE_VERSION VERSION_LESS "3.26")
56+
message(warning "We can't build assembly language for ARM64 until CMake 3.26")
57+
set(SWIFT_ASM_AVAILABLE NO)
58+
else()
59+
set(SWIFT_ASM_DIALECT ASM_MARMASM)
60+
endif()
5561
else()
5662
set(SWIFT_ASM_DIALECT ASM_MASM)
5763
endif()
5864
set(SWIFT_ASM_EXT asm)
5965
endif()
6066

61-
enable_language(${SWIFT_ASM_DIALECT})
67+
if(SWIFT_ASM_AVAILABLE)
68+
enable_language(${SWIFT_ASM_DIALECT})
69+
endif()
6270

6371
# Use C++14.
6472
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")

Diff for: stdlib/public/Backtracing/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ set(BACKTRACING_SOURCES
2828
get-cpu-context.${SWIFT_ASM_EXT}
2929
)
3030

31+
set(BACKTRACING_COMPILE_FLAGS)
32+
33+
if(SWIFT_ASM_AVAILABLE)
34+
list(APPEND BACKTRACING_SOURCES get-cpu-context.${SWIFT_ASM_EXT})
35+
list(APPEND BACKTRACING_COMPILE_FLAGS "-DSWIFT_ASM_AVAILABLE")
36+
else()
37+
message(warning "Assembly language not available on this platform; backtracing will fail.")
38+
endif()
39+
3140
set(LLVM_OPTIONAL_SOURCES
3241
get-cpu-context.S
3342
get-cpu-context.asm
@@ -48,6 +57,7 @@ add_swift_target_library(swift_Backtracing ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
4857

4958
SWIFT_COMPILE_FLAGS
5059
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
60+
${BACKTRACING_COMPILE_FLAGS}
5161
-parse-stdlib
5262

5363
LINK_FLAGS

Diff for: stdlib/public/Backtracing/Context.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ extension arm_gprs {
268268
}
269269
#endif
270270

271-
#if os(Windows)
272-
struct NotYetImplemented: Error {}
271+
#if os(Windows) || !SWIFT_ASM_AVAILABLE
272+
struct NotImplemented: Error {}
273273
public static func withCurrentContext<T>(fn: (X86_64Context) throws -> T) throws -> T {
274-
throw NotYetImplemented()
274+
throw NotImplemented()
275275
}
276276
#elseif arch(x86_64)
277277
@_silgen_name("_swift_get_cpu_context")
@@ -423,10 +423,10 @@ extension arm_gprs {
423423

424424
public static var registerCount: Int { return 50 }
425425

426-
#if os(Windows)
427-
struct NotYetImplemented: Error {}
426+
#if os(Windows) || !SWIFT_ASM_AVAILABLE
427+
struct NotImplemented: Error {}
428428
public static func withCurrentContext<T>(fn: (I386Context) throws -> T) throws -> T {
429-
throw NotYetImplemented()
429+
throw NotImplemented()
430430
}
431431
#elseif arch(i386)
432432
@_silgen_name("_swift_get_cpu_context")
@@ -624,10 +624,10 @@ extension arm_gprs {
624624
}
625625
#endif
626626

627-
#if os(Windows)
628-
struct NotYetImplemented: Error {}
627+
#if os(Windows) || !SWIFT_ASM_AVAILABLE
628+
struct NotImplemented: Error {}
629629
public static func withCurrentContext<T>(fn: (ARM64Context) throws -> T) throws -> T {
630-
throw NotYetImplemented()
630+
throw NotImplemented()
631631
}
632632
#elseif arch(arm64) || arch(arm64_32)
633633
@_silgen_name("_swift_get_cpu_context")
@@ -763,10 +763,10 @@ extension arm_gprs {
763763

764764
public static var registerCount: Int { return 16 }
765765

766-
#if os(Windows)
767-
struct NotYetImplemented: Error {}
766+
#if os(Windows) || !SWIFT_ASM_AVAILABLE
767+
struct NotImplemented: Error {}
768768
public static func withCurrentContext<T>(fn: (ARMContext) throws -> T) throws -> T {
769-
throw NotYetImplemented()
769+
throw NotImplemented()
770770
}
771771
#elseif arch(arm)
772772
@_silgen_name("_swift_get_cpu_context")

0 commit comments

Comments
 (0)