[llvm] 128bb29 - [gn] Add "/Zc:preprocessor" build flag on windows when using cl.exe (#108252)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 02:14:13 PDT 2024


Author: GkvJwa
Date: 2024-09-12T17:14:07+08:00
New Revision: 128bb29e6d9f0aec03ea34e1477efeb561d97f8f

URL: https://github.com/llvm/llvm-project/commit/128bb29e6d9f0aec03ea34e1477efeb561d97f8f
DIFF: https://github.com/llvm/llvm-project/commit/128bb29e6d9f0aec03ea34e1477efeb561d97f8f.diff

LOG: [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)

Added: 
    

Modified: 
    llvm/utils/gn/build/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 1ccaefdc21c822..27f95bb5a49f1f 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -183,9 +183,11 @@ config("compiler_defaults") {
     cflags += [ "/EHs-c-" ]
     cflags_cc += [ "/std:c++17" ]
 
-    # cl.exe doesn't set __cplusplus correctly by default.
-    # clang-cl gets it right by default, so don't needlessly add the flag there.
     if (!is_clang) {
+      # expand __VA_ARGS__ in "OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__)"
+      cflags += [ "/Zc:preprocessor" ]
+      # cl.exe doesn't set __cplusplus correctly by default.
+      # clang-cl gets it right by default, so don't needlessly add the flag there.
       cflags_cc += [ "/Zc:__cplusplus" ]
     }
 


        


More information about the llvm-commits mailing list