meson: clear flags used for build

Some were duplicated between GCC and Clange. Others were missing in
Clang case. Instead test all the flags and don't make assumptions that
will get invalid over time. Testing flags is almost free.
This commit is contained in:
Kacper Michajłow 2024-06-04 21:51:26 +02:00
parent b4683fd3d8
commit 0fd4c84a5e
1 changed files with 18 additions and 28 deletions

View File

@ -266,41 +266,31 @@ cc = meson.get_compiler('c')
flags = ['-D_FILE_OFFSET_BITS=64'] flags = ['-D_FILE_OFFSET_BITS=64']
link_flags = [] link_flags = []
test_flags = ['-Werror=implicit-function-declaration', test_flags = ['-Wdisabled-optimization',
'-Wno-missing-field-initializers',
'-Wno-sign-compare',
'-Wno-unused-parameter',
'-Wno-cast-function-type',
'-Wempty-body', '-Wempty-body',
'-Wdisabled-optimization', '-Wformat',
'-Wstrict-prototypes',
'-Wno-format-zero-length',
'-Wno-redundant-decls',
'-Wvla',
'-Wno-format-truncation',
'-Wimplicit-fallthrough', '-Wimplicit-fallthrough',
'-Wmissing-prototypes',
'-Wparentheses',
'-Wpointer-arith',
'-Wshadow',
'-Wstrict-prototypes',
'-Wundef',
'-Wvla',
'-Werror=implicit-function-declaration',
'-Wno-cast-function-type',
'-Wno-format-zero-length',
'-Wno-missing-field-initializers',
'-Wno-pointer-sign',
'-Wno-sign-compare',
'-Wno-switch',
'-Wno-unused-parameter',
'-fno-math-errno'] '-fno-math-errno']
flags += cc.get_supported_arguments(test_flags) flags += cc.get_supported_arguments(test_flags)
if cc.has_multi_arguments('-Wformat', '-Werror=format-security') if cc.has_multi_arguments('-Wformat', '-Werror=format-security')
flags += ['-Wformat', '-Werror=format-security'] flags += '-Werror=format-security'
endif
if cc.get_id() == 'gcc'
gcc_flags = ['-Wundef', '-Wmissing-prototypes', '-Wshadow',
'-Wno-switch', '-Wparentheses', '-Wpointer-arith',
'-Wno-pointer-sign',
# GCC bug 66425
'-Wno-unused-result']
flags += gcc_flags
endif
if cc.get_id() == 'clang'
clang_flags = ['-Wno-logical-op-parentheses', '-Wno-switch',
'-Wno-tautological-compare', '-Wno-pointer-sign',
'-Wno-tautological-constant-out-of-range-compare']
flags += clang_flags
endif endif
darwin = host_machine.system() == 'darwin' darwin = host_machine.system() == 'darwin'