How to Build GHDL on Apple M
This post is also a note to myself since I am using GHDL also on Apple M4.
The steps below are tested with, at the time of writing this post, the latest GHDL sources (GHDL 6.0.0-dev@b4f5a1e) on Apple M4 running the latest macOS (15.6).
To build GHDL, GNAT, LLVM and libbacktrace is required.
The steps below do not pay attention to the working directory. Run the commands in appropriate directories.
Install GNAT
Install Alire with GetAda:
$ curl --proto '=https' -sSf https://www.getada.dev/init.sh | sh
This will install the latest Alire (2.1.0) and modify ~/.profile to add ~/.getada/bin to your PATH.
Restart your shell, and check alr:
$ alr --version
alr 2.1.0
Install GNAT with Alire. I am using the latest gnat_native (15.1.2) and gprbuild (25.0.1):
$ alr toolchain --select
Add GNAT’s binaries to your PATH, add to your ~/.zshrc something similar to this, check ~/.local/share/alire/toolchains directory:
export PATH="/Users/mete/.local/share/alire/toolchains/gnat_native_15.1.2_60748c54/bin:$PATH"
Restart your shell, and check gnat:
$ which gnat
/Users/mete/.local/share/alire/toolchains/gnat_native_14.2.1_cc5517d6/bin/gnat
$ gnat
GNAT 15.0.1 20250418 (prerelease)
...
Install LLVM
On Apple M silicon, LLVM or GCC backend is required. I use LLVM.
Attention: this changes the compiler already installed in the system.
GHDL requires llvm-config, but macOS does not supply one with the existing, already installed LLVM on macOS. So I install the latest LLVM (20) with brew.
$ brew install llvm
In order to use this LLVM, add following to your ~/.zshrc:
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib $LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include $CPPFLAGS"
export CC=clang
export CXX=clang++
export LD=ld.lld
export AR=llvm-ar
export RANLIB=llvm-ranlib
Restart your shell, and check llvm-config:
$ which llvm-config
/opt/homebrew/opt/llvm/bin/llvm-config
$ llvm-config --version
20.1.8
Build libbacktrace
Build libbacktrace to be linked with GHDL:
$ git clone https://github.com/ianlancetaylor/libbacktrace
$ cd libbacktrace
$ ./configure
$ make
libbacktrace.a should be under .libs directory:
$ ls .libs
libbacktrace.a libbacktrace.la libbacktrace.lai
There is no need to install (no need to run make install).
Build GHDL
$ git clone https://github.com/ghdl/ghdl.git
$ ./configure --with-llvm-config --with-backtrace-lib=<PATH_TO_LIBBACKTRACE>/.libs/libbacktrace.a
$ make -j`sysctl -n hw.ncpu`
$ sudo make install
(sysctl -n hw.ncpu returns the number of cores in the system)
If you want to run configure again, do not forget to run make distclean
first.
Check ghdl:
$ ghdl -v
GHDL 6.0.0-dev (5.1.1.r37.gb4f5a1e93) [Dunoon edition]
Compiled with GNAT Version: 15.0.1 20250418 (prerelease)
llvm 20.1.8 code generator
Written by Tristan Gingold.
...
The (5.1.1.r37) line is automatically generated from the last git tag (using git describe), it can be ignored.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.