LDC fork to experiment direct interfacing with C++
Clone or download
Pull request Compare This branch is 1310 commits ahead, 728 commits behind ldc-developers:master.
Syniurge Decl::getCanonicalDecl() may return an out-of-line friend decl, use c…
…pp::getCanonicalDecl() instead.

Qt 5.9.1's QGraphicsItem was being skipped from the mapping.
Latest commit bc928fb Mar 26, 2018
Permalink
Failed to load latest commit information.
.circleci CircleCI & AppVeyor: Upgrade LDC-LLVM to v5.0.1 Dec 21, 2017
bash_completion.d Use bash completion dir from config if available Feb 19, 2015
cmake/Modules CMake: use llvm-config to determine LLVM's cmake directory, if possible. Jan 5, 2018
ddmd Decl::getCanonicalDecl() may return an out-of-line friend decl, use c… Mar 27, 2018
deps MSVC: adjust vftable linkage and GEP after upgrading to Clang 5. Feb 25, 2018
docs Renamings Nov 10, 2017
driver Merge remote-tracking branch 'upstream/release-1.7.x' into ldc-1.7 Feb 18, 2018
examples modmap -> pragma(cppmap) in examples/. Mar 27, 2018
gen Omit struct dtor from typeinfo if not emitted. Mar 27, 2018
ir Better support for TypeReference in codegen. Mar 4, 2018
res Merge 2.076.0 front-end and stdlibs Oct 7, 2017
runtime modmap -> pragma(cppmap) in runtime/calypso/. Mar 27, 2018
tests pragma(cppmap) rework to (finally) enable parsing new headers after t… Mar 27, 2018
tools Create llvm-profdata-6.0.cpp Jul 26, 2017
utils Merge branch 'upstream/release-1.5.x' into ldc-1.5 Feb 14, 2018
vcbuild MSVC: Detect VS 2017 and VS Build Tools 2017 Apr 10, 2017
.clang-format clang-format files touched in d01a91f [nfc] May 24, 2017
.clang-tidy clang-tidy: Add readability-else-after-return Nov 2, 2015
.editorconfig Add a .editorconfig file for dfmt. The settings are the same as DMD's… Mar 4, 2016
.gitattributes set proper attributes for Windows Jul 1, 2014
.gitmodules ÏT BU║L▓S! May 14, 2017
.travis.yml Travis: use a pre-built MacOSX Clang submodule to avoid timeout errors. Mar 16, 2018
CMakeCPack.cmake Add CPack configuration for debian packages Feb 12, 2014
CMakeLists.txt CMake: Apple Clang should be handled like LLVM Clang everywhere. Mar 27, 2018
Doxyfile Inlined sources in Doxygen docs (for tablet use) and increased DOT ma… Feb 20, 2015
LICENSE Renamings Nov 10, 2017
README.md modmap -> pragma(cppmap) in README.md and tests/. Mar 27, 2018
appveyor.yml Merge remote-tracking branch 'upstream/release-1.7.x' into ldc-1.7 Feb 18, 2018
ldc2.conf.in Merge remote-tracking branch 'upstream/release-1.4.x' into ldc-1.4 Feb 13, 2018
ldc2_install.conf.in Add `post-switches` to config file sections Aug 20, 2017
ldc2_phobos.conf.in Merge branch 'upstream/release-1.6.x' into ldc-1.6 Feb 15, 2018

README.md

Calypso notes

Calypso creates a bridge between DMD/LDC and Clang, both at the AST level (DMD <=> Clang's AST, Sema, ...) and at the code generation level (LDC <=> Clang's Codegen) to make D interface directly with the almost entire spectrum of C++ features.

It's not a separate tool, but a fork of LDC which enables you to directly import/include a C/C++ header and use the declarations from within D. No intermediate file is necessary, and no binding is involved.

Calypso introduces a new pragma, cppmap, along with the concept of language plugins which are queried by DMD's parser when it encounters special « import (ABC) xxx.yyy; » symbols. Interfacing with C++ declarations comes down to:

pragma (cppmap, "cppheader.h");  // tells Clang to parse cppheader.h but do not import anything

import (C++) NamespaceA.Class1;  // imports NamespaceA::Class1
import (C++) NamespaceA._;       // special module per namespace, imports every global variables,
                                 // global functions and typedefs whose direct parent is NamespaceA::

The resulting imported symbols are usable like their D counterparts. For more detailed examples see tests/calypso and examples.

Although Calypso is currently soldered to LDC, separating the two and placing Calypso and its bulky Clang dependency in an optional shared library should be easy. In this way, D compilers won't have to depend on a C/C++ compiler, and wider C++ support than what D currently has won't result in too cumbersome intrusions in core DMD/LDC.

Installation notes

Refer to the LDC wiki (Linux and OS X and Windows).

There are only a few requirements specific to Calypso:

  • CMake minimum version is 3.4+
  • Clang is tied to its corresponding LLVM version, it's therefore strongly recommended to build Calypso which introduces a Clang 5.0 submodule against LLVM 5.0
  • MSVC (Windows) builds require Ninja

cmake -G Ninja is recommended instead of make to take advantage by default of all available CPU cores while building the Clang external module (it's also possible to set cmake -DCLANG_BUILD_FLAGS="-jX").

Calypso may also have nightly builds in the future.

Specific flags

The -cpp-flags option was added to LDC to pass arguments to Clang during header parsing, e.g to enable C++11:

$ ldc2 -cpp-args -std=c++11 main.d

Missing features

Exception handling

Other

  • Register the destructor of C++ classes and structs while allocating a C++ class through the GC (as is being done for D structs)
  • Map macro functions as enums and templates (https://github.com/Syniurge/Calypso/issues/66). Currently only macro constants get mapped.

LDC – the LLVM-based D Compiler

Build Status Build Status Build Status Build Status Bountysource

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 version of D2, 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).

Please consult the D wiki for further information: http://wiki.dlang.org/LDC

D1 is no longer available; see the 'd1' Git branch for the last version supporting it.

Installation

From a pre-built package

Linux and OS X

Some package managers include recent versions of LDC, so manually installing it might not be necessary. For several platforms, there are also stand-alone binary builds available at the GitHub release page.

Command
Arch Linux pacman -S ldc
Debian apt install ldc
Fedora dnf install ldc
Gentoo layman -a ldc
Homebrew brew install ldc
Ubuntu apt install ldc

Windows

The latest official releases can be downloaded from the GitHub release page.

For bleeding-edge users, we also provide the latest successful continuous integration builds.

LDC for Windows relies on the Microsoft linker. So you'll either need Visual Studio 2015 or 2017 with Visual C++, or the stand-alone Visual C++ Build Tools.

Building from source

In-depth material on building and installing LDC and the standard libraries is available on the project wiki for Linux and OS X and Windows.

If you have a working C++ build environment, CMake, and a current LLVM (≥ 3.7) available, there should be no big surprises. Building LDC also requires a working D compiler, DMD and LDC are supported. (LDC 0.17 is the last version that does not need a D compiler, and for that reason we try to maintain it in the 'ltsmaster' branch).

Do not forget to make sure all the submodules (druntime, phobos, dmd-testsuite) are up to date:

$ cd ldc
$ git submodule update --init

Contact

The best way to get in touch with the developers is either via the digitalmars.D.ldc forum/newsgroup/mailing list (http://forum.dlang.org) or our Gitter chat. There is also the #ldc IRC channel on FreeNode.

For further documentation, contributor information, etc. please see the D wiki: http://wiki.dlang.org/LDC

Feedback of any kind is very much appreciated!