Skip to content

Commit

Permalink
Include sysroots from Debian 6 up to 9
Browse files Browse the repository at this point in the history
Also allow cross-compiling software to these targets by adding wrappers that calls GCC/G++ with the appropriate --sysroot option.
  • Loading branch information
Kartatz committed Aug 21, 2024
1 parent 335914a commit 1bb7dd0
Show file tree
Hide file tree
Showing 16 changed files with 401 additions and 1,266 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "submodules/debian-sysroot"]
path = submodules/debian-sysroot
url = https://github.com/AmanoTeam/debian-sysroot
8 changes: 4 additions & 4 deletions aarch64-unknown-linux-gnu.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/l/linux/linux-libc-dev_3.16.56-1+deb8u1_arm64.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6-dev_2.19-18+deb8u10_arm64.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6_2.19-18+deb8u10_arm64.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/s/systemtap/systemtap-sdt-dev_2.6-0.2_arm64.deb'
'https://archive.debian.org/debian/pool/main/l/linux/linux-libc-dev_3.16.56-1+deb8u1_arm64.deb'
'https://archive.debian.org/debian/pool/main/g/glibc/libc6-dev_2.19-18+deb8u10_arm64.deb'
'https://archive.debian.org/debian/pool/main/g/glibc/libc6_2.19-18+deb8u10_arm64.deb'
'https://archive.debian.org/debian/pool/main/s/systemtap/systemtap-sdt-dev_2.6-0.2_arm64.deb'
)

declare extra_configure_flags=''
Expand Down
6 changes: 3 additions & 3 deletions alpha-unknown-linux-gnu.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/l/linux-2.6/linux-libc-dev_2.6.26-29_alpha.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6.1-dev_2.7-18lenny7_alpha.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6.1_2.7-18lenny7_alpha.deb'
'https://archive.debian.org/debian/pool/main/l/linux-2.6/linux-libc-dev_2.6.26-29_alpha.deb'
'https://archive.debian.org/debian/pool/main/g/glibc/libc6.1-dev_2.7-18lenny7_alpha.deb'
'https://archive.debian.org/debian/pool/main/g/glibc/libc6.1_2.7-18lenny7_alpha.deb'
)

declare extra_configure_flags=''
Expand Down
6 changes: 3 additions & 3 deletions arm-unknown-linux-gnueabi.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/l/linux-2.6/linux-libc-dev_2.6.26-29_armel.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6-dev_2.7-18lenny7_armel.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6_2.7-18lenny7_armel.deb'
'https://archive.debian.org/debian/pool/main/l/linux-2.6/linux-libc-dev_2.6.26-29_armel.deb'
'https://archive.debian.org/debian/pool/main/g/glibc/libc6-dev_2.7-18lenny7_armel.deb'
'https://archive.debian.org/debian/pool/main/g/glibc/libc6_2.7-18lenny7_armel.deb'
)

declare extra_configure_flags='--with-arch=armv4t --with-float=soft --disable-libsanitizer'
Expand Down
8 changes: 4 additions & 4 deletions arm-unknown-linux-gnueabihf.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://archive.debian.org/debian-security/pool/updates/main/l/linux/linux-libc-dev_3.2.102-1_armhf.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian-security/pool/updates/main/e/eglibc/libc6-dev_2.13-38+deb7u12_armhf.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian-security/pool/updates/main/e/eglibc/libc6_2.13-38+deb7u12_armhf.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/s/systemtap/systemtap-sdt-dev_1.7-1+deb7u1_armhf.deb'
'https://archive.debian.org/debian-security/pool/updates/main/l/linux/linux-libc-dev_3.2.102-1_armhf.deb'
'https://archive.debian.org/debian-security/pool/updates/main/e/eglibc/libc6-dev_2.13-38+deb7u12_armhf.deb'
'https://archive.debian.org/debian-security/pool/updates/main/e/eglibc/libc6_2.13-38+deb7u12_armhf.deb'
'https://archive.debian.org/debian/pool/main/s/systemtap/systemtap-sdt-dev_1.7-1+deb7u1_armhf.deb'
)

declare extra_configure_flags='--with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb'
Expand Down
60 changes: 44 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,22 @@ make all --jobs
make install

declare -ra targets=(
'ia64-unknown-linux-gnu'
'alpha-unknown-linux-gnu'
# 'ia64-unknown-linux-gnu'
# 'alpha-unknown-linux-gnu'
'x86_64-unknown-linux-gnu'
'i386-unknown-linux-gnu'
'arm-unknown-linux-gnueabi'
'arm-unknown-linux-gnueabihf'
'hppa-unknown-linux-gnu'
'aarch64-unknown-linux-gnu'
'mips-unknown-linux-gnu'
'mipsel-unknown-linux-gnu'
'powerpc-unknown-linux-gnu'
's390-unknown-linux-gnu'
's390x-unknown-linux-gnu'
'sparc-unknown-linux-gnu'
'powerpc64le-unknown-linux-gnu'
'mips64el-unknown-linux-gnuabi64'
# 'i386-unknown-linux-gnu'
# 'arm-unknown-linux-gnueabi'
# 'arm-unknown-linux-gnueabihf'
# 'hppa-unknown-linux-gnu'
# 'aarch64-unknown-linux-gnu'
# 'mips-unknown-linux-gnu'
# 'mipsel-unknown-linux-gnu'
# 'powerpc-unknown-linux-gnu'
# 's390-unknown-linux-gnu'
# 's390x-unknown-linux-gnu'
# 'sparc-unknown-linux-gnu'
# 'powerpc64le-unknown-linux-gnu'
# 'mips64el-unknown-linux-gnuabi64'
)

for target in "${targets[@]}"; do
Expand Down Expand Up @@ -248,7 +248,7 @@ for target in "${targets[@]}"; do
--with-static-standard-libraries \
--with-bugurl='https://github.com/AmanoTeam/obggcc/issues' \
--with-gcc-major-version-only \
--with-pkgversion="OBGGCC v0.8-${obggcc_revision}" \
--with-pkgversion="OBGGCC v0.9-${obggcc_revision}" \
--with-sysroot="${toolchain_directory}/${triple}" \
--with-native-system-header-dir='/include' \
--enable-__cxa_atexit \
Expand Down Expand Up @@ -301,3 +301,31 @@ for target in "${targets[@]}"; do
patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/"*'/cc1plus'
patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/"*'/lto1'
done

declare cc='gcc'

if ! (( is_native )); then
cc="${CC}"
fi

declare -r sysroot_tarball='/tmp/sysroot.tar.xz'
declare -r executable='/tmp/gcc-wrapper'

while read item; do
declare glibc_version="$(jq '.glibc_version' <<< "${item}")"
declare triplet="$(jq --raw-output '.triplet' <<< "${item}")"

"${cc}" \
"${workdir}/tools/gcc-wrapper/filesystem.c" \
"${workdir}/tools/gcc-wrapper/main.c" \
"${workdir}/tools/gcc-wrapper/path.c" \
-Os \
-s \
-o "${executable}"

cp "${executable}" "${toolchain_directory}/bin/${triplet}${glibc_version}-gcc"
cp "${executable}" "${toolchain_directory}/bin/${triplet}${glibc_version}-g++"

wget --no-verbose "https://github.com/AmanoTeam/debian-sysroot/releases/download/latest/${triplet}${glibc_version}.tar.xz" --output-document="${sysroot_tarball}"
tar --directory="${toolchain_directory}" --extract --file="${sysroot_tarball}"
done <<< "$(jq --compact-output '.[]' "${workdir}/submodules/debian-sysroot/dist.json")"
6 changes: 3 additions & 3 deletions hppa-unknown-linux-gnu.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/l/linux-2.6/linux-libc-dev_2.6.26-29_hppa.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6-dev_2.7-18lenny7_hppa.deb'
'https://web.archive.org/web/0if_/https://archive.debian.org/debian/pool/main/g/glibc/libc6_2.7-18lenny7_hppa.deb'
'https://archive.debian.org/debian/pool/main/l/linux-2.6/linux-libc-dev_2.6.26-29_hppa.deb'
'/https://archive.debian.org/debian/pool/main/g/glibc/libc6-dev_2.7-18lenny7_hppa.deb'
'https://archive.debian.org/debian/pool/main/g/glibc/libc6_2.7-18lenny7_hppa.deb'
)

declare extra_configure_flags='--disable-libsanitizer'
Expand Down
1 change: 1 addition & 0 deletions submodules/debian-sysroot
Submodule debian-sysroot added at 8cd10c
Loading

0 comments on commit 1bb7dd0

Please sign in to comment.