Skip to content

Commit 8b189d9

Browse files
authored
Turn off SWIFT_ENABLE_REFLECTION on the stdlib_minimal preset (#39030)
1 parent fe321ca commit 8b189d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+63
-2
lines changed

stdlib/private/StdlibUnittest/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ if (NOT IS_BUILD_TYPE_OPTIMIZED)
1010
list(APPEND swift_stdlib_unittest_compile_flags "-DSWIFT_STDLIB_DEBUG")
1111
endif()
1212

13+
if(SWIFT_ENABLE_REFLECTION)
14+
list(APPEND swift_stdlib_unittest_compile_flags "-DSWIFT_ENABLE_REFLECTION")
15+
endif()
16+
1317
set(swift_stdlib_unittest_link_libraries "")
1418
set(swift_stdlib_unittest_modules "")
1519
if (SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)

stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,11 @@ public struct LinearCongruentialGenerator: RandomNumberGenerator {
294294
return _state
295295
}
296296
}
297+
298+
#if !SWIFT_ENABLE_REFLECTION
299+
300+
public func dump<T, TargetStream: TextOutputStream>(_ value: T, to target: inout TargetStream) {
301+
target.write("(reflection not available)")
302+
}
303+
304+
#endif

stdlib/public/Platform/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ if(NOT BUILD_STANDALONE)
1111
list(APPEND darwin_depends copy_apinotes)
1212
endif()
1313

14+
set(swift_platform_compile_flags)
15+
if(SWIFT_ENABLE_REFLECTION)
16+
list(APPEND swift_platform_compile_flags "-DSWIFT_ENABLE_REFLECTION")
17+
endif()
18+
1419
set(swiftDarwin_target_sdks ALL_APPLE_PLATFORMS)
1520
if(SWIFT_FREESTANDING_FLAVOR STREQUAL "apple")
1621
set(swiftDarwin_target_sdks ALL_APPLE_PLATFORMS FREESTANDING)
@@ -30,6 +35,7 @@ add_swift_target_library(swiftDarwin ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_
3035
${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}
3136
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
3237
-Xfrontend -disable-objc-attr-requires-foundation-module
38+
${swift_platform_compile_flags}
3339
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
3440
TARGET_SDKS "${swiftDarwin_target_sdks}"
3541
INSTALL_IN_COMPONENT sdk-overlay
@@ -51,6 +57,7 @@ add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_O
5157
SWIFT_COMPILE_FLAGS
5258
${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}
5359
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
60+
${swift_platform_compile_flags}
5461
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
5562
TARGET_SDKS "${swiftGlibc_target_sdks}"
5663
INSTALL_IN_COMPONENT sdk-overlay
@@ -68,6 +75,7 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE
6875
${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}
6976
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
7077
-Xcc -D_USE_MATH_DEFINES
78+
${swift_platform_compile_flags}
7179
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
7280
TARGET_SDKS WINDOWS
7381
INSTALL_IN_COMPONENT sdk-overlay)

stdlib/public/Platform/Platform.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ public struct DarwinBoolean : ExpressibleByBooleanLiteral {
4646
}
4747
}
4848

49+
#if SWIFT_ENABLE_REFLECTION
4950
extension DarwinBoolean : CustomReflectable {
5051
/// Returns a mirror that reflects `self`.
5152
public var customMirror: Mirror {
5253
return Mirror(reflecting: boolValue)
5354
}
5455
}
56+
#endif
5557

5658
extension DarwinBoolean : CustomStringConvertible {
5759
/// A textual representation of `self`.

test/lit.site.cfg.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ if "@SWIFT_OPTIMIZED@" == "TRUE":
9797
if "@SWIFT_STDLIB_SINGLE_THREADED_RUNTIME@" == "TRUE":
9898
config.available_features.add("single_threaded_runtime")
9999

100+
if "@SWIFT_ENABLE_REFLECTION@" == "TRUE":
101+
config.available_features.add("reflection")
102+
100103
if "@SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS@" == "TRUE":
101104
config.available_features.add('runtime_function_counters')
102105

test/stdlib/DebuggerSupport.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33
// REQUIRES: optimized_stdlib
4+
// REQUIRES: reflection
45

56
import StdlibUnittest
67

test/stdlib/Error.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// RUN: %target-codesign %t/Error
44
// RUN: %target-run %t/Error
55
// REQUIRES: executable_test
6+
// REQUIRES: reflection
67

78
import StdlibUnittest
89

test/stdlib/ForEachField.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// RUN: %target-run-simple-swift
1414
// REQUIRES: executable_test
15+
// REQUIRES: reflection
1516

1617
@_spi(Reflection) import Swift
1718
import StdlibUnittest

test/stdlib/Mirror.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
// REQUIRES: executable_test
2626
// REQUIRES: shell
27+
// REQUIRES: reflection
2728

2829
import StdlibUnittest
2930

test/stdlib/Optional.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
3+
// REQUIRES: reflection
34

45
import StdlibUnittest
56
import Swift

0 commit comments

Comments
 (0)