Newer
Older
set -o errexit
set -o pipefail
set -o nounset
echo "Getting system compiler"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
${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("\(.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
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