Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
disable LTO on the arm builder, as it is believed to be too heavy for this particular...
[simgrid.git] / tools / jenkins / build.sh
1 #!/usr/bin/env sh
2
3 # This script is used by various build projects on Jenkins
4
5 # See https://ci.inria.fr/simgrid/job/SimGrid/configure
6 # See https://ci.inria.fr/simgrid/job/Simgrid-Windows/configure
7
8 # ensure that the locales are set, so that perl keeps its nerves
9 export LC_ALL=C
10
11 echo "XXXX Cleanup previous attempts. Remaining content of /tmp:"
12 rm -f /tmp/cc*
13 rm -f /tmp/*.so
14 rm -f /tmp/*.so.*
15 rm -rf /tmp/simgrid-java*
16 rm -rf /var/tmp/simgrid-java*
17 rm -rf /tmp/jvm-*
18 find $WORKSPACE -name "hs_err_pid*.log" -exec rm -f {} +
19 ls /tmp
20 df -h
21 echo "XXXX Let's go"
22
23 set -e
24
25 # Help older cmakes
26 if [ -e /usr/lib/jvm/java-7-openjdk-amd64 ] ;
27 then
28   export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
29 fi
30
31 # usage: die status message...
32 die () {
33   status=${1:-1}
34   shift
35   [ $# -gt 0 ] || set -- "Error - Halting"
36   echo "$@" >&2
37   exit "$status"
38 }
39
40 # Get an ON/OFF string from a command:
41 onoff() {
42   if "$@" > /dev/null ; then
43     echo ON
44   else
45     echo OFF
46   fi
47 }
48
49 if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
50     # linuxbase.org
51     os=$(lsb_release -si)
52     ver="$(lsb_release -sr) ($(lsb_release -sc))"
53 elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
54     . /etc/lsb-release
55     os=$DISTRIB_ID
56     ver=$DISTRIB_RELEASE
57 elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
58     os=Debian
59     ver=$(cat /etc/debian_version)
60 elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
61     read -r os ver < /etc/redhat-release
62 elif [ -f /usr/bin/sw_vers ]; then #osx
63     os=$(sw_vers -productName)
64     ver=$(sw_vers -productVersion)
65 elif [ -f /bin/freebsd-version ]; then #freebsd
66     os=$(uname -s)
67     ver=$(freebsd-version -u)
68 elif [ -f /etc/release ]; then #openindiana
69     read -r os ver < /etc/release
70 elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
71     . /etc/os-release
72     os=$NAME
73     ver=$VERSION_ID
74 else
75     # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
76     echo "fallback as OS name not found"
77     os=$(uname -s)
78     ver=$(uname -r)
79 fi
80
81 # Are we running on wsl ?
82 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
83     #To identify the windows underneath the linux
84     PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
85     major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
86     build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
87     ver="$major v$build - WSL $os $ver"
88     os=Windows
89 fi
90
91 case $(uname -m) in
92 x86_64)
93     bits="64 bits"
94     ;;
95 i*86)
96     bits="32 bits"
97     ;;
98 *)
99     bits=""
100     ;;
101 esac
102 echo "OS Version : $os $ver $bits"
103
104
105 build_mode="$1"
106 echo "Build mode $build_mode on $(uname -np)" >&2
107 case "$build_mode" in
108   "Debug")
109       INSTALL="$HOME/simgrid_install"
110   ;;
111
112   "ModelChecker")
113       INSTALL="$HOME/mc_simgrid_install"
114   ;;
115
116   "DynamicAnalysis")
117       INSTALL=""
118   ;;
119
120   *)
121     die 1 "Unknown build_mode $build_mode"
122   ;;
123 esac
124
125 if [ "$2" = "" ]; then
126   branch_name="unknown"
127 else
128   branch_name="$2"
129 fi
130 echo "Branch built is $branch_name"
131
132 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
133 GENERATOR="Unix Makefiles"
134
135 ulimit -c 0 || true
136
137 echo "XX"
138 echo "XX Get out of the tree"
139 echo "XX"
140 if [ -d "$WORKSPACE"/build ]
141 then
142   # Windows cannot remove the directory if it's still used by the previous build
143   rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build
144 fi
145 mkdir "$WORKSPACE"/build
146 cd "$WORKSPACE"/build
147
148 have_NS3="no"
149 if [ "$os" = "Debian" ] ; then
150   if dpkg --compare-versions "$(dpkg-query -f '${Version}' -W libns3-dev)" ge 3.28; then
151     have_NS3="yes"
152   fi
153 fi
154 if [ "$os" = "Ubuntu" ] ; then
155   if dpkg --compare-versions "$(dpkg-query -f '${Version}' -W libns3-dev)" ge 3.36; then
156     have_NS3="yes"
157   fi
158 fi
159 if [ "$os" = "nixos" ] ; then
160   have_NS3="yes"
161 fi
162 echo "XX have_NS3: ${have_NS3}"
163
164 SIMGRID_PYTHON_LIBDIR=""
165 if [ "$os" = "nixos" ] ; then
166   SIMGRID_PYTHON_LIBDIR="/home/ci/simgrid_install/lib64"
167 fi
168 echo "XX SIMGRID_PYTHON_LIBDIR: ${SIMGRID_PYTHON_LIBDIR}"
169
170 # This is for Windows:
171 PATH="$WORKSPACE/build/lib:$PATH"
172
173 echo "XX"
174 echo "XX Build the archive out of the tree"
175 echo "XX   pwd: $(pwd)"
176 echo "XX"
177
178 cmake -G"$GENERATOR" -Denable_documentation=OFF "$WORKSPACE"
179 make dist -j $NUMBER_OF_PROCESSORS
180 SIMGRID_VERSION=$(cat VERSION)
181
182 echo "XX"
183 echo "XX Open the resulting archive"
184 echo "XX"
185 gunzip "${SIMGRID_VERSION}".tar.gz
186 tar xf "${SIMGRID_VERSION}".tar
187 mkdir "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
188 cd "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
189 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
190
191 echo "XX"
192 echo "XX Configure and build SimGrid"
193 echo "XX   pwd: $(pwd)"
194 echo "XX"
195 set -x
196
197 if cmake --version | grep -q 3\.11 ; then
198   # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
199   # https://gitlab.kitware.com/cmake/cmake/issues/17933
200   MAY_DISABLE_SOURCE_CHANGE=""
201 else
202   MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
203 fi
204
205 if [ "$os" = "CentOS" ]; then
206     if [ "$(ld -v | cut -d\  -f4 | cut -c1-4)" = "2.30" ]; then
207         echo "Temporary disable LTO, believed to be broken on this system."
208         MAY_DISABLE_LTO=-Denable_lto=OFF
209     else
210         MAY_DISABLE_LTO=
211     fi
212 fi
213
214 if [ $NODE_NAME = "armv8" ]; then
215     echo "disable LTO, believed to be too heavy for this particular system"
216     MAY_DISABLE_LTO=-Denable_lto=OFF
217 fi
218
219 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
220   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
221   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
222   -Denable_smpi_MBI_testsuite=OFF \
223   -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
224   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
225   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
226   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
227   -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
228   -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
229   -DSIMGRID_PYTHON_LIBDIR=${SIMGRID_PYTHON_LIBDIR} \
230   ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} \
231   -Denable_java=$(onoff test "$build_mode" = "ModelChecker") \
232   -Denable_msg=$(onoff test "$build_mode" = "ModelChecker") \
233   -DLTO_EXTRA_FLAG="auto" \
234   "$SRCFOLDER"
235 set +x
236
237 make -j $NUMBER_OF_PROCESSORS VERBOSE=1 tests
238
239 echo "XX"
240 echo "XX Run the tests"
241 echo "XX   pwd: "$(pwd)
242 echo "XX"
243
244 ctest -T test --output-on-failure --no-compress-output -j $NUMBER_OF_PROCESSORS || true
245
246 if test -n "$INSTALL" && [ "${branch_name}" = "origin/master" ] ; then
247   echo "XX"
248   echo "XX Test done. Install everything since it's a regular build, not on a Windows."
249   echo "XX"
250
251   rm -rf "$INSTALL"
252
253   make install
254 fi
255
256 echo "XX"
257 echo "XX Done. Return the results to cmake"
258 echo "XX"