Maintaining Spack Buildcache - GEOS-ESM/MAPL GitHub Wiki

This page details the efforts to create a buildcache for use in Spack CI tests in MAPL.

Useful Links

Building Packages on AWS

Preliminaries

Padded Length

Testing showed we apparently need to increase the length of the padding in the install tree. This is what I ran:

spack config add config:install_tree:padded_length:256

packages.yaml

My current packages.yaml is set as:

packages:

  gcc:
    externals:
    - spec: [email protected] languages='c,c++,fortran'
      prefix: /usr
      extra_attributes:
        compilers:
          c: /usr/bin/gcc
          cxx: /usr/bin/g++
          fortran: /usr/bin/gfortran
        flags: {}
        environment: {}
        extra_rpaths: []
    - spec: [email protected] languages='c,c++,fortran'
      prefix: /usr
      extra_attributes:
        compilers:
          c: /usr/bin/gcc-14
          cxx: /usr/bin/g++-14
          fortran: /usr/bin/gfortran-14
        flags: {}
        environment: {}
        extra_rpaths: []
    buildable: false

  all:
    require: target=x86_64_v3
    providers:
      mpi: [openmpi, intel-oneapi-mpi]
      blas: [openblas, intel-oneapi-mkl]
      lapack: [openblas, intel-oneapi-mkl]

  gcc:
    buildable: false
  openmpi:
    require:
    - any_of: ['%gcc']
      message: Only use Open MPI with GCC

  intel-oneapi-mpi:
    require:
    - any_of: ['%oneapi']
      message: Only use Intel MPI with Intel

  hdf5:
    variants: +fortran +szip +hl +threadsafe +mpi
    # Note that cdo requires threadsafe, but hdf5 doesn't
    # seem to want that with parallel. Hmm.
  netcdf-c:
    variants: +dap
    #variants: +hdf4 +dap
  esmf:
    #variants: ~pnetcdf ~xerces ~external-parallelio
    variants: ~pnetcdf ~xerces
  cdo:
    variants: ~proj ~fftw3
    # cdo wanted a lot of extra stuff for proj and fftw3. Turn off for now
  pflogger:
    variants: +mpi
  pfunit:
    variants: +mpi +fhamcrest
  fms:
    require: '@2024.03 ~gfs_phys +pic constants=GEOS precision=32,64 +deprecated_io ~yaml target=x86_64_v3'
    # NOTE: I have to re-add the target here otherwise spack seemed to not build for a generic processor
  mapl:
    variants: +extdata2g +fargparse +pflogger +pfunit ~pnetcdf

repos.yaml

Spack is now split with packages in a separate repo. To be consistent, we manually clone and put it in a place easy to maintain. As such, our repos.yaml is:

repos:
  builtin:
    git: [email protected]:spack/spack-packages.git
    destination: /home/ubuntu/spack-packages
  geosesm: /home/ubuntu/geosesm-spack

Building Packages

We want all the dependencies of GEOS, so we need to do:

spack install --only dependencies mapl
spack install mepo openblas [email protected]

This (should) get us everything that MAPL and GEOS needs to build.

Building the Buildcache

Create Spack Environment

It turns out, you can't build or push a buildcache unless you are in a Spack environment. So we need to create one:

spack env create geos-buildcache
spack env activate -p geos-buildcache

Add Packages to Environment

spack install --add esmf gftl gftl-shared fargparse pflogger pfunit yafyaml ecbuild udunits mepo openblas [email protected]
spack concretize -f

Add mirror for buildcache

spack mirror add --oci-username mathomp4 --oci-password-variable GEOS_BUILDCACHE_TOKEN --unsigned geos-buildcache oci://ghcr.io/GEOS-ESM/geos-buildcache

Pushing the Buildcache

spack buildcache push --update-index oci://ghcr.io/GEOS-ESM/geos-buildcache