Skip to content

Commit e20e206

Browse files
authored
Windows: Disable clang headers when C-preprocessing with clang-cl (#4934)
As they apparently use unsupported types like __int128, __bf16 etc., even if preprocessing with `/std:c11`. Use the Microsoft headers instead.
1 parent 2582b12 commit e20e206

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

driver/cpreprocessor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ FileName runCPreprocessor(FileName csrcfile, Loc loc, OutBuffer &defines) {
151151

152152
// need to redefine some macros in importc.h
153153
args.push_back("-Wno-builtin-macro-redefined");
154+
155+
// disable the clang resource headers (immintrin.h etc.), using
156+
// unsupported types like __int128, __bf16 etc. - stick to the MS headers
157+
args.push_back("-nobuiltininc");
154158
}
155159

156160
args.push_back(csrcfile.toChars());

runtime/druntime/test/importc_compare/Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,3 @@ endif
2121
include ../common.mak
2222

2323
extra_dflags += -d
24-
25-
ifeq ($(OS),windows)
26-
ifdef IN_LDC
27-
# use Microsoft's cl.exe as preprocessor; clang-cl leads to unsupported `_Float16` etc.
28-
extra_dflags += -gcc=cl
29-
endif
30-
endif

tests/dmd/compilable/stdcheaders.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
* Many platforms do not support all the C Standard headers.
33
*/
44

5-
/* LDC defaults to clang-cl (if available) as preprocessor on Windows, which for
6-
* this test causes importC trouble starting with the MSVC v17.13 headers, wrt.
7-
* `__declspec(_Noreturn)`, `_Float16`, `__bf16`, `unsigned __int128` etc.
8-
*
9-
* => use Microsoft's cl.exe as preprocessor
10-
* REQUIRED_ARGS(windows): -gcc=cl
11-
*
12-
* => ignore cl.exe printing the preprocessed filename (auto-suppressed by DMD)
13-
* TRANSFORM_OUTPUT(windows): remove_lines("^stdcheaders\.c$")
14-
*/
15-
165
#include <assert.h>
176

187
#include <complex.h>

0 commit comments

Comments
 (0)