Skip to content

Commit c7847e1

Browse files
authored
Merge pull request #85618 from etcwilde/ewilde-6.3/stdlib-tracing
πŸ’6.3: CMake: Runtimes: Enable tracing on Apple OSs
2 parents 896e1fb + b46b5ef commit c7847e1

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

β€ŽRuntimes/Core/CMakeLists.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ defaulted_option(SwiftCore_ENABLE_RUNTIME_OS_VERSIONING "Enable runtime OS versi
106106
defaulted_option(SwiftCore_ENABLE_STATIC_PRINT "Disable full print")
107107
defaulted_option(SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS "Resolve absolute function pointer as identity")
108108
defaulted_option(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT "Add symbols for runtime backdeployment")
109-
defaulted_option(SwiftCore_ENABLE_STDLIB_TRACING "Enable tracing in the runtime. Assumes the presence of os_log(3) and the os_signpost(3) API.")
110109
defaulted_option(SwiftCore_ENABLE_CONCURRENCY "Enable Concurrency runtime support")
111110
defaulted_option(SwiftCore_ENABLE_REMOTE_MIRROR "Enable RemoteMirror runtime support")
112111
defaulted_set(SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR STRING "Default Concurrency global executor implementation")
112+
option(SwiftCore_ENABLE_STDLIB_TRACING "Enable tracing in the runtime. Requires os_log(3) and the os_signpost(3) API." OFF)
113113
option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support" ON)
114114
option(SwiftCore_ENABLE_UNICODE_DATA "Include unicode data in Swift runtimes" ON)
115115
option(SwiftCore_ENABLE_SHORT_MANGLING_LOOKUPS "Build with fast-path context descriptor lookups based on well-known short manglings." ON)

β€ŽRuntimes/Core/Concurrency/CMakeLists.txtβ€Ž

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ add_library(swift_Concurrency
2222
TaskLocal.cpp
2323
TaskStatus.cpp
2424
ThreadingError.cpp
25-
TracingSignpost.cpp
2625
"${PROJECT_SOURCE_DIR}/CompatibilityOverride/CompatibilityOverride.cpp"
2726
"./linker-support/magic-symbols-for-install-name.c"
2827
Actor.swift
@@ -99,6 +98,15 @@ add_library(swift_Concurrency
9998
"${CMAKE_CURRENT_BINARY_DIR}/TaskGroup+addTask.swift"
10099
"${CMAKE_CURRENT_BINARY_DIR}/Task+immediate.swift")
101100

101+
if(SwiftCore_ENABLE_STDLIB_TRACING)
102+
target_compile_definitions(swift_Concurrency
103+
PRIVATE
104+
SWIFT_STDLIB_TRACING
105+
SWIFT_STDLIB_CONCURRENCY_TRACING)
106+
target_sources(swift_Concurrency
107+
PRIVATE TracingSignpost.cpp)
108+
endif()
109+
102110
if(APPLE)
103111
target_sources(swift_Concurrency PRIVATE
104112
CFExecutor.swift

β€ŽRuntimes/Core/cmake/caches/Vendors/Apple/apple-common.cmakeβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
1313
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
1414
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")
1515
set(SwiftCore_ENABLE_STRICT_AVAILABILITY ON CACHE BOOL "")
16+
set(SwiftCore_ENABLE_STDLIB_TRACING ON CACHE BOOL "")
1617

1718
set(SwiftCore_OPTIMIZATION_REMARKS "bitstream" CACHE STRING "")
1819

β€ŽRuntimes/Core/runtime/CMakeLists.txtβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ if(SwiftCore_ENABLE_FILESYSTEM_SUPPORT AND (NOT SwiftCore_ARCH_SUBDIR OR NOT Swi
7272
message(SEND_ERROR "Filesystem support requires setting `SwiftCore_ARCH_SUBDIR` and `SwiftCore_PLATFORM_SUBDIR`")
7373
endif()
7474

75+
if(SwiftCore_ENABLE_STDLIB_TRACING)
76+
check_symbol_exists("os_signpost_interval_begin" "os/signpost.h" SwiftCore_HAS_OS_SIGNPOST)
77+
check_symbol_exists("os_log" "os/log.h" SwiftCore_HAS_OS_LOG)
78+
if(NOT SwiftCore_HAS_OS_LOG OR NOT SwiftCore_HAS_OS_SIGNPOST)
79+
message(SEND_ERROR "Tracing requires 'os_signpost' and 'os_log' APIs")
80+
endif()
81+
endif()
82+
7583
# TODO: Probably worth considering putting half of these in a RuntimeConfig.h.in
7684
# file rather than pushing them through macro flags.
7785
target_compile_definitions(swiftRuntime

0 commit comments

Comments
Β (0)