Skip to content

Commit c2f2f20

Browse files
authored
Merge pull request #73762 from mikeash/lazy-signposts-option-6.0
[6.0][Runtime] Use CMake variable to control os_trace_lazy_init usage.
2 parents 3c3ca0a + cab1625 commit c2f2f20

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

include/swift/Runtime/TracingCommon.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
extern "C" const char *__progname;
2626

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

@@ -47,7 +45,7 @@ static inline bool shouldEnableTracing() {
4745
}
4846

4947
static inline bool tracingReady() {
50-
#if SWIFT_BNI_OS_BUILD
48+
#if SWIFT_USE_OS_TRACE_LAZY_INIT
5149
if (!_os_trace_lazy_init_completed_4swift())
5250
return false;
5351
#endif

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ function(_add_target_variant_c_compile_flags)
473473
list(APPEND result "-DSWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE")
474474
endif()
475475

476+
if(SWIFT_USE_OS_TRACE_LAZY_INIT)
477+
list(APPEND result "-DSWIFT_USE_OS_TRACE_LAZY_INIT")
478+
endif()
479+
476480
list(APPEND result ${SWIFT_STDLIB_EXTRA_C_COMPILE_FLAGS})
477481

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

stdlib/cmake/modules/StdlibOptions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ option(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY
210210
"Build the standard libraries assuming that they will be used in an environment with only a single thread."
211211
FALSE)
212212

213+
option(SWIFT_USE_OS_TRACE_LAZY_INIT
214+
"Use the os_trace call to check if lazy init has been completed before making os_signpost calls."
215+
FALSE)
216+
213217
# Use dispatch as the system scheduler by default.
214218
# For convenience, we set this to false when concurrency is disabled.
215219
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)

0 commit comments

Comments
 (0)