Skip to content

Commit

Permalink
bugfix: associate nodes directly with specs for compiler flag reorder…
Browse files Browse the repository at this point in the history
…ing (spack#48496)
  • Loading branch information
becker33 authored Jan 14, 2025
1 parent 8196c68 commit 2447d16
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/spack/spack/solver/asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3540,15 +3540,13 @@ def reorder_flags(self):
)
cmd_specs = dict((s.name, s) for spec in self._command_line_specs for s in spec.traverse())

for spec in self._specs.values():
for node, spec in self._specs.items():
# if bootstrapping, compiler is not in config and has no flags
flagmap_from_compiler = {}
if spec.compiler in compilers:
flagmap_from_compiler = compilers[spec.compiler].flags

for flag_type in spec.compiler_flags.valid_compiler_flags():
node = SpecBuilder.make_node(pkg=spec.name)

ordered_flags = []

# 1. Put compiler flags first
Expand Down
13 changes: 13 additions & 0 deletions lib/spack/spack/test/concretization/flag_mixing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest

import spack.concretize
import spack.config
import spack.environment as ev
import spack.paths
Expand Down Expand Up @@ -96,6 +97,18 @@ def test_mix_spec_and_compiler_cfg(concretize_scope, test_repo):
assert s1.satisfies('cflags="-Wall -O2"')


def test_pkg_flags_from_compiler_and_none(concretize_scope, mock_packages):
conf_str = _compiler_cfg_one_entry_with_cflags("-Wall")
update_concretize_scope(conf_str, "compilers")

s1 = Spec("cmake%[email protected]")
s2 = Spec("cmake-client^cmake%clang")
concrete = dict(spack.concretize.concretize_together([(s1, None), (s2, None)]))

assert concrete[s1].compiler_flags["cflags"] == ["-Wall"]
assert concrete[s2].compiler_flags["cflags"] == []


@pytest.mark.parametrize(
"cmd_flags,req_flags,cmp_flags,dflags,expected_order",
[
Expand Down
2 changes: 2 additions & 0 deletions var/spack/repos/builtin.mock/packages/cmake/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Cmake(Package):
homepage = "https://www.cmake.org"
url = "https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz"

tags = ["build-tools"]

version(
"3.23.1",
md5="4cb3ff35b2472aae70f542116d616e63",
Expand Down

0 comments on commit 2447d16

Please sign in to comment.