Use -Oz when optimization=s in Clang

-Oz is the appropriate flag to use when you want to produce the smallest
possible binary, and is one would expect when setting optimization to s
or using the minsize build type.
pull/9287/head
Andrea Pappacoda 3 years ago committed by Dylan Baker
parent ca866bcfc7
commit 68eca11cc6
  1. 2
      mesonbuild/compilers/mixins/clang.py
  2. 2
      mesonbuild/interpreter/interpreter.py

@ -40,7 +40,7 @@ clang_optimization_args = {
'1': ['-O1'], '1': ['-O1'],
'2': ['-O2'], '2': ['-O2'],
'3': ['-O3'], '3': ['-O3'],
's': ['-Os'], 's': ['-Oz'],
} # type: T.Dict[str, T.List[str]] } # type: T.Dict[str, T.List[str]]
class ClangCompiler(GnuLikeCompiler): class ClangCompiler(GnuLikeCompiler):

@ -2322,7 +2322,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
# https://github.com/mesonbuild/meson/issues/3275#issuecomment-641354956 # https://github.com/mesonbuild/meson/issues/3275#issuecomment-641354956
# https://github.com/mesonbuild/meson/issues/3742 # https://github.com/mesonbuild/meson/issues/3742
warnargs = ('/W1', '/W2', '/W3', '/W4', '/Wall', '-Wall', '-Wextra') warnargs = ('/W1', '/W2', '/W3', '/W4', '/Wall', '-Wall', '-Wextra')
optargs = ('-O0', '-O2', '-O3', '-Os', '/O1', '/O2', '/Os') optargs = ('-O0', '-O2', '-O3', '-Os', '-Oz', '/O1', '/O2', '/Os')
for arg in args: for arg in args:
if arg in warnargs: if arg in warnargs:
mlog.warning(f'Consider using the built-in warning_level option instead of using "{arg}".', mlog.warning(f'Consider using the built-in warning_level option instead of using "{arg}".',

Loading…
Cancel
Save