]> granicus.if.org Git - llvm/commitdiff
gn build: Build clang with -fno-strict-aliasing, make building with gcc much quieter
authorNico Weber <nicolasweber@gmx.de>
Fri, 25 Jan 2019 00:29:17 +0000 (00:29 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 25 Jan 2019 00:29:17 +0000 (00:29 +0000)
- gcc doesn't understand -Wstring-conversion, so pass that only to clang
- disable a few gcc warnings that are noisy and also disabled in the cmake build
- -Wstrict-aliasing pointed out that the cmake build builds clang with
  -fno-strict-aliasing, so do that too

Differential Revision: https://reviews.llvm.org/D57191

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352141 91177308-0d34-0410-b5e6-96231b3b80d8

utils/gn/build/BUILD.gn

index e5c8d2a6209561386cdb19e782f434d8cfae78b4..18e25827aaf91a9aca7e991e83294747a11541cf 100644 (file)
@@ -93,12 +93,27 @@ config("compiler_defaults") {
         "-Wextra",
       ]
     }
-    cflags += [
-      "-Wno-unused-parameter",
-      "-Wstring-conversion",
-    ]
+    cflags += [ "-Wno-unused-parameter" ]
     if (is_clang) {
-      cflags += [ "-Wdelete-non-virtual-dtor" ]
+      cflags += [
+        "-Wdelete-non-virtual-dtor",
+        "-Wstring-conversion",
+      ]
+    } else {
+      cflags += [
+        # GCC's -Wcomment complains about // comments ending with '\' if the
+        # next line is also a // comment.
+        "-Wno-comment",
+
+        # Disable gcc's potentially uninitialized use analysis as it presents
+        # lots of false positives.
+        "-Wno-maybe-uninitialized",
+      ]
+      cflags_cc += [
+        # The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not
+        # useful.
+        "-Wno-noexcept-type",
+      ]
     }
     if (is_clang && use_goma) {
       # goma converts all paths to lowercase on the server, breaking this
@@ -135,6 +150,9 @@ config("lld_code") {
 }
 
 config("clang_code") {
+  if (host_os != "win") {
+    cflags = [ "-fno-strict-aliasing" ]
+  }
   include_dirs = [
     "//clang/include",
     "$root_gen_dir/clang/include",