-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-alibuild
executable file
·357 lines (339 loc) · 12.4 KB
/
run-alibuild
1
2
3
4
5
6
7
8
9
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#!/bin/bash
if [[ "${EUID}" = 0 ]]; then
echo "error: root should not run $(basename "$0")" 1>&2
exit 1
fi
alienv_follow_symbolic_link()
{
# Make alienv follow symbolic link
/usr/bin/sed -i -e "s/(find \\\$/(find -L \\\$/" alibuild/alienv
}
patch_alibuild()
{
/usr/bin/sed -i -e \
"s/\\(processor\\.\\)\\(replace(\\)/\\1decode().\\2/" \
alibuild/alibuild_helpers/utilities.py
}
patch_alidist_general()
{
# Disable the rounding check in CGAL so the resulting code using
# the library can be debugged with Valgrind
/usr/bin/sed -i -e \
"s/\\(cmake \\.\\) .*\\(\\\\\\)/\\1 -DCMAKE_CXX_FLAGS=\"-DCGAL_DISABLE_ROUNDING_MATH_CHECK\" \\2/" \
alidist/cgal.sh
/usr/bin/sed -i -e \
"s/\\(ADDITIONAL_FLAGS=\"\\)\\([^ ]*-L\$GMP_ROOT\\)/\\1-DCGAL_DISABLE_ROUNDING_MATH_CHECK \\2/" \
alidist/fastjet.sh
# The underlying SLES has a GCC with "Stack Clash" protection, and
# therfore the Perl MakeMaker will default to this particular
# compiler option, which the ALICE software GCC will not have
/usr/bin/sed -i -e \
"s<.*make\$</usr/bin/sed -i -e \"s>\\\\(Makefile\\\\.PL;\\\\).*\\\\(make;\\\\)>\\\\1 /usr/bin/sed -i -e \\\\\"s@ -fstack-clash-protection @ @\\\\\" Makefile; \\\\2>\" client/gclientlib/Makefile; make<" \
alidist/xalienfs.sh
# Not fixed in ALICE's outdated ROOT version, but breaks with
# MariaDB in CLE 7/SLES 15:
# https://github.com/root-project/root/commit/
# 511ae175e21c6b5fa32201de23b379f80ed37981
/usr/bin/sed -i -e "s@^\\( *\\).*\\(cmake --build.*\\)@\\1/usr/bin/sed -i -e \"s/^#include <my_global.h>//\" \"\${SOURCEDIR}/sql/mysql/src/TMySQLServer.cxx\"; \\2@" \
alidist/root.sh
# Cython needs to be installed first to prevent compilation
# failure as a dependency on RHEL/RHSCL
/usr/bin/sed -i -e "s/\\(-IU\\) \\(numpy\\)/\\1 cython \\2/" \
alidist/python-modules.sh
# The memory limit is not applicable to modern HPC systems, e.g.
# Cori's login nodes have 8 GB RAM per core
for m in dds qualitycontrol root; do
/usr/bin/sed -i -e "s/ *JOBS=\$.*//" alidist/${m}.sh
done
}
patch_alidist_gnu()
{
# Experimental settings for memory debugging, not active at the
# moment
#
# extra="-fsanitize=address -fno-omit-frame-pointer \
# -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -fstack-protector"
# for f in alidist/aliroot*.sh alidist/aliphysics*.sh; do
# /usr/bin/sed -i -e \
# "s/\\(cmake\\)[^\"]*\\(\"\\\$\\|\\\$\\)/\\1 -DCMAKE_CXX_FLAGS=\"\${CXXFLAGS} ${extra}\" \\2/" "$f"
# done
#
# AliPhysics is missing the setting for the Fortran compiler being
# gfortran (while AliRoot has it). If not set, CMake will default
# to Cray's Fortran wrapper, ftn, which cannot produce dynamic
# libraries.
/usr/bin/sed -i -e \
"s/^\\( *\\)\\(-DROOTSYS=\\)/\\1-DCMAKE_Fortran_COMPILER=gfortran \\2/" \
alidist/aliphysics.sh
}
detect_intel_cpu()
{
# CPU detection
intel_compiler_x=""
if /usr/bin/grep -q "flags[^ ]*: .* avx512pf avx512er" \
/proc/cpuinfo; then
intel_compiler_x="KNL"
elif /usr/bin/grep -q "flags[^ ]*: .* avx2" /proc/cpuinfo; then
intel_compiler_x="HASWELL"
elif /usr/bin/grep -q "flags[^ ]*: .* f16c rdrand" \
/proc/cpuinfo; then
intel_compiler_x="IVYBRIDGE"
elif /usr/bin/grep -q \
"model[^ ]*: \\(4[235689]\\|[5-9][0-9]\\)" \
/proc/cpuinfo; then
intel_compiler_x="SANDYBRIDGE"
fi
}
patch_alidist_intel()
{
# Modifications to force ALICE software being built with Intel
# C++/Fortran compiler
#
# Example for the first option: IVYBRIDGE, HASWELL, KNL
opt="-g -O3 -no-prec-div -fp-model fast=2 -ax${1}"
configure_opt="CC=icc CXX=icpc F77=ifort \
CFLAGS=\"\$(echo \"\${CFLAGS}\" | sed \"s/-g -O[0-9]//\") ${opt}\" \
CXXFLAGS=\"\$(echo \"\${CXXFLAGS}\" | sed \"s/-g -O[0-9]//\") ${opt}\" \
F77FLAGS=\"\$(echo \"\${F77FLAGS}\" | sed \"s/-g -O[0-9]//\") ${opt}\""
cmake_opt="-DCMAKE_C_COMPILER=icc -DCMAKE_CC_COMPILER=icc \
-DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort \
-DCMAKE_C_FLAGS=\"${opt}\" -DCMAKE_CXX_FLAGS=\"${opt}\" \
-DCMAKE_Fortran_FLAGS=\"${opt}\""
# Fake GCC-Toolchain
/usr/bin/sed -i -e "/which gfortran /{s/gfortran /ifort /g};\
/which cc /{s/ cc/ icc/g;s/\\([ \\/]\\)c++ /\\1icpc /g};" \
alidist/gcc-toolchain.sh
# Boost
/usr/bin/sed -i -e "s@\\(TOOLSET=\\)[^ ]*@\\1intel@;s@^.*\$EXTRA_CXXFLAGS@ cxxflags=\"${opt}\" \$EXTRA_CXXFLAGS@" \
alidist/boost.sh
# CMake itself
/usr/bin/sed -i -e "s@.*\\(\$SOURCEDIR/bootstrap \\)[^ ]*@${configure_opt} \\1@" \
alidist/cmake.sh
# Autoconf-like (ApMon-CPP, GSL, SWIG, xalienfs)
for p in apmon-cpp gsl swig xalienfs; do
/usr/bin/sed -i -e \
"s@\\(./configure\\).*\\(--prefix=\\|--disable-ccache\\)@\\1 ${configure_opt} \\2@" \
"alidist/${p}.sh"
done
# CMake-like (XRootD)
/usr/bin/sed -i -e "s@\\(cmake\\).*\\(\"\$SOURCEDIR\"\\)@\\1 ${cmake_opt} \\2@" \
alidist/xrootd.sh
# ROOT
/usr/bin/sed -i -e "s@\\(COMPILER_CC=\\)[^ ]*@\\1icc@;\
s@\\(COMPILER_CXX=\\)[^ ]*@\\1icpc@;\
s@\\(COMPILER_LD=\\)[^ ]*@\\1icpc@;\
s@\\(--with-f77=\\)[^ ]*@\\1ifort@;
s@\\(-DCMAKE_Fortran_COMPILER=\\)[^ ]*@\\1ifort@;" \
alidist/root.sh
# UUID
/usr/bin/sed -i -e \
"s@\\(./configure\\).*\\(\$(\\[\\[\\)@\\1 ${configure_opt} \\2@" \
alidist/uuid.sh
}
patch_cray_pe()
{
if [[ -n "${CRAY_CC_VERSION}" ]]; then
# Cray Compiling Environment (CCE) does not accept source code
# from the standard input, there is no easy way to make it
# work with AliBuild
echo "${application}: error: Compiler wrapper cannot be set to Cray Compiling Environment (CCE), do either \`module swap PrgEnv-cray PrgEnv-intel' or \`module swap PrgEnv-cray PrgEnv-gnu'" 1>&2
exit 1
fi
if [[ -z "${PYTHON_DIR}" ]]; then
# Python as installed with CLE 7 does not have requests, but
# NERSC's Anaconda installation does
echo "${application}: error: Python from CLE 7 cannot be used. Do \`module load python' first" 1>&2
exit 1
fi
# Cray compiler wrappers by default set "-static", unless with
# "-dynamic", and it does not pass "-L" to the linker unless with
# "-Wl"
/usr/bin/sed -i -e \
"s@ cc -xc .*-l@ cc -xc -dynamic -l@" \
ali-master/alidist/curl.sh
/usr/bin/sed -i -e \
"s@ cc -xc -lperl -L\\(.*\\) -I@ cc -xc -dynamic -lperl -L\\1 -Wl,-L\\1 -I@" \
ali-master/alidist/libperl.sh
# Protect Cray PE environment variables from being unset
/usr/bin/sed -i -e \
"s@ and x != \"ALIBUILD_VERSION\":@ and not x in ('ALIBUILD_VERSION', 'CRAYPE_VERSION', 'CRAY_LIBSCI_VERSION', 'DVS_VERSION', 'GCC_VERSION', 'GNU_VERSION', 'INTEL_MAJOR_VERSION', 'INTEL_MINOR_VERSION', 'INTEL_VERSION', 'LIBSCI_VERSION'):@" \
alibuild/alibuild_helpers/utilities.py
# Directories on GPFS do change after the compilation, tar cannot
# be required to return 0
/usr/bin/sed -i -e \
"/^\$MY_TAR.*-c/i set +e" -e "/^\$MY_TAR.*-c/a set -e" \
alibuild/alibuild_helpers/build_template.sh
}
load_cray_module_gcc()
{
# Replace Cray wrappers by NERSC installed Cray Modules of GCC,
# cause it to be detected by aliBuild
eval $(modulecmd bash load gcc)
# Ugly work-around for the NERSC specific installation, where gcc
# and g++ are shell scripts
gcc_prefix="$(/usr/bin/readlink -f $(/usr/bin/dirname \
$(/usr/bin/which gcc))/../snos)"
/usr/bin/mkdir -p usr/bin
/usr/bin/ln -sf "${gcc_prefix}/bin/gcc" usr/bin/cc
/usr/bin/ln -sf "${gcc_prefix}/bin/g++" usr/bin/c++
export PATH="$(/usr/bin/readlink -f usr/bin):$PATH"
}
aliroot_bugfix()
{
# A bugfix needed to run GEANT simulation on SLES, where its
# particular glibc will detect a memory bug
cat <<EOF | base64 -d | gzip -dc | patch -p1
H4sICMrXNlsCA2FsaXJvb3QtaW52YWxpZF9yZWFkLTIwMTgwNjI5LnBhdGNoAKVWbW/iS
Az+vPkVPk6qQgOBUJqW0q56ut6+6Kq7lVrdl2q1GhKHTBsyKJmwoFX/+3kyeS2UstpIkM
R+5rHHHtvxeRBAvz/nEtjg0+394P7Ln7d8Nvgj4vSmXsTc9tZrmO3TGjz2cQ3O6ZCdn4+
d01PbDsZDxx2OZswBZzh0x2Oj3+/vt2FYlvWGnetr6E96zgSsSW80getrAwz4ncdelPkI
nRY+7JCy3xRdXNzT/y2uMIK2PNDSq7b06R8R49SwDuP4iDIXmyvB/a5h/TAsgFQyyT14j
aGwC1ew27KiSFBmSVxCSfisNu2JOJXghSw5frn2r9gnwk5nuhf1JUHvANgnyuvbqJuay+
inMuHxnP6RLbbifJeLaRct1NFWKDVuVyxbC2vCKtfEMCfAluVaNW2FtfLojbh+iLI0NLs
GbCe2NPnCiAEAgwGkiBAi8zGBgEcIgUjAi1iagi+8bIGxohKxQvNYEnyFCZebq+FUifR2
QSScWM1OpzvNq2A06VEVnKh/ej3A64qJS0yazAtMUzZHTV364LH4jtzKUuVFH6owwfv3l
YO54nuotmT+VgJsFIHZ7VKQSNlepw1T7Or0dtt8Vs3XwNSUlqJ8sbraDnkegNnw/GoIR0
e53vbEYskSNJux+Rs3/+ZB7RJSsYO+KGPc5x6TmIcBRFAEv4xUCWyYcnRSzh2VlInzE0m
B1qGxi7v5pGUfmGRRr7Bve98oZWa3B0+4+S4SvxYUnpWCbhGQGYXpKX9+bibR9iJkBHuZ
jFpenw5cLOVGn40mgzKTq7ZJmiqo6izvDarC/EMmTrhnDoTFtDk7c4PJmTs7Z7Y9Gwfjk
2DmuZPDpk34xqwJ83S6w97oBCy6OeM8oXnRNoGgj83g+DgP+LEKBMgQQbcnW0sHKnQ7ut
dR6yz/eNmRnl9peq1lqvHt9CAqelKkpsYOR+ohVA2upg962DRd2LVAW18mfEXlcqHYyRF
g7R4tBR0CD/kKc8dEJpeZfD0qdQDggKvor2wmVmj0Sw+aAaCeSy3gtc2XO4UDr9326EBU
9jhVPYs9bFvcMyh+zqJONjWX5UZ3mCTzJE2UZSJCPqNu5yvDhGqeU1P3oqboSJdnnq805
fNYDSIQS0zYNl2raD/f36lfyheqaOhp5TgfUSxQJpu7u5vic/EAVFHIQRBMJu7IZVTI/u
mpOwrOAobtQj6ETZf0IUhV3GP33O05I7D0Q17g6msDdq26uLhlG0xc856E/4mIpvYxLIQ
Mu7r+f+UqvhJukEWRoLGjZ/JCJJtfp6bqVV8b5udYfpPA6RttOKXbJR3Ap0jtKM4WM5qf
wC2rGrDq8jFCGoA0mCWuI57KB/417/TPyiniLCmvFOHlLjqKzLsa+KiAj5cx+nNMLYeeC
UKIdy1LZOXhkQxBKV6ILFYRSbPlUhCCVq9Qnffcnwr28LUmoEH1brf7Tfg65T421jR1mz
26tUdlgklD+z/6AfP6Qw0AAA==
EOF
}
aliroot_compatibility()
{
f="STEER/STEERBase/AliMCParticle.h"
/usr/bin/grep -qF GetFirstDaughter "${f}" || /usr/bin/sed -i -e \
"/GetDaughterFirst/{N;\
s/\\(.*\\)\\(DaughterFirst\\)\\(.*\\)\\(DaughterLast\\)\\(.*\\)/\\1\\2\\3\\4\\5\n\\1FirstDaughter\\3LastDaughter\\5/}" \
"${f}"
}
aliroot_update_pythia8()
{
pythia_version="8235"
wget -N "http://home.thep.lu.se/~torbjorn/pythia8/pythia${pythia_version}.tgz"
}
aliroot_add_herwig7()
{
thepeg_version="2.1.4"
wget -N "https://www.hepforge.org/archive/thepeg/ThePEG-${thepeg_version}.tar.bz2"
}
application="$(basename "$0")"
update=""
module_gcc=""
intel=""
user=""
root6=""
prefix="${HOME}/alice"
# [[ -d "${prefix}" ]] && prefix="${HOME}/alice-test"
package="AliRoot,AliPhysics,AliRoot-OCDB"
for o in "$@"; do
case "${o}" in
--update)
update=1
;;
--user)
user=1
;;
--root6)
root6=1
;;
--module-gcc)
module_gcc=1
;;
--intel)
intel=1
;;
--prefix=*)
prefix="$(echo "$o" | sed "s/[^=]*=//")"
;;
--package=*)
package="$(echo "$o" | sed "s/[^=]*=//")"
;;
--*dpg*)
package="${package},AliDPG"
;;
--*generator*)
package="${package},AliGenerators"
;;
esac
done
if [[ -n "${user}" && -n "${root6}" ]]; then
default="--defaults user-next-root6"
elif [[ -n "${user}" ]]; then
default="--defaults user"
elif [[ -n "${root6}" ]]; then
default="--defaults next-root6"
fi
[[ -d "${prefix}" ]] || /usr/bin/mkdir -p "${prefix}"
pushd "${prefix}"
if [[ ! -d "${prefix}/alibuild" ]]; then
/usr/bin/git clone https://github.com/alisw/alibuild
patch_alibuild
fi
alienv_follow_symbolic_link
aliBuild="/usr/bin/nice -19 ${prefix}/alibuild/aliBuild"
alienv="${prefix}/alibuild/alienv"
if [[ -n "${update}" ]]; then
for d in sw/MIRROR/*; do
pushd "$d"
git remote update
popd
done
# Then how with mirror?
# git checkout master
# git reset --hard origin/master
# git pull a-repo-url +refs/heads/*:refs/heads/*
# tag?
:
else
$aliBuild init "${package}" -z ali-master
fi
# As aliBuild also do not properly whitelist actual RHEL (despite
# stating so), globally force unknown architectures
force="--force-unknown-architecture"
[[ -n "${CRAYPE_VERSION}" ]] && patch_cray_pe
[[ -n "${module_gcc}" ]] && load_cray_module_gcc
popd # "${prefix}"
pushd "${prefix}/ali-master"
patch_alidist_general
if [[ -n "${intel}" ]]; then
detect_intel_cpu
patch_alidist_intel "${intel_compiler_x}"
else
patch_alidist_gnu
fi
pushd "AliRoot"
aliroot_compatibility
popd # "AliRoot"
for p in $(echo "${package}" | /usr/bin/tr , " "); do
case "${p}" in
AliRoot) ;;
*) $aliBuild -z -w ../sw -d build "${p}" \
${default} ${force} ;;
esac
done
popd # "${prefix}/ali-master"
# Fix for AliEve
# /home/ylaiali/alice/sw/slc7_x86-64/AliRoot/src/OCDB
# pushd "${prefix}"/sw/*/AliRoot/src/OCDB
# ln -sf ../../../AliRoot-OCDB/latest-ali-master-release/OCDB/* .
# popd
# pushd "${prefix}"/sw/*/AliRoot/ali-master-1/EVE/macros/data
# ln -sf ../../../../../../../ali-master/AliRoot/EVE/oldStuff/macros/VizDB_scan.C .
# popd
if [[ -n "${root6}" ]]; then
pushd "${prefix}/root6"
export CMAKE_C_COMPILER=gcc
export CMAKE_CXX_COMPILER=g++
$aliBuild -z -d -w ../sw build ROOT ${default} ${force}
popd # "${prefix}/root6"
fi # [[ -n "${root6}" ]]; then