{"id":2231,"date":"2019-11-06T12:30:29","date_gmt":"2019-11-06T12:30:29","guid":{"rendered":"http:\/\/dlang.org\/blog\/?p=2231"},"modified":"2021-09-30T13:37:57","modified_gmt":"2021-09-30T13:37:57","slug":"dmd-2-089-0-released","status":"publish","type":"post","link":"https:\/\/dlang.org\/blog\/2019\/11\/06\/dmd-2-089-0-released\/","title":{"rendered":"DMD 2.089.0 Released"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignleft size-full wp-image-181\" src=\"http:\/\/dlang.org\/blog\/wp-content\/uploads\/2016\/08\/d6.png\" alt=\"Digital Mars logo\" width=\"200\" height=\"200\" \/>The latest release of DMD, the D reference compiler, <a href=\"https:\/\/dlang.org\/download.html\">is ready for download<\/a>. It\u2019s a relatively light release in terms of changes and features, with <a href=\"https:\/\/dlang.org\/changelog\/2.089.0.html\">11 major changes and 66 closed Bugzilla issues<\/a>. Most of the changes cover narrow use cases. To highlight a few: proper non-D mangling in template mixins, a renamed default linker, and expanded support in DUB for LDC.<\/p>\n<h3 id=\"propernon-dmanglingintemplatemixins\">Proper non-D mangling in template mixins<\/h3>\n<p>Maintainers of C bindings, or anyone writing D programs that need to interface with a custom C codebase, may find this change particularly useful. Previously, symbols declared as <code>extern(C)<\/code>, <code>extern(Windows)<\/code>(which is <code>stdcall<\/code>), and <code>extern(Objective-C)<\/code> <a href=\"https:\/\/dlang.org\/spec\/template-mixin.html\">in template mixins<\/a> were <a href=\"https:\/\/dlang.org\/changelog\/2.089.0.html#mixin_template_mangling\">improperly mangled as D symbols<\/a> when the templates were mixed in at global scope. It was easy to work around if you didn&#8217;t need parameterization (just use string mixins), but if you did need it, then you were either stuck or had to jump through hoops.<\/p>\n<p>The root of the issue was that a template mixin introduces a new scope at the point it\u2019s mixed in and creates aliases to the declarations inside that scope so that they may be accessed externally without the need for dot notation. This is a major convenience when only one instance of the template is mixed into a scope (as is the usual case) and allows for code to be written as if the template mixin doesn&#8217;t exist. In other words:<\/p>\n<pre class=\"prettyprint lang-d\">mixin template Foo(T)\r\n{\r\n    T x;\r\n}\r\n\r\nmixin Foo;\r\n\r\n\/\/ Not required\r\n\/\/ mixin Foo f;\r\n\r\n\/\/ Allows this:\r\nint main()\r\n{\r\n    x = 10;\r\n\r\n    \/\/ Not required\r\n    \/\/ f.x = 10;\r\n}<\/pre>\n<p>The additional scope meant that, e.g., an <code>extern(C)<\/code> symbol in a template mixin was never in global scope, so it was mangled as a D symbol rather than a C symbol. With the change, such symbols are promoted from the mixin scope to the global scope and are properly mangled. Now you can choose either string mixins or template mixins for your C\/stdcall \/Objective-C boilerplate.<\/p>\n<h3 id=\"nomorelink.execonflict\">No more link.exe conflict<\/h3>\n<p>From the first alpha release of DMD, <a href=\"https:\/\/www.digitalmars.com\/ctg\/optlink.html\">OPTLINK has been the default linker<\/a> that ships with the compiler on Windows. When Walter Bright first started working on DMD, he used the existing C compiler backend he had been maintaining for 20 years. Since the backend already output object files in the Intel OMF format, he also decided to make use of OPTLINK; it had become a part of the C and C++ compiler package while he was at Borland. It was several years later that he added support Microsoft\u2019s MSCOFF (PE) and the Microsoft linker, cl, to DMD. The fact that both the OPTLINK and cl executables were named <code>link.exe<\/code> wasn\u2019t an issue early on, but over time it has begun to pop up more often, particularly when performing the compile and link steps separately.<\/p>\n<p>With DMD 2.089, it will never be an issue again. The version of OPTLINK that ships with DMD <a href=\"https:\/\/dlang.org\/changelog\/2.089.0.html#optlink\">has been renamed to <code>optlink.exe<\/code><\/a>.<\/p>\n<h3 id=\"dubandldc\">DUB and LDC<\/h3>\n<p>DUB, the D build tool and package manager, has shipped with DMD for several releases. When executing <code>dub<\/code> on a properly configured source package, DMD is the default compiler. It also supports LDC (<a href=\"https:\/\/wiki.dlang.org\/LDC\">the LLVM-based D compiler<\/a>) and GDC (<a href=\"https:\/\/wiki.dlang.org\/GDC\">the GCC-based D compiler<\/a>, which <a href=\"https:\/\/gcc.gnu.org\/gcc-9\/changes.html\">is part of GCC 9<\/a>) via command-line options, but the full range of DUB features haven\u2019t been available for those compilers.<\/p>\n<p>The latest version <a href=\"https:\/\/dlang.org\/changelog\/2.089.0.html#ldc2\">improves support for LDC<\/a>. DUB command-line options to enable code coverage, profiling, keeping the stack frame, and separate linking now work with LDC. Target triples can be given to the <code>--architecture<\/code> (<code>-a<\/code>) switch to enable cross-compilation with LDC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The latest release of DMD, the D reference compiler, is ready for download. It\u2019s a relatively light release in terms of changes and features, with 11 major changes and 66 closed Bugzilla issues. Most of the changes cover narrow use cases. To highlight a few: proper non-D mangling in template mixins, a renamed default linker, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,27,4],"tags":[],"_links":{"self":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/2231"}],"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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/comments?post=2231"}],"version-history":[{"count":6,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/2231\/revisions"}],"predecessor-version":[{"id":2268,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/2231\/revisions\/2268"}],"wp:attachment":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/media?parent=2231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/categories?post=2231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/tags?post=2231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}