Difference between revisions of "LDC"

From D Wiki
Jump to: navigation, search
(ARM)
m (Project status: Update wrt. macOS arm64 and Android)
 
(59 intermediate revisions by 13 users not shown)
Line 8: Line 8:
  
 
== Getting started ==
 
== Getting started ==
* [http://forum.dlang.org/post/mailman.990.1370788529.13711.digitalmars-d-ldc@puremagic.com 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/macOS/Windows/Android/FreeBSD.
 
* [[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]]
+
* [[Using LDC]] ([[LDC-specific language changes]] — [[LDC inline assembly expressions]] — [[LDC inline IR]])
* [[Using LDC]] ([[LDC-specific language changes]] — [[LDC inline assembly expressions]])
+
* [[Cross-compiling 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.
 
  
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.
+
'''NOTE''': As Wiki pages usually don't keep up with development, the [https://github.com/ldc-developers/ldc/blob/master/CHANGELOG.md changelog] might be of use to check for recent developments and newly conquered targets.
  
=== x86 Windows using MinGW ===
+
=== Architectures ===
  
* LDC 2 from Git master compiles and builds druntime/Phobos, but requires recent MinGW and LLVM versions for a few critical bug fixes. See [[Building LDC on MinGW x86]].
+
{| class="wikitable"
* Hello World-style programs work (including TLS and exception handling).
+
|-
* 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.
+
! x86 / x86_64
* Estimate for making Windows x86/MinGW a »first class« target: 1 weekend of focused work, plus a Windows CI slave.
+
| Fine, CI-tested.
 +
|-
 +
! 64-bit ARM
 +
| Basically fine, a few testsuite failures remain (for non-Apple OS). See [https://github.com/ldc-developers/ldc/issues/2153 tracker issue] for ~current status.
 +
|-
 +
! 32-bit ARM
 +
| Should be okay-ish, not really CI-tested though (Android ARMv7-A somewhat is). E.g., see [https://github.com/ldc-developers/ldc/issues/2810 tracker issue] and [[Minimal semihosted ARM Cortex-M %22Hello World%22]].
 +
|-
 +
! WebAssembly
 +
| Should work fine; currently limited to <tt>-betterC</tt> (lacking druntime/Phobos support). See [[Generating WebAssembly with LDC]] for a quick how-to.
 +
|-
 +
! PowerPC
 +
| Incomplete; has been worked on (32-bit, 64-bit big & little endian) but not touched/tested in years. E.g., see [https://github.com/ldc-developers/ldc/issues/1313 tracker issue].
 +
|-
 +
! MIPS
 +
| Incomplete; has been worked on but not really touched/tested in years. E.g., see [https://github.com/ldc-developers/ldc/issues/2995 tracker issue].
 +
|-
 +
! Others
 +
| Basic code generation should work as long as there's an LLVM backend, and simple <tt>-betterC</tt> code might just work.<br>druntime/Phobos support is most likely lacking (and probably requires a new <tt>version</tt> predefined by the compiler).<br>Proper C(++) interop most likely requires a new <tt>TargetABI</tt> implementation in the compiler.
 +
|-
 +
|}
  
=== x86-64 Windows using MSVC ===
+
=== Operating Systems ===
  
* LDC2 from master branch compiles without patches.
+
{| class="wikitable"
* See [[Building and hacking LDC on Windows using MSVC]] for detailed instructions.
+
|-
* LLVM 3.1 is required (3.0 does not work because of missing TLS support); LLVM 3.2/3.3 is preferred.
+
! Linux
* druntime and Phobos compile but linker errors are still possible.
+
| glibc environments are working fine & CI-tested (on i686/x86_64 and AArch64).<br>musl/uClibc should be usable but aren't tested.
* Exception handling still needs work. You have to use LLVM 3.4 head and this [http://www.redstar.de/ldc/win64eh_all_20130524.diff patch] to LLVM.
+
|-
* Contact: kai@redstar.de
+
! macOS
 +
| Fine, CI-tested on arm64 and x86_64. Requires macOS v10.7+ for native TLS. 32-bit i686 support was dropped with LDC v1.15.
 +
|-
 +
! Windows
 +
| Fine for 'native' MSVC (Microsoft Visual C++) environments, CI-tested on Win32 & Win64.<br>'''NOTE''': LDC uses 64-bit double precision for <tt>real</tt>, unlike DMD, for MSVC <tt>long double</tt> compatibility.<br>32-bit MinGW support was almost complete at one stage but got neglected; a manageable number of adaptations (mainly in druntime) would probably suffice to support it again.
 +
|-
 +
! Android
 +
| Should be usable for ARMv7-A / AArch64 / i686 / x86_64, only rudimentarily CI-tested though (cross-compilability).<br>Check out the [[Build D for Android]] article for how to get started.
 +
|-
 +
! iOS / tvOS /<br>watchOS
 +
| Should be usable with 64-bit ARM (all druntime/Phobos unittests pass on iOS with LDC v1.21), only rudimentarily CI-tested though.<br>The [https://github.com/ldc-developers/ldc/releases/latest official] prebuilt macOS package supports cross-compilation out-of-the-box, just use <tt>-mtriple=arm64-apple-ios12.0</tt>.
 +
|-
 +
! FreeBSD
 +
| Fine, CI-tested on x86_64. Requires LLD 9+ to pull in <tt>libexecinfo</tt> automatically when linking static druntime.
 +
|-
 +
! Other BSDs
 +
| Should be usable, not CI-tested though.
 +
|-
 +
! Solaris
 +
| Ditto.
 +
|-
 +
|}
  
=== ARM ===
+
== Contributing ==
  
* LDC from Git master is able to build a working Phobos "Hello World" application.
+
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]].
* LLVM 3.3 is required, there are many known bugs affecting ARM in older versions.
 
* EH support is still broken, and there are many other severe bugs: https://github.com/ldc-developers/ldc/issues?labels=B-arm&state=open
 
* Android has not been tested yet and most likely does not even compile.
 
  
=== PowerPC 32-bit ===
+
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.
  
* Requires at least LLVM 3.4 because of [http://llvm.org/bugs/show_bug.cgi?id=16556 PR16556]
+
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.
* TLS support only for LocalExec model, see [http://llvm.org/bugs/show_bug.cgi?id=16555 PR16555]
 
* Issues in druntime and phobos:
 
** druntime: Compiles cleanly with this [http://www.redstar.de/ldc/ppc_druntime.diff patch] applied
 
** phobos: Compiles cleanly with this [http://www.redstar.de/ldc/ppc_phobos.diff patch] applied
 
** Most of these changes are already passed as upstream pull requests
 
* Threads and fibers require some more work
 
* Contact: kai@redstar.de
 
  
=== PowerPC 64-bit ===
+
== Presentations ==
  
* Requires at least LLVM 3.3 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]. Use of debug symbols requires at least LLVM 3.4 because of [http://llvm.org/bugs/show_bug.cgi?id=15580 PR15580]. Solution for [https://github.com/ldc-developers/ldc/issues/372 issue #372] (failure in std.bitmanip) is still missing.
+
LDC is an active project and the team promotes the use of D and LDC.
* Only Linux because LLVM does not cleanly compile on AIX.
 
* Code generation is known to work.
 
* Issues in druntime and phobos:
 
** druntime: Compiles cleanly
 
** phobos: Compiles cleanly with this [http://www.redstar.de/ldc/ppc_phobos.diff patch] applied (but not all std.math functionality is available)
 
** Most of these changes are already passed as upstream pull requests
 
* For 0.11.0: 95% of the test suite passes - only 52 tests (out of 1036) fail. These are some modules with problems (incomplete):
 
** Unit test failures: core.math (math precision), std.complex, std.bitmanip (release only with -O2/-O3, [https://github.com/ldc-developers/ldc/issues/372 issue #372]), std.outbuffer, std.csv, std.math, std.getopt (math precision), std.regex (endian), ...
 
** Seg faults: std.datetime, std.range, ...
 
** Reason for failures are likely: math precision, thread synchronisation, frontend bugs, endian issues, bad code generation, ...
 
* Linux/PPC64 specific implementations are missing: core.cpuid, std.internal.math.bigintppc64, ...
 
* Multi-lib build is possible with patches for PPC32 applied
 
* Contact: kai@redstar.de
 
  
== Contributing ==
+
* 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]
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]].
+
* 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]
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.
+
* Johan's [http://dconf.org/2017/talks/engelen.html talk about LDC's optimized assembly output] at [http://dconf.org/2017/index.html DConf 2017]: [http://dconf.org/2017/talks/engelen.pdf Slides] [https://www.youtube.com/watch?v=IZY67TBZ0V4 Video]
 
+
* Johan's [http://dconf.org/2018/talks/engelen.html talk about LDC's LLVM-backed goodies: PGO, fuzzing, and Address Sanitizer] at [http://dconf.org/2018/index.html DConf 2018]: [http://dconf.org/2018/talks/engelen.pdf Slides] [https://www.youtube.com/watch?v=GMKvYrjaaoU Video]
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.
 
  
 
== Useful Links ==
 
== Useful Links ==
 
* [https://github.com/ldc-developers/ldc/issues Issue tracker (GitHub)]
 
* [https://github.com/ldc-developers/ldc/issues Issue tracker (GitHub)]
 
* [https://github.com/ldc-developers/ldc Source code (GitHub)]
 
* [https://github.com/ldc-developers/ldc Source code (GitHub)]
* [http://forum.dlang.org/group/digitalmars.D.ldc LDC discussion forum] (also available via NNTP and a mailing list interface, see the forum index)
+
* [https://forum.dlang.org/group/ldc LDC discussion forum] (also available via NNTP and a mailing list interface, see the forum index)
 +
* [https://gitter.im/ldc-developers/main Gitter chat room]
 
* [irc://irc.freenode.net/ldc LDC IRC channel] (#ldc on [http://freenode.net Freenode])
 
* [irc://irc.freenode.net/ldc LDC IRC channel] (#ldc on [http://freenode.net Freenode])
  
 
[[Category:LDC]]
 
[[Category:LDC]]

Latest revision as of 20:51, 11 May 2024

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

NOTE: As Wiki pages usually don't keep up with development, the changelog might be of use to check for recent developments and newly conquered targets.

Architectures

x86 / x86_64 Fine, CI-tested.
64-bit ARM Basically fine, a few testsuite failures remain (for non-Apple OS). See tracker issue for ~current status.
32-bit ARM Should be okay-ish, not really CI-tested though (Android ARMv7-A somewhat is). E.g., see tracker issue and Minimal semihosted ARM Cortex-M "Hello World".
WebAssembly Should work fine; currently limited to -betterC (lacking druntime/Phobos support). See Generating WebAssembly with LDC for a quick how-to.
PowerPC Incomplete; has been worked on (32-bit, 64-bit big & little endian) but not touched/tested in years. E.g., see tracker issue.
MIPS Incomplete; has been worked on but not really touched/tested in years. E.g., see tracker issue.
Others Basic code generation should work as long as there's an LLVM backend, and simple -betterC code might just work.
druntime/Phobos support is most likely lacking (and probably requires a new version predefined by the compiler).
Proper C(++) interop most likely requires a new TargetABI implementation in the compiler.

Operating Systems

Linux glibc environments are working fine & CI-tested (on i686/x86_64 and AArch64).
musl/uClibc should be usable but aren't tested.
macOS Fine, CI-tested on arm64 and x86_64. Requires macOS v10.7+ for native TLS. 32-bit i686 support was dropped with LDC v1.15.
Windows Fine for 'native' MSVC (Microsoft Visual C++) environments, CI-tested on Win32 & Win64.
NOTE: LDC uses 64-bit double precision for real, unlike DMD, for MSVC long double compatibility.
32-bit MinGW support was almost complete at one stage but got neglected; a manageable number of adaptations (mainly in druntime) would probably suffice to support it again.
Android Should be usable for ARMv7-A / AArch64 / i686 / x86_64, only rudimentarily CI-tested though (cross-compilability).
Check out the Build D for Android article for how to get started.
iOS / tvOS /
watchOS
Should be usable with 64-bit ARM (all druntime/Phobos unittests pass on iOS with LDC v1.21), only rudimentarily CI-tested though.
The official prebuilt macOS package supports cross-compilation out-of-the-box, just use -mtriple=arm64-apple-ios12.0.
FreeBSD Fine, CI-tested on x86_64. Requires LLD 9+ to pull in libexecinfo automatically when linking static druntime.
Other BSDs Should be usable, not CI-tested though.
Solaris Ditto.

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