Skip to content

Commit 42457b9

Browse files
authored
Merge pull request #32092 from compnerd/undeocrating-undecoration
runtime: extract `swiftDemangling` into a support library
2 parents 1dcd25a + fb58228 commit 42457b9

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

stdlib/public/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,34 @@ endif()
5050

5151
add_subdirectory(SwiftShims)
5252

53+
# This static library is shared across swiftCore and swiftReflection
54+
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)
55+
# TODO: due to the use of `add_swift_target_library` rather than `add_library`
56+
# we cannot use `target_sources` and thus must resort to list manipulations to
57+
# adjust the source list.
58+
set(swiftDemanglingSources
59+
"${SWIFT_SOURCE_DIR}/lib/Demangling/Context.cpp"
60+
"${SWIFT_SOURCE_DIR}/lib/Demangling/Demangler.cpp"
61+
"${SWIFT_SOURCE_DIR}/lib/Demangling/ManglingUtils.cpp"
62+
"${SWIFT_SOURCE_DIR}/lib/Demangling/NodePrinter.cpp"
63+
"${SWIFT_SOURCE_DIR}/lib/Demangling/OldDemangler.cpp"
64+
"${SWIFT_SOURCE_DIR}/lib/Demangling/OldRemangler.cpp"
65+
"${SWIFT_SOURCE_DIR}/lib/Demangling/Punycode.cpp"
66+
"${SWIFT_SOURCE_DIR}/lib/Demangling/Remangler.cpp")
67+
68+
# When we're building with assertions, include the demangle node dumper to aid
69+
# in debugging.
70+
if(LLVM_ENABLE_ASSERTIONS)
71+
list(APPEND swiftDemanglingSources
72+
"${SWIFT_SOURCE_DIR}/lib/Demangling/NodeDumper.cpp")
73+
endif()
74+
75+
add_swift_target_library(swiftDemangling OBJECT_LIBRARY
76+
${swiftDemanglingSources}
77+
C_COMPILE_FLAGS -DswiftCore_EXPORTS
78+
INSTALL_IN_COMPONENT never_install)
79+
endif()
80+
5381
if(SWIFT_BUILD_STDLIB)
5482
# These must be kept in dependency order so that any referenced targets
5583
# exist at the time we look for them in add_swift_*.

stdlib/public/Reflection/CMakeLists.txt

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,13 @@ set(swiftReflection_SOURCES
22
MetadataSource.cpp
33
TypeLowering.cpp
44
TypeRef.cpp
5-
TypeRefBuilder.cpp
6-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Context.cpp"
7-
"${SWIFT_SOURCE_DIR}/lib/Demangling/OldDemangler.cpp"
8-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Demangler.cpp"
9-
"${SWIFT_SOURCE_DIR}/lib/Demangling/NodePrinter.cpp"
10-
"${SWIFT_SOURCE_DIR}/lib/Demangling/ManglingUtils.cpp"
11-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Punycode.cpp"
12-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Remangler.cpp")
13-
14-
# When we're building with assertions, include the demangle node dumper to aid
15-
# in debugging.
16-
if (LLVM_ENABLE_ASSERTIONS)
17-
list(APPEND swiftReflection_SOURCES
18-
"${SWIFT_SOURCE_DIR}/lib/Demangling/NodeDumper.cpp")
19-
endif(LLVM_ENABLE_ASSERTIONS)
5+
TypeRefBuilder.cpp)
206

217
add_swift_target_library(swiftReflection STATIC
228
${swiftReflection_SOURCES}
239
C_COMPILE_FLAGS ${SWIFT_RUNTIME_CXX_FLAGS} -DswiftCore_EXPORTS
2410
LINK_FLAGS ${SWIFT_RUNTIME_LINK_FLAGS}
25-
INCORPORATE_OBJECT_LIBRARIES swiftLLVMSupport
11+
INCORPORATE_OBJECT_LIBRARIES
12+
swiftLLVMSupport swiftDemangling
2613
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
2714
INSTALL_IN_COMPONENT dev)

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ add_swift_target_library(swiftCore
321321
PRIVATE_LINK_LIBRARIES
322322
${swift_core_private_link_libraries}
323323
INCORPORATE_OBJECT_LIBRARIES
324-
swiftRuntime swiftLLVMSupport swiftStdlibStubs
324+
swiftRuntime swiftLLVMSupport swiftDemangling swiftStdlibStubs
325325
FRAMEWORK_DEPENDS
326326
${swift_core_framework_depends}
327327
INSTALL_IN_COMPONENT

stdlib/public/runtime/CMakeLists.txt

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ set(swift_runtime_objc_sources
2323
SwiftObject.mm
2424
SwiftValue.mm
2525
ReflectionMirror.mm
26-
ObjCRuntimeGetImageNameFromClass.mm
27-
"${SWIFT_SOURCE_DIR}/lib/Demangling/OldRemangler.cpp"
28-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Remangler.cpp"
29-
)
26+
ObjCRuntimeGetImageNameFromClass.mm)
3027

3128
set(swift_runtime_sources
3229
AnyHashableSupport.cpp
@@ -62,19 +59,7 @@ set(swift_runtime_sources
6259
ProtocolConformance.cpp
6360
RefCount.cpp
6461
RuntimeInvocationsTracking.cpp
65-
SwiftDtoa.cpp
66-
"${SWIFT_SOURCE_DIR}/lib/Demangling/OldDemangler.cpp"
67-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Demangler.cpp"
68-
"${SWIFT_SOURCE_DIR}/lib/Demangling/NodePrinter.cpp"
69-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Context.cpp"
70-
"${SWIFT_SOURCE_DIR}/lib/Demangling/ManglingUtils.cpp"
71-
"${SWIFT_SOURCE_DIR}/lib/Demangling/Punycode.cpp")
72-
73-
# When we're building with assertions, include the demangle node dumper to aid
74-
# in debugging.
75-
if (LLVM_ENABLE_ASSERTIONS)
76-
list(APPEND swift_runtime_sources "${SWIFT_SOURCE_DIR}/lib/Demangling/NodeDumper.cpp")
77-
endif(LLVM_ENABLE_ASSERTIONS)
62+
SwiftDtoa.cpp)
7863

7964
# Acknowledge that the following sources are known.
8065
set(LLVM_OPTIONAL_SOURCES
@@ -174,7 +159,6 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY
174159
${swift_runtime_library_compile_flags}
175160
${_RUNTIME_NONATOMIC_FLAGS}
176161
LINK_FLAGS ${swift_runtime_linker_flags}
177-
INCORPORATE_OBJECT_LIBRARIES swiftLLVMSupport
178162
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
179163
INSTALL_IN_COMPONENT never_install)
180164

unittests/runtime/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
7575
# and the stdlib.
7676
$<TARGET_OBJECTS:swiftRuntime${SWIFT_PRIMARY_VARIANT_SUFFIX}>
7777
$<TARGET_OBJECTS:swiftLLVMSupport${SWIFT_PRIMARY_VARIANT_SUFFIX}>
78+
$<TARGET_OBJECTS:swiftDemangling${SWIFT_PRIMARY_VARIANT_SUFFIX}>
7879
)
7980

8081
# The local stdlib implementation provides definitions of the swiftCore

unittests/runtime/LongTests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
3838
# and the stdlib.
3939
$<TARGET_OBJECTS:swiftRuntime${SWIFT_PRIMARY_VARIANT_SUFFIX}>
4040
$<TARGET_OBJECTS:swiftLLVMSupport${SWIFT_PRIMARY_VARIANT_SUFFIX}>
41+
$<TARGET_OBJECTS:swiftDemangling${SWIFT_PRIMARY_VARIANT_SUFFIX}>
4142
)
4243

4344
# The local stdlib implementation provides definitions of the swiftCore

0 commit comments

Comments
 (0)