Skip to content

Commit

Permalink
compilers: handle -Wno-attributes= for GCC
Browse files Browse the repository at this point in the history
For other reasons, Meson transforms "-Wno-x" into "-Wx -Wno-x" for GCC,
but this breaks with "-Wno-attributes=x" with:
```
cc1plus: error: arguments ignored for '-Wattributes='; use '-Wno-attributes=' instead
```

Suppress that workaround for -Wno-attributes=.

Closes: mesonbuild#13022
  • Loading branch information
thesamesam committed Jul 15, 2024
1 parent 8e89a38 commit a7ff44c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mesonbuild/compilers/mixins/clike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ def _has_multi_arguments(self, args: T.List[str], env: 'Environment', code: str)
# some compilers, e.g. GCC, don't warn for unsupported warning-disable
# flags, so when we are testing a flag like "-Wno-forgotten-towel", also
# check the equivalent enable flag too "-Wforgotten-towel"
if arg.startswith('-Wno-'):
if arg.startswith('-Wno-') and not arg.startswith('-Wno-attributes='):
new_args.append('-W' + arg[5:])
if arg.startswith('-Wl,'):
mlog.warning(f'{arg} looks like a linker argument, '
Expand Down
6 changes: 6 additions & 0 deletions test cases/common/104 has arg/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ if cc.get_id() == 'gcc'
assert(not cc.has_multi_arguments(['-Wno-pragmas', '-Wno-lol-meson-test-flags']), 'should error out even if some -Wno args are valid')
endif

if cpp.get_id() == 'gcc' and cpp.version().version_compare('>=12.1.0')
# Handle special -Wno-attributes=foo where -Wattributes=foo is invalid
# i.e. our usual -Wno-foo -Wfoo hack doesn't work for -Wattributes=foo.
assert(cpp.has_argument('-Wno-attributes=meson::i_do_not_exist'))
endif

if cc.get_id() == 'clang' and cc.version().version_compare('<=4.0.0')
# 4.0.0 does not support -fpeel-loops. Newer versions may.
# Please adjust above version number as new versions of clang are released.
Expand Down

0 comments on commit a7ff44c

Please sign in to comment.