Skip to content

Commit b57d1be

Browse files
authored
Utilize Debian style sysroot (#48)
* Add patches to support Debian style library paths * Don't fail if `strip` cannot be found * Tell Debian patches that there are more directories to look in * Update GNU mirror * flag cleanup. Debian CXX linkage broken. All of RoboRIO support needs testing. * disable multilib * autoclean on failure * Delete even when write protected * Allow quicker backend builds for debian targets
1 parent b4fa054 commit b57d1be

14 files changed

+872
-57
lines changed

makes/src/11-sources.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ FUNC_ONLY=true
2626
source "$(dirname "$0")/common.sh"
2727

2828
function download_or_die() {
29+
echo "[INFO] Downloading from $1"
30+
2931
wget -nc -nv "$1" &>/dev/null ||
3032
die "Failed to download archive from $1"
3133
}
@@ -39,7 +41,7 @@ rm -rf "${DOWNLOAD_DIR}"
3941
mkdir -p "${DOWNLOAD_DIR}"
4042

4143
xpushd "${DOWNLOAD_DIR}"
42-
GNU_MIRROR="https://ftpmirror.gnu.org/gnu"
44+
GNU_MIRROR="https://mirrors.kernel.org/gnu"
4345
GCC_INFRA_MIRROR="https://gcc.gnu.org/pub/gcc/infrastructure"
4446
EXPAT_MIRROR="https://github.com/libexpat/libexpat/releases/download"
4547
SAVANNAH_MIRROR="https://git.savannah.gnu.org/cgit/config.git/plain"

makes/src/12-patches.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ function patch_project() {
4242
src="gcc-${V_GCC}"
4343
ver="${V_GCC}"
4444
;;
45+
bin)
46+
proj="binutils"
47+
src="binutils-${V_BIN}"
48+
ver="${V_BIN}"
49+
;;
4550
*) die "Unknown config" ;;
4651
esac
4752

@@ -53,6 +58,11 @@ function patch_project() {
5358
# builds
5459
continue
5560
fi
61+
if [[ "$_patch" =~ debian ]] && [ "$TARGET_DISTRO" != "debian" ] &&
62+
[ "$TARGET_DISTRO" != "raspbian" ]; then
63+
# Do not apply debian patches to roborio targets
64+
continue
65+
fi
5666
_patch="${PWD}/$_patch"
5767
xpushd "${DOWNLOAD_DIR}/${src}"
5868
patch_or_die "$_patch"
@@ -71,6 +81,7 @@ function patch_project() {
7181
}
7282

7383
patch_project gcc
84+
patch_project bin
7485

7586
if [ -d "${PATCH_DIR}/targets/consts/${TOOLCHAIN_NAME}" ]; then
7687
xpushd "${PATCH_DIR}/targets/consts/${TOOLCHAIN_NAME}"

makes/src/13-normalize.sh

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -57,60 +57,30 @@ if [ "${TARGET_DISTRO}" = "roborio" ] ||
5757
fi
5858

5959
else
60-
# lib
61-
rm -rf lib/ld-linux*.so*
62-
rsync -aEL lib/"${TARGET_TUPLE}"/ lib/
63-
rm -rf lib/"${TARGET_TUPLE}"
64-
65-
# usr/include
66-
rsync -aEL usr/include/"${TARGET_TUPLE}"/ usr/include/
67-
rm -rf usr/include/"${TARGET_TUPLE}"
68-
69-
# usr/lib
70-
rsync -aEL usr/lib/"${TARGET_TUPLE}"/ usr/lib/
71-
rm -rf usr/lib/"${TARGET_TUPLE}"
72-
73-
cp usr/lib/gcc/"${TARGET_TUPLE}/${V_GCC/.*/}"/*.so* \
74-
usr/lib/gcc/"${TARGET_TUPLE}/${V_GCC/.*/}"/lib*_preinit.o \
75-
usr/lib/gcc/"${TARGET_TUPLE}/${V_GCC/.*/}"/libsanitizer.spec \
76-
usr/lib/
77-
7860
rm -rf usr/lib/audit
7961
rm -rf usr/lib/bfd-plugins
8062
rm -rf usr/lib/compat-ld
8163
rm -rf usr/lib/gold-ld
8264
rm -rf usr/lib/ldscripts
8365
rm -rf usr/lib/mime
8466
rm -rf usr/lib/tar
85-
86-
# Point the libc linker script to correct location
87-
sed -i "s/\/lib\/${TARGET_TUPLE}/\/lib/g" usr/lib/libc.so
8867
fi
8968

90-
# Clear GCC unneeded files from sysroot
91-
for item in cc1 \
92-
cc1plus \
93-
collect2 \
94-
f951 \
95-
lto1 \
96-
lto-wrapper \
97-
plugin \
98-
libasan \
99-
libubsan \
100-
libatomic \
101-
libcc1.so \
102-
libgcc_s.so \
103-
liblto_plugin.so; do
104-
rm -rf usr/lib/gcc/"${TARGET_TUPLE}/${V_GCC/.*/}/${item}"*
105-
done
106-
10769
if [ "${TARGET_LIB_REBUILD}" = "true" ]; then
10870
# Delete libstdc++ headers which will be replaced
10971
rm -rf usr/include/c++/
11072

11173
# Delete GCC runtime artifacts
112-
rm -rf usr/lib/gcc/
113-
rm -rf usr/lib/libgcc_s.so*
114-
rm -rf usr/lib/libatomic.so*
115-
rm -rf usr/lib/libstdc++.so*
74+
if [ "${TARGET_DISTRO}" = "roborio" ] ||
75+
[ "${TARGET_DISTRO}" = "roborio-academic" ]; then
76+
rm -rf usr/lib/gcc/
77+
rm -rf usr/lib/libgcc_s.so*
78+
rm -rf usr/lib/libatomic.so*
79+
rm -rf usr/lib/libstdc++.so*
80+
else
81+
rm -rf usr/lib/"${TARGET_TUPLE}"/gcc/
82+
rm -rf usr/lib/"${TARGET_TUPLE}"/libgcc_s.so*
83+
rm -rf usr/lib/"${TARGET_TUPLE}"/libatomic.so*
84+
rm -rf usr/lib/"${TARGET_TUPLE}"/libstdc++.so*
85+
fi
11686
fi

makes/src/30-binutils.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,21 @@ if is_step_backend && ! is_lib_rebuild_required; then
2727
exit 0
2828
fi
2929

30+
# This is a part of the debian specific patch. This is no-op for the roborio.
31+
export APPEND_TOOLLIBDIR=yes
32+
export DEB_TARGET_MULTIARCH="${TARGET_TUPLE}"
33+
3034
CONFIGURE_BINUTILS=(
31-
"${CONFIGURE_COMMON[@]}"
32-
"--enable-poison-system-directories"
33-
"--enable-ld"
34-
"--enable-deterministic-archives"
35+
"--build=${BUILD_TUPLE}" # Build machine
36+
"--host=${HOST_TUPLE}" # Host machine
37+
"--target=${TARGET_TUPLE}" # Target machine
38+
"--prefix=${WPI_HOST_PREFIX}" # Filesystem prefix
39+
"--program-prefix=${TARGET_PREFIX}" # Program prefix
40+
"--disable-werror" # Allow host builds to be permissive
41+
"--disable-nls" # Disable localization
42+
"--disable-multilib" # Disable multilib for 64-bit targets
43+
44+
"--with-sysroot=${SYSROOT_PATH}"
3545
)
3646

3747
xpushd "${BUILD_DIR}/binutils-build"

makes/src/99-tree.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ elif [ -e "/usr/bin/${HOST_TUPLE}-strip" ]; then
6565
STRIP_CMD="/usr/bin/${HOST_TUPLE}-strip"
6666
elif [ -e "/usr/bin/${WPI_HOST_TUPLE}-strip" ]; then
6767
STRIP_CMD="/usr/bin/${WPI_HOST_TUPLE}-strip"
68+
elif [ -e "/usr/bin/llvm-strip" ]; then
69+
# LLVM strip is architecture agnostic
70+
STRIP_CMD="/usr/bin/llvm-strip"
6871
elif [ "${WPI_HOST_NAME}" = "Mac" ]; then
72+
# Xcode strip is just LLVM strip
6973
STRIP_CMD="strip"
7074
else
71-
die "Cannot find proper strip command"
75+
warn "Cannot find proper strip command"
7276
fi
7377

7478
# Remove any executables that may have the incorrect names

makes/src/common.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,16 @@ CONFIGURE_COMMON_LITE=(
4949
"--host=${HOST_TUPLE}"
5050
"--prefix=${WPI_HOST_PREFIX}"
5151
"--program-prefix=${TARGET_PREFIX}"
52-
"--enable-lto"
5352
"--disable-nls"
54-
"--disable-plugin"
5553
"--disable-werror"
56-
"--disable-dependency-tracking"
54+
"--disable-multilib"
5755
)
5856

5957
CONFIGURE_COMMON=(
6058
"${CONFIGURE_COMMON_LITE[@]}"
6159
"--target=${TARGET_TUPLE}"
6260
"--with-sysroot=${SYSROOT_PATH}"
6361
"--libdir=${SYSROOT_PATH}/usr/lib"
64-
"--with-toolexeclibdir=${SYSROOT_PATH}/usr/lib"
6562
"--with-build-sysroot=${SYSROOT_BUILD_PATH}"
6663
)
6764

makes/src/utils/conf-gcc.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,19 @@ function gcc_make_multi() {
3232
}
3333

3434
CONFIGURE_GCC=(
35-
"${CONFIGURE_COMMON[@]}"
36-
"--enable-poison-system-directories"
35+
"--build=${BUILD_TUPLE}"
36+
"--host=${HOST_TUPLE}"
37+
"--target=${TARGET_TUPLE}"
38+
"--prefix=${WPI_HOST_PREFIX}"
39+
"--program-prefix=${TARGET_PREFIX}"
40+
"--disable-werror"
41+
"--disable-nls"
42+
"--disable-multilib"
43+
44+
"--libdir=${SYSROOT_PATH}/usr/lib"
45+
"--with-sysroot=${SYSROOT_PATH}"
46+
"--with-build-sysroot=${SYSROOT_BUILD_PATH}"
47+
3748
"--enable-threads=posix"
3849
"--enable-shared"
3950
"--with-gcc-major-version-only"

makes/src/utils/funcs.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ configure_target_vars() {
9191
gcc_update_target_list() {
9292
env_exists SYSROOT_BUILD_PATH
9393
gcc_need_lib_build() {
94-
local lib="${SYSROOT_BUILD_PATH}/usr/lib/$1"
94+
local lib1="${SYSROOT_BUILD_PATH}/usr/lib/$1"
95+
local lib2="${SYSROOT_BUILD_PATH}/usr/lib/gcc/${TARGET_TUPLE}/${V_GCC/.*/}/$1"
9596
if [ "$TARGET_LIB_REBUILD" = "true" ]; then
9697
return 0
9798
fi
98-
if compgen -G "${lib}.so*" >/dev/null; then
99+
if (compgen -G "${lib1}.so*" || compgen -G "${lib2}.so*") >/dev/null; then
99100
return 1
100101
fi
101102
return 0

patches/README.multiarch.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Debian sysroot enablement
2+
3+
The Debian filesystem is different from the simple NI Linux layout. Debian chose
4+
to use a design which allowed for the same development packages to be installed
5+
with differing architectures. This can make Debian-to-Debian development quite
6+
easy but it requires further patching to work with a third-party toolchain.
7+
8+
## GCC
9+
* https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-10-debian/debian/patches/gcc-multiarch.diff
10+
* https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-10-debian/debian/patches/gcc-multilib-multiarch.diff
11+
* https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-10-debian/debian/patches/g%2B%2B-multiarch-incdir.diff
12+
13+
## Binutils
14+
* https://salsa.debian.org/toolchain-team/binutils/-/blob/binutils-2.38/debian/patches/129_multiarch_libpath.patch

0 commit comments

Comments
 (0)