@@ -26,10 +26,25 @@ declare -r gcc_directory='/tmp/gcc-master'
26
26
27
27
declare -r sysroot_tarball=' /tmp/sysroot.tar.xz'
28
28
29
- declare -r optflags=' -w -Os'
29
+ declare -r max_jobs=' 40'
30
+
31
+ declare -r optlto=" -flto=${max_jobs} -fno-fat-lto-objects"
32
+ declare -r optfatlto=" -flto=${max_jobs} -ffat-lto-objects"
33
+
34
+ declare -r optflags=' -w -O2'
30
35
declare -r linkflags=' -Wl,-s'
31
36
32
- declare -r max_jobs=" $(( $(nproc) * 10 )) "
37
+ declare -ra targets=(
38
+ ' powerpc64le-unknown-linux-musl'
39
+ ' s390x-unknown-linux-musl'
40
+ ' arm-unknown-linux-musleabihf'
41
+ ' armv7l-unknown-linux-musleabihf'
42
+ ' mips64-unknown-linux-musl'
43
+ ' x86_64-unknown-linux-musl'
44
+ ' aarch64-unknown-linux-musl'
45
+ ' riscv64-unknown-linux-musl'
46
+ ' i386-unknown-linux-musl'
47
+ )
33
48
34
49
declare build_type=" ${1} "
35
50
@@ -43,64 +58,124 @@ if [ "${build_type}" == 'native' ]; then
43
58
is_native=' 1'
44
59
fi
45
60
46
- declare OBGGCC_TOOLCHAIN=' /tmp/obggcc-toolchain'
47
61
declare CROSS_COMPILE_TRIPLET=' '
48
62
49
- declare cross_compile_flags=' '
50
-
51
63
if ! (( is_native )) ; then
52
64
source " ./submodules/obggcc/toolchains/${build_type} .sh"
53
- cross_compile_flags+=" --host=${CROSS_COMPILE_TRIPLET} "
54
65
fi
55
66
67
+ declare -r \
68
+ build_type \
69
+ is_native
70
+
56
71
if ! [ -f " ${gmp_tarball} " ]; then
57
- wget --no-verbose ' https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz' --output-document=" ${gmp_tarball} "
58
- tar --directory=" $( dirname " ${gmp_directory} " ) " --extract --file=" ${gmp_tarball} "
72
+ curl \
73
+ --url ' https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz' \
74
+ --retry ' 30' \
75
+ --retry-all-errors \
76
+ --retry-delay ' 0' \
77
+ --retry-max-time ' 0' \
78
+ --location \
79
+ --silent \
80
+ --output " ${gmp_tarball} "
81
+
82
+ tar \
83
+ --directory=" $( dirname " ${gmp_directory} " ) " \
84
+ --extract \
85
+ --file=" ${gmp_tarball} "
59
86
fi
60
87
61
88
if ! [ -f " ${mpfr_tarball} " ]; then
62
- wget --no-verbose ' https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz' --output-document=" ${mpfr_tarball} "
63
- tar --directory=" $( dirname " ${mpfr_directory} " ) " --extract --file=" ${mpfr_tarball} "
89
+ curl \
90
+ --url ' https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz' \
91
+ --retry ' 30' \
92
+ --retry-all-errors \
93
+ --retry-delay ' 0' \
94
+ --retry-max-time ' 0' \
95
+ --location \
96
+ --silent \
97
+ --output " ${mpfr_tarball} "
98
+
99
+ tar \
100
+ --directory=" $( dirname " ${mpfr_directory} " ) " \
101
+ --extract \
102
+ --file=" ${mpfr_tarball} "
64
103
fi
65
104
66
105
if ! [ -f " ${mpc_tarball} " ]; then
67
- wget --no-verbose ' https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz' --output-document=" ${mpc_tarball} "
68
- tar --directory=" $( dirname " ${mpc_directory} " ) " --extract --file=" ${mpc_tarball} "
106
+ curl \
107
+ --url ' https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz' \
108
+ --retry ' 30' \
109
+ --retry-all-errors \
110
+ --retry-delay ' 0' \
111
+ --retry-max-time ' 0' \
112
+ --location \
113
+ --silent \
114
+ --output " ${mpc_tarball} "
115
+
116
+ tar \
117
+ --directory=" $( dirname " ${mpc_directory} " ) " \
118
+ --extract \
119
+ --file=" ${mpc_tarball} "
69
120
fi
70
121
71
122
if ! [ -f " ${binutils_tarball} " ]; then
72
- wget --no-verbose ' https://ftp.gnu.org/gnu/binutils/binutils-with-gold-2.44.tar.xz' --output-document=" ${binutils_tarball} "
73
- tar --directory=" $( dirname " ${binutils_directory} " ) " --extract --file=" ${binutils_tarball} "
123
+ curl \
124
+ --url ' https://ftp.gnu.org/gnu/binutils/binutils-with-gold-2.44.tar.xz' \
125
+ --retry ' 30' \
126
+ --retry-all-errors \
127
+ --retry-delay ' 0' \
128
+ --retry-max-time ' 0' \
129
+ --location \
130
+ --silent \
131
+ --output " ${binutils_tarball} "
132
+
133
+ tar \
134
+ --directory=" $( dirname " ${binutils_directory} " ) " \
135
+ --extract \
136
+ --file=" ${binutils_tarball} "
74
137
75
138
patch --directory=" ${binutils_directory} " --strip=' 1' --input=" ${workdir} /submodules/obggcc/patches/0001-Revert-gold-Use-char16_t-char32_t-instead-of-uint16_.patch"
76
139
patch --directory=" ${binutils_directory} " --strip=' 1' --input=" ${workdir} /submodules/obggcc/patches/0001-Disable-annoying-linker-warnings.patch"
77
140
fi
78
141
79
142
if ! [ -f " ${gcc_tarball} " ]; then
80
- wget --no-verbose ' https://github.com/gcc-mirror/gcc/archive/refs/heads/master.tar.gz' --output-document=" ${gcc_tarball} "
81
- tar --directory=" $( dirname " ${gcc_directory} " ) " --extract --file=" ${gcc_tarball} "
143
+ curl \
144
+ --url ' https://github.com/gcc-mirror/gcc/archive/refs/heads/master.tar.gz' \
145
+ --retry ' 30' \
146
+ --retry-all-errors \
147
+ --retry-delay ' 0' \
148
+ --retry-max-time ' 0' \
149
+ --location \
150
+ --silent \
151
+ --output " ${gcc_tarball} "
152
+
153
+ tar \
154
+ --directory=" $( dirname " ${gcc_directory} " ) " \
155
+ --extract \
156
+ --file=" ${gcc_tarball} "
157
+
158
+ patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /patches/0001-Fix-libgcc-build-on-musl.patch"
82
159
83
160
patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /submodules/obggcc/patches/0001-Fix-libgcc-build-on-arm.patch"
84
161
patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /submodules/obggcc/patches/0001-Change-the-default-language-version-for-C-compilatio.patch"
85
162
patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /submodules/obggcc/patches/0001-Turn-Wimplicit-int-back-into-an-warning.patch"
86
163
patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /submodules/obggcc/patches/0001-Turn-Wint-conversion-back-into-an-warning.patch"
87
164
patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /submodules/obggcc/patches/0001-Revert-GCC-change-about-turning-Wimplicit-function-d.patch"
88
- patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /patches/0001-Fix-libgcc-build-on-musl.patch"
89
- patch --directory=" ${gcc_directory} " --strip=' 1' --input=" ${workdir} /patches/0001-Fix-libquadmath-build-on-musl.patch"
90
165
fi
91
166
92
167
[ -d " ${gmp_directory} /build" ] || mkdir " ${gmp_directory} /build"
93
168
94
169
cd " ${gmp_directory} /build"
95
170
96
171
../configure \
172
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
97
173
--prefix=" ${toolchain_directory} " \
98
174
--enable-shared \
99
175
--enable-static \
100
- ${cross_compile_flags} \
101
- CFLAGS=" ${optflags} " \
102
- CXXFLAGS=" ${optflags} " \
103
- LDFLAGS=" ${linkflags} "
176
+ CFLAGS=" ${optflags} ${optlto} " \
177
+ CXXFLAGS=" ${optflags} ${optlto} " \
178
+ LDFLAGS=" ${linkflags} ${optlto} "
104
179
105
180
make all --jobs
106
181
make install
@@ -110,14 +185,14 @@ make install
110
185
cd " ${mpfr_directory} /build"
111
186
112
187
../configure \
188
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
113
189
--prefix=" ${toolchain_directory} " \
114
190
--with-gmp=" ${toolchain_directory} " \
115
191
--enable-shared \
116
192
--enable-static \
117
- ${cross_compile_flags} \
118
- CFLAGS=" ${optflags} " \
119
- CXXFLAGS=" ${optflags} " \
120
- LDFLAGS=" ${linkflags} "
193
+ CFLAGS=" ${optflags} ${optlto} " \
194
+ CXXFLAGS=" ${optflags} ${optlto} " \
195
+ LDFLAGS=" ${linkflags} ${optlto} "
121
196
122
197
make all --jobs
123
198
make install
@@ -127,30 +202,18 @@ make install
127
202
cd " ${mpc_directory} /build"
128
203
129
204
../configure \
205
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
130
206
--prefix=" ${toolchain_directory} " \
131
207
--with-gmp=" ${toolchain_directory} " \
132
208
--enable-shared \
133
209
--enable-static \
134
- ${cross_compile_flags} \
135
- CFLAGS=" ${optflags} " \
136
- CXXFLAGS=" ${optflags} " \
137
- LDFLAGS=" ${linkflags} "
210
+ CFLAGS=" ${optflags} ${optlto} " \
211
+ CXXFLAGS=" ${optflags} ${optlto} " \
212
+ LDFLAGS=" ${linkflags} ${optlto} "
138
213
139
214
make all --jobs
140
215
make install
141
216
142
- declare -ra targets=(
143
- ' arm-unknown-linux-musleabihf'
144
- ' armv7l-unknown-linux-musleabihf'
145
- ' powerpc64le-unknown-linux-musl'
146
- ' s390x-unknown-linux-musl'
147
- ' mips64-unknown-linux-musl'
148
- ' x86_64-unknown-linux-musl'
149
- ' aarch64-unknown-linux-musl'
150
- ' riscv64-unknown-linux-musl'
151
- ' i386-unknown-linux-musl'
152
- )
153
-
154
217
for target in " ${targets[@]} " ; do
155
218
source " ${workdir} /${target} .sh"
156
219
@@ -163,10 +226,12 @@ for target in "${targets[@]}"; do
163
226
--retry-delay ' 0' \
164
227
--retry-max-time ' 0' \
165
228
--location \
166
- --continue-at ' -' \
167
229
--output " ${sysroot_tarball} "
168
230
169
- tar --directory=" ${toolchain_directory} " --extract --file=" ${sysroot_tarball} "
231
+ tar \
232
+ --directory=" ${toolchain_directory} " \
233
+ --extract \
234
+ --file=" ${sysroot_tarball} "
170
235
171
236
unlink " ${sysroot_tarball} "
172
237
@@ -176,6 +241,7 @@ for target in "${targets[@]}"; do
176
241
rm --force --recursive ./*
177
242
178
243
../configure \
244
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
179
245
--target=" ${triplet} " \
180
246
--prefix=" ${toolchain_directory} " \
181
247
--enable-gold \
@@ -184,10 +250,9 @@ for target in "${targets[@]}"; do
184
250
--disable-gprofng \
185
251
--with-static-standard-libraries \
186
252
--with-sysroot=" ${toolchain_directory} /${triplet} " \
187
- ${cross_compile_flags} \
188
- CFLAGS=" ${optflags} " \
189
- CXXFLAGS=" ${optflags} " \
190
- LDFLAGS=" ${linkflags} "
253
+ CFLAGS=" ${optflags} ${optlto} " \
254
+ CXXFLAGS=" ${optflags} ${optlto} " \
255
+ LDFLAGS=" ${linkflags} ${optlto} "
191
256
192
257
make all --jobs
193
258
make install
@@ -199,14 +264,15 @@ for target in "${targets[@]}"; do
199
264
rm --force --recursive ./*
200
265
201
266
../configure \
267
+ --host=" ${CROSS_COMPILE_TRIPLET} " \
202
268
--target=" ${triplet} " \
203
269
--prefix=" ${toolchain_directory} " \
204
270
--with-linker-hash-style=' gnu' \
205
271
--with-gmp=" ${toolchain_directory} " \
206
272
--with-mpc=" ${toolchain_directory} " \
207
273
--with-mpfr=" ${toolchain_directory} " \
208
274
--with-bugurl=' https://github.com/AmanoTeam/Raiden/issues' \
209
- --with-pkgversion=" Raiden v0.7 -${revision} " \
275
+ --with-pkgversion=" Raiden v0.8 -${revision} " \
210
276
--with-sysroot=" ${toolchain_directory} /${triplet} " \
211
277
--with-gcc-major-version-only \
212
278
--with-native-system-header-dir=' /include' \
@@ -226,7 +292,7 @@ for target in "${targets[@]}"; do
226
292
--enable-ld \
227
293
--enable-gold \
228
294
--enable-languages=' c,c++' \
229
- --disable -plugin \
295
+ --enable -plugin \
230
296
--disable-libsanitizer \
231
297
--disable-fixincludes \
232
298
--disable-gnu-unique-object \
@@ -241,7 +307,6 @@ for target in "${targets[@]}"; do
241
307
--disable-nls \
242
308
--without-headers \
243
309
${extra_configure_flags} \
244
- ${cross_compile_flags} \
245
310
libat_cv_have_ifunc=no \
246
311
CFLAGS=" ${optflags} " \
247
312
CXXFLAGS=" ${optflags} " \
@@ -253,13 +318,6 @@ for target in "${targets[@]}"; do
253
318
all --jobs=" ${max_jobs} "
254
319
make install
255
320
256
- cd " ${toolchain_directory} /${triplet} /bin"
257
-
258
- for name in * ; do
259
- rm " ${name} "
260
- ln --symbolic " ../../bin/${triplet} -${name} " " ${name} "
261
- done
262
-
263
321
patchelf --add-rpath ' $ORIGIN/../../../../lib' " ${toolchain_directory} /libexec/gcc/${triplet} /" * " /cc1"
264
322
patchelf --add-rpath ' $ORIGIN/../../../../lib' " ${toolchain_directory} /libexec/gcc/${triplet} /" * " /cc1plus"
265
323
patchelf --add-rpath ' $ORIGIN/../../../../lib' " ${toolchain_directory} /libexec/gcc/${triplet} /" * " /lto1"
0 commit comments