Skip to content

Commit fc23eef

Browse files
authored
Disable macro on windows (#71685)
On windows (PECOFF), the `static let` properties produced by `DebugDescriptionMacro` are not constants, and as a result the `@_section` macro cannot be applied. The error message is: > global variable must be a compile-time constant to use `@_section` attribute Until this issue is addressed, DebugDescriptionMacro is disabled for windows targets.
1 parent d35dcc8 commit fc23eef

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/Macros/Sources/SwiftMacros/DebugDescriptionMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,17 @@ extension _DebugDescriptionPropertyMacro: PeerMacro {
213213

214214
// Serialize the type summary into a global record, in a custom section, for LLDB to load.
215215
let decl: DeclSyntax = """
216+
#if !os(Windows)
216217
#if os(Linux)
217218
@_section(".lldbsummaries")
218-
#elseif os(Windows)
219-
@_section(".lldbsummaries")
220219
#else
221220
@_section("__TEXT,__lldbsummaries")
222221
#endif
223222
@_used
224223
static let _lldb_summary = (
225224
\(raw: encodeTypeSummaryRecord(typeIdentifier, summaryString))
226225
)
226+
#endif
227227
"""
228228

229229
return [decl]

test/Macros/DebugDescription/linkage.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
struct MyStruct: CustomDebugStringConvertible {
99
var debugDescription: String { "thirty" }
1010
}
11+
// CHECK: #if !os(Windows)
1112
// CHECK: #if os(Linux)
1213
// CHECK: @_section(".lldbsummaries")
13-
// CHECK: #elseif os(Windows)
14-
// CHECK: @_section(".lldbsummaries")
1514
// CHECK: #else
1615
// CHECK: @_section("__TEXT,__lldbsummaries")
1716
// CHECK: #endif
1817
// CHECK: @_used
1918
// CHECK: static let _lldb_summary = (
19+
// CHECK: /* version */ 1 as UInt8,
20+
// CHECK: /* record size */ 23 as UInt8,
21+
// CHECK: /* "main.MyStruct" */ 14 as UInt8, 109 as UInt8, 97 as UInt8, 105 as UInt8, 110 as UInt8, 46 as UInt8, 77 as UInt8, 121 as UInt8, 83 as UInt8, 116 as UInt8, 114 as UInt8, 117 as UInt8, 99 as UInt8, 116 as UInt8, 0 as UInt8,
22+
// CHECK: /* "thirty" */ 7 as UInt8, 116 as UInt8, 104 as UInt8, 105 as UInt8, 114 as UInt8, 116 as UInt8, 121 as UInt8, 0 as UInt8
23+
// CHECK: )
24+
// CHECK: #endif
2025

0 commit comments

Comments
 (0)