Skip to content

solver: don't give a penalty for compiler reuse on compilers#51744

Merged
becker33 merged 1 commit into
spack:developfrom
alalazo:solver/improve-default-choices-for-fresh-concretization
Feb 12, 2026
Merged

solver: don't give a penalty for compiler reuse on compilers#51744
becker33 merged 1 commit into
spack:developfrom
alalazo:solver/improve-default-choices-for-fresh-concretization

Conversation

@alalazo

@alalazo alalazo commented Dec 12, 2025

Copy link
Copy Markdown
Member

In the solver we give a penalty if "reuse" introduces a node compiled with a compiler that is not used otherwise. This is to avoid that extraneous compilers are introduced in the DAG when reusing binaries.

Here we make an exception if such a node is a compiler itself.

@lorisercole

Copy link
Copy Markdown
Contributor

Thanks @alalazo!
I can confirm that this change solves the following common scenario:
If we have an old external compiler gcc@12 and one that was just installed by spack gcc@14 and that was never used:

$ spack compiler list
==> Available compilers
-- gcc ubuntu24.04-x86_64 ---------------------------------------
[e]  gcc@12.4.0  [+]  gcc@14.3.0

In a fresh concretization, the solver preferred to reuse the old (external) compiler:

$ spack spec --fresh openblas
 -   openblas@0.3.29~bignuma~consistent_fpcsr+dynamic_dispatch+fortran~ilp64+locking+pic+shared build_system=makefile symbol_suffix=none threads=none platform=linux os=ubuntu24.04 target=skylake %c,cxx,fortran=gcc@12.4.0
[+]      ^compiler-wrapper@1.0 build_system=generic platform=linux os=ubuntu24.04 target=skylake
[e]      ^gcc@12.4.0~binutils+bootstrap~graphite~mold~nvptx~piclibs~profiled~strip build_system=autotools build_type=RelWithDebInfo languages:='c,c++,fortran' platform=linux os=ubuntu24.04 target=x86_64
[+]      ^gcc-runtime@12.4.0 build_system=generic platform=linux os=ubuntu24.04 target=skylake
[e]      ^glibc@2.39 build_system=autotools platform=linux os=ubuntu24.04 target=x86_64
-        ^gmake@4.4.1~guile build_system=generic platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0

With this PR, it will choose the newer one:

$ spack spec --fresh openblas
 -   openblas@0.3.29~bignuma~consistent_fpcsr+dynamic_dispatch+fortran~ilp64+locking+pic+shared build_system=makefile symbol_suffix=none threads=none platform=linux os=ubuntu24.04 target=skylake %c,cxx,fortran=gcc@14.3.0
[+]      ^compiler-wrapper@1.0 build_system=generic platform=linux os=ubuntu24.04 target=skylake
[+]      ^gcc@14.3.0~binutils+bootstrap~graphite~mold~nvptx~piclibs~profiled~strip build_system=autotools build_type=RelWithDebInfo languages:='c,c++,fortran' platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[-]          ^diffutils@3.10 build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^libiconv@1.18 build_system=autotools libs:=shared,static platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]          ^gawk@5.3.1~nls build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^libsigsegv@2.14 build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^readline@8.2 build_system=autotools patches:=1ea4349,24f587b,3d9885e,5911a5b,622ba38,6c8adf8,758e2ec,79572ee,a177edc,bbf97f1,c7b45ff,e0013d9,e065038 platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[e]          ^gcc@12.4.0~binutils+bootstrap~graphite~mold~nvptx~piclibs~profiled~strip build_system=autotools build_type=RelWithDebInfo languages:='c,c++,fortran' platform=linux os=ubuntu24.04 target=x86_64
[+]          ^gcc-runtime@12.4.0 build_system=generic platform=linux os=ubuntu24.04 target=skylake
[-]          ^gmake@4.4.1~guile build_system=generic platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[+]          ^gmp@6.3.0+cxx build_system=autotools libs:=shared,static platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[-]              ^autoconf@2.72 build_system=autotools platform=linux os=ubuntu24.04 target=skylake
[-]              ^automake@1.16.5 build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^m4@1.4.20+sigsegv build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[-]          ^libtool@2.4.7 build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^findutils@4.10.0 build_system=autotools patches:=440b954 platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[+]          ^mpc@1.3.1 build_system=autotools libs:=shared,static platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[+]          ^mpfr@4.2.1 build_system=autotools libs:=shared,static patches:=3ec29a6 platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^autoconf-archive@2023.02.20 build_system=autotools platform=linux os=ubuntu24.04 target=skylake
[-]          ^perl@5.40.0+cpanm+opcode+open+shared+threads build_system=generic platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^berkeley-db@18.1.40+cxx~docs+stl build_system=autotools patches:=26090f4,b231fcc platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[-]              ^bzip2@1.0.8~debug~pic+shared build_system=generic platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^gdbm@1.23 build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]          ^texinfo@7.1 build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[-]              ^gettext@0.23.1+bzip2+curses+git~libunistring+libxml2+pic+shared+tar+xz build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[-]                  ^libxml2@2.13.5~http+pic~python+shared build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]                  ^tar@1.35 build_system=autotools zip=pigz platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]                      ^pigz@2.8 build_system=makefile platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]                  ^xz@5.6.3~pic build_system=autotools libs:=shared,static platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[-]              ^ncurses@6.5~symlinks+termlib abi=none build_system=autotools patches:=7a351bc platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[-]                  ^pkgconf@2.3.0 build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c=gcc@12.4.0
[+]          ^zlib-ng@2.2.4+compat+new_strategies+opt+pic+shared build_system=autotools platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
[+]          ^zstd@1.5.7+programs build_system=makefile compression:=none libs:=shared,static platform=linux os=ubuntu24.04 target=skylake %c,cxx=gcc@12.4.0
 -       ^gcc-runtime@14.3.0 build_system=generic platform=linux os=ubuntu24.04 target=skylake
[e]      ^glibc@2.39 build_system=autotools platform=linux os=ubuntu24.04 target=x86_64
 -       ^gmake@4.4.1~guile build_system=generic platform=linux os=ubuntu24.04 target=skylake %c=gcc@14.3.0

@tgamblin tgamblin added this to the v1.2.0 milestone Jan 12, 2026
lorisercole added a commit to lorisercole/spack that referenced this pull request Jan 27, 2026
@alalazo alalazo force-pushed the solver/improve-default-choices-for-fresh-concretization branch from 19b55fc to ddf497a Compare February 3, 2026 13:22
@github-actions github-actions Bot added the solver label Feb 3, 2026
@alalazo alalazo added bugfix Something wasn't working, here's a fix and removed solver labels Feb 3, 2026
In the solver we give a penalty if "reuse" introduces a node
compiled with a compiler that is not used otherwise. This is
to avoid that extraneous compilers are introduced in the DAG
when reusing binaries.

Here we make an exception if such a node is a compiler itself.

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
@alalazo alalazo force-pushed the solver/improve-default-choices-for-fresh-concretization branch from ddf497a to 0bf6c74 Compare February 12, 2026 09:08
@becker33 becker33 merged commit 6c79f6b into spack:develop Feb 12, 2026
56 of 60 checks passed
@alalazo alalazo deleted the solver/improve-default-choices-for-fresh-concretization branch February 12, 2026 17:27
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 solver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants