Skip to content

Commit 7c0e1f5

Browse files
committed
[Concurrency] Fix embedded, cannot refer to runtime/env vars from Actor.cpp
1 parent da59253 commit 7c0e1f5

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,25 +345,40 @@ bool __swift_bincompat_useLegacyNonCrashingExecutorChecks() {
345345
#endif
346346
}
347347

348+
// Shimming call to Swift runtime because Swift Embedded does not have
349+
// these symbols defined.
350+
const char *__swift_runtime_env_useLegacyNonCrashingExecutorChecks() {
351+
// Potentially, override the platform detected mode, primarily used in tests.
352+
#if SWIFT_STDLIB_HAS_ENVIRON && !SWIFT_CONCURRENCY_EMBEDDED
353+
return swift::runtime::environment::
354+
concurrencyIsCurrentExecutorLegacyModeOverride();
355+
#else
356+
return nullptr;
357+
#endif
358+
}
359+
360+
#pragma clang diagnostic push
361+
#pragma ide diagnostic ignored "ConstantConditionsOC"
348362
// Done this way because of the interaction with the initial value of
349363
// 'unexpectedExecutorLogLevel'
350364
bool swift_bincompat_useLegacyNonCrashingExecutorChecks() {
351365
bool legacyMode = __swift_bincompat_useLegacyNonCrashingExecutorChecks();
352366

353367
// Potentially, override the platform detected mode, primarily used in tests.
354-
#if SWIFT_STDLIB_HAS_ENVIRON
355-
if (const char *modeStr = runtime::environment::
356-
concurrencyIsCurrentExecutorLegacyModeOverride()) {
357-
if (strcmp(modeStr, "nocrash") == 0 || strcmp(modeStr, "legacy") == 0) {
368+
if (const char *modeStr =
369+
__swift_runtime_env_useLegacyNonCrashingExecutorChecks()) {
370+
if (strcmp(modeStr, "nocrash") == 0 ||
371+
strcmp(modeStr, "legacy") == 0) {
358372
return true;
359-
} else if (strcmp(modeStr, "crash") == 0 || strcmp(modeStr, "swift6") == 0) {
373+
} else if (strcmp(modeStr, "crash") == 0 ||
374+
strcmp(modeStr, "swift6") == 0) {
360375
return false; // don't use the legacy mode
361376
} // else, just use the platform detected mode
362377
} // no override, use the default mode
363-
#endif // SWIFT_STDLIB_HAS_ENVIRON
364378

365379
return legacyMode;
366380
}
381+
#pragma clang diagnostic pop
367382

368383
// Check override of executor checking mode.
369384
static void checkIsCurrentExecutorMode(void *context) {

0 commit comments

Comments
 (0)