Skip to content

Commit 128bb29

Browse files
authored
[gn] Add "/Zc:preprocessor" build flag on windows when using cl.exe (#108252)
Add ```/Zc:preprocessor``` to fix the ```__VA_ARGS__``` expansion error encountered when building with gn and cl.exe(msvc)
1 parent 7294396 commit 128bb29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/utils/gn/build/BUILD.gn

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,11 @@ config("compiler_defaults") {
183183
cflags += [ "/EHs-c-" ]
184184
cflags_cc += [ "/std:c++17" ]
185185

186-
# cl.exe doesn't set __cplusplus correctly by default.
187-
# clang-cl gets it right by default, so don't needlessly add the flag there.
188186
if (!is_clang) {
187+
# expand __VA_ARGS__ in "OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__)"
188+
cflags += [ "/Zc:preprocessor" ]
189+
# cl.exe doesn't set __cplusplus correctly by default.
190+
# clang-cl gets it right by default, so don't needlessly add the flag there.
189191
cflags_cc += [ "/Zc:__cplusplus" ]
190192
}
191193

0 commit comments

Comments
 (0)