<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/72639>72639</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[asan][Darwin] Unprotected use of Apple blocks breaks build with GCC
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fxcoudert
</td>
</tr>
</table>
<pre>
The commit at https://github.com/llvm/llvm-project/commit/020cdaff615acbdc9ef6a801075a484ef74d5070 broke build of asan on macOS with GCC. GCC does not support the Apple blocks extension (yet). Uses of blocks in other parts of the sanitisers are protected by `MISSING_BLOCKS_SUPPORT`. But the type definition is not.
Could the same thing be done here? This works for me (tested in a build of asan inside GCC):
```
diff --git a/libsanitizer/asan/asan_mac.cpp b/libsanitizer/asan/asan_mac.cpp
index 5d5146e0cde..6252fa20d5e 100644
--- a/libsanitizer/asan/asan_mac.cpp
+++ b/libsanitizer/asan/asan_mac.cpp
@@ -139,9 +139,11 @@ typedef void (*dispatch_mach_handler_function_t)(void *context,
dispatch_mach_reason reason,
dispatch_mach_msg_t message,
mach_error_t error);
+#if !defined(MISSING_BLOCKS_SUPPORT)
typedef void (^dispatch_mach_handler_t)(dispatch_mach_reason reason,
dispatch_mach_msg_t message,
mach_error_t error);
+#endif
// A wrapper for the ObjC blocks used to support libdispatch.
typedef struct {
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VE1v2zgQ_TX0ZWCBpD4sHXSwnXVR7EeKTXI2SHFksZFIgaTqZH_9gpK8abst0F4KCBwKM3ycN8N5wnt9MYg1yQ8kv9uIKXTW1e1LYyeFLmykVa_1Y4fQ2GHQAUSALoTRk3RP-Inw00WHbpJJYwfCT33_6Wa2o7MfsQmEn5ajhJ8op40SbVuwXDRSNRW2hSgpo7tcZGWG7S5TOd1RkM4-I8hJ9wpsC8ILA9bAIJr7B7jq0MG74zGJCy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