-
Notifications
You must be signed in to change notification settings - Fork 167
/
select-compiler.sh
317 lines (294 loc) · 10 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
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
# 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 ;;
*armv7l* ) SELECT_ARCH=ARMV7L ;;
*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
# Linux distros should be arch agnostic
case $NODE_NAME in
*rhel9*|*ubi9*)
echo "Setting compiler for Node.js $NODEJS_MAJOR_VERSION on" `cat /etc/redhat-release`
if [ "$NODEJS_MAJOR_VERSION" -gt "22" ]; then
. /opt/rh/gcc-toolset-12/enable
elif [ "$NODEJS_MAJOR_VERSION" -gt "21" ]; then
# s390x, use later toolset to avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106355
if [ "$SELECT_ARCH" = "S390X" ]; then
. /opt/rh/gcc-toolset-12/enable
fi
fi
export CC="ccache gcc"
export CXX="ccache g++"
echo "Selected compiler:" `${CXX} -dumpversion`
return
;;
*rhel8*|*ubi8*)
case "$CONFIG_FLAGS" in
*--enable-lto*)
echo "Setting compiler for Node.js $NODEJS_MAJOR_VERSION (LTO) on" `cat /etc/redhat-release`
if [ "$NODEJS_MAJOR_VERSION" -gt "22" ]; then
. /opt/rh/gcc-toolset-12/enable
else
. /opt/rh/devtoolset-11/enable
fi
export CC="ccache gcc"
export CXX="ccache g++"
echo "Selected compiler:" `${CXX} -dumpversion`
return
;;
*)
echo "Setting compiler for Node.js $NODEJS_MAJOR_VERSION on" `cat /etc/redhat-release`
if [ "$NODEJS_MAJOR_VERSION" -gt "22" ]; then
. /opt/rh/gcc-toolset-12/enable
export CC="ccache gcc"
export CXX="ccache g++"
echo "Selected compiler:" `${CXX} -dumpversion`
return
fi
if [ "$NODEJS_MAJOR_VERSION" -gt "21" ]; then
# s390x, use later toolset to avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106355
if [ "$SELECT_ARCH" = "S390X" ]; then
. /opt/rh/gcc-toolset-12/enable
export CC="ccache gcc"
export CXX="ccache g++"
echo "Selected compiler:" `${CXX} -dumpversion`
return
fi
fi
if [ "$NODEJS_MAJOR_VERSION" -gt "19" ]; then
. /opt/rh/gcc-toolset-10/enable
export CC="ccache gcc"
export CXX="ccache g++"
echo "Selected compiler:" `${CXX} -dumpversion`
return
fi
# Default gcc on RHEL 8 is gcc 8.
if [ "$v8test" != "" ]; then
# For V8 builds make `gcc` and `g++` point to non-ccache shims.
export PATH=/usr/bin:$PATH
export CC="ccache gcc"
export CXX="ccache g++"
else
export CC="gcc"
export CXX="g++"
fi
echo "Compiler left as system default:" `${CXX} -dumpversion`
return
;;
esac
;;
*ubuntu2204*)
if [ "$NODEJS_MAJOR_VERSION" -gt "22" ]; then
export CC="ccache gcc-12"
export CXX="ccache g++-12"
echo ""
else
# Default gcc on Ubuntu 22.04 is gcc 11.
export CC="ccache gcc"
export CXX="ccache g++"
fi
echo "Compiler set to GCC" `$CXX -dumpversion`
return
;;
esac
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"
# LTO builds need later compilers
case $nodes in
rhel7-lto-s390x)
# Setup devtoolset-10, sets LD_LIBRARY_PATH, PATH, etc.
. /opt/rh/devtoolset-10/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-10"
return;
;;
esac
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
if [ "$NODEJS_MAJOR_VERSION" -gt "22" ]; then
export COMPILER_LEVEL="12"
else
export COMPILER_LEVEL="10"
fi
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
if [ "$NODEJS_MAJOR_VERSION" -gt "22" ]; then
export COMPILER_LEVEL="12"
elif [ "$NODEJS_MAJOR_VERSION" -gt "19" ]; then
export COMPILER_LEVEL="10"
elif [ "$NODEJS_MAJOR_VERSION" -gt "15" ]; then
export COMPILER_LEVEL="8"
elif [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
export COMPILER_LEVEL="6"
fi
export AIX_VERSION=`oslevel`
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on AIX $AIX_VERSION"
export CC="gcc-${COMPILER_LEVEL}"
export CXX="g++-${COMPILER_LEVEL}"
export LINK="g++-${COMPILER_LEVEL}"
if [ "$COMPILER_LEVEL" -ne "10" ]; then
export LIBPATH=/opt/freeware/lib/gcc/powerpc-ibm-aix$AIX_VERSION/$COMPILER_LEVEL/pthread:/opt/freeware/lib:/usr/lib:/lib
else
unset LIBPATH
fi
export PATH="/opt/ccache-3.7.4/libexec:/opt/freeware/bin:$PATH"
echo "Compiler set to GCC" `$CXX -dumpversion`
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"
;;
centos7-64-gcc6 )
. /opt/rh/devtoolset-6/enable
echo "Compiler set to devtoolset-6"
;;
*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"
;;
centos7-arm64-gcc6 )
. /opt/rh/devtoolset-6/enable
echo "Compiler set to devtoolset-6"
;;
*ubuntu1804* )
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`
;;
*ubuntu2004* )
if [ "$NODEJS_MAJOR_VERSION" -gt "19" ]; then
export CC="ccache gcc-10"
export CXX="ccache g++-10"
export LINK="g++-10"
else
export CC="ccache gcc"
export CXX="ccache g++"
export LINK="g++"
fi
echo "Compiler set to GCC" `$CXX -dumpversion`
;;
esac
elif [ "$SELECT_ARCH" = "ARMV7L" ]; then
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on armv7l"
case $nodes in
*ubuntu2004* )
if [ "$NODEJS_MAJOR_VERSION" -gt "19" ]; then
export CC="ccache gcc-10"
export CXX="ccache g++-10"
export LINK="g++-10"
else
export CC="ccache gcc"
export CXX="ccache g++"
export LINK="g++"
fi
echo "Compiler set to GCC" `$CXX -dumpversion`
;;
esac
fi