Skip to content

solver: fix error with flags when a package appears multiple times in the DAG#51218

Merged
becker33 merged 6 commits intospack:developfrom
alalazo:bugfix/flags-and-duplicate-nodes
Sep 5, 2025
Merged

solver: fix error with flags when a package appears multiple times in the DAG#51218
becker33 merged 6 commits intospack:developfrom
alalazo:bugfix/flags-and-duplicate-nodes

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Aug 25, 2025

fixes #51209

Compiler flags from the command line are evaluated as part of the ASP problem, so they are already in the output, but:

  1. They might have the wrong order, or
  2. They might be conflated on a single node, when they come from duplicates of the same package

In this PR we fix those issues, just by reordering the spec from a "literal" source correctly.

Before the PR

$ spack -m spec gcc@14 cflags=-O3
==> Error: set() does not equal {'-O3'}
$ spack spec hdf5~mpi %gmake cflags="-O2" ^zlib-ng %gmake cflags="-O3"
==> Error: set() does not equal {'-O3'}

After the PR

$ spack -m spec gcc@14 cflags=-O3
 -   [email protected] cflags=-O3  build_system=generic languages:='c,c++,fortran' platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
 -       ^[email protected] build_system=generic platform=linux os=ubuntu20.04 target=icelake 
[e]      ^[email protected] build_system=generic languages:='c,c++,fortran' platform=linux os=ubuntu20.04 target=icelake 
 -       ^[email protected] build_system=generic platform=linux os=ubuntu20.04 target=icelake 
[e]      ^[email protected] build_system=autotools platform=linux os=ubuntu20.04 target=icelake 

$ spack spec hdf5~mpi %gmake cflags="-O2" ^zlib-ng %gmake cflags="-O3"
 -   [email protected]~cxx~fortran~hl~ipo~java~map~mpi+shared~szip~threadsafe+tools api=default build_system=cmake build_type=Release generator=make platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -       ^[email protected]~doc+ncurses+ownlibs~qtgui build_system=generic build_type=Release platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
 -           ^[email protected]~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs:=shared,static tls:=openssl platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
 -               ^[email protected] build_system=autotools platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
 -                   ^[email protected] build_system=autotools platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -                       ^[email protected] build_system=autotools libs:=shared,static platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -               ^[email protected]~docs+shared build_system=generic certs=mozilla platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
 -                   ^ca-certificates-mozilla@2025-05-20 build_system=generic platform=linux os=ubuntu20.04 target=icelake 
 -               ^[email protected]+cpanm+opcode+open+shared+threads build_system=generic platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -                   ^[email protected]+cxx~docs+stl build_system=autotools patches:=26090f4,b231fcc platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
 -                   ^[email protected]~debug~pic+shared build_system=generic platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -                   ^[email protected] build_system=autotools platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -                       ^[email protected] build_system=autotools patches:=21f0a03 platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -           ^[email protected]~symlinks+termlib abi=none build_system=autotools patches:=7a351bc platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
[+]      ^[email protected] build_system=generic platform=linux os=ubuntu20.04 target=icelake 
[e]      ^[email protected]~binutils+bootstrap~graphite~nvptx~piclibs~profiled~strip build_system=autotools build_type=RelWithDebInfo languages:='c,c++,fortran' patches:=2c18531 platform=linux os=ubuntu20.04 target=icelake 
[+]      ^[email protected] build_system=generic platform=linux os=ubuntu20.04 target=icelake 
[e]      ^[email protected] build_system=autotools platform=linux os=ubuntu20.04 target=icelake 
 -       ^[email protected] cflags=-O2 ~guile build_system=generic platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -       ^[email protected] build_system=autotools platform=linux os=ubuntu20.04 target=icelake %[email protected]
 -       ^[email protected]+compat+new_strategies+opt+pic+shared build_system=autotools platform=linux os=ubuntu20.04 target=icelake %c,[email protected]
 -           ^[email protected] cflags=-O3 ~guile build_system=generic platform=linux os=ubuntu20.04 target=icelake %[email protected]

@alalazo alalazo added the bugfix Something wasn't working, here's a fix label Aug 25, 2025
Signed-off-by: Massimiliano Culpo <[email protected]>
fixes spack#51209

Compiler flags from the command line are evaluated as part
of the ASP problem, so they are already in the output, but
with a possibly wrong order.

Instead of matching with input specs, just reorder the flags
from a "literal" source correctly.

Signed-off-by: Massimiliano Culpo <[email protected]>
Signed-off-by: Massimiliano Culpo <[email protected]>
@alalazo alalazo force-pushed the bugfix/flags-and-duplicate-nodes branch from 0171c70 to 094d870 Compare September 3, 2025 13:43
Signed-off-by: Massimiliano Culpo <[email protected]>
@alalazo alalazo marked this pull request as ready for review September 3, 2025 15:35
@alalazo alalazo added the v1.0.2 PRs / Bug fixes to backport for v1.0.2 label Sep 3, 2025
@alalazo alalazo mentioned this pull request Sep 3, 2025
26 tasks
Copy link
Copy Markdown
Member

@becker33 becker33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, asking for a couple comments to make it more readable

@becker33 becker33 merged commit f71acf9 into spack:develop Sep 5, 2025
32 of 33 checks passed
@alalazo alalazo deleted the bugfix/flags-and-duplicate-nodes branch September 5, 2025 11:55
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Sep 5, 2025

Thanks!

alalazo added a commit that referenced this pull request Sep 8, 2025
… the DAG (#51218)

* Add regression tests

Signed-off-by: Massimiliano Culpo <[email protected]>

* solver: evaluate cli compiler flags from the solver output

fixes #51209

Compiler flags from the command line are evaluated as part
of the ASP problem, so they are already in the output, but
with a possibly wrong order.

Instead of matching with input specs, just reorder the flags
from a "literal" source correctly.

Signed-off-by: Massimiliano Culpo <[email protected]>

---------

Signed-off-by: Massimiliano Culpo <[email protected]>
haampie pushed a commit that referenced this pull request Sep 12, 2025
… the DAG (#51218)

* Add regression tests

Signed-off-by: Massimiliano Culpo <[email protected]>

* solver: evaluate cli compiler flags from the solver output

fixes #51209

Compiler flags from the command line are evaluated as part
of the ASP problem, so they are already in the output, but
with a possibly wrong order.

Instead of matching with input specs, just reorder the flags
from a "literal" source correctly.

Signed-off-by: Massimiliano Culpo <[email protected]>

---------

Signed-off-by: Massimiliano Culpo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Something wasn't working, here's a fix v1.0.2 PRs / Bug fixes to backport for v1.0.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

solver: error with flags when a package appears multiple times in the DAG

2 participants