1
1
#! /bin/bash
2
2
3
- set -e
4
- set -u
3
+ set -eu
5
4
6
5
declare -r current_source_directory=" ${PWD} "
7
6
8
- declare -r toolchain_directory=' /tmp/unknown-unknown-musl'
9
- declare -r toolchain_tarball=" $( pwd) /musl-cross.tar.xz"
7
+ declare -r revision=" $( git rev-parse --short HEAD) "
8
+
9
+ declare -r toolchain_directory=' /tmp/raiden'
10
10
11
11
declare -r gmp_tarball=' /tmp/gmp.tar.xz'
12
12
declare -r gmp_directory=' /tmp/gmp-6.2.1'
@@ -23,6 +23,11 @@ declare -r binutils_directory='/tmp/binutils-2.40'
23
23
declare -r gcc_tarball=' /tmp/gcc.tar.xz'
24
24
declare -r gcc_directory=' /tmp/gcc-12.2.0'
25
25
26
+ declare -r optflags=' -Os'
27
+ declare -r linkflags=' -Wl,-s'
28
+
29
+ source " ./submodules/obggcc/toolchains/${1} .sh"
30
+
26
31
if ! [ -f " ${gmp_tarball} " ]; then
27
32
wget --no-verbose ' https://mirrors.kernel.org/gnu/gmp/gmp-6.2.1.tar.xz' --output-document=" ${gmp_tarball} "
28
33
tar --directory=" $( dirname " ${gmp_directory} " ) " --extract --file=" ${gmp_tarball} "
@@ -48,54 +53,64 @@ if ! [ -f "${gcc_tarball}" ]; then
48
53
tar --directory=" $( dirname " ${gcc_directory} " ) " --extract --file=" ${gcc_tarball} "
49
54
fi
50
55
51
- while read file; do
52
- sed -i ' s/-O2/-Os -s -DNDEBUG/g' " ${file} "
53
- done <<< " $(find '/tmp' -type 'f' -wholename '*configure')"
56
+ sed --in-place ' s/LDBL_MANT_DIG == 106/defined(__powerpc64__)/g' " ${gcc_directory} /libgcc/dfp-bit.h"
54
57
55
58
[ -d " ${gmp_directory} /build" ] || mkdir " ${gmp_directory} /build"
56
59
57
60
cd " ${gmp_directory} /build"
58
61
59
62
../configure \
63
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
60
64
--prefix=" ${toolchain_directory} " \
61
65
--enable-shared \
62
- --enable-static
66
+ --enable-static \
67
+ CFLAGS=" ${optflags} " \
68
+ CXXFLAGS=" ${optflags} " \
69
+ LDFLAGS=" ${linkflags} "
63
70
64
- make all --jobs= " $( nproc ) "
71
+ make all --jobs
65
72
make install
66
73
67
74
[ -d " ${mpfr_directory} /build" ] || mkdir " ${mpfr_directory} /build"
68
75
69
76
cd " ${mpfr_directory} /build"
70
77
71
78
../configure \
79
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
72
80
--prefix=" ${toolchain_directory} " \
73
81
--with-gmp=" ${toolchain_directory} " \
74
82
--enable-shared \
75
- --enable-static
83
+ --enable-static \
84
+ CFLAGS=" ${optflags} " \
85
+ CXXFLAGS=" ${optflags} " \
86
+ LDFLAGS=" ${linkflags} "
76
87
77
- make all --jobs= " $( nproc ) "
88
+ make all --jobs
78
89
make install
79
90
80
91
[ -d " ${mpc_directory} /build" ] || mkdir " ${mpc_directory} /build"
81
92
82
93
cd " ${mpc_directory} /build"
83
94
84
95
../configure \
96
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
85
97
--prefix=" ${toolchain_directory} " \
86
98
--with-gmp=" ${toolchain_directory} " \
87
99
--enable-shared \
88
- --enable-static
100
+ --enable-static \
101
+ CFLAGS=" ${optflags} " \
102
+ CXXFLAGS=" ${optflags} " \
103
+ LDFLAGS=" ${linkflags} "
89
104
90
- make all --jobs= " $( nproc ) "
105
+ make all --jobs
91
106
make install
92
107
93
108
declare -ra targets=(
109
+ ' powerpc64le-unknown-linux-musl'
94
110
' x86_64-unknown-linux-musl'
95
111
' aarch64-unknown-linux-musl'
96
112
' armv7l-unknown-linux-musleabihf'
97
113
' arm-unknown-linux-musleabihf'
98
- ' powerpc64le-unknown-linux-musl'
99
114
' riscv64-unknown-linux-musl'
100
115
' s390x-unknown-linux-musl'
101
116
' i386-unknown-linux-musl'
@@ -166,12 +181,19 @@ for target in "${targets[@]}"; do
166
181
rm --force --recursive ./*
167
182
168
183
../configure \
184
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
169
185
--target=" ${triple} " \
170
186
--prefix=" ${toolchain_directory} " \
171
187
--enable-gold \
172
- --enable-ld
188
+ --enable-ld \
189
+ --enable-lto \
190
+ --disable-gprofng \
191
+ --with-static-standard-libraries \
192
+ CFLAGS=" ${optflags} " \
193
+ CXXFLAGS=" ${optflags} " \
194
+ LDFLAGS=" ${linkflags} "
173
195
174
- make all --jobs=" $( nproc) "
196
+ make all --jobs=" $(( $( nproc) * 8 ) )"
175
197
make install
176
198
177
199
[ -d " ${gcc_directory} /build" ] || mkdir " ${gcc_directory} /build"
@@ -181,14 +203,14 @@ for target in "${targets[@]}"; do
181
203
rm --force --recursive ./*
182
204
183
205
../configure \
206
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
184
207
--target=" ${triple} " \
185
208
--prefix=" ${toolchain_directory} " \
186
209
--with-linker-hash-style=' gnu' \
187
210
--with-gmp=" ${toolchain_directory} " \
188
211
--with-mpc=" ${toolchain_directory} " \
189
212
--with-mpfr=" ${toolchain_directory} " \
190
- --with-system-zlib \
191
- --with-bugurl=' https://github.com/AmanoTeam/muslcr00s/issues' \
213
+ --with-bugurl=' https://github.com/AmanoTeam/Raiden/issues' \
192
214
--enable-__cxa_atexit \
193
215
--enable-cet=' auto' \
194
216
--enable-checking=' release' \
@@ -218,14 +240,34 @@ for target in "${targets[@]}"; do
218
240
--enable-ld \
219
241
--enable-gold \
220
242
--with-pic \
243
+ --with-pkgversion=" Raiden v0.2-${revision} " \
221
244
--with-sysroot=" ${toolchain_directory} /${triple} " \
222
245
--with-gcc-major-version-only \
223
246
--with-native-system-header-dir=' /include' \
247
+ --disable-nls \
248
+ ${extra_configure_flags} \
224
249
libat_cv_have_ifunc=no \
225
- ${extra_configure_flags}
250
+ CFLAGS=" ${optflags} " \
251
+ CXXFLAGS=" ${optflags} " \
252
+ LDFLAGS=" -Wl,-rpath-link,${OBGGCC_TOOLCHAIN} /${CROSS_COMPILE_TRIPLET} /lib ${linkflags} "
226
253
227
- LD_LIBRARY_PATH=" ${toolchain_directory} /lib" PATH=" ${PATH} :${toolchain_directory} /bin" make all --jobs=" $( nproc) "
254
+ LD_LIBRARY_PATH=" ${toolchain_directory} /lib" PATH=" ${PATH} :${toolchain_directory} /bin" make \
255
+ CFLAGS_FOR_TARGET=" ${optflags} ${linkflags} " \
256
+ CXXFLAGS_FOR_TARGET=" ${optflags} ${linkflags} " \
257
+ all --jobs=" $(( $(nproc) * 8 )) "
228
258
make install
259
+
260
+ cd " ${toolchain_directory} /${triple} /bin"
261
+
262
+ for name in * ; do
263
+ rm " ${name} "
264
+ ln -s " ../../bin/${triple} -${name} " " ${name} "
265
+ done
266
+
267
+ rm --recursive " ${toolchain_directory} /share"
268
+ rm --recursive " ${toolchain_directory} /lib/gcc/${triple} /12/include-fixed"
269
+
270
+ patchelf --add-rpath ' $ORIGIN/../../../../lib' " ${toolchain_directory} /libexec/gcc/${triple} /12/cc1"
271
+ patchelf --add-rpath ' $ORIGIN/../../../../lib' " ${toolchain_directory} /libexec/gcc/${triple} /12/cc1plus"
272
+ patchelf --add-rpath ' $ORIGIN/../../../../lib' " ${toolchain_directory} /libexec/gcc/${triple} /12/lto1"
229
273
done
230
-
231
- tar --directory=" $( dirname " ${toolchain_directory} " ) " --create --file=- " $( basename " ${toolchain_directory} " ) " | xz --threads=0 --compress -9 > " ${toolchain_tarball} "
0 commit comments