forked from VcDevel/Vc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test_all_compilers.sh
executable file
·137 lines (125 loc) · 3.46 KB
/
Test_all_compilers.sh
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
#!/bin/sh -e
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
export LANG="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
unset CFLAGS CXXFLAGS
cd "`dirname "$0"`"
test -z "dashboard_model" && export dashboard_model=Experimental
runTest() {
CFLAGS="$1" CXXFLAGS="$1" ctest -S test.cmake
}
tested_compilers="lsakdfjwowleqirjodfisj"
runAllTests() {
# first make sure we don't test a compiler a second time
id="`which $CXX`"
id="`readlink -f $id`"
echo "$id"|grep -qF "$tested_compilers" && return
tested_compilers="$tested_compilers
$id"
# alright run the ctest script
runTest
supports32Bit && runTest -m32
supportsx32 && runTest -mx32
}
supports32Bit() {
test `uname -m` = "x86_64" || return 1
CXX=${CXX:-c++}
cat > /tmp/m32test.cpp <<END
#include <algorithm>
#include <string>
#include <iostream>
#include <cerrno>
void foo(int x) { switch (x) { case 0x0A: break; case 0x0B: break; case 0x0C: break; case 0x0D: break; case 0x0E: break; } }
int main() { std::cout << "Hello World!\n"; return 0; }
END
$CXX -m32 -o /tmp/m32test /tmp/m32test.cpp >/dev/null 2>&1 || return 1
rm /tmp/m32test*
return 0
}
supportsx32() {
test `uname -m` = "x86_64" || return 1
CXX=${CXX:-c++}
cat > /tmp/mx32test.cpp <<END
#include <algorithm>
#include <string>
#include <iostream>
#include <cerrno>
void foo(int x) { switch (x) { case 0x0A: break; case 0x0B: break; case 0x0C: break; case 0x0D: break; case 0x0E: break; } }
int main() { std::cout << "Hello World!\n"; return 0; }
END
$CXX -mx32 -o /tmp/mx32test /tmp/mx32test.cpp >/dev/null 2>&1 || return 1
rm /tmp/mx32test*
return 0
}
system_compilers() {
cxxlist="`find /usr/bin/ /usr/local/bin/ -name '*++-[0-9]*'|grep -v -- -linux-gnu`"
if test -z "$cxxlist"; then
cxxlist="`find /usr/bin/ /usr/local/bin/ -name '*++'|grep -v -- -linux-gnu`"
fi
if test -z "$cxxlist"; then
# default compiler
runAllTests
else
for CXX in $cxxlist; do
CC=`echo "$CXX"|sed 's/clang++/clang/;s/g++/gcc/'`
if test -x "$CC" -a -x "$CXX"; then
export CC
export CXX
runAllTests
fi
done
fi
}
modules_compilers() {
if test -r /etc/profile.d/modules.sh; then
source /etc/profile.d/modules.sh
for mod in `module avail -t 2>&1`; do
case `echo $mod|tr '[:upper:]' '[:lower:]'` in
*intel*|*icc*) export CC=icc CXX=icpc;;
*gnu*|*gcc*) export CC=gcc CXX=g++;;
*llvm*|*clang*) export CC=clang CXX=clang++;;
*) continue;;
esac
module load $mod
runAllTests
module unload $mod
done
fi
}
gccbuild_compilers() {
for VcEnv in `find /opt/ -mindepth 2 -maxdepth 2 -name Vc.env`; do (
. "$VcEnv"
case "$VcEnv" in
*-snapshot/Vc.env)
( cd $HOME/src/gcc-build && ./update.sh "`dirname "$VcEnv"`" )
;;
esac
runAllTests
) done
}
icc_compilers() {
export CC=icc
export CXX=icpc
icclist="`find /opt/intel/compiler* -name 'iccvars.sh' | xargs readlink -e | sort -ur`"
case `uname -m` in
x86_64)
COMPILERVARS_ARCHITECTURE=intel64
;;
i[345678]86)
COMPILERVARS_ARCHITECTURE=ia32
;;
esac
export COMPILERVARS_ARCHITECTURE
test -n "$icclist" && for IccEnv in $icclist; do (
. $IccEnv $COMPILERVARS_ARCHITECTURE
runAllTests
) done
}
system_compilers
modules_compilers
gccbuild_compilers
icc_compilers