-
Notifications
You must be signed in to change notification settings - Fork 382
/
solaris.sh
executable file
·147 lines (123 loc) · 3.8 KB
/
solaris.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
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local arch="${1}"
local manufacturer="${2}"
local binutils=2.28.1 \
gcc=8.4.0 \
target="${arch}-${manufacturer}-solaris2.10"
install_packages bzip2 \
ca-certificates \
curl \
dirmngr \
g++ \
gpg-agent \
make \
patch \
software-properties-common \
wget \
xz-utils
local td
td="$(mktemp -d)"
pushd "${td}"
mkdir "${td}"/{binutils,gcc}{,-build} "${td}/solaris"
download_binutils "${binutils}" "xz"
tar -C "${td}/binutils" --strip-components=1 -xJf "binutils-${binutils}.tar.xz"
download_gcc "${gcc}" "xz"
tar -C "${td}/gcc" --strip-components=1 -xJf "gcc-${gcc}.tar.xz"
cd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
cd ..
local apt_arch=
local lib_arch=
case "${arch}" in
x86_64)
apt_arch=solaris-i386
lib_arch=amd64
;;
sparcv9)
apt_arch=solaris-sparc
lib_arch=sparcv9
;;
esac
apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2 main'
dpkg --add-architecture "${apt_arch}"
apt-get update
apt-get install -y --download-only \
"libc:${apt_arch}" \
"liblgrp:${apt_arch}" \
"libm-dev:${apt_arch}" \
"libpthread:${apt_arch}" \
"libresolv:${apt_arch}" \
"librt:${apt_arch}" \
"libsendfile:${apt_arch}" \
"libsocket:${apt_arch}" \
"system-crt:${apt_arch}" \
"system-header:${apt_arch}"
for deb in /var/cache/apt/archives/*"${apt_arch}.deb"; do
dpkg -x "${deb}" "${td}/solaris"
done
apt-get clean
# The -dev packages are not available from the apt repository we're using.
# However, those packages are just symlinks from *.so to *.so.<version>.
# This makes all those symlinks.
while IFS= read -r -d '' lib; do
link_name=${lib%.so.*}.so
[ -e "$link_name" ] || ln -sf "${lib##*/}" "$link_name"
done < <(find . -name '*.so.*' -print0)
cd binutils-build
../binutils/configure \
--target="${target}"
make "-j$(nproc)"
make install
cd ..
# Remove Solaris 11 functions that are optionally used by libbacktrace.
# This is for Solaris 10 compatibility.
rm solaris/usr/include/link.h
patch -p0 << 'EOF'
--- solaris/usr/include/string.h
+++ solaris/usr/include/string10.h
@@ -93 +92,0 @@
-extern size_t strnlen(const char *, size_t);
EOF
local destdir="/usr/local/${target}"
mkdir "${destdir}/usr"
cp -r "${td}/solaris/usr/include" "${destdir}/usr"
mv "${td}/solaris/usr/lib/${lib_arch}"/* "${destdir}/lib"
mv "${td}/solaris/lib/${lib_arch}"/* "${destdir}/lib"
ln -s usr/include "${destdir}/sys-include"
ln -s usr/include "${destdir}/include"
# note: solaris2.10 is obsolete, so we can't upgrade to GCC 10 till then.
# for gcc 9.4.0, need `--enable-obsolete`
cd gcc-build
../gcc/configure \
--disable-libada \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-nls \
--enable-languages=c,c++,fortran \
--with-gnu-as \
--with-gnu-ld \
--target="${target}"
make "-j$(nproc)"
make install
cd ..
# clean up
popd
purge_packages
rm -rf "${td}"
rm "${0}"
}
main "${@}"