Skip to content

Add a build option for the concurrency tracing feature. #41746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,15 @@ function(_add_target_variant_c_compile_flags)
if(SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING)
list(APPEND result "-DSWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING")
endif()

if(SWIFT_STDLIB_ENABLE_UNICODE_DATA)
list(APPEND result "-D" "SWIFT_STDLIB_ENABLE_UNICODE_DATA")
endif()

if(SWIFT_STDLIB_CONCURRENCY_TRACING)
list(APPEND result "-DSWIFT_STDLIB_CONCURRENCY_TRACING")
endif()

list(APPEND result ${SWIFT_STDLIB_EXTRA_C_COMPILE_FLAGS})

set("${CFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)
Expand Down
11 changes: 11 additions & 0 deletions stdlib/cmake/modules/StdlibOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,14 @@ option(SWIFT_FREESTANDING_FLAVOR
set(SWIFT_STDLIB_ENABLE_LTO OFF CACHE STRING "Build Swift stdlib with LTO. One
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
option only affects the standard library and runtime, not tools.")

if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
set(SWIFT_STDLIB_CONCURRENCY_TRACING_default TRUE)
else()
set(SWIFT_STDLIB_CONCURRENCY_TRACING_default FALSE)
endif()

option(SWIFT_STDLIB_CONCURRENCY_TRACING
"Enable concurrency tracing in the runtime; assumes the presence of os_log(3)
and the os_signpost(3) API."
"${SWIFT_STDLIB_CONCURRENCY_TRACING_default}")
2 changes: 1 addition & 1 deletion stdlib/public/Concurrency/Tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void job_run_end(ExecutorRef *executor, job_run_info info);
} // namespace concurrency
} // namespace swift

#if __has_include(<os/signpost.h>)
#if SWIFT_STDLIB_CONCURRENCY_TRACING
#include "TracingSignpost.h"
#else
#include "TracingStubs.h"
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/Concurrency/TracingSignpost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
//===----------------------------------------------------------------------===//

#if __has_include(<os/signpost.h>)
#if SWIFT_STDLIB_CONCURRENCY_TRACING

#include "TracingSignpost.h"
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,7 @@ swift-stdlib-has-environ=0
swift-stdlib-has-locale=0
swift-runtime-static-image-inspection=1
swift-stdlib-single-threaded-runtime=1
swift-stdlib-concurrency-tracing=0
swift-stdlib-os-versioning=0
swift-stdlib-has-commandline=0
swift-stdlib-lto=full
Expand Down
8 changes: 8 additions & 0 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ KNOWN_SETTINGS=(
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"
swift-runtime-static-image-inspection "0" "whether to build stdlib assuming the runtime environment only supports a single runtime image with Swift code"
swift-stdlib-single-threaded-runtime "0" "whether to build stdlib as a single-threaded runtime only"
swift-stdlib-concurrency-tracing "" "whether to enable tracing signposts for concurrency; default is 1 on Darwin platforms, 0 otherwise"
swift-stdlib-os-versioning "1" "whether to build stdlib with availability based on OS versions (Darwin only)"
swift-stdlib-has-commandline "1" "whether to build stdlib with the CommandLine enum and support for argv/argc"
swift-stdlib-stable-abi "" "should stdlib be built with stable ABI, if not set defaults to true on Darwin, false otherwise"
Expand Down Expand Up @@ -2210,6 +2211,13 @@ for host in "${ALL_HOSTS[@]}"; do
)
fi

if [[ "${SWIFT_STDLIB_CONCURRENCY_TRACING}" ]] ; then
cmake_options=(
"${cmake_options[@]}"
-DSWIFT_STDLIB_CONCURRENCY_TRACING:BOOL=$(true_false "${SWIFT_STDLIB_CONCURRENCY_TRACING}")
)
fi

build_targets=(all "${SWIFT_STDLIB_TARGETS[@]}")
if [[ $(true_false "${build_perf_testsuite_this_time}") == "TRUE" ]]; then
native_swift_tools_path="$(build_directory_bin ${LOCAL_HOST} swift)"
Expand Down