Skip to content

Commit cb3365f

Browse files
committed
build: split out swiftReflection builds
We would build two copies of swiftReflection, one for the host and one for the target. However, the compiler configuration cannot be swapped out in the middle as we were attempting to do. This would result in a failure to build sometimes due to the missing dependency on the wanted compiler. More importantly, it would also use the wrong compiler when building the library. Although this duplicates the source paths, correctness is preserved.
1 parent 4f98772 commit cb3365f

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,6 @@ else()
10961096
# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
10971097
# ensure we build that when building tools.
10981098
if(SWIFT_INCLUDE_TOOLS)
1099-
add_subdirectory(stdlib/public/Reflection)
11001099
add_subdirectory(stdlib/public/SwiftShims)
11011100
endif()
11021101
endif()

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ add_subdirectory(RemoteAST)
3737
add_subdirectory(Sema)
3838
add_subdirectory(Serialization)
3939
add_subdirectory(SwiftDemangle)
40+
add_subdirectory(SwiftReflection)
4041
add_subdirectory(SIL)
4142
add_subdirectory(SILGen)
4243
add_subdirectory(SILOptimizer)

lib/SwiftReflection/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
add_swift_host_library(swiftReflection STATIC
3+
${SWIFT_SOURCE_DIR}/stdlib/public/Reflection/MetadataSource.cpp
4+
${SWIFT_SOURCE_DIR}/stdlib/public/Reflection/TypeLowering.cpp
5+
${SWIFT_SOURCE_DIR}/stdlib/public/Reflection/TypeRef.cpp
6+
${SWIFT_SOURCE_DIR}/stdlib/public/Reflection/TypeRefBuilder.cpp)
7+
target_link_libraries(swiftReflection PUBLIC
8+
swiftDemangling)

stdlib/public/Reflection/CMakeLists.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,3 @@ if(SWIFT_BUILD_STDLIB)
2828
INSTALL_IN_COMPONENT dev)
2929
endif()
3030

31-
# Build a specific version for the host with the host toolchain. This is going
32-
# to be used by tools (e.g. lldb)
33-
if(SWIFT_INCLUDE_TOOLS)
34-
if(NOT SWIFT_BUILD_STDLIB)
35-
add_custom_target(swiftReflection-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR})
36-
endif()
37-
38-
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
39-
set(CURRENT_CMAKE_C_COMPILER ${CMAKE_C_COMPILER})
40-
set(CURRENT_CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER})
41-
set(CMAKE_C_COMPILER ${HOST_CMAKE_C_COMPILER})
42-
set(CMAKE_CXX_COMPILER ${HOST_CMAKE_CXX_COMPILER})
43-
endif()
44-
45-
add_swift_host_library(swiftReflection STATIC
46-
${swiftReflection_SOURCES})
47-
target_compile_options(swiftReflection PRIVATE
48-
${SWIFT_RUNTIME_CXX_FLAGS})
49-
set_property(TARGET swiftReflection
50-
APPEND_STRING PROPERTY LINK_FLAGS ${SWIFT_RUNTIME_LINK_FLAGS})
51-
52-
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
53-
set(CMAKE_C_COMPILER ${CURRENT_CMAKE_C_COMPILER})
54-
set(CMAKE_CXX_COMPILER ${CURRENT_CMAKE_CXX_COMPILER})
55-
endif()
56-
endif()

0 commit comments

Comments
 (0)