D language on Apple Silicon

Using D programming language on Apple Silicon

Created: by Pradeep Gowda Updated: Aug 23, 2023 Tagged: dlang · literate-programming

While trying to install Literate using the homebrew version of the D language compiler, I ran into the issue of dub package manager expecting x86_64 architecture.

It was not clear from the DMD (the default implementation) download page if the dmd compiler works for arm64 (Apple Silicon) or not.

So, I ended up using the LLVM D compiler (aka ldc2) from here.

tar xvf ldc2-1.33.0-osx-arm64.tar.xz
mv ldc2-1.33.0-osx-arm64 ~/ldc2
export PATH=$HOME/ldc2/bin:$PATH

After this I was able to compile Literate as usual, since ldc provides its own dub.

dub --root=lit/tangle build

While DMD is where the architects of the language do their primary development, LDC is considered to be more performant. This was a good occassion to learn how to use LDC.