Skip to content

Instantly share code, notes, and snippets.

@etiennecollin
Last active November 15, 2024 08:12
Show Gist options
  • Save etiennecollin/2fdf65a4391dfda6e6ba89789e7da0a7 to your computer and use it in GitHub Desktop.
Save etiennecollin/2fdf65a4391dfda6e6ba89789e7da0a7 to your computer and use it in GitHub Desktop.
Installing and Fixing GHDL on macOS

Installing GHDL successfully on macOS

The Problem

Homebrew installs the LLVM version of GHDL. Unfortunately, currently, there is an issue with Apple's LLVM and GHDL. Hence, we will use the mcode version of GHDL.

The Solution

Download the mcode version of GHDL from the official github repo and then replace the brew-installed LLVM version with the manually downloaded mcode version.

  1. Download ghdl with brew
    • brew install ghdl
  2. Download the mcode version of ghdl (the file named ghdl-macos-11-mcode) from the official release of GHDL
  3. Unzip the downloaded ghdl-macos-11-mcode.tgz
  4. Go to /opt/homebrew/Caskroom/ghdl/<version> (version 3.0.0 at the time of writing this) and delete the bin, include and lib directories (these contain the llvm version that is causing problems)
  5. Copy the bin, include and lib directories from the unzipped ghdl-macos-11-mcode directory to the /opt/homebrew/Caskroom/ghdl/<version> directory

We are done! You can now call the ghdl command from a new terminal shell**. For example,

ghdl --version

** You might have to go to the Privacy and Security settings of your mac to allow the execution of ghdl when you run it for the first time.

Important

If, for whatever reason, ghdl is updated by Homebrew and the issue still exists with Apple's LLVM and GHDL, then you will need to redo the process outlined in the solution.

More Info

The reason why we are not directly installing and using the mcode version from the release, is that it would require placing the downloaded files into the /bin, /include and /lib directories which can be bothersome since they are protected by the OS.

There are certainly other ways of doing it, but I found that this way is quite simple and easy to revert (simply run brew reinstall ghdl or brew uninstall ghdl).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment