10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
+ // Note that this module map requires some changes to the Musl headers in order
14
+ // for it to work. Specifically:
15
+ //
16
+ // - The types need to be broken out of <bits/alltypes.h> into individual files
17
+ // in <bits/types>.
18
+ //
19
+ // - The definitions included in <bits/alltypes.h> need to be broken out into
20
+ // <bits/musldefs.h>.
21
+ //
22
+ // - A _modules directory needs to be created; for each of the files mentioned
23
+ // in _modules below there should be a header that looks like
24
+ //
25
+ // #if !__building_module(stdc_foo)
26
+ // #error "Do not include this header directly, include <foo.h> instead"
27
+ // #endif
28
+ // #include <foo.h>
29
+ //
30
+ // This is so that the replacement headers from Clang and Libc++ work as
31
+ // expected.
32
+
13
33
module _musl [system] {
14
34
config_macros _GNU_SOURCE, _BSD_SOURCE, _XOPEN_SOURCE, _POSIX_SOURCE, _POSIX_C_SOURCE, _LARGEFILE64_SOURCE, _ALL_SOURCE, _DEFAULT_SOURCE, __STRICT_ANSI__
15
35
@@ -28,164 +48,270 @@ module _musl [system] {
28
48
}
29
49
}
30
50
31
- module stdc_assert [system] {
32
- config_macros NDEBUG
51
+ // Headers that can be overridden by Clang or libc++; in this case what we do is
52
+ // we create an underscored module to wrap the actual header, then have the
53
+ // module with the nicer name include a forwarding header from _modules. This
54
+ // ensures that e.g. `import stdc_float` will result in pulling in the Clang
55
+ // or libc++ versions as expected.
56
+
57
+ module _stdc_assert [system] {
33
58
textual header "assert.h"
59
+ }
60
+ module stdc_assert [system] {
61
+ header "_modules/stdc_assert.h"
34
62
export *
35
63
}
36
64
37
- module stdc_float [system] {
38
- header "float .h"
65
+ module _stdc_complex [system] {
66
+ header "complex .h"
39
67
export *
40
68
}
41
-
42
- module stdc_iso646 [system] {
43
- header "iso646.h"
69
+ module stdc_complex [system] {
70
+ header "_modules/stdc_complex.h"
44
71
export *
45
72
}
46
73
47
- module stdc_limits [system] {
74
+ module _stdc_ctype [system] {
48
75
config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
49
- header "limits .h"
76
+ header "ctype .h"
50
77
export *
51
78
}
52
-
53
- module stdc_stdalign [system] {
54
- header "stdalign.h"
79
+ module stdc_ctype [system] {
80
+ header "_modules/stdc_ctype.h"
55
81
export *
56
82
}
57
83
58
- module stdc_stdarg [system] {
59
- header "stdarg.h"
84
+ module _stdc_errno [system] {
85
+ config_macros _GNU_SOURCE
86
+ header "errno.h"
60
87
export *
61
88
}
62
-
63
- module stdc_stdatomic [system] {
64
- header "stdatomic.h"
89
+ module stdc_errno [system] {
90
+ header "_modules/stdc_errno.h"
65
91
export *
66
92
}
67
93
68
- module stdc_stdbool [system] {
69
- header "stdbool .h"
94
+ module _stdc_fenv [system] {
95
+ header "fenv .h"
70
96
export *
71
97
}
72
-
73
- module stdc_stddef [system] {
74
- header "stddef.h"
98
+ module stdc_fenv [system] {
99
+ header "_modules/stdc_fenv.h"
75
100
export *
76
101
}
77
102
78
- module stdc_stdint [system] {
79
- header "stdint .h"
103
+ module _stdc_float [system] {
104
+ header "float .h"
80
105
export *
81
106
}
82
-
83
- module stdc_time [system] {
84
- config_macros _POSIX_SOURCE, _POSIX_C_SOURCE, _XOPEN_SOURCE, _GNU_SOURCE, _BSD_SOURCE
85
- header "time.h"
107
+ module stdc_float [system] {
108
+ header "_modules/stdc_float.h"
86
109
export *
87
110
}
88
111
89
- module stdc_tgmath [system] {
90
- header "tgmath .h"
112
+ module _stdc_inttypes [system] {
113
+ header "inttypes .h"
91
114
export *
92
115
}
93
-
94
- module stdc_complex [system] {
95
- header "complex.h"
116
+ module stdc_inttypes [system] {
117
+ header "_modules/stdc_inttypes.h"
118
+ use stdc_stdint
96
119
export *
97
120
}
98
121
99
- module stdc_ctype [system] {
100
- config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
101
- header "ctype.h"
122
+ module _stdc_iso646 [system] {
123
+ header "iso646.h"
102
124
export *
103
125
}
104
-
105
- module stdc_errno [system] {
106
- config_macros _GNU_SOURCE
107
- header "errno.h"
126
+ module stdc_iso646 [system] {
127
+ header "_modules/stdc_iso646.h"
108
128
export *
109
129
}
110
130
111
- module stdc_fenv [system] {
112
- header "fenv.h"
131
+ module _stdc_limits [system] {
132
+ config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
133
+ header "limits.h"
113
134
export *
114
135
}
115
-
116
- module stdc_inttypes [system] {
117
- header "inttypes.h"
136
+ module stdc_limits [system] {
137
+ header "_modules/stdc_limits.h"
118
138
export *
119
139
}
120
140
121
- module stdc_locale [system] {
141
+ module _stdc_locale [system] {
122
142
config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
123
143
header "locale.h"
124
144
export *
125
145
}
146
+ module stdc_locale [system] {
147
+ header "_modules/stdc_locale.h"
148
+ export *
149
+ }
126
150
127
- module stdc_math [system] {
151
+ module _stdc_math [system] {
128
152
config_macros _BSD_SOURCE, _GNU_SOURCE, _XOPEN_SOURCE
129
153
header "math.h"
130
154
export *
131
155
}
156
+ module stdc_math [system] {
157
+ header "_modules/stdc_math.h"
158
+ export *
159
+ }
132
160
133
- module stdc_setjmp [system] {
161
+ module _stdc_setjmp [system] {
134
162
config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
135
163
header "setjmp.h"
136
164
export *
137
165
}
166
+ module stdc_setjmp [system] {
167
+ header "_modules/stdc_setjmp.h"
168
+ export *
169
+ }
138
170
139
- module stdc_signal [system] {
140
- config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
141
- header "signal.h"
171
+ module _stdc_stdalign [system] {
172
+ header "stdalign.h"
173
+ export *
174
+ }
175
+ module stdc_stdalign [system] {
176
+ header "_modules/stdc_stdalign.h"
142
177
export *
143
178
}
144
179
145
- module stdc_stdio [system] {
180
+ module _stdc_stdarg [system] {
181
+ header "stdarg.h"
182
+ export *
183
+ }
184
+ module stdc_stdarg [system] {
185
+ header "_modules/stdc_stdarg.h"
186
+ export *
187
+ }
188
+
189
+ module _stdc_stdatomic [system] {
190
+ header "stdatomic.h"
191
+ export *
192
+ }
193
+ module stdc_stdatomic [system] {
194
+ header "_modules/stdc_stdatomic.h"
195
+ export *
196
+ }
197
+
198
+ module _stdc_stdbool [system] {
199
+ header "stdbool.h"
200
+ export *
201
+ }
202
+ module stdc_stdbool [system] {
203
+ header "_modules/stdc_stdbool.h"
204
+ export *
205
+ }
206
+
207
+ module _stdc_stddef [system] {
208
+ header "stddef.h"
209
+ export *
210
+ }
211
+ module stdc_stddef [system] {
212
+ header "_modules/stdc_stddef.h"
213
+ export *
214
+ }
215
+
216
+ module _stdc_stdint [system] {
217
+ header "stdint.h"
218
+ export *
219
+ }
220
+ module stdc_stdint [system] {
221
+ header "_modules/stdc_stdint.h"
222
+ export *
223
+ }
224
+
225
+ module _stdc_stdio [system] {
146
226
config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
147
227
header "stdio.h"
148
228
export *
149
229
}
230
+ module stdc_stdio [system] {
231
+ header "_modules/stdc_stdio.h"
232
+ export *
233
+ }
150
234
151
- module stdc_stdlib [system] {
235
+ module _stdc_stdlib [system] {
152
236
config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
153
237
header "stdlib.h"
154
238
export *
155
239
}
156
-
157
- module stdc_stdnoreturn [system] {
158
- header "stdnoreturn.h"
240
+ module stdc_stdlib [system] {
241
+ header "_modules/stdc_stdlib.h"
159
242
export *
160
243
}
161
244
162
- module stdc_string [system] {
245
+ module _stdc_string [system] {
163
246
config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
164
247
header "string.h"
165
248
export *
166
249
}
250
+ module stdc_string [system] {
251
+ header "_modules/stdc_string.h"
252
+ export *
253
+ }
167
254
168
- module stdc_threads [system] {
169
- header "threads.h"
255
+ module _stdc_tgmath [system] {
256
+ header "tgmath.h"
257
+ export *
258
+ }
259
+ module stdc_tgmath [system] {
260
+ header "_modules/stdc_tgmath.h"
170
261
export *
171
262
}
172
263
173
- module stdc_uchar [system] {
264
+ module _stdc_uchar [system] {
174
265
header "uchar.h"
175
266
export *
176
267
}
268
+ module stdc_uchar [system] {
269
+ header "_modules/stdc_uchar.h"
270
+ export *
271
+ }
177
272
178
- module stdc_wchar [system] {
273
+ module _stdc_wchar [system] {
179
274
config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
180
275
header "wchar.h"
181
276
export *
182
277
}
278
+ module stdc_wchar [system] {
279
+ header "_modules/stdc_wchar.h"
280
+ export *
281
+ }
183
282
184
- module stdc_wctype [system] {
283
+ module _stdc_wctype [system] {
185
284
config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
186
285
header "wctype.h"
187
286
export *
188
287
}
288
+ module stdc_wctype [system] {
289
+ header "_modules/stdc_wctype.h"
290
+ export *
291
+ }
292
+
293
+ // C library headers
294
+ module stdc_time [system] {
295
+ config_macros _POSIX_SOURCE, _POSIX_C_SOURCE, _XOPEN_SOURCE, _GNU_SOURCE, _BSD_SOURCE
296
+ header "time.h"
297
+ export *
298
+ }
299
+
300
+ module stdc_signal [system] {
301
+ config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE
302
+ header "signal.h"
303
+ export *
304
+ }
305
+
306
+ module stdc_stdnoreturn [system] {
307
+ header "stdnoreturn.h"
308
+ export *
309
+ }
310
+
311
+ module stdc_threads [system] {
312
+ header "threads.h"
313
+ export *
314
+ }
189
315
190
316
// POSIX
191
317
module posix_aio [system] {
0 commit comments