-
Notifications
You must be signed in to change notification settings - Fork 163
/
select-compiler.sh
201 lines (182 loc) · 6.54 KB
/
select-compiler.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
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
# Usage:
# .../node % . ./build/jenkins/scripts/select-compiler.sh
#
# This file is sourced from the CWD of node by CI build scripts to select the
# compiler to be used based on the version of node in the CWD.
#
# It must be /bin/sh syntax (no bashims).
# Notes and warnings:
# - ccache and CC: v8 builds (at least) depend on the ability to be able to do
# `ln -s $CC some/place` (but only on some plaforms), so the
# `export CC="ccache /a/gcc-version/cc"` idiom breaks those builds. The best
# way to do ccache is to push `/path/to/gcc-version` on to the front of PATH,
# then push a `/path/to/ccache/wrappers` in front of the compiler path.
if [ "$DONTSELECT_COMPILER" != "DONT" ]; then
NODE_NAME=${NODE_NAME:-$HOSTNAME}
echo "Selecting compiler based on $NODE_NAME"
case $NODE_NAME in
*ppc64*le* ) SELECT_ARCH=PPC64LE ;;
*s390x* ) SELECT_ARCH=S390X ;;
*aix* ) SELECT_ARCH=AIXPPC ;;
*x64* ) SELECT_ARCH=X64 ;;
*arm64* ) SELECT_ARCH=ARM64 ;;
*ibmi73* ) SELECT_ARCH=IBMI73 ;;
esac
fi
# get node version
if [ -z ${NODEJS_MAJOR_VERSION+x} ]; then
NODE_VERSION="$(python tools/getnodeversion.py)"
NODEJS_MAJOR_VERSION="$(echo "$NODE_VERSION" | cut -d . -f 1)"
fi
if [ "$SELECT_ARCH" = "PPC64LE" ]; then
# Set default
export COMPILER_LEVEL="4.8"
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on ppc64le"
case $NODE_NAME in
*centos7* )
if [ "$NODEJS_MAJOR_VERSION" -gt "13" ]; then
# Setup devtoolset-8, sets LD_LIBRARY_PATH, PATH, etc.
. /opt/rh/devtoolset-8/enable
export CC="ccache ppc64le-redhat-linux-gcc"
export CXX="ccache ppc64le-redhat-linux-g++"
export LINK="ppc64le-redhat-linux-g++"
echo "Compiler set to devtoolset-8"
return
elif [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
# Setup devtoolset-6, sets LD_LIBRARY_PATH, PATH, etc.
. /opt/rh/devtoolset-6/enable
export CC="ccache ppc64le-redhat-linux-gcc"
export CXX="ccache ppc64le-redhat-linux-g++"
export LINK="ppc64le-redhat-linux-g++"
echo "Compiler set to devtoolset-6"
return
fi
;;
esac
elif [ "$SELECT_ARCH" = "S390X" ]; then
# Set default
# Default is 4.8 but it does not have the prefixes
export COMPILER_LEVEL=""
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on s390x"
if [ "$NODEJS_MAJOR_VERSION" -gt "13" ]; then
# Setup devtoolset-8, sets LD_LIBRARY_PATH, PATH, etc.
. /opt/rh/devtoolset-8/enable
export CC="ccache s390x-redhat-linux-gcc"
export CXX="ccache s390x-redhat-linux-g++"
export LINK="s390x-redhat-linux-g++"
echo "Compiler set to devtoolset-8"
elif [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
# Setup devtoolset-6, sets LD_LIBRARY_PATH, PATH, etc.
. /opt/rh/devtoolset-6/enable
export CC="ccache s390x-redhat-linux-gcc"
export CXX="ccache s390x-redhat-linux-g++"
export LINK="s390x-redhat-linux-g++"
echo "Compiler set to devtoolset-6"
else
# Select the appropriate compiler
export CC="ccache gcc${COMPILER_LEVEL}"
export CXX="ccache g++${COMPILER_LEVEL}"
export LINK="g++${COMPILER_LEVEL}"
echo "Compiler set to $COMPILER_LEVEL"
fi
elif [ "$SELECT_ARCH" = "IBMI73" ]; then
export COMPILER_LEVEL="10"
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on IBMI73"
export CC="ccache gcc-${COMPILER_LEVEL}"
export CXX="ccache g++-${COMPILER_LEVEL}"
export LINK="g++-${COMPILER_LEVEL}"
echo "Compiler set to $COMPILER_LEVEL"
elif [ "$SELECT_ARCH" = "AIXPPC" ]; then
case $NODE_NAME in
*aix72* )
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on AIX7.2"
if [ "$NODEJS_MAJOR_VERSION" -gt "15" ]; then
export PATH="/opt/ccache-3.7.4/libexec:/opt/freeware/bin:$PATH"
export CC="gcc" CXX="g++" CXX_host="g++"
unset LIBPATH
echo "Compiler set to 8.3"
return
elif [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
export PATH="/opt/ccache-3.7.4/libexec:/opt/gcc-6.3/bin:/opt/freeware/bin:$PATH"
export CC="gcc" CXX="g++" CXX_host="g++"
export LIBPATH=/opt/gcc-6.3/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0/pthread/ppc64:/opt/gcc-6.3/lib
echo "Compiler set to 6.3"
return
else
echo "Compiler left as system default:" `g++ -dumpversion`
return
fi
;;
*aix71* )
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on AIX7.1"
if [ "$NODEJS_MAJOR_VERSION" -gt "15" ]; then
export PATH="/opt/ccache-3.7.4/libexec:/opt/freeware/bin:$PATH"
export CC="gcc" CXX="g++" CXX_host="g++"
unset LIBPATH
echo "Compiler set to 8.3"
return
elif [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
export PATH="/opt/ccache-3.7.4/libexec:/opt/freeware/gcc6/bin:/opt/freeware/bin:$PATH"
export CC="gcc-6" CXX="g++-6" CXX_host="g++-6"
unset LIBPATH
echo "Compiler set to 6.3"
return
else
echo "Compiler left as system default:" `g++ -dumpversion`
return
fi
;;
esac
elif [ "$SELECT_ARCH" = "X64" ]; then
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on x64"
case $nodes in
centos7-64-gcc8 )
. /opt/rh/devtoolset-8/enable
echo "Compiler set to devtoolset-8"
;;
centos6-64-gcc48 )
. /opt/rh/devtoolset-2/enable
echo "Compiler set to devtoolset-2"
;;
centos[67]-64-gcc6 )
. /opt/rh/devtoolset-6/enable
echo "Compiler set to devtoolset-6"
;;
centos7-release-sources )
if [ "$NODEJS_MAJOR_VERSION" -gt "15" ]; then
. /opt/rh/devtoolset-8/enable
else
. /opt/rh/devtoolset-6/enable
fi
export CC="ccache gcc"
export CXX="ccache g++"
echo "Compiler set to GCC" `$CXX -dumpversion`
;;
*ubuntu1804*64|*ubuntu1604-*64|benchmark )
if [ "$NODEJS_MAJOR_VERSION" -gt "15" ]; then
export CC="ccache gcc-8"
export CXX="ccache g++-8"
export GCOV="gcov-8"
export LINK="g++-8"
else
export CC="ccache gcc-6"
export CXX="ccache g++-6"
export GCOV="gcov-6"
export LINK="g++-6"
fi
echo "Compiler set to GCC" `$CXX -dumpversion`
;;
esac
elif [ "$SELECT_ARCH" = "ARM64" ]; then
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on arm64"
case $nodes in
centos7-arm64-gcc8 )
. /opt/rh/devtoolset-8/enable
echo "Compiler set to devtoolset-8"
;;
centos[67]-arm64-gcc6 )
. /opt/rh/devtoolset-6/enable
echo "Compiler set to devtoolset-6"
;;
esac
fi