spack / spack

A flexible package manager that supports multiple versions, configurations, platforms, and compilers.
https://spack.io
Other
4.43k stars 2.29k forks source link

Mixing compatible gcc-runtime versions when `reuse: false` #44978

Open vanderwb opened 5 months ago

vanderwb commented 5 months ago

Summary

Before the gcc-runtime package was introduced back in December, it was possible to use older GCC versions (e.g., the system GCC) to compile low-level package dependencies and then use require: settings to force the concretizer to reuse those versions, even when reuse: false. With the introduction of the runtime packages, this seems impossible now.

For example, let's say I have the following restriction set:

  packages:
    zlib:
      require: '%gcc@7.5.0'

In older versions, a spec like hdf5~mpi%gcc@13.2.0 would then use the already-installed zlib. But now, because gcc-runtime always seems to use the parent runtime version, a duplicate zlib installation is created:

$ spack spec -c edges -l hdf5~mpi %gcc@13.2.0                                                                                                                                                                                                                                                    
Input spec
--------------------------------
 -   hdf5%gcc@13.2.0~mpi

Concretized
--------------------------------
 -   o64ao32  hdf5@1.14.3%gcc@13.2.0~cxx~fortran~hl~ipo~java~map~mpi+shared~szip~threadsafe+tools api=default build_system=cmake build_type=Release generator=make patches=82088c8 arch=linux-sles15-x86_64_v3
 -   5umfaqv      ^cmake@3.29.6%gcc@13.2.0~doc+ncurses+ownlibs build_system=generic build_type=Release arch=linux-sles15-x86_64_v3
 -   5zfgvax          ^curl@8.4.0%gcc@13.2.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-sles15-x86_64_v3
 -   gjgvnab              ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d              ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   5umskve              ^gmake@4.4.1%gcc@13.2.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   haonhor              ^nghttp2@1.62.0%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   qwnmrkm                  ^diffutils@3.10%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   gjgvnab                      ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                      ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   5umskve                      ^gmake@4.4.1%gcc@13.2.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   gjgvnab                  ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                  ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   5umskve                  ^gmake@4.4.1%gcc@13.2.0~guile build_system=generic arch=linux-sles15-x86_64_v3
[e]  u2h5vob                  ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
[e]  rwk3nll              ^openssl@1.1.1l%gcc@7.5.0~docs+shared build_system=generic certs=mozilla arch=linux-sles15-x86_64_v3
[e]  u2h5vob              ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
 -   swjzeqs              ^zlib@1.3.1%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-sles15-x86_64_v3
 -   gjgvnab          ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d          ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   5umskve          ^gmake@4.4.1%gcc@13.2.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   nfekobe          ^ncurses@6.5%gcc@13.2.0~symlinks+termlib abi=none build_system=autotools patches=7a351bc arch=linux-sles15-x86_64_v3
 -   gjgvnab              ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d              ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   5umskve              ^gmake@4.4.1%gcc@13.2.0~guile build_system=generic arch=linux-sles15-x86_64_v3
[e]  u2h5vob              ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
 -   swjzeqs          ^zlib@1.3.1%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-sles15-x86_64_v3
 -   gjgvnab      ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d          ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[e]  foh2t6d      ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   5umskve      ^gmake@4.4.1%gcc@13.2.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   gjgvnab          ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d          ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[e]  u2h5vob      ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
 -   swjzeqs      ^zlib@1.3.1%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-sles15-x86_64_v3
 -   gjgvnab          ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d          ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   4m5a2bo          ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   gjgvnab              ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d              ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3

However, the concretizer will use the correct zlib if explicitly forced (this causes the concretizer to use a different curl version for some reason, but that's not an immediate concern):

$ spack spec -c edges -l hdf5~mpi %gcc@13.2.0 ^/eoi5pri
Input spec
--------------------------------
 -   hdf5%gcc@13.2.0~mpi
 -       ^/eoi5pri

Concretized                                                                                                                                                                                                                                                                                                                                 [4/1212]--------------------------------
 -   eigyqqu  hdf5@1.14.3%gcc@13.2.0~cxx~fortran~hl~ipo~java~map~mpi+shared~szip~threadsafe+tools api=default build_system=cmake build_type=Release generator=make patches=82088c8 arch=linux-sles15-x86_64_v3
 -   zjo5rer      ^cmake@3.29.6%gcc@13.2.0~doc+ncurses+ownlibs build_system=generic build_type=Release arch=linux-sles15-x86_64_v3
 -   2lyqmyy          ^curl@8.7.1%gcc@13.2.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-sles15-x86_64_v3
 -   gjgvnab              ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d              ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l              ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   dfph73h              ^nghttp2@1.62.0%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   f6kva3k                  ^diffutils@3.10%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   gjgvnab                      ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                      ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l                      ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   gjgvnab                  ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                  ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l                  ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
[e]  u2h5vob                  ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
[e]  rwk3nll              ^openssl@1.1.1l%gcc@7.5.0~docs+shared build_system=generic certs=mozilla arch=linux-sles15-x86_64_v3
 -   md73u3q              ^perl@5.38.2%gcc@13.2.0+cpanm+opcode+open+shared+threads build_system=generic arch=linux-sles15-x86_64_v3
 -   7zg34fs                  ^berkeley-db@18.1.40%gcc@13.2.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-sles15-x86_64_v3
 -   gjgvnab                      ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                      ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l                      ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   3o7e4ih                  ^bzip2@1.0.8%gcc@13.2.0~debug~pic+shared build_system=generic arch=linux-sles15-x86_64_v3
 -   f6kva3k                      ^diffutils@3.10%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   gjgvnab                      ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                      ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l                      ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   gjgvnab                  ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
 -   h6lexso                  ^gdbm@1.23%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
 -   gjgvnab                      ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                      ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l                      ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   54lztsa                      ^readline@8.2%gcc@13.2.0 build_system=autotools patches=bbf97f1 arch=linux-sles15-x86_64_v3
 -   gjgvnab                          ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d                          ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l                          ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   gdwtalu                          ^ncurses@6.5%gcc@13.2.0~symlinks+termlib abi=none build_system=autotools patches=7a351bc arch=linux-sles15-x86_64_v3
[e]  foh2t6d                  ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l                  ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
[+]  eoi5pri                  ^zlib@1.3.1%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-sles15-x86_64_v3
[e]  u2h5vob              ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
[+]  eoi5pri              ^zlib@1.3.1%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-sles15-x86_64_v3
 -   gjgvnab          ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d          ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l          ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
 -   gdwtalu          ^ncurses@6.5%gcc@13.2.0~symlinks+termlib abi=none build_system=autotools patches=7a351bc arch=linux-sles15-x86_64_v3
 -   gjgvnab              ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d              ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l              ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
[e]  u2h5vob              ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
[+]  eoi5pri          ^zlib@1.3.1%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-sles15-x86_64_v3
 -   gjgvnab      ^gcc-runtime@13.2.0%gcc@13.2.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  foh2t6d          ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[e]  foh2t6d      ^glibc@2.31%gcc@13.2.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l      ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3
[+]  ungbwrk          ^gcc-runtime@7.5.0%gcc@7.5.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  rb4wl77              ^glibc@2.31%gcc@7.5.0 build_system=autotools arch=linux-sles15-x86_64_v3
[e]  rb4wl77          ^glibc@2.31%gcc@7.5.0 build_system=autotools arch=linux-sles15-x86_64_v3
[e]  u2h5vob      ^pkg-config@0.29.2%gcc@7.5.0+internal_glib build_system=autotools arch=linux-sles15-x86_64_v3
[+]  eoi5pri      ^zlib@1.3.1%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-sles15-x86_64_v3
[+]  ungbwrk          ^gcc-runtime@7.5.0%gcc@7.5.0 build_system=generic arch=linux-sles15-x86_64_v3
[e]  rb4wl77          ^glibc@2.31%gcc@7.5.0 build_system=autotools arch=linux-sles15-x86_64_v3
[+]  go6me6l          ^gmake@4.4.1%gcc@7.5.0~guile build_system=generic arch=linux-sles15-x86_64_v3

I haven't been able to find a way to produce this reuse behavior without explicitly specifying hashes of dependencies, which isn't tenable for a whole stack. If I try to require %gcc@7.5.0 ^gcc-runtime@7.5.0 on zlib, I get this error upon concretization:

$ spack spec -c edges -l hdf5~mpi %gcc@13.2.0
==> Error: Version requirement 7.5.0 on zlib for gcc-runtime cannot match any known version from package.py or externals

Rationale

This used to work, and since older runtimes should be compatible with newer compilers, I think the request here is valid from a linking standpoint. Without the desired behavior, the ability to reuse packages compiled with older runtimes is restricted.

Description

I'd like to be able to request that low-level packages like zlib, curl, cmake, etc... be compiled only once within a reuse: false stack. We like to build subsets of our larger stack for container images and other use cases, and with reuse: true, the subset will not concretize to the same packages as the main stack and so the binary cache we have becomes much less useful.

In summary, I'm creating this issue to:

a) State the concern b) Understand whether the current behavior is desired (and thus will persist into the "compilers as dependencies" era) c) Find out an estimated timeline for a fix, if the current behavior is not the final goal

We haven't been able to use any versions of Spack since December when the gcc-runtime package was introduced, and this is becoming more challenging to deal with as our HPC users request new package versions.

Additional information

Most recently tested with:

$ spack debug report
* **Spack:** 0.23.0.dev0 (00663f29a926b92c8e89dad371f960372e7ff59e)
* **Python:** 3.11.9
* **Platform:** linux-sles15-zen3
* **Concretizer:** clingo

General information

haampie commented 5 months ago

Yeah, I don't like the current implementation either.

x%gcc@x.y.z should imply a direct dependency on gcc-runtime@x.y.z.

Currently if you first install zlib %gcc@old and then concetrize parent %gcc@new, it will reuse zlib ^gcc-runtime@old as is. But if there is no zlib to reuse, you get zlib ^gcc-runtime@new, which leads to more duplication than necessary.