Newer
Older
set -o errexit
set -o pipefail
set -o nounset
echo "Getting system compiler"
${STACK_LOCATION}/spack/bin/spack compiler find --scope system /usr
for c in "core_compilers" "compilers"; do
echo "Installing $c"
_specs=$(comp=$c jq -Mr '.stack | .system_arch as $arch | with_entries(select(.key==env.comp)) | to_entries | .[].value | map("\(.spec) \($arch)")[]' ${STACK_CONFIG})
echo "Compilers to install:"
echo "${_specs}"
if [ "x${_specs}" != "x" ]; then
${STACK_LOCATION}/spack/bin/spack spec \
--install-status \
--namespaces \
--long \
--types \
${_specs}
${STACK_LOCATION}/spack/bin/spack spec \
--install-status \
--namespaces \
--long \
--types \
--json \
${_specs} > compilers_spec.json
${STACK_LOCATION}/spack/bin/spack install \
--log-file spack-install.xml \
--log-format junit \
--fail-fast \
--show-log-on-error \
${_specs}
hashes=$(jq -Mr '.spec.nodes | map("/\(.hash)") | join(" ")' compilers_spec.json)
echo "Adding packages to buildcache"
${STACK_LOCATION}/spack/bin/spack buildcache create \
--update-index \
--key EDC904DCE3D2E84E \
/buildcache ${hashes}
for compiler_hash in $(echo ${hashes}); do
location=$(${STACK_LOCATION}/spack/bin/spack location -i ${compiler_hash})
# echo "Checking for compiler"
# echo " - ${location}"
# echo " - ${location}/compiler/latest"
# echo " - ${location}/compiler/latest/linux"
# echo " - ${location}/Linux_x86_64/2024/compilers"
${STACK_LOCATION}/spack/bin/spack compiler find \
--scope system \
${location} \
${location}/compiler/latest \
${location}/compiler/latest/linux \
${location}/Linux_x86_64/2024/compilers
done
fi
compilers_specs=$(jq -Mr '.stack | .system_arch as $arch | .core_compilers + .compilers | map("\(.spec) \($arch)")' ${STACK_CONFIG})
system_compiler=$(jq -Mrc '.stack | .system_arch as $arch | .system_compiler | map("\(.compiler)@\(.version) \($arch)")' ${STACK_CONFIG})
core_compilers=$(jq -Mrc '.stack | .system_compiler + .core_compilers | map("\(.compiler)@\(.version)")' ${STACK_CONFIG})
compilers=$(jq -Mrc '.stack | .compilers | map(select(.constraint == null)) | map("\(.compiler)@\(.version)")' ${STACK_CONFIG})
echo "definitions:" > ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
set +o nounset
for c in "compilers_specs" "system_compiler" "core_compilers" "compilers"; do
if [ "x${!c}" != "x" ]; then
echo " - ${c}: ${!c}" >> ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
fi
done
set -o nounset
jq -Mrc '
.stack
| .system_arch as $arch
| .compilers
| map(select(.constraint != null))
| map(" - {when: \(.constraint), compilers_spec: [\(.spec) \($arch)]}")
| .[]
' ${STACK_CONFIG} >> ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
cat ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
#yq -y -s ".[0].spack.definitions = .[1].definitions + .[0].spack.definitions | .[0]" ${SPACK_SYSTEM_CONFIG_PATH}/spack.yaml ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml > ${SPACK_SYSTEM_CONFIG_PATH}/spack.yaml.new
#mv ${SPACK_SYSTEM_CONFIG_PATH}/spack.yaml.new ${SPACK_SYSTEM_CONFIG_PATH}/spack.yaml