Apple M1 ARM GDB Build from Source with Python Support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|# NOTE: First, have to ignore the following warnings to make it build on M1 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"|
|# 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.|
|rm -rf $GDB|
|# Get archives|
|# Extract archives|
|tar xzvf $GDB.tar.gz|
|../$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|
Mar 22, 2023
No, it's not a user-error, but just missing support for it in gdb.
The latest information appears to be in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96168 - it links to a fork which has support for macOS on aarch64, but I didn't try it yet.
Mar 22, 2023
Hey guys, I apologize for late response! This script that I posted only works for
arm-none-eabi. I haven't personally tried to compile gdb for
aarch64 since its not supported. Essentially, it's an abi issue. Check out gcc-darwin-arm64 for further support (haven't tried it yet). Thanks @JayFoxRox for the link!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@JayFoxRox Have you solved the issue with
"[...]/main": not in executable format: file format not recognized (file: main: Mach-O 64-bit executable arm64).
I'm on the same stage and cannot solve the issue.
If you have any progress, please share the solution. Currently my OS version is 13.1
Thanks in advance.