diff --git a/Repos/anton_fix_llvm_error.patch b/Repos/anton_fix_llvm_error.patch new file mode 100644 index 0000000000000000000000000000000000000000..aae3cb6ee3df1a4f861e6b19cea86ff0487c6c87 --- /dev/null +++ b/Repos/anton_fix_llvm_error.patch @@ -0,0 +1,11 @@ +--- sancus-main/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h 2019-11-13 03:18:57.226325476 +0100 ++++ sancus-main/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.patched.h 2019-11-13 03:18:52.269658941 +0100 +@@ -687,7 +687,7 @@ + + uint32_t getTrampolineSize() const { return RemoteTrampolineSize; } + +- Expected<std::vector<char>> readMem(char *Dst, JITTargetAddress Src, ++ Expected<std::vector<unsigned char>> readMem(char *Dst, JITTargetAddress Src, + uint64_t Size) { + // Check for an 'out-of-band' error, e.g. from an MM destructor. + if (ExistingError) diff --git a/Repos/anton_fix_mspgcc_version.patch b/Repos/anton_fix_mspgcc_version.patch new file mode 100644 index 0000000000000000000000000000000000000000..e8f1bae81e237027f64f75a2678f98eed7c2ae4c --- /dev/null +++ b/Repos/anton_fix_mspgcc_version.patch @@ -0,0 +1,18 @@ +--- sancus-main/Makefile.pkgs 2019-11-13 08:50:02.266565018 +0100 ++++ sancus-main/Makefile.patched.pkgs 2019-11-13 08:49:48.833232042 +0100 +@@ -4,8 +4,13 @@ + # --------------------------------------------------------------------------- + # Package config for TI MSPGCC + +-TI_MSPGCC_VER = 6.4.0.32 +-TI_MSPGCC_SRC_DIR = msp430-gcc-$(TI_MSPGCC_VER)_source-full ++# CHANGE: ++# - changed to version 8.3.0.16, because 6.4.0.32 couldn't be found online anymore ++# - changed src_dir template, because the naming sheme was changed ++# TI_MSPGCC_VER = 6.4.0.32 ++# TI_MSPGCC_SRC_DIR = msp430-gcc-$(TI_MSPGCC_VER)_source-full ++TI_MSPGCC_VER = 8.3.0.16 ++TI_MSPGCC_SRC_DIR = msp430-gcc-$(TI_MSPGCC_VER)-source-full + TI_MSPGCC_SRC_TBZ = $(TI_MSPGCC_SRC_DIR).tar.bz2 + TI_MSPGCC_SRC_URL = http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/exports/$(TI_MSPGCC_SRC_TBZ) + TI_MSPGCC_PREFIX = /usr/local diff --git a/Repos/apply_patch.sh b/Repos/apply_patch.sh new file mode 100755 index 0000000000000000000000000000000000000000..63092c8557f2bbaa95d162e61a5521d7f4349d75 --- /dev/null +++ b/Repos/apply_patch.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +# # Patches: +# - anton_fix_llvm_error.patch +# On my system, when trying to build sancus-main, target 'llvm-build', +# a conversion error in a C++ file deep down the directory tree caused the +# build to fail. At least for me, that fixed the problem +# - anton_fix_mspgcc_version.patch +# Apparently TI MSPGCC version 6.4.0.32 isn't online anymore, so I upgraded +# to version 8.3.0.16 + +# Make sure we are in the dir the script is in, +# because the paths in the patchfiles are realtive to this dir +# Absolute path to this script, e.g. /home/user/bin/foo.sh +script=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/bin +scriptpath=$(dirname "$script") +cd $scriptpath + +patchfile= + +usage() { + echo "usage: $0 [--unpatch] patchfile.patch" +} +do_patch() { + # p0 means that the paths in the .patch file don't need be stripped + # (they are relative to the current directory) + patch -p0 --forward < $patchfile +} +do_unpatch() { + patch -p0 -R < $patchfile; \ +} + +case $1 in + -h | --help ) + usage + ;; + -u | --unpatch | --undo ) + patchfile=$2 + do_unpatch + ;; + --patch | --apply) + patchfile=$2 + do_patch + ;; + "" ) + usage + exit 1 + ;; + * ) + patchfile=$1 + do_patch + ;; +esac \ No newline at end of file diff --git a/Repos/build_documentation_arch.md b/Repos/build_documentation_arch.md new file mode 100644 index 0000000000000000000000000000000000000000..bd1a2665d2c5b352ccadc7c581bafcfd6337c4b6 --- /dev/null +++ b/Repos/build_documentation_arch.md @@ -0,0 +1,52 @@ +# Steps i took to build/install the toolchain on arch + +1. get sancus-main repo + ```(sh) + git clone git@github.com:sancus-pma/sancus-main.git + ``` + or + ```(sh) + git clone https://github.com/sancus-pma/sancus-main.git + ``` +2. ```(sh) + cd sancus-main` + ``` +3. ```(sh) + make llvm-build + ``` + * On my machine the compilation failed due to an invalid type signature + * If that is the case for you too, I created a patch that fixes the problem + * ```(sh) + ../apply_patch.sh ../anton_fix_llvm_error.patch + ``` + * (retry `make`) +4. ```(sh) + make llvm-inst + ``` +5. Building TI MSPGCC will most likely also fail, because the specified version isn't online anymore (at least when i looked). To fix this, there is another patch that adjusts the MSPGCC version to 8.3.0.16 (hoping that everything is backwards compatible) + ```(sh) + ../apply_patch.sh ../anton_fix_mspgcc_version.patch + make ti-mspgcc-build + ``` +6. ```(sh) + make ti-mspgcc-inst + ``` +7. Install [gcc-msp430 (AUR)](https://aur.archlinux.org/packages/gcc-msp430/) + ```(sh) + yay -S binutils-msp430 gcc-msp430 msp430-libc msp430mcu + ``` +8. Trick `make` into thinking target `debian-deps` was correctly installed and install python3 pip packages + ```(sh) + touch debian-deps + make pip-deps + ``` + +## Todo +* Maybe write this as a Makefile itself +* Find out whether the llvm error occurs on other systems too. Maybe it was just my system that was badly configured +* Is `make ti-mspgcc-build` necessary? There is [msp430-elf-binutils (AUR)](https://aur.archlinux.org/packages/msp430-elf-binutils/), maybe that works too? +* Look into: + * [https://aur.archlinux.org/packages/ti-msp430ware/] + * [https://aur.archlinux.org/packages/python-msp430-tools/] + * [https://aur.archlinux.org/packages/mspgcc-ti/] + * \ No newline at end of file