Skip to content

Commit 52a125e

Browse files
mborlanddaveedvdv-nvidia
authored andcommitted
Do not define __BLOCKS__ with macOS Clang [GH edgcpp#307]
1 parent 5a3ab44 commit 52a125e

9 files changed

Lines changed: 50 additions & 8 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ cmake/macro-conf/*.cmakedef
6666

6767
# AI tooling items to ignore:
6868
CLAUDE.md
69+
70+
# macOS specific items to ignore:
71+
*.DS_Store

‎bases/cmake-native/macos-arm/clang/lib/predefined_macros.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ clang no __ATOMIC_RELEASE 3
111111
clang no __ATOMIC_SEQ_CST 5
112112
clang no __BIGGEST_ALIGNMENT__ 8
113113
clang no __BITINT_MAXWIDTH__ 128
114-
clang no __BLOCKS__ 1
115114
clang no __BOOL_WIDTH__ 8
116115
clang no __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
117116
clang no __CHAR_BIT__ 8
@@ -439,7 +438,6 @@ clang no __aarch64__ 1
439438
clang no __apple_build_version__ 15000309
440439
clang no __arm64 1
441440
clang no __arm64__ 1
442-
clang no __block __attribute__((__blocks__(byref)))
443441
clang no __clang_literal_encoding__ "UTF-8"
444442
clang no __clang_wide_literal_encoding__ "UTF-32"
445443
clang no __llvm__ 1

‎bases/cmake-native/macos-arm/clang/lib_macos_arm64/predefined_macros.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ clang no __ATOMIC_RELEASE 3
111111
clang no __ATOMIC_SEQ_CST 5
112112
clang no __BIGGEST_ALIGNMENT__ 8
113113
clang no __BITINT_MAXWIDTH__ 128
114-
clang no __BLOCKS__ 1
115114
clang no __BOOL_WIDTH__ 8
116115
clang no __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
117116
clang no __CHAR_BIT__ 8
@@ -439,7 +438,6 @@ clang no __aarch64__ 1
439438
clang no __apple_build_version__ 15000309
440439
clang no __arm64 1
441440
clang no __arm64__ 1
442-
clang no __block __attribute__((__blocks__(byref)))
443441
clang no __clang_literal_encoding__ "UTF-8"
444442
clang no __clang_wide_literal_encoding__ "UTF-32"
445443
clang no __llvm__ 1

‎bases/cmake-native/macos-x86_64/clang/lib/predefined_macros.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ clang no __ATOMIC_RELAXED 0
6262
clang no __ATOMIC_RELEASE 3
6363
clang no __ATOMIC_SEQ_CST 5
6464
clang no __BIGGEST_ALIGNMENT__ 16
65-
clang no __BLOCKS__ 1
6665
clang no __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
6766
clang no __CHAR_BIT__ 8
6867
clang no __CLANG_ATOMIC_BOOL_LOCK_FREE 2
@@ -387,7 +386,6 @@ clang no __WINT_WIDTH__ 32
387386
clang no __amd64 1
388387
clang no __amd64__ 1
389388
clang no __apple_build_version__ 12050022
390-
clang no __block __attribute__((__blocks__(byref)))
391389
clang no __code_model_small__ 1
392390
clang no __core2 1
393391
clang no __core2__ 1

‎bases/cmake-native/macos-x86_64/clang/lib_macos_x86_64/predefined_macros.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ clang no __ATOMIC_RELAXED 0
6262
clang no __ATOMIC_RELEASE 3
6363
clang no __ATOMIC_SEQ_CST 5
6464
clang no __BIGGEST_ALIGNMENT__ 16
65-
clang no __BLOCKS__ 1
6665
clang no __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
6766
clang no __CHAR_BIT__ 8
6867
clang no __CLANG_ATOMIC_BOOL_LOCK_FREE 2
@@ -387,7 +386,6 @@ clang no __WINT_WIDTH__ 32
387386
clang no __amd64 1
388387
clang no __amd64__ 1
389388
clang no __apple_build_version__ 12050022
390-
clang no __block __attribute__((__blocks__(byref)))
391389
clang no __code_model_small__ 1
392390
clang no __core2 1
393391
clang no __core2__ 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fe_only -DTEST_NUMBER=1 --clang Test_name.c

‎tests/tests/changes/GH307.sft.cpp‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//type:fp
2+
//options:--clang
3+
//remark:[GH #307] The macOS clang bases no longer predefine __BLOCKS__ and __block
4+
//
5+
// The front end does not support Apple's blocks extension (there is no block
6+
// pointer type, and "^" cannot start a declarator), so __BLOCKS__ must not be
7+
// predefined: the macOS SDK headers declare their block-taking functions
8+
// (atexit_b, bsearch_b, qsort_b, ...) under "#ifdef __BLOCKS__", and every
9+
// translation unit that included <stdlib.h> got errors.
10+
11+
// The declaration that failed to parse.
12+
#if __BLOCKS__
13+
int atexit_b(void (^)(void));
14+
#endif
15+
16+
#ifdef __BLOCKS__
17+
#error "__BLOCKS__ is defined"
18+
#endif
19+
20+
#ifdef __block
21+
#error "__block is defined"
22+
#endif
23+
24+
#if __has_feature(blocks) || __has_extension(blocks)
25+
#error "the front end does not support blocks"
26+
#endif
27+
28+
int main() { return 0; }

‎util/Changes‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
Version 7.1
2+
3+
10/15/26 [GH #307]
4+
Suppress the blocks macros in make_predef_macro_table output
5+
6+
The __BLOCKS__ and __block macros are now suppressed when running
7+
make_predef_macro_table with --clang (so these don't end up in a
8+
predefined_macros.txt file). Clang defines them together when the blocks
9+
extension is enabled (the default for Apple clang), but the front end does not
10+
support that extension, and the system headers that test __BLOCKS__ (the macOS
11+
SDK declares atexit_b, qsort_b and others under it) would then use block
12+
pointer types. They have also been removed from the predefined_macros.txt
13+
files of the macOS clang bases.
14+
15+
16+
-------------------------------------------------------------------------------
117
Version 7.0, September 28, 2026
218

319
9/27/26 [EDGcpfe/29061]

‎util/make_predef_macro_table‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ delete_unneeded_entries()
119119
unneeded="$unneeded __clang_minor__"
120120
unneeded="$unneeded __clang_patchlevel__"
121121
unneeded="$unneeded __clang_version__"
122+
unneeded="$unneeded __BLOCKS__"
123+
unneeded="$unneeded __block"
122124
else
123125
unneeded="$unneeded __GNUC__"
124126
unneeded="$unneeded __GNUC_MINOR__"

0 commit comments

Comments
 (0)