reorder_flags: properly handle flags from concrete reused specs (#35951)
This commit is contained in:
		| @@ -1463,6 +1463,7 @@ class Head(object): | ||||
|             node_compiler = fn.attr("node_compiler_set") | ||||
|             node_compiler_version = fn.attr("node_compiler_version_set") | ||||
|             node_flag = fn.attr("node_flag_set") | ||||
|             node_flag_source = fn.attr("node_flag_source") | ||||
|             node_flag_propagate = fn.attr("node_flag_propagate") | ||||
|             variant_propagate = fn.attr("variant_propagate") | ||||
| 
 | ||||
| @@ -1476,6 +1477,7 @@ class Body(object): | ||||
|             node_compiler = fn.attr("node_compiler") | ||||
|             node_compiler_version = fn.attr("node_compiler_version") | ||||
|             node_flag = fn.attr("node_flag") | ||||
|             node_flag_source = fn.attr("node_flag_source") | ||||
|             node_flag_propagate = fn.attr("node_flag_propagate") | ||||
|             variant_propagate = fn.attr("variant_propagate") | ||||
| 
 | ||||
| @@ -1557,6 +1559,7 @@ class Body(object): | ||||
|         for flag_type, flags in spec.compiler_flags.items(): | ||||
|             for flag in flags: | ||||
|                 clauses.append(f.node_flag(spec.name, flag_type, flag)) | ||||
|                 clauses.append(f.node_flag_source(spec.name, flag_type, spec.name)) | ||||
|                 if not spec.concrete and flag.propagate is True: | ||||
|                     clauses.append(f.node_flag_propagate(spec.name, flag_type)) | ||||
| 
 | ||||
| @@ -2181,6 +2184,7 @@ def __init__(self, specs, hash_lookup=None): | ||||
|         self._specs = {} | ||||
|         self._result = None | ||||
|         self._command_line_specs = specs | ||||
|         self._hash_specs = [] | ||||
|         self._flag_sources = collections.defaultdict(lambda: set()) | ||||
|         self._flag_compiler_defaults = set() | ||||
| 
 | ||||
| @@ -2191,6 +2195,7 @@ def __init__(self, specs, hash_lookup=None): | ||||
|     def hash(self, pkg, h): | ||||
|         if pkg not in self._specs: | ||||
|             self._specs[pkg] = self._hash_lookup[h] | ||||
|         self._hash_specs.append(pkg) | ||||
| 
 | ||||
|     def node(self, pkg): | ||||
|         if pkg not in self._specs: | ||||
| @@ -2316,8 +2321,8 @@ def reorder_flags(self): | ||||
|                     ) | ||||
| 
 | ||||
|                     # add flags from each source, lowest to highest precedence | ||||
|                     for source_name in sorted_sources: | ||||
|                         source = cmd_specs[source_name] | ||||
|                     for name in sorted_sources: | ||||
|                         source = self._specs[name] if name in self._hash_specs else cmd_specs[name] | ||||
|                         extend_flag_list(from_sources, source.compiler_flags.get(flag_type, [])) | ||||
| 
 | ||||
|                 # compiler flags from compilers config are lowest precedence | ||||
| @@ -2392,10 +2397,12 @@ def build_specs(self, function_tuples): | ||||
|                     continue | ||||
| 
 | ||||
|                 # if we've already gotten a concrete spec for this pkg, | ||||
|                 # do not bother calling actions on it. | ||||
|                 # do not bother calling actions on it except for node_flag_source, | ||||
|                 # since node_flag_source is tracking information not in the spec itself | ||||
|                 spec = self._specs.get(pkg) | ||||
|                 if spec and spec.concrete: | ||||
|                     continue | ||||
|                     if name != "node_flag_source": | ||||
|                         continue | ||||
| 
 | ||||
|             action(*args) | ||||
| 
 | ||||
|   | ||||
| @@ -1274,6 +1274,18 @@ def test_reuse_installed_packages_when_package_def_changes( | ||||
|         # Structure and package hash will be different without reuse | ||||
|         assert root.dag_hash() != new_root_without_reuse.dag_hash() | ||||
| 
 | ||||
|     def test_reuse_with_flags(self, mutable_database, mutable_config): | ||||
|         if spack.config.get("config:concretizer") == "original": | ||||
|             pytest.xfail("Original concretizer does not reuse") | ||||
| 
 | ||||
|         spack.config.set("concretizer:reuse", True) | ||||
|         spec = Spec("a cflags=-g cxxflags=-g").concretized() | ||||
|         spack.store.db.add(spec, None) | ||||
| 
 | ||||
|         testspec = Spec("a cflags=-g") | ||||
|         testspec.concretize() | ||||
|         assert testspec == spec | ||||
| 
 | ||||
|     @pytest.mark.regression("20784") | ||||
|     def test_concretization_of_test_dependencies(self): | ||||
|         # With clingo we emit dependency_conditions regardless of the type | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Greg Becker
					Greg Becker