Skip to content

Commit 246e644

Browse files
committed
Build all cross-compilers with OBGGCC
1 parent 853b2f0 commit 246e644

10 files changed

+186
-44
lines changed

.github/workflows/build.yml

+35-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,46 @@ on:
77

88
jobs:
99
build:
10-
concurrency:
11-
group: ${{ github.workflow }}-${{ github.ref }}
12-
cancel-in-progress: true
1310
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
target: [
14+
alpha-unknown-linux-gnu,
15+
x86_64-unknown-linux-gnu,
16+
i386-unknown-linux-gnu,
17+
arm-unknown-linux-gnueabi,
18+
arm-unknown-linux-gnueabihf,
19+
hppa-unknown-linux-gnu,
20+
aarch64-unknown-linux-gnu,
21+
mips-unknown-linux-gnu,
22+
mipsel-unknown-linux-gnu,
23+
powerpc-unknown-linux-gnu,
24+
s390-unknown-linux-gnu,
25+
s390x-unknown-linux-gnu,
26+
sparc-unknown-linux-gnu,
27+
powerpc64le-unknown-linux-gnu
28+
]
1429
steps:
1530
- uses: actions/checkout@main
1631
with:
1732
submodules: true
18-
- name: Run build script
19-
run: bash ./build.sh
33+
- name: Install required dependencies
34+
run: |
35+
sudo apt-get install --assume-yes libfl-dev
36+
- name: Build Raiden with OBGGCC
37+
run: |
38+
source './tools/setup_toolchain.sh'
39+
source './submodules/obggcc/tools/setup_toolchain.sh'
40+
41+
bash './build.sh' '${{ matrix.target }}'
42+
- name: Generate tarball
43+
run: |
44+
declare tarball_filename='${{ matrix.target }}.tar.xz'
45+
tar --directory='/tmp' --create --file=- 'raiden' | xz --threads=0 --compress -9 > "${tarball_filename}"
46+
sha256sum "${tarball_filename}" > "${tarball_filename}.sha256"
2047
- name: Upload artifact
2148
uses: actions/upload-artifact@main
2249
with:
23-
path: ./musl-cross.tar.xz
50+
path: |
51+
${{ matrix.target }}.tar.xz
52+
${{ matrix.target }}.tar.xz.sha256

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "submodules/obggcc"]
2+
path = submodules/obggcc
3+
url = https://github.com/AmanoTeam/obggcc

build.sh

+64-22
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22

3-
set -e
4-
set -u
3+
set -eu
54

65
declare -r current_source_directory="${PWD}"
76

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'
1010

1111
declare -r gmp_tarball='/tmp/gmp.tar.xz'
1212
declare -r gmp_directory='/tmp/gmp-6.2.1'
@@ -23,6 +23,11 @@ declare -r binutils_directory='/tmp/binutils-2.40'
2323
declare -r gcc_tarball='/tmp/gcc.tar.xz'
2424
declare -r gcc_directory='/tmp/gcc-12.2.0'
2525

26+
declare -r optflags='-Os'
27+
declare -r linkflags='-Wl,-s'
28+
29+
source "./submodules/obggcc/toolchains/${1}.sh"
30+
2631
if ! [ -f "${gmp_tarball}" ]; then
2732
wget --no-verbose 'https://mirrors.kernel.org/gnu/gmp/gmp-6.2.1.tar.xz' --output-document="${gmp_tarball}"
2833
tar --directory="$(dirname "${gmp_directory}")" --extract --file="${gmp_tarball}"
@@ -48,54 +53,64 @@ if ! [ -f "${gcc_tarball}" ]; then
4853
tar --directory="$(dirname "${gcc_directory}")" --extract --file="${gcc_tarball}"
4954
fi
5055

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"
5457

5558
[ -d "${gmp_directory}/build" ] || mkdir "${gmp_directory}/build"
5659

5760
cd "${gmp_directory}/build"
5861

5962
../configure \
63+
--host="${CROSS_COMPILE_TRIPLET}" \
6064
--prefix="${toolchain_directory}" \
6165
--enable-shared \
62-
--enable-static
66+
--enable-static \
67+
CFLAGS="${optflags}" \
68+
CXXFLAGS="${optflags}" \
69+
LDFLAGS="${linkflags}"
6370

64-
make all --jobs="$(nproc)"
71+
make all --jobs
6572
make install
6673

6774
[ -d "${mpfr_directory}/build" ] || mkdir "${mpfr_directory}/build"
6875

6976
cd "${mpfr_directory}/build"
7077

7178
../configure \
79+
--host="${CROSS_COMPILE_TRIPLET}" \
7280
--prefix="${toolchain_directory}" \
7381
--with-gmp="${toolchain_directory}" \
7482
--enable-shared \
75-
--enable-static
83+
--enable-static \
84+
CFLAGS="${optflags}" \
85+
CXXFLAGS="${optflags}" \
86+
LDFLAGS="${linkflags}"
7687

77-
make all --jobs="$(nproc)"
88+
make all --jobs
7889
make install
7990

8091
[ -d "${mpc_directory}/build" ] || mkdir "${mpc_directory}/build"
8192

8293
cd "${mpc_directory}/build"
8394

8495
../configure \
96+
--host="${CROSS_COMPILE_TRIPLET}" \
8597
--prefix="${toolchain_directory}" \
8698
--with-gmp="${toolchain_directory}" \
8799
--enable-shared \
88-
--enable-static
100+
--enable-static \
101+
CFLAGS="${optflags}" \
102+
CXXFLAGS="${optflags}" \
103+
LDFLAGS="${linkflags}"
89104

90-
make all --jobs="$(nproc)"
105+
make all --jobs
91106
make install
92107

93108
declare -ra targets=(
109+
'powerpc64le-unknown-linux-musl'
94110
'x86_64-unknown-linux-musl'
95111
'aarch64-unknown-linux-musl'
96112
'armv7l-unknown-linux-musleabihf'
97113
'arm-unknown-linux-musleabihf'
98-
'powerpc64le-unknown-linux-musl'
99114
'riscv64-unknown-linux-musl'
100115
's390x-unknown-linux-musl'
101116
'i386-unknown-linux-musl'
@@ -166,12 +181,19 @@ for target in "${targets[@]}"; do
166181
rm --force --recursive ./*
167182

168183
../configure \
184+
--host="${CROSS_COMPILE_TRIPLET}" \
169185
--target="${triple}" \
170186
--prefix="${toolchain_directory}" \
171187
--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}"
173195

174-
make all --jobs="$(nproc)"
196+
make all --jobs="$(($(nproc) * 8))"
175197
make install
176198

177199
[ -d "${gcc_directory}/build" ] || mkdir "${gcc_directory}/build"
@@ -181,14 +203,14 @@ for target in "${targets[@]}"; do
181203
rm --force --recursive ./*
182204

183205
../configure \
206+
--host="${CROSS_COMPILE_TRIPLET}" \
184207
--target="${triple}" \
185208
--prefix="${toolchain_directory}" \
186209
--with-linker-hash-style='gnu' \
187210
--with-gmp="${toolchain_directory}" \
188211
--with-mpc="${toolchain_directory}" \
189212
--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' \
192214
--enable-__cxa_atexit \
193215
--enable-cet='auto' \
194216
--enable-checking='release' \
@@ -218,14 +240,34 @@ for target in "${targets[@]}"; do
218240
--enable-ld \
219241
--enable-gold \
220242
--with-pic \
243+
--with-pkgversion="Raiden v0.2-${revision}" \
221244
--with-sysroot="${toolchain_directory}/${triple}" \
222245
--with-gcc-major-version-only \
223246
--with-native-system-header-dir='/include' \
247+
--disable-nls \
248+
${extra_configure_flags} \
224249
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}"
226253

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))"
228258
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"
229273
done
230-
231-
tar --directory="$(dirname "${toolchain_directory}")" --create --file=- "$(basename "${toolchain_directory}")" | xz --threads=0 --compress -9 > "${toolchain_tarball}"

build_all.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
declare -ra targets=(
6+
'alpha-unknown-linux-gnu'
7+
'x86_64-unknown-linux-gnu'
8+
'i386-unknown-linux-gnu'
9+
'arm-unknown-linux-gnueabi'
10+
'arm-unknown-linux-gnueabihf'
11+
'hppa-unknown-linux-gnu'
12+
'aarch64-unknown-linux-gnu'
13+
'mips-unknown-linux-gnu'
14+
'mipsel-unknown-linux-gnu'
15+
'powerpc-unknown-linux-gnu'
16+
's390-unknown-linux-gnu'
17+
's390x-unknown-linux-gnu'
18+
'sparc-unknown-linux-gnu'
19+
'powerpc64le-unknown-linux-gnu'
20+
'mips64el-unknown-linux-gnuabi64'
21+
)
22+
23+
declare -r tarballs_directory="${PWD}/raiden-tarballs"
24+
25+
[ -d "${tarballs_directory}" ] || mkdir "${tarballs_directory}"
26+
27+
source './tools/setup_toolchain.sh'
28+
source './submodules/obggcc/tools/setup_toolchain.sh'
29+
30+
for target in "${targets[@]}"; do
31+
bash './build.sh' "${target}"
32+
33+
declare tarball_filename="${tarballs_directory}/${target}.tar.xz"
34+
35+
tar --directory='/tmp' --create --file=- 'raiden' | xz --threads=0 --compress -9 > "${tarball_filename}"
36+
sha256sum "${tarball_filename}" > "${tarball_filename}.sha256"
37+
38+
rm --recursive --force '/tmp/raiden'
39+
done

i386-unknown-linux-musl.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
declare packages=(
4-
'https://dl-3.alpinelinux.org/alpine/edge/main/x86/musl-1.2.3_git20230322-r3.apk'
5-
'https://dl-3.alpinelinux.org/alpine/edge/main/x86/musl-dev-1.2.3_git20230322-r3.apk'
6-
'https://dl-3.alpinelinux.org/alpine/edge/main/x86/linux-headers-6.2-r0.apk'
4+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/x86/musl-1.2.4-r0.apk'
5+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/x86/musl-dev-1.2.4-r0.apk'
6+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/x86/linux-headers-6.3-r0.apk'
77
)
88

99
declare extra_configure_flags='--with-arch=i586 --with-tune=generic'
@@ -12,6 +12,6 @@ declare triple='i386-unknown-linux-musl'
1212

1313
declare ld='ld-musl-i386.so.1'
1414

15-
declare sysroot='https://dl-cdn.alpinelinux.org/alpine/edge/releases/x86/alpine-minirootfs-3.17.0-x86.tar.gz'
15+
declare sysroot='http://web.archive.org/web/0if_/https://dl-cdn.alpinelinux.org/alpine/edge/releases/x86/alpine-minirootfs-3.17.0-x86.tar.gz'
1616

1717
declare os='alpine'

powerpc64le-unknown-linux-musl.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
declare packages=(
4-
'https://dl-3.alpinelinux.org/alpine/edge/main/ppc64le/musl-1.2.3_git20230322-r3.apk'
5-
'https://dl-3.alpinelinux.org/alpine/edge/main/ppc64le/musl-dev-1.2.3_git20230322-r3.apk'
6-
'https://dl-3.alpinelinux.org/alpine/edge/main/ppc64le/linux-headers-6.2-r0.apk'
4+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/ppc64le/musl-1.2.4-r0.apk'
5+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/ppc64le/musl-dev-1.2.4-r0.apk'
6+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/ppc64le/linux-headers-6.3-r0.apk'
77
)
88

99
declare extra_configure_flags='--with-abi=elfv2'
@@ -12,6 +12,6 @@ declare triple='powerpc64le-unknown-linux-musl'
1212

1313
declare ld='ld-musl-powerpc64le.so.1'
1414

15-
declare sysroot='https://dl-cdn.alpinelinux.org/alpine/edge/releases/ppc64le/alpine-minirootfs-3.9.0_rc5-ppc64le.tar.gz'
15+
declare sysroot='http://web.archive.org/web/0if_/https://dl-cdn.alpinelinux.org/alpine/edge/releases/ppc64le/alpine-minirootfs-3.10.0-ppc64le.tar.gz'
1616

1717
declare os='alpine'

riscv64-unknown-linux-musl.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
declare packages=(
4-
'https://dl-3.alpinelinux.org/alpine/edge/main/riscv64/musl-1.2.3_git20230322-r0.apk'
5-
'https://dl-3.alpinelinux.org/alpine/edge/main/riscv64/musl-dev-1.2.3_git20230322-r0.apk'
6-
'https://dl-3.alpinelinux.org/alpine/edge/main/riscv64/linux-headers-6.2-r0.apk'
4+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/riscv64/musl-1.2.4-r0.apk'
5+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/riscv64/musl-dev-1.2.4-r0.apk'
6+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/riscv64/linux-headers-6.3-r0.apk'
77
)
88

99
declare extra_configure_flags='--with-arch=rv64gc --with-abi=lp64d'
@@ -12,6 +12,6 @@ declare triple='riscv64-unknown-linux-musl'
1212

1313
declare ld='ld-musl-riscv64.so.1'
1414

15-
declare sysroot='https://dl-cdn.alpinelinux.org/alpine/edge/releases/riscv64/alpine-minirootfs-3.17.0-riscv64.tar.gz'
15+
declare sysroot='http://web.archive.org/web/0if_/https://dl-cdn.alpinelinux.org/alpine/edge/releases/riscv64/alpine-minirootfs-3.17.0-riscv64.tar.gz'
1616

1717
declare os='alpine'

s390x-unknown-linux-musl.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
declare packages=(
4-
'https://dl-3.alpinelinux.org/alpine/edge/main/s390x/musl-1.2.3_git20230322-r3.apk'
5-
'https://dl-3.alpinelinux.org/alpine/edge/main/s390x/musl-dev-1.2.3_git20230322-r3.apk'
6-
'https://dl-3.alpinelinux.org/alpine/edge/main/s390x/linux-headers-6.2-r0.apk'
4+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/s390x/musl-1.2.4-r0.apk'
5+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/s390x/musl-dev-1.2.4-r0.apk'
6+
'http://web.archive.org/web/0if_/https://dl-3.alpinelinux.org/alpine/edge/main/s390x/linux-headers-6.3-r0.apk'
77
)
88

99
declare extra_configure_flags='--with-arch=z196 --with-tune=zEC12 --with-zarch'
@@ -12,6 +12,6 @@ declare triple='s390x-unknown-linux-musl'
1212

1313
declare ld='ld-musl-s390x.so.1'
1414

15-
declare sysroot='https://dl-cdn.alpinelinux.org/alpine/edge/releases/s390x/alpine-minirootfs-3.17.0-s390x.tar.gz'
15+
declare sysroot='http://web.archive.org/web/0if_/https://dl-cdn.alpinelinux.org/alpine/edge/releases/s390x/alpine-minirootfs-3.17.0-s390x.tar.gz'
1616

1717
declare os='alpine'

submodules/obggcc

Submodule obggcc added at 34f49c8

tools/setup_toolchain.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
declare -r RAIDEN_HOME='/tmp/raiden-toolchain'
6+
7+
if [ -d "${RAIDEN_HOME}" ]; then
8+
PATH+=":${RAIDEN_HOME}/bin"
9+
export RAIDEN_HOME \
10+
PATH
11+
return 0
12+
fi
13+
14+
declare -r RAIDEN_CROSS_TAG="$(jq --raw-output '.tag_name' <<< "$(curl --retry 10 --retry-delay 3 --silent --url 'https://api.github.com/repos/AmanoTeam/Raiden/releases/latest')")"
15+
declare -r RAIDEN_CROSS_TARBALL='/tmp/raiden.tar.xz'
16+
declare -r RAIDEN_CROSS_URL="https://github.com/AmanoTeam/Raiden/releases/download/${RAIDEN_CROSS_TAG}/x86_64-linux-gnu.tar.xz"
17+
18+
curl --retry 10 --retry-delay 3 --silent --location --url "${RAIDEN_CROSS_URL}" --output "${RAIDEN_CROSS_TARBALL}"
19+
tar --directory="$(dirname "${RAIDEN_CROSS_TARBALL}")" --extract --file="${RAIDEN_CROSS_TARBALL}"
20+
21+
rm "${RAIDEN_CROSS_TARBALL}"
22+
23+
mv '/tmp/unknown-unknown-musl' "${RAIDEN_HOME}"
24+
25+
PATH+=":${RAIDEN_HOME}/bin"
26+
27+
export RAIDEN_HOME \
28+
PATH

0 commit comments

Comments
 (0)