Difference between revisions of "Compilers"

From D Wiki
Jump to: navigation, search
(Package and/or binary availability, by platform and compiler)
(Experimental compilers and forks: Add dscripten)
(46 intermediate revisions by 15 users not shown)
Line 5: Line 5:
 
<td style="width:33%; vertical-align: top; padding: 10px 10px; background: #f9f9f9; border: 1px solid #ccc; border-top: 1px solid #eee; border-bottom: 2px solid #999;">
 
<td style="width:33%; vertical-align: top; padding: 10px 10px; background: #f9f9f9; border: 1px solid #ccc; border-top: 1px solid #eee; border-bottom: 2px solid #999;">
 
= [[DMD|DMD &raquo;]] =
 
= [[DMD|DMD &raquo;]] =
'''Digital Mars D compiler''' <br/>The formal D compiler.
+
'''Digital Mars D compiler''' <br/>The official reference D compiler.
 
<div style="text-align: right;">[[DMD|DMD Portal &raquo;]]</div>
 
<div style="text-align: right;">[[DMD|DMD Portal &raquo;]]</div>
 
</td>
 
</td>
Line 17: Line 17:
 
= [[GDC|GDC &raquo;]] =
 
= [[GDC|GDC &raquo;]] =
 
'''GCC D compiler'''<br/>
 
'''GCC D compiler'''<br/>
Fast and open source.
+
The DMD compiler front end coupled with the GCC compiler back end. Fast and open source.
 
<div style="text-align: right;">[[GDC|GDC Portal &raquo;]]</div>
 
<div style="text-align: right;">[[GDC|GDC Portal &raquo;]]</div>
 
</td>
 
</td>
Line 24: Line 24:
 
= [[LDC|LDC &raquo;]] =
 
= [[LDC|LDC &raquo;]] =
 
'''LLVM D compiler'''<br/>
 
'''LLVM D compiler'''<br/>
Fast and open source.
+
The DMD compiler front end coupled with the LLVM compiler back end. Fast and open source.
 
<div style="text-align: right;">[[LDC|LDC Portal &raquo;]]</div>
 
<div style="text-align: right;">[[LDC|LDC Portal &raquo;]]</div>
 
</td>
 
</td>
Line 30: Line 30:
 
</tr>
 
</tr>
 
</table>
 
</table>
 
 
Also see: [[Experimental compilers]]
 
 
  
 
== Which compiler should I use? ==
 
== Which compiler should I use? ==
If you're a beginner DMD is the recommended choice, as it is the implementation closest to the D Language Specification. Otherwise it depends on what you need, what platforms you intend to develop for, and your personal preferences. GDC and LDC both generate substantially faster binaries than DMD.
+
For beginners, DMD is the recommended choice, as it is the implementation closest to the D Language Specification. Otherwise, the best choice depends on the project's needs, the target platforms, and personal preferences. GDC and LDC both generate substantially faster binaries than DMD.
  
 
== Comparison ==
 
== Comparison ==
Line 48: Line 44:
 
|'''Platforms'''
 
|'''Platforms'''
 
|
 
|
 +
*Windows
 
*Linux
 
*Linux
*Mac
+
*OS X
 
*FreeBSD
 
*FreeBSD
*Win
 
 
|
 
|
 +
*Windows (alpha)
 
*Linux
 
*Linux
*Mac
+
*OS X (untested)
*FreeBSD
+
*FreeBSD (untested)
*Win
 
 
|
 
|
 +
*Windows
 
*Linux
 
*Linux
*Mac
+
*OS X
 
*FreeBSD
 
*FreeBSD
*Win
+
*OpenSolaris
 +
*iOS (alpha)
 +
*Android
 
|---
 
|---
 +
 
|'''Architectures'''
 
|'''Architectures'''
 
|
 
|
Line 68: Line 68:
 
* amd64
 
* amd64
 
|
 
|
 +
Complete (runtime / standard library) support:
 
* i386
 
* i386
 
* amd64
 
* amd64
 +
* x32
 +
* armel
 +
* armhf
 +
 +
Partial or bare-metal only support (packages for gdc in [https://packages.debian.org/sid/gdc-5 debian]):
 +
* alpha
 +
* arm64 (aarch64)
 +
* hppa
 +
* hurd-i386
 +
* kfreebsd-amd64
 +
* kfreebsd-i386
 +
* m68k
 +
* mips
 +
* mipsel
 +
* ppc
 +
* pcc64
 +
* ppc64el
 +
* s390x
 +
* sparc64
 
|
 
|
 +
Complete (runtime / standard library) support:
 
* i386
 
* i386
 
* amd64
 
* amd64
 +
* armel
 +
* armhf
 +
 +
Near-complete support:
 +
* arm64 (aarch64)
 
* ppc
 
* ppc
 
* ppc64
 
* ppc64
 +
* ppc64el
 +
* mips64
 +
 +
Partial or bare-metal only support:
 +
* mips
 +
* s390x
 
|---
 
|---
 
|'''Distribution'''
 
|'''Distribution'''
| Source, multi-platform source/binary archive, multi-platform installer ([https://github.com/jacob-carlborg/dvm DVM]),Windows installer, packages for OS X (.dmg), Debian/Ubuntu (.deb), Fedora (.rpm), OpenSUSE (.rpm), Debian/Ubuntu repository via http://d-apt.sourceforge.net, OS-X homebrew and macports repositories.
+
|
| Source, Windows binary archive, Debian/Ubuntu repository
+
*Source
| Source, Linux / OS X binary archive, Debian/Ubuntu repository, Fedora repository, Gentoo repository
+
*Multi-platform source/binary archive
 +
*Multi-platform installer ([https://github.com/jacob-carlborg/dvm DVM])
 +
*Windows installer
 +
*OS X package (.dmg)
 +
*Debian/Ubuntu package (.deb)
 +
*Fedora package (.rpm)
 +
*OpenSUSE (.rpm) package
 +
*Debian/Ubuntu repository via http://d-apt.sourceforge.net
 +
*OS-X homebrew and macports repositories
 +
*Nix/NixOS package (for NixOS, other Linux and OS X)
 +
|
 +
*Source
 +
*Windows / Linux binary archive
 +
*Debian/Ubuntu repository
 +
*Gentoo repository
 +
*Archlinux repository
 +
|
 +
*Source
 +
*Windows / Linux / OS X binary archive
 +
*Debian/Ubuntu repository
 +
*Fedora repository
 +
*Gentoo repository
 +
*FreeBSD repository
 +
*[[Installing_LDC_on_GNU_Guix|GNU Guix]]
 +
*Nix/NixOS package (for NixOS, other Linux and OS X)
 
|---
 
|---
 
|'''Backend'''
 
|'''Backend'''
| [https://github.com/D-Programming-Language/dmd/tree/master/src/backend DMD] ([http://digitalmars.com/download/freecompiler.html DMC] fork)
+
| [https://github.com/dlang/dmd/tree/master/src/dmd/backend DMD] ([http://digitalmars.com/download/freecompiler.html DMC] fork)
 
| [http://gcc.gnu.org/ GCC]
 
| [http://gcc.gnu.org/ GCC]
 
| [http://llvm.org/ LLVM]
 
| [http://llvm.org/ LLVM]
 
|---
 
|---
 
|'''License'''
 
|'''License'''
| Frontend: GPL 1 or later / Artistic License
+
| Boost
Backend: [https://github.com/D-Programming-Language/dmd/blob/master/src/backendlicense.txt custom]
 
 
| GPL 3 or later
 
| GPL 3 or later
 
| LDC-specific code: 3-clause BSD
 
| LDC-specific code: 3-clause BSD
 
|---
 
|---
 
|'''Inline assembler'''
 
|'''Inline assembler'''
| Yes, x86
+
|
| Yes, GCC-style only (all targets)
+
* DMD Intel-like syntax (i386/amd64)
| Yes, D-style (x86) and GCC-style (all targets)
+
|
 +
* GCC syntax (all targets)
 +
|
 +
* DMD Intel-like syntax (i386/amd64)
 +
* GCC syntax (all targets)
 +
* [[LDC inline IR|LLVM inline IR]]
 
|---
 
|---
 
|'''SIMD'''
 
|'''SIMD'''
Line 101: Line 161:
 
| Partial (?)
 
| Partial (?)
 
| Partial (?)
 
| Partial (?)
 +
|---
 +
|'''Phobos as a shared library'''
 +
|
 +
* Linux
 +
* FreeBSD ?
 +
|
 +
|
 +
* Linux
 +
|---
 +
|'''Building D code as shared library'''
 +
|
 +
* Linux
 +
* FreeBSD ?
 +
* Windows ?
 +
|
 +
|
 +
* Linux
 +
* OS X
 +
|---
 +
|'''Dynamic loading of D shared libraries'''
 +
|
 +
* Linux
 +
|
 +
|
 +
* Linux
 +
* OS X
 
|---
 
|---
 
!colspan="4" align="center"|<br/>'''Linux specific'''
 
!colspan="4" align="center"|<br/>'''Linux specific'''
Line 119: Line 205:
 
|---
 
|---
 
|'''Object file format'''
 
|'''Object file format'''
| OMF (32) / COFF (64)
+
| OMF (32) / COFF (32 & 64)
 
| COFF
 
| COFF
 
| COFF
 
| COFF
Line 125: Line 211:
  
 
==Package and/or binary availability, by platform and compiler==
 
==Package and/or binary availability, by platform and compiler==
 
Version number is given in brackets. Many of the manual download links have 10s of versions available, only the most recent few are listed here.
 
  
 
Some unofficial repositories and downloads are listed here, but of course many more do exist. With a little searching, you may be able to find something more up to date for your chosen OS.
 
Some unofficial repositories and downloads are listed here, but of course many more do exist. With a little searching, you may be able to find something more up to date for your chosen OS.
Line 142: Line 226:
 
!Windows
 
!Windows
 
|
 
|
*[http://dlang.org/download.html Manual download] (2.068.0)
+
*[http://dlang.org/download.html Manual download]
*[https://chocolatey.org Chocolatey] (2.067.0, 2.067.1 available awaiting moderation)
+
*[https://chocolatey.org Chocolatey]
 
|
 
|
*[http://gdcproject.org/downloads Manual download] (4.9.2)
+
*[http://gdcproject.org/downloads Manual download]
 
|
 
|
*[https://github.com/ldc-developers/ldc/releases Manual download] (0.15.1, 0.15.2-beta2)
+
*[https://github.com/ldc-developers/ldc/releases Manual download]
 
|---
 
|---
 
!OS X
 
!OS X
 
|
 
|
*[http://brew.sh Homebrew] (2.068.0)
+
*[http://brew.sh Homebrew]
*[https://www.macports.org MacPorts] (2.067.0)
+
*[https://www.macports.org MacPorts]
*[http://dlang.org/download.html Manual download] (2.068.0)
+
*[https://nixos.org/nixos/packages.html#dmd Nix]
 +
*[http://dlang.org/download.html Manual download]
 
|
 
|
 
|
 
|
*[http://brew.sh Homebrew] (0.15.1, 0.15.2-beta2)
+
*[http://brew.sh Homebrew]
*[https://github.com/ldc-developers/ldc/releases Manual download] (0.15.1, 0.15.2-beta2)
+
*[https://nixos.org/nixos/packages.html#ldc Nix]
 +
*[https://github.com/ldc-developers/ldc/releases Manual download]
 +
|---
 +
!iOS
 +
|
 +
|
 +
|
 +
*[https://github.com/smolt/ldc-iphone-dev/releases Manual download]
 +
|---
 +
!Android
 +
|
 +
|
 +
|
 +
*[https://github.com/ldc-developers/ldc/releases Manual download]
 +
*[[Build D for Android|Instructions on setup]], including a native package
 
|---
 
|---
 
!Linux (generic)
 
!Linux (generic)
 
|
 
|
*[http://dlang.org/download.html Manual download] (2.068.0)
+
*[http://dlang.org/download.html Manual download]
 
|
 
|
*[http://gdcproject.org/downloads Manual download] (4.9.2)
+
*[http://gdcproject.org/downloads Manual download]
 
|
 
|
*[https://github.com/ldc-developers/ldc/releases Manual download] (0.15.1, 0.15.2-beta2)
+
*[https://github.com/ldc-developers/ldc/releases Manual download]
 +
*[[LDC cross-compilation for ARM GNU/Linux|Source]] (ARM/Linux cross-compiler)
 
|---
 
|---
 
!Cross-platform
 
!Cross-platform
Line 177: Line 277:
 
!Debian
 
!Debian
 
|
 
|
*[http://dlang.org/download.html Manual download] (2.067.1)
+
*[http://dlang.org/download.html Manual download]
*[http://d-apt.sourceforge.net APT repository] (2.067.1)
+
*[http://d-apt.sourceforge.net APT repository]
 
|
 
|
*Stable/Testing (4.8.4, 4.9.2)
+
* [https://packages.debian.org/jessie/gdc stable]
*Unstable (4.8.4, 4.9.2, 5.1.1)
+
* [https://packages.debian.org/stretch/gdc testing]
*Experimental (5.x.x)
+
* [https://packages.debian.org/sid/gdc unstable]
 
|
 
|
*Stable/Testing/Unstable (0.14.0)
+
* [https://packages.debian.org/jessie/ldc stable]
*Experimental (0.15.1)
+
* [https://packages.debian.org/sid/ldc unstable]
 
|---
 
|---
 
!Ubuntu
 
!Ubuntu
 
|
 
|
*[http://dlang.org/download.html Manual download] (2.067.1)
+
*[http://dlang.org/download.html Manual download]
*[http://d-apt.sourceforge.net APT repository] (2.067.1)
+
*[http://d-apt.sourceforge.net APT repository]
 
|
 
|
*14.04 (4.8.2)
+
[http://packages.ubuntu.com/search?keywords=ldc gdc]
*14.10 (4.8.3, 4.9.1)
 
*15.04 (4.8.4, 4.9.2)
 
 
|
 
|
*14.10 (0.14.0)
+
[http://packages.ubuntu.com/search?keywords=ldc ldc]
 
|---
 
|---
 
!Fedora
 
!Fedora
 
|
 
|
*[http://dlang.org/download.html Manual download] (2.067.1)
+
*[http://dlang.org/download.html Manual download]
*20/21 [https://build.opensuse.org/package/show?project=home%3Azhonghuaren&package=dmd Unofficial repository] (2.066.1)
 
 
|
 
|
 
|
 
|
*20 (between 0.13.0-alpha1 and 0.13.0-alpha2)
+
See https://apps.fedoraproject.org/packages/ldc
*21 (0.13.0)
 
*22 (0.15.1)
 
*Rawhide (0.15.2-beta1)
 
 
|---
 
|---
 
!OpenSuse
 
!OpenSuse
 
|
 
|
*[https://build.opensuse.org/project/show/devel:languages:D devel:languages:D] (2.068.0)
+
*[https://build.opensuse.org/package/show/devel:languages:D/dmd devel:languages:D]
<!--*[https://build.opensuse.org/project/show/home:marc_schuetz:branches:devel:languages:D home:marc_schuetz] (2.067.0)-->
 
 
|
 
|
 
|
 
|
*[https://build.opensuse.org/project/show/devel:languages:D devel:languages:D] (0.15.1)
+
*[https://build.opensuse.org/project/show/devel:languages:D devel:languages:D]
*[https://build.opensuse.org/project/show/home:marc_schuetz:branches:devel:languages:D home:marc_schuetz] (0.15.2-beta2)
+
*[https://build.opensuse.org/project/show/home:marc_schuetz:branches:devel:languages:D home:marc_schuetz]
 
|---
 
|---
 
!CentOS
 
!CentOS
 
|
 
|
*[http://dlang.org/download.html Manual download] (2.067.1)
+
*[http://dlang.org/download.html Manual download]
 
|
 
|
 
|
 
|
Line 226: Line 319:
 
!Arch Linux
 
!Arch Linux
 
|
 
|
*Community (2.068.0)
+
*Community
 
|
 
|
*Community (5.2.0)
+
*Community
 +
*AUR ([https://aur.archlinux.org/packages/gdc-git/ git HEAD])
 
|
 
|
*Community (0.15.1)
+
*Community
 +
*AUR ([https://aur.archlinux.org/packages/ldc-git/ git HEAD])
 
|---
 
|---
 
!Gentoo
 
!Gentoo
Line 237: Line 332:
 
!FreeBSD
 
!FreeBSD
 
|
 
|
*[http://dlang.org/download.html Manual download] (2.067.1)
+
*[http://dlang.org/download.html Manual download]
*Ports (2.067.0)
+
*Ports
 
|
 
|
 
|
 
|
 +
*[https://www.freshports.org/lang/ldc Ports]
 
|}
 
|}
  
 +
== Experimental compilers and forks ==
 +
 +
* [[SDC|SDC (Stupid D Compiler)]] - from-scratch D compiler implementation, written in idiomatic D.
 +
* [https://github.com/smolt/ldc-iphone-dev LDC for iOS] - LDC-based toolkit for cross-compiling to iOS
 +
* [https://github.com/joakim-noah/android/releases D for Android] - Toolkit for cross-compiling to Android (x86 using DMD and ARM using LDC)
 +
* [https://github.com/Syniurge/Calypso Calypso] - LDC fork which provides direct Clang interoperability, allowing the use of C headers directly.
 +
* DCompute ([[LDC CUDA and SPIRV]]) - Library and LDC fork to "target CUDA and SPIR to enable hassle free native execution on the gpu" -upstreamed into LDC
 +
* [https://github.com/yebblies/dmd/tree/microd MicroD] - DMD fork which outputs C source code instead of object files
 +
* [https://github.com/adamdruppe/dtojs dtojs] - DMD fork which outputs JavaScript source code instead of object files
 +
* [[DIL]] - D compiler written in D2/Tango (inactive project)
 +
* [https://github.com/Ace17/dscripten dscripten] - LDC/emscripten-based toolchain for compiling D to asm.js / WebAssembly
 +
 +
Category page: [[Experimental compilers]]
  
 
[[Category:Compiler]]
 
[[Category:Compiler]]

Revision as of 09:33, 20 May 2018

Compilers: OverviewDMDGDCLDC

DMD »

Digital Mars D compiler
The official reference D compiler.

GDC »

GCC D compiler
The DMD compiler front end coupled with the GCC compiler back end. Fast and open source.

LDC »

LLVM D compiler
The DMD compiler front end coupled with the LLVM compiler back end. Fast and open source.

Which compiler should I use?

For beginners, DMD is the recommended choice, as it is the implementation closest to the D Language Specification. Otherwise, the best choice depends on the project's needs, the target platforms, and personal preferences. GDC and LDC both generate substantially faster binaries than DMD.

Comparison

DMD GDC LDC
Platforms
  • Windows
  • Linux
  • OS X
  • FreeBSD
  • Windows (alpha)
  • Linux
  • OS X (untested)
  • FreeBSD (untested)
  • Windows
  • Linux
  • OS X
  • FreeBSD
  • OpenSolaris
  • iOS (alpha)
  • Android
Architectures
  • i386
  • amd64

Complete (runtime / standard library) support:

  • i386
  • amd64
  • x32
  • armel
  • armhf

Partial or bare-metal only support (packages for gdc in debian):

  • alpha
  • arm64 (aarch64)
  • hppa
  • hurd-i386
  • kfreebsd-amd64
  • kfreebsd-i386
  • m68k
  • mips
  • mipsel
  • ppc
  • pcc64
  • ppc64el
  • s390x
  • sparc64

Complete (runtime / standard library) support:

  • i386
  • amd64
  • armel
  • armhf

Near-complete support:

  • arm64 (aarch64)
  • ppc
  • ppc64
  • ppc64el
  • mips64

Partial or bare-metal only support:

  • mips
  • s390x
Distribution
  • Source
  • Multi-platform source/binary archive
  • Multi-platform installer (DVM)
  • Windows installer
  • OS X package (.dmg)
  • Debian/Ubuntu package (.deb)
  • Fedora package (.rpm)
  • OpenSUSE (.rpm) package
  • Debian/Ubuntu repository via http://d-apt.sourceforge.net
  • OS-X homebrew and macports repositories
  • Nix/NixOS package (for NixOS, other Linux and OS X)
  • Source
  • Windows / Linux binary archive
  • Debian/Ubuntu repository
  • Gentoo repository
  • Archlinux repository
  • Source
  • Windows / Linux / OS X binary archive
  • Debian/Ubuntu repository
  • Fedora repository
  • Gentoo repository
  • FreeBSD repository
  • GNU Guix
  • Nix/NixOS package (for NixOS, other Linux and OS X)
Backend DMD (DMC fork) GCC LLVM
License Boost GPL 3 or later LDC-specific code: 3-clause BSD
Inline assembler
  • DMD Intel-like syntax (i386/amd64)
  • GCC syntax (all targets)
  • DMD Intel-like syntax (i386/amd64)
  • GCC syntax (all targets)
  • LLVM inline IR
SIMD Partial (?) Partial (?) Partial (?)
Phobos as a shared library
  • Linux
  • FreeBSD ?
  • Linux
Building D code as shared library
  • Linux
  • FreeBSD ?
  • Windows ?
  • Linux
  • OS X
Dynamic loading of D shared libraries
  • Linux
  • Linux
  • OS X

Linux specific
Object file format ELF ELF ELF

Mac specific
Object file format Mach-O Mach-O Mach-O

Windows specific
Object file format OMF (32) / COFF (32 & 64) COFF COFF

Package and/or binary availability, by platform and compiler

Some unofficial repositories and downloads are listed here, but of course many more do exist. With a little searching, you may be able to find something more up to date for your chosen OS.

Very old compilers are (mostly) omitted, as they are unlikely to be of interest to users.


Platform
Compiler
DMD GDC LDC
Windows
OS X
iOS
Android
Linux (generic)
Cross-platform
  • DVM (Any version)
Distribution-specific packages
Debian
Ubuntu

gdc

ldc

Fedora

See https://apps.fedoraproject.org/packages/ldc

OpenSuse
CentOS
Arch Linux
  • Community
Gentoo see https://wiki.gentoo.org/wiki/Dlang
FreeBSD

Experimental compilers and forks

  • SDC (Stupid D Compiler) - from-scratch D compiler implementation, written in idiomatic D.
  • LDC for iOS - LDC-based toolkit for cross-compiling to iOS
  • D for Android - Toolkit for cross-compiling to Android (x86 using DMD and ARM using LDC)
  • Calypso - LDC fork which provides direct Clang interoperability, allowing the use of C headers directly.
  • DCompute (LDC CUDA and SPIRV) - Library and LDC fork to "target CUDA and SPIR to enable hassle free native execution on the gpu" -upstreamed into LDC
  • MicroD - DMD fork which outputs C source code instead of object files
  • dtojs - DMD fork which outputs JavaScript source code instead of object files
  • DIL - D compiler written in D2/Tango (inactive project)
  • dscripten - LDC/emscripten-based toolchain for compiling D to asm.js / WebAssembly

Category page: Experimental compilers