[gn build] port some -Wno flags for gcc from the cmake build.
authorNico Weber <thakis@chromium.org>
Thu, 4 Jun 2020 12:10:16 +0000 (08:10 -0400)
committerNico Weber <thakis@chromium.org>
Thu, 4 Jun 2020 12:10:29 +0000 (08:10 -0400)
llvm/utils/gn/build/BUILD.gn

index a1a4b06..f926eee 100644 (file)
@@ -19,6 +19,9 @@ declare_args() {
   # http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
   # for more information.
   use_relative_paths_in_debug_info = false
+
+  # The version of host gcc. Ignored if is_clang is true.
+  gcc_version = 9
 }
 
 assert(!llvm_build_instrumented_coverage || is_clang,
@@ -155,6 +158,23 @@ config("compiler_defaults") {
         # useful.
         "-Wno-noexcept-type",
       ]
+      if (gcc_version >= 8) {
+        cflags_cc += [
+          # Disable -Wclass-memaccess, a C++-only warning from GCC 8 that fires
+          # on LLVM's ADT classes.
+          "-Wno-class-memaccess",
+        ]
+      }
+      if (gcc_version >= 9) {
+        cflags_cc += [
+          # Disable -Wredundant-move on GCC>=9. GCC wants to remove std::move
+          # in code like "A foo(ConvertibleToA a) { return std::move(a); }",
+          # but this code does not compile (or uses the copy constructor
+          # instead) on clang<=3.8. Clang also has a -Wredundant-move, but it
+          # only fires when the types match exactly, so we can keep it here.
+          "-Wno-redundant-move",
+        ]
+      }
     }
     if (is_clang && use_goma) {
       # goma converts all paths to lowercase on the server, breaking this