Skip to content
Snippets Groups Projects
install_compilers.sh 1.81 KiB
Newer Older
STACK_CONFIG=stacks/${stack}/config.json

COMPILER_LIST_SPECS=$(jq -Mr '.stack | .core_compiler as $core | .compilers | map("\(.spec)@\(.spec_version) %\($core)")[]' ${STACK_CONFIG})

echo "Getting system compiler"
spack/bin/spack compiler find --scope system /usr

spack/bin/spack spec \
    --install-status \
    --namespaces \
    --long \
    --types \
    ${COMPILER_LIST_SPECS}

spack/bin/spack spec \
    --install-status \
    --namespaces \
    --long \
    --types \
    --json \
    ${COMPILER_LIST_SPECS} > compilers_spec.json

echo "Compilers to install:"
echo "${COMPILER_LIST_SPECS}"

spack/bin/spack install \
    --log-file spack-install.xml \
    --log-format junit \
    --fail-fast \
    --show-log-on-error \
    ${COMPILER_LIST_SPECS}

hashes=$(jq -Mr '.spec.nodes | map("/\(.hash)") | join(" ")' compilers_spec.json)

echo "Adding packages to buildcache"
spack/bin/spack buildcache create \
    --update-index \
    --key EDC904DCE3D2E84E \
    /buildcache ${hashes}

core_compiler=$(jq -Mrc '.stack | .core_compiler' ${STACK_CONFIG})
compilers=$(jq -Mrc '.stack | .compilers | to_entries | map("\(.key)@\(.value.version)")' ${STACK_CONFIG})
compilers_specs=$(jq -Mrc '.stack | .compilers | map("\(.spec)@\(.spec_version)")' ${STACK_CONFIG})
cat > stacks/${stack}/compiler_definitions.yaml << EOF
definitions:
  - core_compiler: [ ${core_compiler} ]
  - compilers: ${compilers}
  - compilers_specs: ${compilers_specs}
EOF

cat compiler_definitions.yaml

for compiler_hash in $(echo ${hashes}); do
    location=$(spack/bin/spack location -i ${compiler_hash})
Nicolas Richart's avatar
Nicolas Richart committed
    echo "Checking for compiler in locations:"
    echo "  - ${location}"
Nicolas Richart's avatar
Nicolas Richart committed
    echo "  - ${location}/compiler/latest/linux"

    spack/bin/spack compiler find \
        --scope system \
        ${location} \
Nicolas Richart's avatar
Nicolas Richart committed
        ${location}/compiler/latest/linux