Skip to content

Commit 7f2d4be

Browse files
committed
[Runtime] Use CMake variable to control os_trace_lazy_init usage.
SWIFT_BNI_OS_BUILD isn't exactly what we need. Use an option to turn it on/off instead. rdar://128408295
1 parent e1a82f6 commit 7f2d4be

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
@@ -474,6 +474,10 @@ function(_add_target_variant_c_compile_flags)
474474
list(APPEND result "-DSWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE")
475475
endif()
476476

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

479483
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)