Skip to content

Commit 5ea5bb0

Browse files
committed
Split swift-refleciton-test into host and target test targets
swift-reflection-test is now the test that forks a swift executable and performs remote reflection, making it runnable on other targets, such as the iOS simulator. swift-reflection-dump is now a host-side tool that dumps the remote reflection sections for any platform binary and will continue to link in LLVM object file support. This necessitates finally moving lib/Refleciton into stdlib/public, since we're linking target-specific versions of the test tool and we would eventually like to adopt some of this functionality in the runtime anyway.
1 parent 884155c commit 5ea5bb0

File tree

21 files changed

+299
-247
lines changed

21 files changed

+299
-247
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,12 @@ if(SWIFT_BUILD_TOOLS)
699699
endif()
700700
add_subdirectory(utils)
701701
add_subdirectory(stdlib)
702+
703+
if(SWIFT_BUILD_TOOLS)
704+
add_subdirectory(tools/swift-reflection-test)
705+
add_subdirectory(tools/swift-reflection-dump)
706+
endif()
707+
702708
if(SWIFT_BUILD_PERF_TESTSUITE AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
703709
add_subdirectory(benchmark)
704710
endif()

cmake/modules/AddSwift.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ endfunction()
18471847
function(add_swift_target_executable name)
18481848
# Parse the arguments we were given.
18491849
cmake_parse_arguments(SWIFTEXE_TARGET
1850-
"EXCLUDE_FROM_ALL;DONT_STRIP_NON_MAIN_SYMBOLS;DISABLE_ASLR"
1850+
"EXCLUDE_FROM_ALL;DONT_STRIP_NON_MAIN_SYMBOLS;DISABLE_ASLR;BUILD_WITH_STDLIB"
18511851
""
18521852
"DEPENDS;COMPONENT_DEPENDS;LINK_FAT_LIBRARIES"
18531853
${ARGN})
@@ -1887,6 +1887,10 @@ function(add_swift_target_executable name)
18871887
set(SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG_CURRENT "EXCLUDE_FROM_ALL")
18881888
endif()
18891889

1890+
if(SWIFTEXE_TARGET_BUILD_WITH_STDLIB)
1891+
add_dependencies("swift-test-stdlib${VARIANT_SUFFIX}" ${VARIANT_NAME})
1892+
endif()
1893+
18901894
# Don't add the ${arch} to the suffix. We want to link against fat
18911895
# libraries.
18921896
_list_add_string_suffix(

include/swift/Reflection/Reader.h

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

2323
#include <dlfcn.h>
2424
#include <cstdint>
25+
#include <cstring>
2526
#include <memory>
2627
#include <vector>
2728

lib/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ add_subdirectory(Markup)
1212
add_subdirectory(Option)
1313
add_subdirectory(Parse)
1414
add_subdirectory(PrintAsObjC)
15-
add_subdirectory(Reflection)
1615
add_subdirectory(Sema)
1716
add_subdirectory(Serialization)
1817
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")

lib/Reflection/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ internal func sendReflectionInfos() {
187187
for info in infos {
188188
debugLog("Sending info for \(info.imageName)")
189189
let imageNameBytes = Array(info.imageName.utf8)
190-
var imageNameLength = UInt64(imageNameBytes.count)
191-
fwrite(&imageNameLength, sizeof(UInt64.self), 1, stdout)
190+
var imageNameLength = UInt(imageNameBytes.count)
191+
fwrite(&imageNameLength, sizeof(UInt.self), 1, stdout)
192192
fflush(stdout)
193193
fwrite(imageNameBytes, 1, imageNameBytes.count, stdout)
194194
fflush(stdout)
@@ -235,7 +235,7 @@ internal func sendSymbolAddress() {
235235
name.withCString {
236236
let handle = unsafeBitCast(Int(-2), to: UnsafeMutablePointer<Void>.self)
237237
let symbol = dlsym(handle, $0)
238-
let symbolAddress = unsafeBitCast(symbol, to: UInt64.self)
238+
let symbolAddress = unsafeBitCast(symbol, to: UInt.self)
239239
sendValue(symbolAddress)
240240
}
241241
}

stdlib/public/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if(SWIFT_BUILD_STDLIB)
3232
add_subdirectory(core)
3333
add_subdirectory(SwiftOnoneSupport)
3434
add_subdirectory(Platform)
35+
add_subdirectory(Reflection)
3536
endif()
3637

3738
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
add_swift_library(swiftReflection IS_STDLIB
2+
Demangle.cpp
3+
Remangle.cpp
4+
TypeRef.cpp
5+
INSTALL_IN_COMPONENT stdlib)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "../../../lib/Basic/Demangle.cpp"
2+
#include "../../../lib/Basic/Punycode.cpp"
3+
#include "../../../lib/Basic/PunycodeUTF8.cpp"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../../../lib/Basic/Remangle.cpp"

0 commit comments

Comments
 (0)