Encountered a problem with GN which others on this quest may find important. (If you aren't building with GN this may bite you without realising!)
I hit a warning in a third-party module that I had to disable in its build file. First thing I tried was just adding the -Wno flag to this module's cflags:
--- a/third_party/qcms/BUILD.gn
+++ b/third_party/qcms/BUILD.gn
@@ -40,5 +40,11 @@ source_set("qcms") {
"/wd4056", # Overflow in floating-point constant arithmetic (INFINITY).
"/wd4756", # Overflow in constant arithmetic (INFINITY).
]
+
+ if (is_clang) {
+ cflags += [
+ "-Wno-sometimes-uninitialized",
+ ]
+ }
}
}
Unfortunately, this *did not* disable the warning. Thanks to +Sam McNally (very helpful), I found "gn desc <outdir> third_party/qcms" which shows the full gn debug dump. The problem is that -Wno-sometimes-uninitialized was being added right at the start, before /W3, which is in the global config and turns all warnings back on!
So basically, it will not be possible to disable any specific warnings in GN files for a particular module.
The workaround we found was to create a separate "config", so my new patch looks like this:
--- a/third_party/qcms/BUILD.gn
+++ b/third_party/qcms/BUILD.gn
@@ -6,6 +6,14 @@ config("qcms_config") {
include_dirs = [ "src" ]
}
+config("qcms_private_config") {
+ if (is_win && is_clang) {
+ cflags = [
+ "-Wno-sometimes-uninitialized",
+ ]
+ }
+}
+
source_set("qcms") {
sources = [
"src/chain.c",
@@ -23,6 +31,7 @@ source_set("qcms") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
+ configs += [ ":qcms_private_config" ]
public_configs = [ ":qcms_config" ]
if (current_cpu == "x86" || current_cpu == "x64") {
This inserts the -Wno flag at the end after /W3 (in roughly the same spot as all the other -Wnos), so it works.
Feels like a bit of a hack though. Is there any easier way to fix this? (I assume removing /W3 on Clang is out of the question?)