@@ -82,19 +82,6 @@ base_common = [
8282 ' -fno-strict-aliasing' , # Prevent strict aliasing optimizations
8383]
8484
85- # macOS SDK 15+ can deadlock in ASan's pre-main global registration when an
86- # instrumented executable dynamically loads instrumented libraries (Apple
87- # Feedback FB16513866; FastLED #3642). Keep ASan heap/stack instrumentation and
88- # UBSan enabled, but disable the affected ASan globals pass on Apple debug
89- # builds. This must be applied to both runners and every library they load.
90- apple_asan_dlopen_workaround_args = []
91- if build_machine .system() == ' darwin'
92- apple_asan_dlopen_workaround_args = [
93- ' -mllvm' ,
94- ' -asan-globals=0' ,
95- ]
96- endif
97-
9885# Stack trace preservation flags (used in debug and quick modes only)
9986stack_trace_flags = [
10087 ' -fno-omit-frame-pointer' , # Keep frame pointers for stack traces
@@ -117,7 +104,7 @@ if build_mode == 'debug'
117104 ' -g3' , # Full debug symbols (variables, macros, everything)
118105 ' -fsanitize=address' , # Address sanitizer (detect memory errors)
119106 ' -fsanitize=undefined' , # Undefined behavior sanitizer
120- ] + apple_asan_dlopen_workaround_args
107+ ]
121108elif build_mode == ' quick'
122109 # Quick mode: Default mode for fast development iteration
123110 # No optimization, no debug symbols, no sanitizers
@@ -257,6 +244,22 @@ if build_mode == 'debug'
257244 ' -fsanitize=undefined' ,
258245 ' -shared-libasan' , # Use shared ASan runtime (required for DLL architecture)
259246 ]
247+ if is_macos
248+ # macOS 26.4 deadlocks before main() with older ASan runtimes while they
249+ # inspect dyld's shared cache (LLVM #200447, FastLED #3642). GitHub's
250+ # macos-26 image ships Xcode 26.5 by default, whose compiler-rt contains
251+ # Apple's fix. Keep clang-tool-chain for compilation, but make its driver
252+ # link the platform-compatible Xcode sanitizer runtime.
253+ xcrun_program = find_program (' xcrun' )
254+ apple_clang_resource_dir = run_command (
255+ xcrun_program,
256+ ' clang' ,
257+ ' -print-resource-dir' ,
258+ check : true
259+ ).stdout().strip()
260+ sanitizer_link_args += [' -resource-dir=' + apple_clang_resource_dir]
261+ message (' Using Xcode sanitizer runtime: ' + apple_clang_resource_dir)
262+ endif
260263endif
261264
262265# ============================================================================
@@ -403,7 +406,7 @@ if build_mode == 'debug'
403406 ' -g3' ,
404407 ' -fsanitize=address' ,
405408 ' -fsanitize=undefined' ,
406- ] + apple_asan_dlopen_workaround_args
409+ ]
407410elif build_mode == ' quick'
408411 runner_cpp_args += stack_trace_flags + [
409412 ' -O1' ,
0 commit comments