Difference between revisions of "LDC"

From D Wiki
Jump to: navigation, search
(Mention addition of Android x86/x64 support)
(Project status: Rework & update, splitting into architecture and OS tables)
Line 21: Line 21:
  
 
== Project status ==
 
== 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 ===
+
'''NOTE''': As Wiki pages usually don't keep up with development, the [https://github.com/ldc-developers/ldc/blob/v1.21.0/CHANGELOG.md changelog] might be of use to check for recent developments and newly conquered targets.
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 ===
+
=== Architectures ===
* 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.
 
  
=== Android ===
+
{| class="wikitable"
* [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]].
+
|-
* [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.
+
! x86 / x86_64
 +
| Fine, CI-tested.
 +
|-
 +
! 64-bit ARM
 +
| Usable, a few testsuite failures remain (at least for non-Apple OS). See [https://github.com/ldc-developers/ldc/issues/2153 tracker issue] and [https://app.shippable.com/github/ldc-developers/ldc/dashboard latest Linux CI logs] 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).
 +
|-
 +
! 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.
 +
|-
 +
|}
  
=== ARM ===
+
=== Operating Systems ===
  
* Get a native ARM GNU/Linux compiler from [https://github.com/ldc-developers/ldc/releases the official release page].
+
{| class="wikitable"
* 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]].
+
! Linux
* You can use [[Building LDC runtime libraries|the new runtime cross-compilation tool]] to cross-compile also.
+
| glibc environments are working fine & CI-tested (on i686/x86_64 and AArch64).<br>musl/uClibc should be usable but aren't tested.
 
+
|-
=== AArch64 ===
+
! macOS
 
+
| Fine, CI-tested on x86_64. Requires macOS v10.7+ for native TLS. 32-bit support was dropped with LDC v1.15.
* 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.
+
|-
* Complete test suite can be run but still has failures, unoptimized codegen isn't currently working.
+
! 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.
=== iOS (iPhone OS) ===
+
|-
 
+
! Android
* 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.
+
| Should be usable for ARMv7-A / AArch64 / i686 / x86_64, only rudimentarily CI-tested though (compilability).<br>'''NOTE''': Requires an LDC linked against our [https://github.com/ldc-developers/llvm-project/releases LLVM fork] due to a custom TLS emulation scheme.<br>See [[Cross-compiling with LDC]] for how to set up cross-compilation with the Android NDK.<br>Also check out the extensive (but a bit dated) [[Build D for Android]] article, but note that quite a few steps would now be much simpler with a properly set up <tt>ldc2.conf</tt>.
* Full druntime/phobos support
+
|-
* Supports 32/64-bit ARM devices and iOS Simulator
+
! iOS / tvOS / watchOS
* See https://github.com/smolt/ldc-iphone-dev. The README.md explains what is available and what is missing.
+
| 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>.
* Releases available: https://github.com/smolt/ldc-iphone-dev/releases
+
|-
 
+
! BSDs
=== PowerPC 32-bit ===
+
| Should be usable, not CI-tested though.
 
+
|-
* Requires at least LLVM 3.4 because of [http://llvm.org/bugs/show_bug.cgi?id=16556 PR16556]
+
! Solaris
* TLS support only for LocalExec model, see [http://llvm.org/bugs/show_bug.cgi?id=16555 PR16555]
+
| Ditto.
* 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 [http://llvm.org/bugs/show_bug.cgi?id=21443 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 [https://github.com/ldc-developers/ldc/issues/1313 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 ==
 
== Contributing ==

Revision as of 02:22, 9 May 2020

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 Usable, a few testsuite failures remain (at least for non-Apple OS). See tracker issue and latest Linux CI logs 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).
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 x86_64. Requires macOS v10.7+ for native TLS. 32-bit 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 (compilability).
NOTE: Requires an LDC linked against our LLVM fork due to a custom TLS emulation scheme.
See Cross-compiling with LDC for how to set up cross-compilation with the Android NDK.
Also check out the extensive (but a bit dated) Build D for Android article, but note that quite a few steps would now be much simpler with a properly set up ldc2.conf.
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.
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