Skip to content

Commit

Permalink
Build OpenOCD and Risc-V toolchain as static on Linux and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
will-v-pi committed Sep 7, 2024
1 parent af49969 commit d3c64dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/linux/openocd/build-openocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
cd openocd
sed -i -e 's/uint /unsigned int /g' ./src/flash/nor/rp2040.c
./bootstrap
./configure --disable-werror
./configure LDFLAGS=-static --disable-werror
make clean
make -j$(nproc)
INSTALLDIR="$PWD/../openocd-install/usr/local/bin"
Expand Down
2 changes: 1 addition & 1 deletion packages/linux/riscv/build-riscv-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ mkdir -p $INSTALLDIR
BUILDDIR=$(pwd)

cd riscv-gnu-toolchain
./configure --prefix=$BUILDDIR/$INSTALLDIR --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" --with-gcc-src=$BUILDDIR/gcc
./configure LDFLAGS=-static --prefix=$BUILDDIR/$INSTALLDIR --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" --with-gcc-src=$BUILDDIR/gcc
make -j$(nproc)
20 changes: 10 additions & 10 deletions packages/macos/openocd/build-openocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ sed -i -e 's/uint /unsigned int /g' ./src/flash/nor/rp2040.c
./bootstrap
# See https://github.com/raspberrypi/openocd/issues/30
# ./configure --disable-werror CAPSTONE_CFLAGS="$(pkg-config capstone --cflags | sed s/.capstone\$//)"
./configure --disable-werror
./configure LDFLAGS=-static --disable-werror
make clean
make -j$(nproc)
INSTALLDIR="$PWD/../openocd-install/usr/local/bin"
rm -rf "$PWD/../openocd-install"
DESTDIR="$PWD/../openocd-install" make install

libusbpath=($(otool -L $INSTALLDIR/openocd | grep libusb))
echo ${libusbpath[0]}
cp "${libusbpath[0]}" $INSTALLDIR/libusb-1.0.dylib
install_name_tool -change "${libusbpath[0]}" @loader_path/libusb-1.0.dylib $INSTALLDIR/openocd
libhidpath=($(otool -L $INSTALLDIR/openocd | grep libhidapi))
echo ${libhidpath[0]}
cp "${libhidpath[0]}" $INSTALLDIR/libhidapi.dylib
install_name_tool -change "${libhidpath[0]}" @loader_path/libhidapi.dylib $INSTALLDIR/openocd
install_name_tool -add_rpath @loader_path/ $INSTALLDIR/openocd
# libusbpath=($(otool -L $INSTALLDIR/openocd | grep libusb))
# echo ${libusbpath[0]}
# cp "${libusbpath[0]}" $INSTALLDIR/libusb-1.0.dylib
# install_name_tool -change "${libusbpath[0]}" @loader_path/libusb-1.0.dylib $INSTALLDIR/openocd
# libhidpath=($(otool -L $INSTALLDIR/openocd | grep libhidapi))
# echo ${libhidpath[0]}
# cp "${libhidpath[0]}" $INSTALLDIR/libhidapi.dylib
# install_name_tool -change "${libhidpath[0]}" @loader_path/libhidapi.dylib $INSTALLDIR/openocd
# install_name_tool -add_rpath @loader_path/ $INSTALLDIR/openocd
2 changes: 1 addition & 1 deletion packages/macos/riscv/build-riscv-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GDB_TARGET_FLAGS_EXTRA="--with-gmp=/opt/homebrew --with-mpfr=/opt/homebrew"
export GDB_TARGET_FLAGS_EXTRA

cd riscv-gnu-toolchain
./configure --prefix=$BUILDDIR/$INSTALLDIR --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" --with-gcc-src=$BUILDDIR/gcc
./configure LDFLAGS=-static --prefix=$BUILDDIR/$INSTALLDIR --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" --with-gcc-src=$BUILDDIR/gcc
# 4 threads, as 8 threads runs out of memory
make -j4

Expand Down

0 comments on commit d3c64dd

Please sign in to comment.