Skip to content

Commit 0d87a10

Browse files
authored
Merge pull request #41746 from al45tair/eng/PR-89787540
Add a build option for the concurrency tracing feature.
2 parents 79533bb + f204f06 commit 0d87a10

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,15 @@ function(_add_target_variant_c_compile_flags)
373373
if(SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING)
374374
list(APPEND result "-DSWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING")
375375
endif()
376-
376+
377377
if(SWIFT_STDLIB_ENABLE_UNICODE_DATA)
378378
list(APPEND result "-D" "SWIFT_STDLIB_ENABLE_UNICODE_DATA")
379379
endif()
380380

381+
if(SWIFT_STDLIB_CONCURRENCY_TRACING)
382+
list(APPEND result "-DSWIFT_STDLIB_CONCURRENCY_TRACING")
383+
endif()
384+
381385
list(APPEND result ${SWIFT_STDLIB_EXTRA_C_COMPILE_FLAGS})
382386

383387
set("${CFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)

stdlib/cmake/modules/StdlibOptions.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,14 @@ option(SWIFT_FREESTANDING_FLAVOR
183183
set(SWIFT_STDLIB_ENABLE_LTO OFF CACHE STRING "Build Swift stdlib with LTO. One
184184
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
185185
option only affects the standard library and runtime, not tools.")
186+
187+
if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
188+
set(SWIFT_STDLIB_CONCURRENCY_TRACING_default TRUE)
189+
else()
190+
set(SWIFT_STDLIB_CONCURRENCY_TRACING_default FALSE)
191+
endif()
192+
193+
option(SWIFT_STDLIB_CONCURRENCY_TRACING
194+
"Enable concurrency tracing in the runtime; assumes the presence of os_log(3)
195+
and the os_signpost(3) API."
196+
"${SWIFT_STDLIB_CONCURRENCY_TRACING_default}")

stdlib/public/Concurrency/Tracing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void job_run_end(ExecutorRef *executor, job_run_info info);
9696
} // namespace concurrency
9797
} // namespace swift
9898

99-
#if __has_include(<os/signpost.h>)
99+
#if SWIFT_STDLIB_CONCURRENCY_TRACING
100100
#include "TracingSignpost.h"
101101
#else
102102
#include "TracingStubs.h"

stdlib/public/Concurrency/TracingSignpost.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17-
#if __has_include(<os/signpost.h>)
17+
#if SWIFT_STDLIB_CONCURRENCY_TRACING
1818

1919
#include "TracingSignpost.h"
2020
#include <stdio.h>

utils/build-presets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,7 @@ swift-stdlib-has-environ=0
25282528
swift-stdlib-has-locale=0
25292529
swift-runtime-static-image-inspection=1
25302530
swift-stdlib-single-threaded-runtime=1
2531+
swift-stdlib-concurrency-tracing=0
25312532
swift-stdlib-os-versioning=0
25322533
swift-stdlib-has-commandline=0
25332534
swift-stdlib-lto=full

utils/build-script-impl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ KNOWN_SETTINGS=(
206206
swift-stdlib-supports-backtrace-reporting "" "whether to build stdlib assuming the runtime environment provides the backtrace(3) API, if not set defaults to true on all platforms except for Cygwin, Haiku and wasm"
207207
swift-runtime-static-image-inspection "0" "whether to build stdlib assuming the runtime environment only supports a single runtime image with Swift code"
208208
swift-stdlib-single-threaded-runtime "0" "whether to build stdlib as a single-threaded runtime only"
209+
swift-stdlib-concurrency-tracing "" "whether to enable tracing signposts for concurrency; default is 1 on Darwin platforms, 0 otherwise"
209210
swift-stdlib-os-versioning "1" "whether to build stdlib with availability based on OS versions (Darwin only)"
210211
swift-stdlib-has-commandline "1" "whether to build stdlib with the CommandLine enum and support for argv/argc"
211212
swift-stdlib-stable-abi "" "should stdlib be built with stable ABI, if not set defaults to true on Darwin, false otherwise"
@@ -2210,6 +2211,13 @@ for host in "${ALL_HOSTS[@]}"; do
22102211
)
22112212
fi
22122213

2214+
if [[ "${SWIFT_STDLIB_CONCURRENCY_TRACING}" ]] ; then
2215+
cmake_options=(
2216+
"${cmake_options[@]}"
2217+
-DSWIFT_STDLIB_CONCURRENCY_TRACING:BOOL=$(true_false "${SWIFT_STDLIB_CONCURRENCY_TRACING}")
2218+
)
2219+
fi
2220+
22132221
build_targets=(all "${SWIFT_STDLIB_TARGETS[@]}")
22142222
if [[ $(true_false "${build_perf_testsuite_this_time}") == "TRUE" ]]; then
22152223
native_swift_tools_path="$(build_directory_bin ${LOCAL_HOST} swift)"

0 commit comments

Comments
 (0)