Skip to content

Commit 8b189d9

Browse files
authored
Turn off SWIFT_ENABLE_REFLECTION on the stdlib_minimal preset (swiftlang#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

test/stdlib/Print.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main
66
// REQUIRES: executable_test
7+
// REQUIRES: reflection
78

89
import StdlibUnittest
910
import PrintTestTypes

test/stdlib/PrintArray.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main
66
// REQUIRES: executable_test
7+
// REQUIRES: reflection
78

89
import StdlibUnittest
910
import PrintTestTypes

test/stdlib/PrintBoolean.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

test/stdlib/PrintClass.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main
66
// REQUIRES: executable_test
7+
// REQUIRES: reflection
78

89
import StdlibUnittest
910
import PrintTestTypes

test/stdlib/PrintDictionary.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

test/stdlib/PrintInteger.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

test/stdlib/PrintPointer.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

test/stdlib/PrintSet.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

test/stdlib/PrintString.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main
66
// REQUIRES: executable_test
7+
// REQUIRES: reflection
78

89
import StdlibUnittest
910
import PrintTestTypes

test/stdlib/PrintStruct.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main
66
// REQUIRES: executable_test
7+
// REQUIRES: reflection
78

89
import StdlibUnittest
910
import PrintTestTypes

test/stdlib/PrintTuple.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main
66
// REQUIRES: executable_test
7+
// REQUIRES: reflection
78

89
import StdlibUnittest
910
import PrintTestTypes

test/stdlib/Reflection.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// RUN: %target-codesign %t/a.out
44
// RUN: %{python} %S/../Inputs/timeout.py 360 %target-run %t/a.out | %FileCheck %s
55
// REQUIRES: executable_test
6+
// REQUIRES: reflection
67
// FIXME: timeout wrapper is necessary because the ASan test runs for hours
78

89
//

test/stdlib/ReflectionHashing.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %target-codesign %t.out
33
// RUN: %target-run %t.out
44
// REQUIRES: executable_test
5+
// REQUIRES: reflection
56

67
// This file contains reflection tests that depend on hash values.
78
// Don't add other tests here.

test/stdlib/Runtime.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// RUN: %target-codesign %t.out
66
// RUN: %target-run %t.out
77
// REQUIRES: executable_test
8+
// REQUIRES: reflection
89

910
import Swift
1011
import StdlibUnittest

test/stdlib/RuntimeRetroactiveConformance.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// RUN: %target-run %t/a.out
77

88
// REQUIRES: executable_test
9+
// REQUIRES: reflection
910

1011
import A
1112
import B

test/stdlib/StaticString.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

test/stdlib/StringAPI.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
//
56
// Tests for the non-Foundation API of String

test/stdlib/StringCompatibility.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %target-build-swift %s -o %t/a.out4 -swift-version 4 && %target-codesign %t/a.out4 && %target-run %t/a.out4
33

44
// REQUIRES: executable_test
5+
// REQUIRES: reflection
56

67
import StdlibUnittest
78

test/stdlib/StringDescribing.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

test/stdlib/UnicodeMetadata.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %target-codesign %t.out
33
// RUN: %target-run %t.out | %FileCheck %s
44
// REQUIRES: executable_test
5+
// REQUIRES: reflection
56

67

78
class myClass { }

test/stdlib/UnsafePointer.swift.gyb

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

45
import StdlibUnittest
56

test/stdlib/WeakMirror.swift

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

2424
// REQUIRES: executable_test
2525
// REQUIRES: shell
26+
// REQUIRES: reflection
2627

2728
import StdlibUnittest
2829

test/stdlib/integer_conversions.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 | %FileCheck %s
22
// REQUIRES: executable_test
3+
// REQUIRES: reflection
34

45
var a : Int
56

utils/build-presets.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,7 @@ build-swift-dynamic-stdlib=0
24522452
build-swift-static-stdlib=1
24532453
swift-objc-interop=0
24542454
swift-enable-compatibility-overrides=0
2455-
swift-enable-reflection=1
2455+
swift-enable-reflection=0
24562456
swift-runtime-macho-no-dyld=1
24572457
swift-stdlib-has-darwin-libmalloc=0
24582458
swift-stdlib-single-threaded-runtime=1

validation-test/stdlib/AnyHashable.swift.gyb

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

45
// FIXME(id-as-any): make Swift errors boxed in NSError eagerly bridged.
56

validation-test/stdlib/Array.swift.gyb

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

45
import StdlibUnittest
56
import StdlibCollectionUnittest

validation-test/stdlib/ArraySlice.swift.gyb

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

45
import StdlibUnittest
56
import StdlibCollectionUnittest

validation-test/stdlib/ContiguousArray.swift.gyb

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

45
import StdlibUnittest
56
import StdlibCollectionUnittest

validation-test/stdlib/HashingRandomization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// environment variable is set.
1616

1717
print("Deterministic: \(Hasher._isDeterministic)")
18-
print("Seed: \(Hasher._executionSeed)")
18+
print("Seed: (\(Hasher._executionSeed.0), \(Hasher._executionSeed.1))")
1919
print("Hash values: <\(0.hashValue), \(1.hashValue)>")
2020

2121
// With randomized hashing, we get a new seed and a new set of hash values on

validation-test/stdlib/Lazy.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212
// RUN: %target-run-simple-swiftgyb
1313
// REQUIRES: executable_test
14+
// REQUIRES: reflection
1415

1516
// With a non-optimized stdlib the test takes very long.
1617
// REQUIRES: optimized_stdlib

validation-test/stdlib/NewArray.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// RUN: %target-codesign %t/a.out
1717
// RUN: %target-run %t/a.out 2>&1 | %line-directive %t/NewArray.swift -- %FileCheck %t/NewArray.swift --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
1818
// REQUIRES: executable_test
19+
// REQUIRES: reflection
1920

2021
import StdlibUnittest
2122
import StdlibCollectionUnittest

validation-test/stdlib/Prototypes/PersistentVector.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-codesign %t/a.out
55
// RUN: %line-directive %t/PersistentVector.swift -- %target-run %t/a.out
66
// REQUIRES: executable_test
7+
// REQUIRES: reflection
78

89
/*
910

validation-test/stdlib/Range.swift.gyb

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

45
import StdlibUnittest
56
import StdlibCollectionUnittest

0 commit comments

Comments
 (0)