{"id":1428,"date":"2018-03-06T13:56:15","date_gmt":"2018-03-06T13:56:15","guid":{"rendered":"http:\/\/dlang.org\/blog\/?p=1428"},"modified":"2021-10-08T11:05:31","modified_gmt":"2021-10-08T11:05:31","slug":"ldc-1-8-0-released","status":"publish","type":"post","link":"https:\/\/dlang.org\/blog\/2018\/03\/06\/ldc-1-8-0-released\/","title":{"rendered":"LDC 1.8.0 Released"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"size-full wp-image-978 alignleft\" src=\"http:\/\/dlang.org\/blog\/wp-content\/uploads\/2017\/07\/ldc.png\" alt=\"\" width=\"160\" height=\"160\" \/>LDC, the D compiler using <a href=\"https:\/\/llvm.org\">the LLVM backend<\/a>, has been actively developed for going on a dozen years, as laid out by co-maintainer David Nadlinger in <a href=\"http:\/\/youtube.com\/watch?v=ntdKZWSiJdY\">his DConf 2013 talk<\/a>. It is considered one of two production compilers for D, along with <a href=\"https:\/\/www.gdcproject.org\">GDC<\/a>, which uses the gcc backend and <a href=\"https:\/\/www.phoronix.com\/scan.php?page=news_item&amp;px=GCC-D-Language-Approved\">has been accepted for inclusion into the gcc tree<\/a>.<\/p>\n<p>The LDC developers are proud to announce the release of version 1.8.0, following <a href=\"https:\/\/dlang.org\/blog\/2016\/06\/20\/making-of-ldc-1-0\/\">a short year and a half from the 1.0 release<\/a>. This version integrates version 2.078.3 of the D front-end (see the <a href=\"https:\/\/dlang.org\/changelog\/2.078.0.html\">DMD 2.078.0 changelog<\/a> for the important front-end changes), which is itself written in D, making LDC one of the most prominent mixed D\/C++ codebases. You can download LDC 1.8.0 and <a href=\"https:\/\/github.com\/ldc-developers\/ldc\/releases\/tag\/v1.8.0\">read about the major changes and bug fixes<\/a> for this release at GitHub.<\/p>\n<h3 id=\"moreplatforms\">More platforms<\/h3>\n<p>Kai Nacke, the other LDC co-maintainer, <a href=\"https:\/\/dconf.org\/2016\/talks\/nacke.html\">talked at DConf 2016 about taking D everywhere<\/a>, to every CPU architecture that LLVM supports and as many OS platforms as we can. LDC is a cross-compiler: the same program can compile code for different platforms, in contrast to <a href=\"https:\/\/dlang.org\/download\">DMD<\/a> and <a href=\"https:\/\/gdcproject.org\/downloads\">GDC<\/a>, where a different DMD\/GDC binary is needed for each platform. Towards that end, this release continues the existing Android cross-compilation support, which was introduced with LDC 1.4. A native LDC compiler <em>to both build and run D apps on your Android phone<\/em> is also available for <a href=\"https:\/\/termux.com\/\">the Termux Android app<\/a>. See the wiki page for <a href=\"https:\/\/wiki.dlang.org\/Build_D_for_Android\">instructions on how to use<\/a> one of the desktop compilers or the native compiler to compile D for Android.<\/p>\n<p>The LDC team has also been putting out LDC builds for ARM boards, such as the Raspberry Pi 3. <a href=\"https:\/\/github.com\/ldc-developers\/ldc\/releases\/tag\/v1.8.0\">Download the armhf build<\/a> if you want to try it out. Finally, some developers have expressed interest in using D for microservices, which usually means running in an Alpine container. This release also comes with an Alpine build of LDC, using the just-merged Musl port by @yshui. This port is brand new. Please try it out and let us know how well it works.<\/p>\n<h3 id=\"linkingoptions-shareddefaultlibraries\">Linking options &#8211; shared default libraries<\/h3>\n<p>LDC now makes it easier to link with the shared version of the default libraries (DRuntime and the standard library, called Phobos) through the <code>-link-defaultlib-shared<\/code> compiler flag. The change was paired with a rework of linking-related options. See the new help output:<\/p>\n<pre>Linking options:\n\n-L= - Pass to the linker\n-Xcc= - Pass to GCC\/Clang for linking\n-defaultlib=&lt;lib1,lib2,\u2026&gt; - Default libraries to link with (overrides previous)\n-disable-linker-strip-dead - Do not try to remove unused symbols during linking\n-link-defaultlib-debug - Link with debug versions of default libraries\n-link-defaultlib-shared - Link with shared versions of default libraries\n-linker=&lt;lld-link|lld|gold|bfd|\u2026&gt; - Linker to use\n-mscrtlib=&lt;libcmt[d]|msvcrt[d]&gt; - MS C runtime library to link with\n-static<\/pre>\n<p><strong>Other new options<\/strong><\/p>\n<ul>\n<li><code>-plugin=...<\/code> for compiling with LLVM-IR pass plugins, such as the <a href=\"https:\/\/github.com\/mirrorer\/afl\/blob\/master\/llvm_mode\/afl-llvm-pass.so.cc\">AFLfuzz LLVM-mode plugin<\/a><\/li>\n<li><code>-fprofile-{generate,use}<\/code> for Profile-Guided Optimization (PGO) based on the LLVM IR code (instead of PGO based on the D abstract syntax tree)<\/li>\n<li><code>-fxray-{instrument,instruction-threshold}<\/code> for generating code for <a href=\"https:\/\/llvm.org\/docs\/XRay.html\">XRay instrumentation<\/a><\/li>\n<li><code>-profile<\/code> (LDMD2) and <code>-fdmd-trace-functions<\/code> (LDC2) to support DMD-style profiling of programs<\/li>\n<\/ul>\n<h3 id=\"vanillacompiler-rtlibraries\">Vanilla compiler-rt libraries<\/h3>\n<p>LDC uses LLVM\u2019s <a href=\"https:\/\/compiler-rt.llvm.org\/\">compiler-rt runtime library<\/a> for <a href=\"https:\/\/en.wikipedia.org\/wiki\/Profile-guided_optimization\">Profile-Guided Optimization (PGO)<\/a>, <a href=\"https:\/\/github.com\/google\/sanitizers\/wiki\/AddressSanitizer\">Address Sanitizer<\/a>, and <a href=\"http:\/\/johanengelen.github.io\/ldc\/2018\/01\/14\/Fuzzing-with-LDC.html\">fuzzing<\/a>. When PGO was first added to LDC 1.1.0, the required portion of compiler-rt was copied to LDC\u2019s source repository. This made it easy to ship the correct version of the library with LDC, and make changes for LDC specifically. However, a copy was needed for each LLVM version that LDC supports (compiler-rt is compatible with only one LLVM version): the source of LDC 1.7.0 has 6 (!) copies of compiler-rt\u2019s profile library.<\/p>\n<p>For the introduction of ASan and libFuzzer in the official LDC binary packages, a different mechanism was used: when building LDC, we check whether the compiler-rt libraries are available in LLVM\u2019s installation and, if so, copy them into LDC\u2019s lib\/ directory. To use the same mechanism for the PGO runtime library, we had to remove our additions to that library. Although the added functionality is rarely used, we didn\u2019t want to just drop it. Instead, the functionality was turned into template-only code, such that it does not need to be compiled into the library (if the templated functionality is called by the user, the template\u2019s code will be generated in the caller\u2019s object file).<\/p>\n<p>With this change, LDC no longer needs its own copy of compiler-rt\u2019s profile library and all copies were removed from LDC\u2019s source repository. LDC 1.8.0 ships with vanilla compiler-rt libraries. LDC\u2019s users shouldn\u2019t notice any difference, but for the LDC team it means less maintenance burden.<\/p>\n<h3 id=\"onward\">Onward<\/h3>\n<p>A compiler developer\u2019s work is never done. With this release out the door, <a href=\"https:\/\/github.com\/ldc-developers\/ldc\/pull\/2587\">we march onward toward 1.9<\/a>. Until then, start optimizing your D programs by downloading the pre-compiled LDC 1.8.0 binaries for Linux, Mac, Windows, Alpine, ARM, and Android, or <a href=\"https:\/\/wiki.dlang.org\/Building_LDC_from_source\">build the compiler from source<\/a> from <a href=\"https:\/\/github.com\/ldc-developers\/ldc\/releases\/tag\/v1.8.0\">our GitHub repository<\/a>.<\/p>\n<p><em>Thanks to LDC contributors Johan Engelen and Joakim for coauthoring this post.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The LDC developers are proud to announce the release of version 1.8.0, following a short year and a half from the 1.0 release. This version integrates version 2.078.3 of the D front-end, which is itself written in D, making LDC one of the most prominent mixed D\/C++ codebases.<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,9,33,4],"tags":[],"_links":{"self":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/1428"}],"collection":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/comments?post=1428"}],"version-history":[{"count":7,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/1428\/revisions"}],"predecessor-version":[{"id":1430,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/1428\/revisions\/1430"}],"wp:attachment":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/media?parent=1428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/categories?post=1428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/tags?post=1428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}