Creating a spack.yaml file¶
Let's create a spack.yaml
file that will allow us to create a Spack
environment for compiling FluidSynth
using CMake.
Below is a spack.yaml
file which you can also find in the
spack-config-templates
repository
inside the environment-templates
sub-directory for the version of Spack you
are using - called spack-cmake.yaml
. Either copy and paste the below or grab
the example from the repository, make sure it is named spack.yaml
and save it
into a directory of your choice for your environment. For the purposes of this
tutorial I am going to save it as:
/data/scratch/${USER}/spack-environments/spack-cmake/spack.yaml
(please create the directory first if it doesn't exist). This means the Spack
environment will also be stored in
/data/scratch/${USER}/spack-environments/spack-cmake
. You may wish to store
your own environments in an alternative location if you need to keep them
for longer. Please refer back to the
Configuration overview page for further
information.
Contents of spack.yaml
(click to expand)
spack:
compilers:
- compiler:
spec: gcc@=11.4.1
paths:
cc: /bin/gcc
cxx: /bin/g++
f77: /bin/gfortran
fc: /bin/gfortran
flags: {}
operating_system: rocky9
target: x86_64
modules: []
environment: {}
extra_rpaths: []
- compiler:
spec: gcc@=12.2.0
paths:
cc: /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gcc/12.2.0-6frskzg/bin/gcc
cxx: /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gcc/12.2.0-6frskzg/bin/g++
f77: /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gcc/12.2.0-6frskzg/bin/gfortran
fc: /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gcc/12.2.0-6frskzg/bin/gfortran
flags: {}
operating_system: rocky9
target: x86_64
modules: []
environment: {}
extra_rpaths: []
concretizer:
unify: true
config:
install_tree:
root: /data/scratch/${USER}/spack/apps
projections:
^mpi: '{architecture}/{compiler.name}-{compiler.version}/{name}/{version}-{^mpi.name}-{^mpi.version}-{hash:7}'
all: '{architecture}/{compiler.name}-{compiler.version}/{name}/{version}-{hash:7}'
license_dir: /data/scratch/${USER}/spack/licenses
source_cache: /data/scratch/${USER}/spack/cache
modules:
prefix_inspections:
./share/aclocal:
- ACLOCAL_PATH
./lib:
- LD_LIBRARY_PATH
- LIBRARY_PATH
./lib64:
- LD_LIBRARY_PATH
- LIBRARY_PATH
./include:
- C_INCLUDE_PATH
- CPLUS_INCLUDE_PATH
packages:
all:
target: [x86_64_v4]
openmpi:
buildable: false
prefer:
- '+gpfs'
externals:
- spec: "openmpi@5.0.3%gcc@12.2.0"
prefix: /share/apps/rocky9/general/libs/openmpi/gcc/12.2.0/5.0.3
ucx:
buildable: false
externals:
- spec: "ucx@1.16.0%gcc@12.2.0"
prefix: /share/apps/rocky9/general/libs/ucx/gcc/12.2.0/1.16.0
specs:
- cmake
- gcc@12.2.0
- glib
upstreams:
apocrita:
install_tree: /share/apps/rocky9/spack/apps
view:
default:
root: .spack-env/view
It's basically identical to our
Python example apart from the specs
list
(which now has cmake
, gcc@12.2.0
and glib
). As before, the modules
section sets the prefix_inspections:
required to set the environment variables
we are going to need for the manual compilation of FluidSynth
using CMake.