Update & add test
Test for propagating compiler flags that aren't the root spec
This commit is contained in:
parent
177976b762
commit
968223758a
@ -862,11 +862,13 @@ def visit(node):
|
||||
self.control.load(os.path.join(parent_dir, "display.lp"))
|
||||
if not setup.concretize_everything:
|
||||
self.control.load(os.path.join(parent_dir, "when_possible.lp"))
|
||||
flags = []
|
||||
for spec in specs:
|
||||
flags.append(spec.compiler_flags)
|
||||
|
||||
if self._compiler_flag_has_propagation(flags):
|
||||
|
||||
has_propagation = False
|
||||
for spec in specs:
|
||||
for dep in spec.traverse(root=True):
|
||||
has_propagation |= self._compiler_flag_has_propagation(dep.compiler_flags)
|
||||
if has_propagation:
|
||||
self.control.load(os.path.join(parent_dir, "propagation.lp"))
|
||||
|
||||
timer.stop("load")
|
||||
@ -978,10 +980,9 @@ def _model_has_cycles(self, models):
|
||||
return cycle_result.unsatisfiable
|
||||
|
||||
def _compiler_flag_has_propagation(self, flags):
|
||||
for flag in flags:
|
||||
for flag_type, flag_vals in flag.items():
|
||||
if any(val.propagate for val in flag_vals):
|
||||
return True
|
||||
for _, flag_vals in flags.items():
|
||||
if any(val.propagate for val in flag_vals):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
@ -349,6 +349,9 @@ def test_compiler_flags_differ_identical_compilers(self):
|
||||
spec.concretize()
|
||||
assert spec.satisfies("cflags=-O2")
|
||||
|
||||
@pytest.mark.only_clingo(
|
||||
"Optional compiler propagation isn't deprecated for original concretizer"
|
||||
)
|
||||
def test_concretize_compiler_flag_propagate(self):
|
||||
spec = Spec("callpath cflags=='-g'")
|
||||
spec.concretize()
|
||||
@ -356,6 +359,16 @@ def test_concretize_compiler_flag_propagate(self):
|
||||
for dep in spec.traverse():
|
||||
assert dep.satisfies("cflags='-g'")
|
||||
|
||||
@pytest.mark.only_clingo(
|
||||
"Optional compiler propagation isn't deprecated for original concretizer"
|
||||
)
|
||||
def test_concretize_non_root_compiler_flag_propagate(self):
|
||||
spec = Spec("callpath ^dyninst cflags=='-g'")
|
||||
spec.concretize()
|
||||
|
||||
assert spec.satisfies("^libdwarf cflags='-g'")
|
||||
assert spec.satisfies("^libelf cflags='-g'")
|
||||
|
||||
@pytest.mark.only_clingo(
|
||||
"Optional compiler propagation isn't deprecated for original concretizer"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user