Skip to content

Commit 1147d08

Browse files
authored
Disable stable ABI on freestanding stdlib (swiftlang#39674)
1 parent 8866a2d commit 1147d08

File tree

6 files changed

+38
-9
lines changed

6 files changed

+38
-9
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,10 +1726,7 @@ function(add_swift_target_library name)
17261726
endif()
17271727

17281728
# Turn off implicit import of _Concurrency when building libraries
1729-
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
1730-
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS
1731-
"-Xfrontend;-disable-implicit-concurrency-module-import")
1732-
endif()
1729+
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-Xfrontend;-disable-implicit-concurrency-module-import")
17331730

17341731
# Turn off implicit import of _Distributed when building libraries
17351732
if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED)

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,10 @@ function(_compile_swift_files
894894
COMMENT "Generating ${module_file}")
895895

896896
if(SWIFTFILE_STATIC)
897+
set(command_copy_interface_file)
898+
if(interface_file)
899+
set(command_copy_interface_file COMMAND "${CMAKE_COMMAND}" "-E" "copy" ${interface_file} ${interface_file_static})
900+
endif()
897901
add_custom_command_target(
898902
module_dependency_target_static
899903
COMMAND
@@ -903,8 +907,7 @@ function(_compile_swift_files
903907
"${CMAKE_COMMAND}" "-E" "copy" ${module_file} ${module_file_static}
904908
COMMAND
905909
"${CMAKE_COMMAND}" "-E" "copy" ${module_doc_file} ${module_doc_file_static}
906-
COMMAND
907-
"${CMAKE_COMMAND}" "-E" "copy" ${interface_file} ${interface_file_static}
910+
${command_copy_interface_file}
908911
OUTPUT ${module_outputs_static}
909912
DEPENDS
910913
"${module_dependency_target}"

stdlib/public/core/Mirror.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,19 +481,31 @@ public struct Mirror {
481481
children: C,
482482
displayStyle: DisplayStyle? = nil,
483483
ancestorRepresentation: AncestorRepresentation = .generated
484-
) where C.Element == Child { Builtin.unreachable() }
484+
) where C.Element == Child {
485+
// Can't use Builtin.unreachable() due to
486+
// https://bugs.swift.org/browse/SR-15300
487+
self.init(reflecting: subject)
488+
}
485489
public init<Subject, C: Collection>(
486490
_ subject: Subject,
487491
unlabeledChildren: C,
488492
displayStyle: DisplayStyle? = nil,
489493
ancestorRepresentation: AncestorRepresentation = .generated
490-
) { Builtin.unreachable() }
494+
) {
495+
// Can't use Builtin.unreachable() due to
496+
// https://bugs.swift.org/browse/SR-15300
497+
self.init(reflecting: subject)
498+
}
491499
public init<Subject>(
492500
_ subject: Subject,
493501
children: KeyValuePairs<String, Any>,
494502
displayStyle: DisplayStyle? = nil,
495503
ancestorRepresentation: AncestorRepresentation = .generated
496-
) { Builtin.unreachable() }
504+
) {
505+
// Can't use Builtin.unreachable() due to
506+
// https://bugs.swift.org/browse/SR-15300
507+
self.init(reflecting: subject)
508+
}
497509
public let subjectType: Any.Type
498510
public let children: Children
499511
public let displayStyle: DisplayStyle?

test/SIL/crash-sr-15300.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -Osize -parse-stdlib -enable-ossa-modules -emit-sil %s
2+
3+
// https://bugs.swift.org/browse/SR-15300
4+
// XFAIL: *
5+
6+
import Swift
7+
8+
public struct A {
9+
public init(_ pairs: KeyValuePairs<Any, Any>) {
10+
Builtin.unreachable()
11+
}
12+
}

test/lit.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,10 @@ if run_vendor == 'apple':
941941
# Build all "freestanding" tests with -disable-objc-interop
942942
swift_execution_tests_extra_flags += ' -Xfrontend -disable-objc-interop'
943943

944+
# The Concurrency module is not available in "freestanding" mode.
945+
swift_execution_tests_extra_flags += \
946+
' -Xfrontend -disable-implicit-concurrency-module-import'
947+
944948
# Link all "freestanding" tests with -dead_strip, which can effectively
945949
# even remove parts of the stdlib and runtime, if it's not needed. Since
946950
# it's a very desired behavior, let's enable it for all executable tests.

utils/build-presets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,7 @@ build-swift-static-stdlib=1
24632463
swift-objc-interop=0
24642464
swift-enable-compatibility-overrides=0
24652465
swift-enable-reflection=0
2466+
swift-stdlib-stable-abi=0
24662467
swift-stdlib-has-dladdr=0
24672468
swift-stdlib-supports-backtrace-reporting=0
24682469
swift-stdlib-has-darwin-libmalloc=0

0 commit comments

Comments
 (0)