Skip to content

Commit 34baf23

Browse files
Make cross-compilation more consistent across devices (UBC-Thunderbots#3451)
* project vimrc for FZF * filter out .swp files * crosstool-ng config * working on getting a nano compilation working * seems to compile * Working impl of x-compiler * updat headed_estop_reader test timeout * Update clang-format to work on ubuntu 24 * wip * Update cross-compiler compilation paths * delete my local computer config * fix runtime issues with robot_info and robot_view widgets * [pre-commit.ci lite] apply automatic fixes * delete crosstool-ng config * Remove boost build flag and build c++20 for robots --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent d62d7d6 commit 34baf23

126 files changed

Lines changed: 713 additions & 555 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

environment_setup/setup_software.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ if [[ $(lsb_release -rs) == "20.04" ]]; then
9595
fi
9696

9797
# Clear the download cache
98-
rm -rf /tmp/tbots_download_cache
98+
sudo rm -rf /tmp/tbots_download_cache
9999
mkdir /tmp/tbots_download_cache
100100

101101
if [[ $(lsb_release -rs) == "22.04" ]] || [[ $(lsb_release -rs) == "24.04" ]]; then
@@ -186,6 +186,10 @@ print_status_msg "Install clang-format"
186186
install_clang_format $arch
187187
print_status_msg "Done installing clang-format"
188188

189+
print_status_msg "Setting up cross compiler for robot software"
190+
install_cross_compiler $arch
191+
print_status_msg "Done setting up cross compiler for robot software"
192+
189193
print_status_msg "Setting Up Python Development Headers"
190194
install_python_dev_cross_compile_headers $arch
191195
print_status_msg "Done Setting Up Python Development Headers"

environment_setup/util.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
install_autoref() {
22
autoref_commit=b30660b78728c3ce159de8ae096181a1ec52e9ba
3-
sudo wget -N https://github.com/TIGERs-Mannheim/AutoReferee/archive/${autoref_commit}.zip -O /tmp/tbots_download_cache/autoReferee.zip
3+
wget -N https://github.com/TIGERs-Mannheim/AutoReferee/archive/${autoref_commit}.zip -O /tmp/tbots_download_cache/autoReferee.zip
44
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/autoReferee.zip
55

66
/tmp/tbots_download_cache/AutoReferee-${autoref_commit}/./gradlew installDist -p /tmp/tbots_download_cache/AutoReferee-${autoref_commit} -Dorg.gradle.java.home=/opt/tbotspython/bin/jdk
77
mv /tmp/tbots_download_cache/AutoReferee-${autoref_commit}/build/install/autoReferee /opt/tbotspython/
8+
rm -rf /tmp/tbots_download_cache/autoReferee.zip /tmp/tbots_download_cache/AutoReferee-${autoref_commit}
89
}
910

1011
install_bazel() {
@@ -20,17 +21,35 @@ install_bazel() {
2021
}
2122

2223
install_clang_format() {
23-
download=https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-aarch64-linux-gnu.tar.xz
24-
clang_format_path=/tmp/tbots_download_cache/clang+llvm-10.0.0-aarch64-linux-gnu/bin/clang-format
24+
download=https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/clang+llvm-19.1.7-aarch64-linux-gnu.tar.xz
25+
clang_folder=clang+llvm-19.1.7-aarch64-linux-gnu
2526

2627
if is_x86 $1; then
27-
download=https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
28-
clang_format_path=/tmp/tbots_download_cache/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format
28+
download=https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/LLVM-19.1.7-Linux-X64.tar.xz
29+
clang_folder=LLVM-19.1.7-Linux-X64
2930
fi
3031

3132
wget $download -O /tmp/tbots_download_cache/clang.tar.xz
32-
tar -xf /tmp/tbots_download_cache/clang.tar.xz -C /tmp/tbots_download_cache/
33+
34+
# Temporarily need more space to extract the clang tarball
35+
mkdir -p ~/.tbots
36+
tar -xf /tmp/tbots_download_cache/clang.tar.xz -C ~/.tbots/
37+
38+
clang_format_path=~/.tbots/$clang_folder/bin/clang-format
3339
sudo cp $clang_format_path /opt/tbotspython/bin/clang-format
40+
rm -rf ~/.tbots
41+
}
42+
43+
install_cross_compiler() {
44+
file_name=aarch64-tbots-linux-gnu-for-aarch64
45+
if is_x86 $1; then
46+
file_name=aarch64-tbots-linux-gnu-for-x86
47+
fi
48+
full_file_name=$file_name.tar.xz
49+
wget https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name -O /tmp/tbots_download_cache/$full_file_name
50+
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
51+
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
52+
rm /tmp/tbots_download_cache/$full_file_name
3453
}
3554

3655
install_gamecontroller () {
@@ -61,8 +80,7 @@ install_gamecontroller () {
6180
sudo chmod +x /opt/tbotspython/gamecontroller
6281

6382
cd -
64-
sudo rm -rf /tmp/tbots_download_cache/ssl-game-controller-3.12.3
65-
sudo rm -rf /tmp/tbots_download_cache/go
83+
sudo rm -rf /tmp/tbots_download_cache/ssl-game-controller-3.12.3 /tmp/tbots_download_cache/go /tmp/tbots_download_cache/go.tar.gz /tmp/tbots_download_cache/ssl-game-controller.zip
6684
}
6785

6886
install_java () {
@@ -71,9 +89,10 @@ install_java () {
7189
if is_x86 $1; then
7290
java_download=https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz
7391
fi
74-
sudo wget -N $java_download -O /tmp/tbots_download_cache/jdk-21.tar.gz
92+
wget -N $java_download -O /tmp/tbots_download_cache/jdk-21.tar.gz
7593
tar -xzf /tmp/tbots_download_cache/jdk-21.tar.gz -C /opt/tbotspython/
7694
mv /opt/tbotspython/jdk-21* /opt/tbotspython/bin/jdk
95+
rm /tmp/tbots_download_cache/jdk-21.tar.gz
7796
}
7897

7998
install_python_dev_cross_compile_headers() {

scripts/lint_and_format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function run_clang_format () {
3636
# clang-format as arguments
3737
# We remove the last -o flag from the extension string
3838
find $CURR_DIR/../src/ ${EXTENSION_STRING::-2} \
39-
| xargs -I{} -n1000 $CLANG_BIN -i -style=file
39+
| xargs -I{} -n1000 $CLANG_BIN -i -style=file:$CURR_DIR/../.clang-format
4040

4141
if [[ "$?" != 0 ]]; then
4242
printf "\n***Failed to run clang-format over all files!***\n\n"

src/WORKSPACE

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,10 @@ new_local_repository(
247247
path = "/usr/lib/llvm-6.0/",
248248
)
249249

250-
http_archive(
250+
new_local_repository(
251251
name = "k8_jetson_nano_cross_compile_gcc",
252252
build_file = "@//extlibs:k8_jetson_nano_cross_compile_gcc.BUILD",
253-
sha256 = "73eed74e593e2267504efbcf3678918bb22409ab7afa3dc7c135d2c6790c2345",
254-
strip_prefix = "gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu",
255-
urls = [
256-
"http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz",
257-
],
253+
path = "/opt/tbotspython/aarch64-tbots-linux-gnu/",
258254
)
259255

260256
# tool used to flash firmware with bazel

src/cc_toolchain/BUILD

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,20 @@ config_setting(
4343
values = {"cpu": "k8_jetson_nano_cross_compile"},
4444
)
4545

46+
# Create a constraint for the glibc version to target the correct glibc version for the robot
47+
constraint_setting(name = "glibc_version")
48+
49+
constraint_value(
50+
name = "glibc_2_27",
51+
constraint_setting = ":glibc_version",
52+
)
53+
4654
platform(
4755
name = "robot",
4856
constraint_values = [
4957
"@platforms//cpu:aarch64",
5058
"@platforms//os:linux",
59+
":glibc_2_27",
5160
],
5261
)
5362

@@ -210,13 +219,10 @@ cc_toolchain_config_k8_jetson_nano_cross_compile(
210219

211220
toolchain(
212221
name = "cc_toolchain_for_k8_jetson_nano_cross_compile",
213-
exec_compatible_with = [
214-
"@platforms//cpu:x86_64",
215-
"@platforms//os:linux",
216-
],
217222
target_compatible_with = [
218223
"@platforms//cpu:aarch64",
219224
"@platforms//os:linux",
225+
":glibc_2_27",
220226
],
221227
toolchain = ":cc_toolchain_k8_jetson_nano_cross_compile",
222228
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",

src/cc_toolchain/cc_toolchain_config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ def _k8_jetson_nano_cross_compile_impl(ctx):
671671
name = "common",
672672
implies = [
673673
"build-id",
674-
"c++17",
674+
"c++2a",
675675
"colour",
676676
"determinism",
677677
"frame-pointer",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash --norc
22

3-
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-linux-gnu-ar "$@"
3+
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-tbots-linux-gnu-ar "$@"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash --norc
22

3-
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-linux-gnu-cpp "$@"
3+
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-tbots-linux-gnu-cpp "$@"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash --norc
22

3-
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-linux-gnu-g++ -Wl,--no-as-needed "$@"
3+
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-tbots-linux-gnu-g++ -Wl,--no-as-needed "$@"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash --norc
22

3-
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-linux-gnu-gcc -Wl,--no-as-needed "$@"
3+
exec external/k8_jetson_nano_cross_compile_gcc/bin/aarch64-tbots-linux-gnu-gcc -Wl,--no-as-needed "$@"

0 commit comments

Comments
 (0)