build: Don't use any -Werror in release builds

Do kep them for debug and debugoptimized builds though.

Keeping -Werror flags in release builds causes issues with forward
compatibility, when new compiler releases or different toolchains
suddenly cause those warnings to be emitted during compilation.

While we certainly want those issues to be investigated and fixed, they
should not prevent anyone from building GTK until they are.

Resolves #4388
This commit is contained in:
Benjamin Otte 2021-11-10 20:01:36 +01:00
parent 46f8600b6a
commit 362e91c40b

View File

@ -291,6 +291,9 @@ elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
'-Wundef',
'-Wuninitialized',
'-Wunused',
]
extra_warnings = [
'-Werror=address',
'-Werror=array-bounds',
'-Werror=empty-body',
@ -312,6 +315,16 @@ elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
'-Werror=write-strings',
]
if get_option('buildtype').startswith('debug')
foreach warning: extra_warnings
test_cflags += '-Werror=@0@'.format(warning)
endforeach
else
foreach warning: extra_warnings
test_cflags += '-W@0@'.format(warning)
endforeach
endif
if cc.get_id() == 'gcc'
test_cflags += ['-Wcast-align'] # This warns too much on clang
endif