'The compiler flags are updated to match those of the spec whose
compiler is used, defaulting to no compiler flags in the spec.
Default specs set at the compiler level will still be added later.'

def concretize_compiler_flags(self, spec):

    if (not (spec.architecture.platform_os and spec.architecture.target)):
        return True
    compiler_match = (lambda other: ((spec.compiler == other.compiler) and (spec.architecture == other.architecture)))
    ret = False
    for flag in spack.spec.FlagMap.valid_compiler_flags():
        if (flag not in spec.compiler_flags):
            spec.compiler_flags[flag] = list()
        try:
            nearest = next((p for p in spec.traverse(direction='parents') if (compiler_match(p) and (p is not spec) and (flag in p.compiler_flags))))
            nearest_flags = set(nearest.compiler_flags.get(flag, []))
            flags = set(spec.compiler_flags.get(flag, []))
            if (nearest_flags - flags):
                spec.compiler_flags[flag] = list((nearest_flags | flags))
                ret = True
        except StopIteration:
            pass
    compiler = spack.compilers.compiler_for_spec(spec.compiler, spec.architecture)
    for flag in compiler.flags:
        config_flags = set(compiler.flags.get(flag, []))
        flags = set(spec.compiler_flags.get(flag, []))
        spec.compiler_flags[flag] = list((config_flags | flags))
        if (config_flags - flags):
            ret = True
    return ret
