From d2cc2481928915a207309a866321cc7e7a65c4de Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Mon, 10 May 2021 10:03:24 +0200 Subject: [PATCH] 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. --- var/spack/repos/builtin/packages/binutils/package.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/var/spack/repos/builtin/packages/binutils/package.py b/var/spack/repos/builtin/packages/binutils/package.py index 7fc8013afe4..3edab97c8ff 100644 --- a/var/spack/repos/builtin/packages/binutils/package.py +++ b/var/spack/repos/builtin/packages/binutils/package.py @@ -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)