-
Notifications
You must be signed in to change notification settings - Fork 168
/
Copy pathselect-compiler.sh
157 lines (134 loc) · 5.05 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
# 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 ;;
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 "9" ]; then
# Setup devtoolset-6, sets LD_LIBRARY_PATH, PATH, etc.
. /opt/rh/devtoolset-6/enable
echo "Compiler set to devtoolset-6"
return
fi
;;
esac
if [ "$NODEJS_MAJOR_VERSION" -gt "11" ]; then
# See: https://github.com/nodejs/build/pull/1723#discussion_r265740122
export PATH=/usr/lib/binutils-2.26/bin/:$PATH
export COMPILER_LEVEL="6"
elif [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
export PATH=/usr/lib/binutils-2.26/bin/:$PATH
export COMPILER_LEVEL="4.9"
fi
# Select the appropriate compiler
export CC="gcc-${COMPILER_LEVEL}"
export CXX="g++-${COMPILER_LEVEL}"
export LINK="g++-${COMPILER_LEVEL}"
echo "Compiler set to $COMPILER_LEVEL"
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 "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" = "AIXPPC" ]; then
case $NODE_NAME in
*aix72* )
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on AIX72"
if [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
export LIBPATH=/opt/gcc-6.3/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0/pthread/ppc64:/opt/gcc-6.3/lib
export PATH="/opt/ccache-3.7.4/libexec:/opt/gcc-6.3/bin:$PATH"
export CC="gcc" CXX="g++" CXX_host="g++"
echo "Compiler set to 6.3"
return
else
echo "Compiler left as system default:" `g++ -dumpversion`
return
fi
;;
esac
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on AIX61"
if [ "$NODEJS_MAJOR_VERSION" -gt "9" ]; then
export LIBPATH=/home/iojs/gmake/opt/freeware/lib:/home/iojs/gcc-6.3.0-1/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/6.3.0/pthread/ppc64:/home/iojs/gcc-6.3.0-1/opt/freeware/lib
export PATH="/home/iojs/gcc-6.3.0-1/opt/freeware/bin:$PATH"
export CC="ccache `which gcc`" CXX="ccache `which g++`" CXX_host="ccache `which g++`"
# TODO(sam-github): configure ccache by pushing /opt/freeware/bin/ccache on
# front of PATH
echo "Compiler set to 6.3"
else
export CC="ccache `which gcc`" CXX="ccache `which g++`" CXX_host="ccache `which g++`"
# TODO(sam-github): configure ccache by pushing /opt/freeware/bin/ccache on
# front of PATH
echo "Compiler set to default at 4.8.5"
fi
elif [ "$SELECT_ARCH" = "X64" ]; then
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on x64"
case $nodes in
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"
;;
ubuntu1604-*64 )
if [ "$NODEJS_MAJOR_VERSION" -gt "12" ]; then
export CC="gcc-6"
export CXX="g++-6"
export LINK="g++-6"
echo "Compiler set to GCC 6 for $NODEJS_MAJOR_VERSION"
fi
;;
esac
elif [ "$SELECT_ARCH" = "ARM64" ]; then
echo "Setting compiler for Node version $NODEJS_MAJOR_VERSION on arm64"
case $nodes in
centos[67]-arm64-gcc6 )
. /opt/rh/devtoolset-6/enable
echo "Compiler set to devtoolset-6"
;;
esac
fi