Skip to content

[Runtime] Use CMake variable to control os_trace_lazy_init usage. #73761

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
May 22, 2024
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: 2 additions & 4 deletions include/swift/Runtime/TracingCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

extern "C" const char *__progname;

// This function may not be present when building at desk, and isn't really
// needed there, so just skip it in that case.
#if SWIFT_BNI_OS_BUILD
#if SWIFT_USE_OS_TRACE_LAZY_INIT
extern "C" bool _os_trace_lazy_init_completed_4swift(void);
#endif

Expand All @@ -47,7 +45,7 @@ static inline bool shouldEnableTracing() {
}

static inline bool tracingReady() {
#if SWIFT_BNI_OS_BUILD
#if SWIFT_USE_OS_TRACE_LAZY_INIT
if (!_os_trace_lazy_init_completed_4swift())
return false;
#endif
Expand Down
4 changes: 4 additions & 0 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ function(_add_target_variant_c_compile_flags)
list(APPEND result "-DSWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE")
endif()

if(SWIFT_USE_OS_TRACE_LAZY_INIT)
list(APPEND result "-DSWIFT_USE_OS_TRACE_LAZY_INIT")
endif()

list(APPEND result ${SWIFT_STDLIB_EXTRA_C_COMPILE_FLAGS})

set("${CFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)
Expand Down
4 changes: 4 additions & 0 deletions stdlib/cmake/modules/StdlibOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ option(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY
"Build the standard libraries assuming that they will be used in an environment with only a single thread."
FALSE)

option(SWIFT_USE_OS_TRACE_LAZY_INIT
"Use the os_trace call to check if lazy init has been completed before making os_signpost calls."
FALSE)

# Use dispatch as the system scheduler by default.
# For convenience, we set this to false when concurrency is disabled.
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
Expand Down