Thread overview
DMD support for Apples new silicon
Jan 10, 2021
Christian Köstlin
Jan 10, 2021
Guillaume Piolat
Jan 10, 2021
Christian Köstlin
Jan 10, 2021
Guillaume Piolat
Jan 11, 2021
Christian Köstlin
Mar 02, 2021
tastyminerals
Mar 02, 2021
Guillaume Piolat
January 10, 2021
Hi all,

are there any plans on supporting Apples new ARM silicon with DMD or would this be something for ldc?

Kind regards,
Christian
January 10, 2021
On Sunday, 10 January 2021 at 14:22:25 UTC, Christian Köstlin wrote:
> Hi all,
>
> are there any plans on supporting Apples new ARM silicon with DMD or would this be something for ldc?
>
> Kind regards,
> Christian

Hello Christian,

LDC since 1.24+ support cross-compiling to Apple Silicon.
Here is how to build for it on Big Sur.


1. Download ldc2-1.24.0-osx-x86_64.tar.xz (or later version)
   from this page: https://github.com/ldc-developers/ldc/releases

2. Unzip where you want, and put the bin/ subdirectory in your PATH envvar

   This will give you the ldc2 and dub command in your command-line, however they won't work straight away in Catalina/Big Sur because of lacking notarization.

3. (optional) In this case, in Finder, right-click + click "Open" on the bin/dub and bin/ldc2 binaries since it is not notarized software, and macOS will ask for your approval first. Once you've done that, dub and ldc2 can be used from your Terminal normally.

4. Type 'ld' in Terminal, this will install the necessary latest XCode.app if it isn't already. That is a painful 10 gb download in general. You can also install Xcode from the App Store. People target Big Sur arm64 from Catalina or Big Sur usually.

5. You can target normal x86_64 (Rosetta 2) with:

      ldc2 <params>
      dub <params>

6. If you want to target arm64, adapt the SDK path in etc/ldc2.conf with your actual Xcode macOS11.0 path, and then use -mtriple=arm64-apple-macos to cross-compile.

      ldc2 -mtriple=arm64-apple-macos <params>
      dub -a arm64-apple-macos <params>

Debugging and notarization is a whole another topic then.
January 10, 2021
On 10.01.21 15:50, Guillaume Piolat wrote:
> On Sunday, 10 January 2021 at 14:22:25 UTC, Christian Köstlin wrote:
>> Hi all,
>>
>> are there any plans on supporting Apples new ARM silicon with DMD or would this be something for ldc?
>>
>> Kind regards,
>> Christian
> 
> Hello Christian,
> 
> LDC since 1.24+ support cross-compiling to Apple Silicon.
> Here is how to build for it on Big Sur.
> 
> 
> 1. Download ldc2-1.24.0-osx-x86_64.tar.xz (or later version)
>     from this page: https://github.com/ldc-developers/ldc/releases
> 
> 2. Unzip where you want, and put the bin/ subdirectory in your PATH envvar
> 
>     This will give you the ldc2 and dub command in your command-line, however they won't work straight away in Catalina/Big Sur because of lacking notarization.
> 
> 3. (optional) In this case, in Finder, right-click + click "Open" on the bin/dub and bin/ldc2 binaries since it is not notarized software, and macOS will ask for your approval first. Once you've done that, dub and ldc2 can be used from your Terminal normally.
> 
> 4. Type 'ld' in Terminal, this will install the necessary latest XCode.app if it isn't already. That is a painful 10 gb download in general. You can also install Xcode from the App Store. People target Big Sur arm64 from Catalina or Big Sur usually.
> 
> 5. You can target normal x86_64 (Rosetta 2) with:
> 
>        ldc2 <params>
>        dub <params>
> 
> 6. If you want to target arm64, adapt the SDK path in etc/ldc2.conf with your actual Xcode macOS11.0 path, and then use -mtriple=arm64-apple-macos to cross-compile.
> 
>        ldc2 -mtriple=arm64-apple-macos <params>
>        dub -a arm64-apple-macos <params>
> 
> Debugging and notarization is a whole another topic then.

Good news!
I was hoping for support in ldc, but dmds super fast compile times would be very welcome. I guess it's more work to put an ARM backend there.

Kind regards,
Christian
January 10, 2021
On Sunday, 10 January 2021 at 16:03:53 UTC, Christian Köstlin wrote:
>
> Good news!
> I was hoping for support in ldc, but dmds super fast compile times would be very welcome. I guess it's more work to put an ARM backend there.
>
> Kind regards,
> Christian

It is indeed more work and up to the DMD leadership what should happen.

You can already switch between compilers with:
  dub --compiler dmd
  dub --compiler ldc2

so as to benefit from dmd fast build times, and then release with ldc.

Apple Silicon and Rosetta 2 are really quite fast, so you should experience pretty quick build times there anyway.
January 11, 2021
On 10.01.21 17:29, Guillaume Piolat wrote:
> On Sunday, 10 January 2021 at 16:03:53 UTC, Christian Köstlin wrote:
>>
>> Good news!
>> I was hoping for support in ldc, but dmds super fast compile times would be very welcome. I guess it's more work to put an ARM backend there.
>>
>> Kind regards,
>> Christian
> 
> It is indeed more work and up to the DMD leadership what should happen.
> 
> You can already switch between compilers with:
>    dub --compiler dmd
>    dub --compiler ldc2
> 
> so as to benefit from dmd fast build times, and then release with ldc.
> 
> Apple Silicon and Rosetta 2 are really quite fast, so you should experience pretty quick build times there anyway.
I do not have new Apple HW, but knowing that dlang is covered is a good thing!

thanks a lot!

christian

March 02, 2021
On Sunday, 10 January 2021 at 14:50:44 UTC, Guillaume Piolat wrote:
> On Sunday, 10 January 2021 at 14:22:25 UTC, Christian Köstlin wrote:
>> [...]
>
> Hello Christian,
>
> [...]

I see that there is a ldc2-1.25.1-osx-arm64.tar.xz already among https://github.com/ldc-developers/ldc/releases

So, one could use this straight away, right?
March 02, 2021
On Tuesday, 2 March 2021 at 08:01:41 UTC, tastyminerals wrote:
> On Sunday, 10 January 2021 at 14:50:44 UTC, Guillaume Piolat wrote:
>> On Sunday, 10 January 2021 at 14:22:25 UTC, Christian Köstlin wrote:
>>> [...]
>>
>> Hello Christian,
>>
>> [...]
>
> I see that there is a ldc2-1.25.1-osx-arm64.tar.xz already among https://github.com/ldc-developers/ldc/releases
>
> So, one could use this straight away, right?

Yes, it will run faster and you get to avoid the flag to target arm64.
On the minus side, you can't target x86_64 with that build IIRC, whereas the x86_64 one cross-compile to arm64.