Skip to content

Commit 6b1490b

Browse files
Adjust to the new clang builtin modules
clang is adding builtin modules for its C standard library headers. This means that stddef.h no longer gets included in the Backtracing module via Libc.h, and the clang builtin module needs to be used instead. <__stddef_size_t.h> is now a modular header, and so will not be absorbed into Darwin. When that happens, Darwin.C.stddef no longer has a size_t declaration, instead it imports the declaration from _Builtin_stddef.size_t. Darwin still has its other size_t declaration though, Darwin.POSIX._types._size_t, and that's the one that will be found currently. If that one ever goes away though, allow for _Builtin_stddef.size_t being found in C-typedef-Darwin.
1 parent 0db93e2 commit 6b1490b

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

stdlib/public/Backtracing/MemoryReader.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import Swift
1919

20+
@_implementationOnly import _Builtin_stddef
21+
2022
@_implementationOnly import OS.Libc
2123
#if os(macOS)
2224
@_implementationOnly import OS.Darwin

stdlib/public/Backtracing/SymbolicatedBacktrace.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Swift
2121
@_implementationOnly import OS.Darwin
2222
#endif
2323

24+
@_implementationOnly import _Builtin_stddef
2425
@_implementationOnly import OS.Libc
2526
@_implementationOnly import Runtime
2627

test/DebugInfo/C-typedef-Darwin.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ let blah = size_t(1024)
99
use(blah)
1010
// CHECK: !DIDerivedType(tag: DW_TAG_typedef,
1111
// CHECK-SAME: scope: ![[DARWIN_MODULE:[0-9]+]],
12-
// CHECK: ![[DARWIN_MODULE]] = !DIModule({{.*}}, name: "stddef"
12+
// size_t is defined in clang by <__stddef_size_t.h> (_Builtin_stddef.size_t)
13+
// and in macOS by <sys/_types/_size_t.h> (Darwin.POSIX._types._size_t). When
14+
// Darwin builds, Darwin.C.stddef will precompile clang's <stddef.h>, which will
15+
// include <__stddef_size_t.h> so that declaration will be visible via the
16+
// `export *`. Darwin.POSIX._types._size_t will precompile <sys/_types/_size_t.h>
17+
// into the Darwin pcm, making it the likely source of size_t. However, if Apple
18+
// stops redeclaring size_t, then the clang one will be the only one, so check
19+
// for either module.
20+
// CHECK: ![[DARWIN_MODULE]] = !DIModule({{.*}}, name: "{{_?size_t}}"

0 commit comments

Comments
 (0)