binutils: Improve flag_handler (#22642)

`flag_handler` currently passes all flags via injection. This makes it
impossible to override the default flags provided by autotools (for
instance, `binutils cflags='-O2'` will still build with `-O2 -g`).
Instead, use injection for our workaround flags and pass other flags to
the build system.
This commit is contained in:
Michael Kuhn 2021-05-10 10:03:24 +02:00 committed by GitHub
parent ecb7d6dca1
commit d2cc248192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,17 +132,20 @@ def install_headers(self):
extradir)
def flag_handler(self, name, flags):
# Use a separate variable for injecting flags. This way, installing
# `binutils cflags='-O2'` will still work as expected.
iflags = []
# To ignore the errors of narrowing conversions for
# the Fujitsu compiler
if name == 'cxxflags' and (
self.spec.satisfies('@:2.31.1') and
self.compiler.name in ('fj', 'clang', 'apple-clang')
):
flags.append('-Wno-narrowing')
iflags.append('-Wno-narrowing')
elif name == 'cflags':
if self.spec.satisfies('@:2.34 %gcc@10:'):
flags.append('-fcommon')
return (flags, None, None)
iflags.append('-fcommon')
return (iflags, None, flags)
def test(self):
spec_vers = str(self.spec.version)