Skip to content

Commit 5b35938

Browse files
authored
[Debug] Introduce use of DebugDescription macro in stdlib (#71425)
Introduces the first use of `@_DebugDescription` in the standard library, applying it to `ObjectIdentifier`. In order to use the DebugDescription macro in the stdlib, the following changes are required: 1. Compilation must reference the just built macros (ie `libSwiftMacros.dylib`), not those from the SDK. This is addressed by adding an explicit `-external-plugin-path` flag that overrides the defaults generated by the compiler (which uses SDK paths, where the macro may or may not exist, and may not be the current version). 2. As DebugDescription uses `@_section`, compilation enables the `SymbolLinkageMarkers` feature. Note that the use of DebugDescription is conditionally enabled for the following reasons: 1. Use is disabled in freestanding builds, where the stdlib macros are not built. 2. Use is temporarily disabled in Linux builds due to a dynamic loader issue that needs further investigation The dynamic loader error causing issues with Linux CI is: > swift-plugin-server: error while loading shared libraries: libswiftGlibc.so: cannot open shared object file: No such file or directory This PR depended on #71639, #71588, and #71685.
1 parent e80df24 commit 5b35938

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

stdlib/public/core/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ if(SWIFT_STDLIB_ENABLE_VECTOR_TYPES)
260260
list(APPEND SWIFTLIB_EMBEDDED_GYB_SOURCES SIMDConcreteOperations.swift.gyb SIMDVectorTypes.swift.gyb)
261261
endif()
262262

263+
# Freestanding and Linux builds both have failures to resolve.
264+
if(NOT SWIFT_FREESTANDING_FLAVOR AND NOT SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX")
265+
list(APPEND SWIFTLIB_SOURCES ObjectIdentifier+DebugDescription.swift)
266+
endif()
267+
263268
list(APPEND SWIFTLIB_EMBEDDED_SOURCES
264269
EmbeddedRuntime.swift
265270
EmbeddedStubs.swift
@@ -310,6 +315,10 @@ list(APPEND swift_stdlib_compile_flags "-enable-experimental-feature" "Freestand
310315
list(APPEND swift_stdlib_compile_flags "-enable-experimental-feature" "Extern")
311316
list(APPEND swift_stdlib_compile_flags "-enable-experimental-feature" "BitwiseCopyable")
312317

318+
list(APPEND swift_stdlib_compile_flags "-external-plugin-path"
319+
"${CMAKE_BINARY_DIR}/lib/swift/host/plugins#${CMAKE_BINARY_DIR}/bin/swift-plugin-server")
320+
list(APPEND swift_stdlib_compile_flags "-enable-experimental-feature" "SymbolLinkageMarkers")
321+
313322
set(swift_core_incorporate_object_libraries)
314323
list(APPEND swift_core_incorporate_object_libraries swiftRuntime)
315324
list(APPEND swift_core_incorporate_object_libraries swiftLLVMSupport)

stdlib/public/core/DebuggerSupport.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ import SwiftShims
6464
/// and other arbitrary computation are not supported. Of note, conditional
6565
/// logic and computed properties are not supported.
6666
/// * Overloaded string interpolation cannot be used.
67-
@available(SwiftStdlib 5.11, *)
6867
@attached(memberAttribute)
6968
public macro _DebugDescription() =
7069
#externalMacro(module: "SwiftMacros", type: "DebugDescriptionMacro")
7170

7271
/// Internal-only macro. See `@_DebugDescription`.
73-
@available(SwiftStdlib 5.11, *)
7472
@attached(peer, names: named(_lldb_summary))
7573
public macro _DebugDescriptionProperty(_ debugIdentifier: String, _ computedProperties: [String]) =
7674
#externalMacro(module: "SwiftMacros", type: "_DebugDescriptionPropertyMacro")

stdlib/public/core/GroupInfo.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@
161161
"Mirror.swift",
162162
"Mirrors.swift",
163163
"ReflectionMirror.swift",
164-
"ObjectIdentifier.swift"
164+
"ObjectIdentifier.swift",
165+
"ObjectIdentifier+DebugDescription.swift"
165166
],
166167
"Math": [
167168
"SetAlgebra.swift",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#if !$Embedded
14+
@_DebugDescription
15+
extension ObjectIdentifier {
16+
var _debugDescription: String {
17+
return "ObjectIdentifier(\(_value))"
18+
}
19+
}
20+
#endif

0 commit comments

Comments
 (0)