Thread overview
Building DMD on macOS arm64 - 23 Feb 2024
Feb 23
Johan
February 23

Hi all,
This took me hours to figure out and work on a robust fix (hopefully) to build.d for others.

Instructions for building DMD on macOS arm64 today:

  1. Download LDC universal package. You can use the Dlang install.sh script, and pass -arch universal. You need this package to target x86_64, because DMD can only be built into an x86_64 binary (because of x86 assembly in its source code).
  2. Apply this patch to build.d: https://github.com/dlang/dmd/pull/16239
  3. Go to DMD checkout and execute:
    HOST_DMD="<path to ldc>/bin/ldmd2" DFLAGS="-mtriple=x86_64-apple-macos11" DMD="<path to ldc>/bin/ldmd2" make

@someone: please add this info to the right places where other people might find it. I really believe that this information is crucial to attract new contributors. If I would be new to the project and wanted to contribute something simple, I would certainly have given up on it. This is not hypothetical: on Slack, Ben Jones told us he just gave up.

-Johan

February 23
On Fri, Feb 23, 2024 at 09:50:47PM +0000, Johan via Digitalmars-d wrote:
> Hi all,
>   This took me hours to figure out and work on a robust fix (hopefully) to
> `build.d` for others.
> 
> Instructions for building DMD on macOS arm64 today:
> 1. Download LDC universal package. You can use the Dlang [install.sh
> script](https://dlang.org/install.html), and pass `-arch universal`. You
> need this package to target x86_64, because DMD can only be built into an
> x86_64 binary (because of x86 assembly in its source code).
> 2. Apply this patch to build.d: https://github.com/dlang/dmd/pull/16239
> 2. Go to DMD checkout and execute:</br>
>  `HOST_DMD="<path to ldc>/bin/ldmd2" DFLAGS="-mtriple=x86_64-apple-macos11"
> DMD="<path to ldc>/bin/ldmd2" make`
> 
> @someone:  please add this info to the right places where other people might find it. I really believe that this information is crucial to attract new contributors. If I would be new to the project and wanted to contribute something simple, I would certainly have given up on it. This is not hypothetical: on Slack, Ben Jones told us he just gave up.
[...]

Why not update this page with the info you have discovered?

	https://wiki.dlang.org/Starting_as_a_Contributor#Building_from_source


T

-- 
There are two types of idiots. One type says "this is old and therefore bad", the other type says "this is new and therefore better". Beware of individuals who fall under both types. -- Crivens
February 23
Thank you for taking the time to help out with this. As H.S.Teoh replied, the wiki.dlang.org is the perfect place for it.