Logo AND Algorithmique Numérique Distribuée

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