Skip to content

Instantly share code, notes, and snippets.

@dluman
Forked from m0sys/build_gdb.sh
Last active December 18, 2023 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dluman/d121472beef219f456417ee0b7647840 to your computer and use it in GitHub Desktop.
Save dluman/d121472beef219f456417ee0b7647840 to your computer and use it in GitHub Desktop.
Apple ARM GDB Build from Source with Python Support
#!/usr/bin/env sh
# NOTE: First, have to ignore the following warnings to make it build on M1/M2 Chip.
#
# -Wno-constant-logical-operand -Wno-format-nonliteral -Wno-self-assign
#
# To do so the above line should be appended to consts CFLAGS and CXXFLAGS
# under the 'Programs producing files for the HOST machine' section of
# the generated Makefile in dir 'build-gdb'.
# With the new updated flags clang should be able build gdb successfully with
# no more errors. Rerun "make" and then "make install" while in the "gdb-build"
# dir.
#
# Second, be sure to update 'with-python' and 'with-libgmp' flags below to appropriate
# location on personal system so gdb knows where to find them.
#
# Third, copy line 24 and 25 to terminal rc file i.e. .zshrc|.bashrc|etc ... so gdb is
# on terminal PATH.
#
# Fourth, enjoy debugging on the M1 with GDB.
export TARGET=arm-none-eabi
export PREFIX=$HOME/.local
export PATH=$PATH:$PREFIX/bin
export VERSION=12.1
export GDB=gdb-$VERSION
rm -rf $GDB
# Get archives
wget http://ftp.gnu.org/gnu/gdb/$GDB.tar.gz
# Extract archives
tar xzvf $GDB.tar.gz
mkdir build-gdb
cd build-gdb
../$GDB/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --with-python=/opt/homebrew/bin/python3 --with-libgmp-prefix=/opt/homebrew/Cellar/gmp/6.2.1_1
make
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment