[PATCH] D57191: gn build: Build clang with -fno-strict-aliasing, make building with gcc much quieter

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 24 14:02:44 PST 2019


thakis created this revision.
thakis added a reviewer: pcc.

- 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


https://reviews.llvm.org/D57191

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


Index: llvm/utils/gn/build/BUILD.gn
===================================================================
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -93,12 +93,27 @@
         "-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("clang_code") {
+  if (host_os != "win") {
+    cflags = [ "-fno-strict-aliasing" ]
+  }
   include_dirs = [
     "//clang/include",
     "$root_gen_dir/clang/include",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57191.183393.patch
Type: text/x-patch
Size: 1343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190124/b2ab707f/attachment.bin>


More information about the llvm-commits mailing list