Difference between revisions of "LDC"

From D Wiki
Jump to: navigation, search
m (ARM: -typo)
(Mention addition of Android x86/x64 support)
(60 intermediate revisions by 12 users not shown)
Line 1: Line 1:
 
{{:Compilers_Widget}}
 
{{:Compilers_Widget}}
  
The LDC project aims to provide a portable D programming language compiler with modern optimization and code generation capabilities. The compiler uses the official DMD frontends to support the latest D2 version, and relies on the [http://llvm.org LLVM Core libraries] for code generation.
+
The LDC project aims to provide a portable D programming language compiler with modern optimization and code generation capabilities. The compiler uses the official DMD frontend to support the latest D2 version and relies on the [http://llvm.org LLVM Core libraries] for code generation.
  
 
LDC is fully Open Source; the parts of the code not taken/adapted from other projects are BSD-licensed (see the [https://github.com/ldc-developers/ldc/blob/master/LICENSE LICENSE] file for details).
 
LDC is fully Open Source; the parts of the code not taken/adapted from other projects are BSD-licensed (see the [https://github.com/ldc-developers/ldc/blob/master/LICENSE LICENSE] file for details).
Line 8: Line 8:
  
 
== Getting started ==
 
== Getting started ==
* [http://forum.dlang.org/post/yxklohfbaltbcdnkpnqw@forum.dlang.org Latest (binary) release]
+
* '''[https://github.com/ldc-developers/ldc/tags Download an official release]''' or the '''[https://github.com/ldc-developers/ldc/releases/tag/CI latest CI build]''', incl. prebuilt binaries for Linux/OSX/Windows.
 
* [[Building LDC from source]]
 
* [[Building LDC from source]]
 
* [[Building and hacking LDC on Windows using MSVC]]
 
* [[Building and hacking LDC on Windows using MSVC]]
* [[Installing LDC on Gentoo]]
+
* [[Building LDC on MinGW x86]] (outdated)
* [[Using LDC]] ([[LDC-specific language changes]] — [[LDC inline assembly expressions]])
+
* [[Installing LDC on FreeBSD]]
 +
* [[Installing LDC on Gentoo]] - [https://wiki.gentoo.org/wiki/Dlang Official Dlang Gentoo overlay]
 +
* [[Installing LDC on GNU Guix]]
 +
* [[Using LDC]] ([[LDC-specific language changes]] — [[LDC inline assembly expressions]] — [[LDC inline IR]])
 +
* [[Cross-compiling with LDC]]
 +
* [[Generating WebAssembly with LDC]]
 
* [[Reporting LDC issues]] — [[LDC contributor's guide]]
 
* [[Reporting LDC issues]] — [[LDC contributor's guide]]
  
 
== Project status ==
 
== Project status ==
In general, LDC should ''work fine on most x86/x86-64 Unix-like systems'', including Linux, OS X 10.7+ and most BSD flavors. Code generation should work for other platforms supported by the LLVM MC codegen infrastructure (for example ARM), but druntime/Phobos support will most likely be lacking.
+
In general, LDC should work fine on most '''x86/x86_64''' systems, including '''Windows''', '''Linux''', '''OS X 10.7+''', '''Solaris''' and most '''BSD''' flavors. Code generation should work for other platforms supported by the LLVM MC codegen infrastructure (for example, ARM or PowerPC), but druntime/Phobos support is sometimes lacking.
  
OS X version prior to 10.7 (Lion) are currently not supported by the D2 compiler, because LLVM's support for thread-local storage depends on functionality which first appeared in 10.7.
+
=== MinGW ===
 +
x86 MinGW support was almost complete at one stage, but got neglected in favor of 'native' MSVC targets on Windows.
 +
A manageable number of adaptations (mainly in druntime) would probably suffice to support it again.
  
=== x86 Windows using MinGW ===
+
=== OS X ===
 +
* OS X version prior to 10.7 (Lion) are not supported in D2, because LLVM's thread-local storage support depends on functionality introduced in 10.7.
 +
* homebrew users can install ldc with <tt>brew install ldc</tt> for the latest stable release or <tt>brew install ldc --devel</tt> for the latest beta / release candidate.
  
* LDC 2 from Git master compiles and builds druntime/Phobos, but requires applying patches to LLVM and the MinGW runtime to fix some bugs. See [[Building LDC on MinGW x86]].
+
=== Android ===
* Hello World-style programs work (including TLS and exception handling).
+
* [https://github.com/ldc-developers/ldc/releases/tag/v1.4.0 Cross-compilation support for 32-bit ARM was added with the 1.4 release] and [https://github.com/ldc-developers/ldc/releases/tag/v1.11.0 64-bit ARM support with the 1.11 release]: [[Build D for Android|instructions on setup and building simple apps are available]].
* A small number of remaining test cases still fails, but many of the harder issues (<tt>real</tt> math precision, MS C runtime-caused problems, ABI differences) have already been solved.
+
* [https://github.com/ldc-developers/ldc/issues/2153 A handful of stdlib tests fail on 64-bit ARM, AArch64]. The other Android CPU architectures, x86 and x64, are supported too.
* Estimate for making Windows x86/MinGW a »first class« target: 1 weekend of focused work, plus a Windows CI slave.
 
  
=== x86-64 Windows using MSVC ===
+
=== ARM ===
 +
 
 +
* Get a native ARM GNU/Linux compiler from [https://github.com/ldc-developers/ldc/releases the official release page].
 +
* LDC from Git branch ltsmaster passes most tests in the test suite (no failure on ARMv7 with NEON, one failure on ARMv7 w/o NEON), similar results with the master branch too.
 +
* LDC has successfully been used to create a minimal free-standing ARM Cortex-M binary, see [[Minimal semihosted ARM Cortex-M %22Hello_World%22]].
 +
* You can use [[Building LDC runtime libraries|the new runtime cross-compilation tool]] to cross-compile also.
 +
 
 +
=== AArch64 ===
  
* LDC/LDC2 from master branch compiles without patches.
+
* Both ltsmaster and master git branches are mostly working. Small pieces of the runtime still need to be ported, such as <tt>core.stdc.stdarg.va_arg</tt>. See [https://github.com/ldc-developers/ldc/issues/2153 tracker issue] and [https://app.shippable.com/github/ldc-developers/ldc/dashboard latest CI logs] for current status.
* See [[Building and hacking LDC on Windows using MSVC]] for detailed instructions.
+
* Complete test suite can be run but still has failures, unoptimized codegen isn't currently working.
* LLVM 3.1 is required (3.0 does not work because of missing TLS support); LLVM 3.2/3.3 is preferred.
+
 
* druntime and Phobos compile but linker errors are still possible.
+
=== iOS (iPhone OS) ===
* Exception handling still needs work (see here for a first [http://article.gmane.org/gmane.comp.compilers.llvm.cvs/120422 patch]; the llvm-objdump part of the patch is [http://article.gmane.org/gmane.comp.compilers.llvm.cvs/128883 here] and was commited in LLVM 3.3)
+
 
* Contact: kai@redstar.de
+
* Compiling D code for iOS is possible now, but it is experimental and not part of LDC main. The person who ported it is too busy, so it hasn't been updated in a couple years. Help is welcome.
 +
* Full druntime/phobos support
 +
* Supports 32/64-bit ARM devices and iOS Simulator
 +
* See https://github.com/smolt/ldc-iphone-dev. The README.md explains what is available and what is missing.
 +
* Releases available: https://github.com/smolt/ldc-iphone-dev/releases
  
=== ARM ===
+
=== PowerPC 32-bit ===
  
 +
* Requires at least LLVM 3.4 because of [http://llvm.org/bugs/show_bug.cgi?id=16556 PR16556]
 +
* TLS support only for LocalExec model, see [http://llvm.org/bugs/show_bug.cgi?id=16555 PR16555]
 
* Code generation is known to work.
 
* Code generation is known to work.
* Currently affected by [http://llvm.org/bugs/show_bug.cgi?id=15293 PR15293], but a proper implementation of the C ABI will be required anyway (similar to x86_64, see Clang source for test cases).
+
* There are no compile issues in druntime and phobos.
* Some initial work has been done on druntime, but support is not yet complete – see [https://github.com/ldc-developers/ldc/issues/116 issue #116].
+
* Linux/PPC32 specific implementations are missing: core.cpuid, std.internal.math.bigintppc32, ...
 +
* More testing is needed.
 +
* Contact: kai@redstar.de
  
=== PowerPC 64-bit ===
+
=== PowerPC 64-bit Big Endian and Little Endian ===
  
* Requires LLVM trunk because of [http://llvm.org/bugs/show_bug.cgi?id=14751 PR14751], [http://llvm.org/bugs/show_bug.cgi?id=14779 PR14779], [http://llvm.org/bugs/show_bug.cgi?id=15347 PR15347], [http://llvm.org/bugs/show_bug.cgi?id=15359 PR15359], [http://llvm.org/bugs/show_bug.cgi?id=15630 PR15630] and [http://llvm.org/bugs/show_bug.cgi?id=15632 PR15632]. A solution for [http://llvm.org/bugs/show_bug.cgi?id=15580 PR15580] is currently missing (blocks linking of Dwarf debug symbols).
+
* PPC64 Big Endian requires at least LLVM 3.4. PPC64 Little Endian requires at least LLVM 3.5. Both are affected by [http://llvm.org/bugs/show_bug.cgi?id=21443 PR21443].
 
* Only Linux because LLVM does not cleanly compile on AIX.
 
* Only Linux because LLVM does not cleanly compile on AIX.
 
* Code generation is known to work.
 
* Code generation is known to work.
* Issues in druntime and phobos:
+
* There are no compile issues in druntime and phobos.
** druntime: Compiles cleanly with this [http://www.redstar.de/ldc/ppc_druntime.diff patch] applied
+
* There are still some test failures. Most of the failures are related to math precision (e.g. unit test expects 80bit reals)
** phobos: Compiles cleanly with this [http://www.redstar.de/ldc/ppc_phobos.diff patch] applied
+
* See [https://github.com/ldc-developers/ldc/issues/1313 issue #1313] for test failures on PPC64 Little Endian
** Most of these changes are already passed as upstream pull requests
+
* Linux/PPC64 specific implementations are missing: core.cpuid, std.internal.math.bigintppc64, ...
* 93% of the test suite passes - only 71 tests (out of 1036) fail. These are some modules with problems (incomplete):
+
* Multi-lib build is possible on Linux/PPC64 Big Endian.
** Unit test failures: core.math (math precision), core.thread (fiber implementation only), std.complex, std.uri, std.regexp (won't fix as removed in 2.063), std.datetime (debug only), std.file, std.bitmanip (release only with -O2/-O3), std.outbuffer, std.csv, std.math, std.getopt (math precision), ...
+
* More testing is needed.
** Seg faults: std.container (release only with -O3), std.traits, std.datetime (release only), std.stream, std.parallelism, ...
+
* Contact: kai@redstar.de
** Reason for failures are likely: math precision, thread synchronisation, frontend bugs, endian issues, bad code generation, ...
+
 
 +
=== MIPS64 ===
 +
 
 +
* Requires at least LLVM 3.6, LLVM 3.7 preferred.
 +
* LDC and druntime compile cleanly but there are some issues in phobos with std.math.
 +
* There seems to be an issue with ld and the integrated assembler: ld segfaults with binaries generated by ldc.
 +
* Known failures with LLVM 3.7: std.math (SROA assert, optimization only), std.bitmanip (assert in SelectionDAG), ...
 +
* Current target is N32/N64 ABI.
 
* Contact: kai@redstar.de
 
* Contact: kai@redstar.de
  
Line 61: Line 91:
 
LDC is an entirely community-driven effort, so all contributions are warmly welcomed. The easiest way to help with development is to write high-quality '''bug reports''' for any issues you run into. For a quick guide on what a useful report should contain, please see [[Reporting LDC issues]].
 
LDC is an entirely community-driven effort, so all contributions are warmly welcomed. The easiest way to help with development is to write high-quality '''bug reports''' for any issues you run into. For a quick guide on what a useful report should contain, please see [[Reporting LDC issues]].
  
If you are interested in getting into compiler development, anecdotal evidence suggests that hacking on LDC might be a nice first step, particularly because the LLVM backend is very comfortable to work with. To get started, just browse through the issue list, find a ticket that tickles your fancy (some of them are specifically marked as "junior jobs"), and work on a fix – and of course don't hesitate to ask for advice at the mailing list or on IRC. An '''[[LDC contributor's guide]]''' is in the works.
+
If you are interested in getting into compiler development, anecdotal evidence suggests that hacking on LDC might be a nice first step, particularly because the LLVM backend is very comfortable to work with. To get started, just browse through the issue list, find a ticket that tickles your fancy (some of them are specifically marked as "junior jobs"), and work on a fix – and of course don't hesitate to ask for advice at the mailing list or on IRC. An '''[[LDC_contributor's_guide|LDC contributor's guide]]''' is in the works. Have a look at [[LDC project ideas]] for a list of features/improvements to add to LDC.
  
 
We would also be excited to see LDC '''packages''' in more OS distributions, particular Debian and its derivatives. So, if you think you might be able to help, please just drop us a line at the development mailing list. We will actively try to make packaging as smooth as possible, but besides the fact that upstream-maintained packages are sometimes discouraged, it is hard to build good packages for a system you don't know well, so we need to rely on external contributors here.
 
We would also be excited to see LDC '''packages''' in more OS distributions, particular Debian and its derivatives. So, if you think you might be able to help, please just drop us a line at the development mailing list. We will actively try to make packaging as smooth as possible, but besides the fact that upstream-maintained packages are sometimes discouraged, it is hard to build good packages for a system you don't know well, so we need to rely on external contributors here.
 +
 +
== Presentations ==
 +
 +
LDC is an active project and the team promotes the use of D and LDC.
 +
 +
* David's [http://dconf.org/2013/talks/nadlinger.html talk about LDC] at [http://dconf.org/2013/index.html DConf 2013]: [http://dconf.org/2013/talks/nadlinger.pdf Slides] [http://archive.org/details/dconf2013-day03-talk04 Video HD] [http://youtube.com/watch?v=ntdKZWSiJdY Video SD]
 +
* Kai's [https://archive.fosdem.org/2014/schedule/event/ldccompiler/ talk about LDC] in the [https://archive.fosdem.org/2014/schedule/track/llvm/ LLVM devroom] at [https://archive.fosdem.org/2014/ FOSDEM'14]: [https://archive.fosdem.org/2014/schedule/event/ldccompiler/attachments/slides/365/export/events/attachments/ldccompiler/slides/365/FOSDEM_2014.pptx Slides (PPTX)] [https://archive.fosdem.org/2014/schedule/event/ldccompiler/attachments/slides/366/export/events/attachments/ldccompiler/slides/366/FOSDEM_2014.pdf Slides (PDF)] [http://video.fosdem.org/2014/K4401/Sunday/LDC_the_LLVMbased_D_compiler.webm Video]
 +
* Kai's [https://archive.fosdem.org/2015/schedule/event/llvm_internal_asm/ talk about the LLVM assembler] in the [https://archive.fosdem.org/2015/schedule/track/llvm_toolchain/ LLVM toolchain devroom] at [https://archive.fosdem.org/2015/ FOSDEM'15]: [https://archive.fosdem.org/2015/schedule/event/llvm_internal_asm/attachments/slides/711/export/events/attachments/llvm_internal_asm/slides/711/Nacke_Extending_Assembler.pdf Slides] [http://video.fosdem.org/2015/devroom-llvm_toolchain/internal_asm__CAM_ONLY_PARTIAL_AUDIO.mp4 Video]
 +
* David's [http://dconf.org/2015/talks/nadlinger.html talk about DRuntime] at [http://dconf.org/2015/index.html DConf 2015]: [http://dconf.org/2015/talks/nadlinger.pdf Slides] [http://dconf.org/2015/talks/nadlinger.html Video HD] [https://www.youtube.com/watch?v=rmRmfoKxMCE Video SD]
  
 
== Useful Links ==
 
== Useful Links ==

Revision as of 17:20, 17 December 2018

Compilers: OverviewDMDGDCLDC

The LDC project aims to provide a portable D programming language compiler with modern optimization and code generation capabilities. The compiler uses the official DMD frontend to support the latest D2 version and relies on the LLVM Core libraries for code generation.

LDC is fully Open Source; the parts of the code not taken/adapted from other projects are BSD-licensed (see the LICENSE file for details).

D1 is no longer supported in the current development tree; the last version supporting it can be found at the d1 Git branch.

Getting started

Project status

In general, LDC should work fine on most x86/x86_64 systems, including Windows, Linux, OS X 10.7+, Solaris and most BSD flavors. Code generation should work for other platforms supported by the LLVM MC codegen infrastructure (for example, ARM or PowerPC), but druntime/Phobos support is sometimes lacking.

MinGW

x86 MinGW support was almost complete at one stage, but got neglected in favor of 'native' MSVC targets on Windows. A manageable number of adaptations (mainly in druntime) would probably suffice to support it again.

OS X

  • OS X version prior to 10.7 (Lion) are not supported in D2, because LLVM's thread-local storage support depends on functionality introduced in 10.7.
  • homebrew users can install ldc with brew install ldc for the latest stable release or brew install ldc --devel for the latest beta / release candidate.

Android

ARM

AArch64

  • Both ltsmaster and master git branches are mostly working. Small pieces of the runtime still need to be ported, such as core.stdc.stdarg.va_arg. See tracker issue and latest CI logs for current status.
  • Complete test suite can be run but still has failures, unoptimized codegen isn't currently working.

iOS (iPhone OS)

  • Compiling D code for iOS is possible now, but it is experimental and not part of LDC main. The person who ported it is too busy, so it hasn't been updated in a couple years. Help is welcome.
  • Full druntime/phobos support
  • Supports 32/64-bit ARM devices and iOS Simulator
  • See https://github.com/smolt/ldc-iphone-dev. The README.md explains what is available and what is missing.
  • Releases available: https://github.com/smolt/ldc-iphone-dev/releases

PowerPC 32-bit

  • Requires at least LLVM 3.4 because of PR16556
  • TLS support only for LocalExec model, see PR16555
  • Code generation is known to work.
  • There are no compile issues in druntime and phobos.
  • Linux/PPC32 specific implementations are missing: core.cpuid, std.internal.math.bigintppc32, ...
  • More testing is needed.
  • Contact: kai@redstar.de

PowerPC 64-bit Big Endian and Little Endian

  • PPC64 Big Endian requires at least LLVM 3.4. PPC64 Little Endian requires at least LLVM 3.5. Both are affected by PR21443.
  • Only Linux because LLVM does not cleanly compile on AIX.
  • Code generation is known to work.
  • There are no compile issues in druntime and phobos.
  • There are still some test failures. Most of the failures are related to math precision (e.g. unit test expects 80bit reals)
  • See issue #1313 for test failures on PPC64 Little Endian
  • Linux/PPC64 specific implementations are missing: core.cpuid, std.internal.math.bigintppc64, ...
  • Multi-lib build is possible on Linux/PPC64 Big Endian.
  • More testing is needed.
  • Contact: kai@redstar.de

MIPS64

  • Requires at least LLVM 3.6, LLVM 3.7 preferred.
  • LDC and druntime compile cleanly but there are some issues in phobos with std.math.
  • There seems to be an issue with ld and the integrated assembler: ld segfaults with binaries generated by ldc.
  • Known failures with LLVM 3.7: std.math (SROA assert, optimization only), std.bitmanip (assert in SelectionDAG), ...
  • Current target is N32/N64 ABI.
  • Contact: kai@redstar.de

Contributing

LDC is an entirely community-driven effort, so all contributions are warmly welcomed. The easiest way to help with development is to write high-quality bug reports for any issues you run into. For a quick guide on what a useful report should contain, please see Reporting LDC issues.

If you are interested in getting into compiler development, anecdotal evidence suggests that hacking on LDC might be a nice first step, particularly because the LLVM backend is very comfortable to work with. To get started, just browse through the issue list, find a ticket that tickles your fancy (some of them are specifically marked as "junior jobs"), and work on a fix – and of course don't hesitate to ask for advice at the mailing list or on IRC. An LDC contributor's guide is in the works. Have a look at LDC project ideas for a list of features/improvements to add to LDC.

We would also be excited to see LDC packages in more OS distributions, particular Debian and its derivatives. So, if you think you might be able to help, please just drop us a line at the development mailing list. We will actively try to make packaging as smooth as possible, but besides the fact that upstream-maintained packages are sometimes discouraged, it is hard to build good packages for a system you don't know well, so we need to rely on external contributors here.

Presentations

LDC is an active project and the team promotes the use of D and LDC.

Useful Links