https://wiki.dlang.org/api.php?action=feedcontributions&user=Notna&feedformat=atomD Wiki - User contributions [en]2024-03-29T15:25:08ZUser contributionsMediaWiki 1.31.2https://wiki.dlang.org/?title=DMD_Widget&diff=9873DMD Widget2020-07-17T19:27:16Z<p>Notna: </p>
<hr />
<div><div style="background: #f9f9f9; padding: 0.5ex 1em; border-top: 1px solid #e0e0e0; margin: 5px 10px;"><br />
Latest DMD:<br />
<span style="background-color: #c4664a; border-bottom: 1px solid #964e39; color: #fff; font-family: monospace; padding: 2px 5px; border-radius: 5px; font-size: 13pt; line-height: 1.8em;">{{Latest_DMD_Version}}</span><!-- To edit, visit: https://wiki.dlang.org/Template:Latest_DMD_Version_Raw --><br />
[http://dlang.org/download.html Download] &mdash;<br />
[http://dlang.org/changelog.html Changelog] &mdash; <br />
[https://github.com/D-Programming-Language Source code] &mdash; <br />
[http://d.puremagic.com/issues/ Bug tracker] &mdash;<br />
[[DMD|More &raquo;]]<br />
<span style="float:right; color:#ccc; font-size:0.9em; padding: 0.5em 0.5em;">[[DMD_Widget|&#9998;]]</span><br />
</div></div>Notnahttps://wiki.dlang.org/?title=Template:Latest_DMD_Version_Raw&diff=9872Template:Latest DMD Version Raw2020-07-17T18:24:35Z<p>Notna: </p>
<hr />
<div>2.093.0</div>Notnahttps://wiki.dlang.org/?title=Template:Latest_DMD_Version_Raw&diff=9871Template:Latest DMD Version Raw2020-07-17T18:23:31Z<p>Notna: </p>
<hr />
<div>[https://github.com/dlang/dlang.org/blob/master/VERSION 2.093.0]</div>Notnahttps://wiki.dlang.org/?title=IDEs&diff=9869IDEs2020-07-16T17:15:43Z<p>Notna: </p>
<hr />
<div>Integrated development environments with D support.<br />
<br />
{| class="wikitable sortable"<br />
!Name<br />
!Platforms<br />
!Comments<br />
!Status<br />
!Last known activity<br />
|-<br />
|[https://marketplace.visualstudio.com/items?itemName=webfreak.code-d Code-d for Visual Studio Code]<br />
|Cross-platform (Linux / Windows / Mac OS X)<br />
|DUB integration, code completion, code formatting, static linting, debugging (gdb/mago-mi), etc... Full list [https://github.com/Pure-D/code-d/wiki here] <br />
Plug-in can be installed from Visual Studio Marketplace.<br />
|Very Active<br />
|2019-01-03<br />
|-<br />
|[http://rainers.github.io/visuald/visuald/StartPage.html Visual-D for Visual Studio]<br />
|Windows<br />
|Visual Studio plug-in written in D with code completion building and debugging support<br />
|Very Active<br />
|2020-07-04<br />
|-<br />
|[https://github.com/intellij-dlanguage/intellij-dlanguage D Plugin for IntelliJ IDEA]<br />
|Cross-platform (Linux / Windows / Mac OS X)<br />
|DUB support, code completion with and without dcd, code formatting, linting, goto declaration, find usages, syntax checking, name refactoring, experimental gdb/mago-mi (windows) debugging support, syntax highlighting, d-unit integration and a structure view which shows symbols in a file. <br />
Plugin can be installed from IntelliJ repositories.<br />
| Active<br />
|2020-05-27<br />
|-<br />
|[https://gitlab.com/basile.b/dexed Dexed (D Extended EDitor), built purposely for D]<br />
|Linux, <s>Windows</s><br />
|Dexed, (D EXtended EDitor), is an IDE dedicated to the D programming language, its compilers (DMD, GDC, LDC), tools (DUB, DCD, D-Scanner, Dfmt) and libraries. <br />
|Very Active<br />
|2020-07-06<br />
|}<br />
<br />
== Other IDEs (some are considered inactive) ==<br />
<br />
{| class="wikitable"<br />
!Name<br />
!Platforms<br />
!Comments<br />
!Version<br />
!Last known activity<br />
|-<br />
|[[CodeBlocks | Code&#x3a;&#x3a;Blocks]]<br />
|Linux/Windows/Mac OS X/FreeBSD (wxWidgets)<br />
|D project creation, highlighting and debugging work as of version 12.<br />
|[http://www.codeblocks.org/downloads/26 17.12]<br />
|2017-12-30<br />
|-<br />
|[https://github.com/buggins/dlangide Dlang IDE]<br />
|Cross platform (Dlang UI)<br />
|IDE itself is written in D and can be installed by cloning from github and running dub.<br />
It has DUB support, syntax highlight, code completion with DCD, debugging support with GDB/mago-mi/lldbmi2<br />
|[https://github.com/buggins/dlangide/releases/tag/v0.8.17 0.8.17]<br />
|2018-11-26<br />
|-<br />
|[https://bitbucket.org/KuanHsu/poseidond Poseidon]<br />
|Windows/Linux<br />
|Written in D, using Tango and IUP which allows it to run and build also on Linux.<br />
|[https://bitbucket.org/KuanHsu/poseidond/downloads/poseidonD_x64_rev040.tar.gz v0.040]<br />
|2019-07-02<br />
|-<br />
|[http://www.zeusedit.com/d.html Zeus]<br />
|Windows/*nix (using Wine)<br />
|Zeus is a language neutral programmer's editor/IDE for the Windows platform.<br />
Recent Zeus releases have added many other D specific language features.<br />
Shareware(45 days free trial)<br />
|[http://www.zeusedit.com/phpBB3/viewforum.php?f=6 3.98p]<br />
|2018-07-01<br />
|-<br />
|[https://developer.apple.com/xcode/ Xcode]<br />
|MacOS X<br />
|[http://michelf.com/projects/d-for-xcode/ D for Xcode plugin]<br />
|[https://littoral.michelf.ca/code/d-for-xcode//d-for-xcode-1.2.2.zip 1.2.2]<br />
|2011-03-28<br />
|-<br />
|[[Mono-D]]<br />
|Cross-platform (Mono)<br />
|Code Completion/Refactoring etc.; dmd/ldc/gdc support. Has been part of GSoC 2012. [https://github.com/aBothe/Mono-D GitHub page]<br />
|[[Mono-D Release Notes|2.14.5]]<br />
|2016-07-12<br />
|-<br />
|[http://ddt-ide.github.io/ DDT]<br />
|Cross-platform (Java + Eclipse)<br />
|DUB support, code completion, debugging support with GDB. ([https://github.com/bruno-medeiros/DDT/blob/latest/documentation/Features.md#ddt-features Features/Screenshots]).<br />
|[https://github.com/DDT-IDE/DDT/releases/tag/1.0.3 1.0.3]<br />
|2017-09-25<br />
|}<br />
<br />
<noinclude><br />
<br />
== See also ==<br />
* [[Editors]] - integration with light-weight editors<br />
<br />
== External links ==<br />
*[https://www.youtube.com/watch?v=qeCWv5pgAiw YouTube: Using Visual Studio Code for D programming] - July 09, 2020 by Lawrence Aberba<br />
*[https://dlang.org/blog/2016/08/12/project-highlight-visual-d/ Project Highlight: Visual D] - August 12, 2016 [[Michael Parker]]<br />
<br />
[[Category:IDEs]]<br />
</noinclude></div>Notnahttps://wiki.dlang.org/?title=Template:Latest_DMD_Version_Raw&diff=9457Template:Latest DMD Version Raw2019-01-12T13:45:04Z<p>Notna: </p>
<hr />
<div>2.084.0</div>Notnahttps://wiki.dlang.org/?title=Template:Latest_DMD_Version_Raw&diff=8662Template:Latest DMD Version Raw2017-11-03T19:26:35Z<p>Notna: </p>
<hr />
<div>2.077.0</div>Notnahttps://wiki.dlang.org/?title=Template:Latest_DMD_Version_Raw&diff=8647Template:Latest DMD Version Raw2017-10-20T11:22:45Z<p>Notna: </p>
<hr />
<div>2.076.1</div>Notnahttps://wiki.dlang.org/?title=Books&diff=8578Books2017-08-09T19:54:55Z<p>Notna: </p>
<hr />
<div><u>'''PLEASE NOTE''': The links to Amazon are affiliated with the D Language Foundation, so by simply following them you support the Foundation at no cost to you.</u><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://amzn.to/1ZTDmqH]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1ZTDmqH Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:100px-PiD_1stEd_Cover.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
November 2015<br/><br />
with frequent online updates<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive book for beginners (free and available for purchase)<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1MJGyTL Amazon]<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_D_Web_Development.png|100px|link=https://www.packtpub.com/web-development/d-web-development]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Web Development'''<br><br />
Kai Nacke<br/><br />
January 2016<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the power of D and the vibe.d framework to develop web applications that are incredibly fast<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/web-development/d-web-development Publisher's page]<br />
* [http://amzn.to/1qdrvrH Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_Learning_D.png|100px|link=https://www.packtpub.com/application-development/learning-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learning D'''<br><br />
Michael Parker<br><br />
November 27, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the modern convenience and modelling power of the D programming language to develop software with native efficiency<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/application-development/learning-d Publisher's page]<br />
* [http://amzn.to/1IlQkZX Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:Twp-DCover.png|100px|link=https://leanpub.com/twp-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The way to program - Let's think like a D(eveloper)'''<br><br />
Richard Cattermole<br><br />
June 16, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Programming is a difficult subject to get into. Especially with a very wide variety of options available to learn from. In both book form and websites. The goal of this book is bring topics to your attention and introduce them in a practical manner.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/twp-d Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://d.readthedocs.org/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Quick Start With D'''<br><br />
Ilya Yaroshenko<br><br />
April 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice quick start introduction. Available on-line.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://d.readthedocs.org/ Read the docs]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:ctfebookcover1424127575.jpg|100px|link=https://leanpub.com/ctfe]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Developing with compile time in mind'''<br><br />
Richard Cattermole<br><br />
February 17, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Runtime execution is difficult enough, with compile time execution available as well it becomes unimaginable. This book describes design patterns and how to work with compile time function execution effectively.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/ctfe Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://www.tutorialspoint.com/d_programming/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D programming'''<br><br />
Unknown<br><br />
January 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice introductory tutorial to D programming. Available on-line and in the PDF format.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.tutorialspoint.com/d_programming/ Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://amzn.to/1ZTE47m Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf PDF]<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.chm CHM] Microsoft Compiled HTML Help<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.epub EPub] E-book Readers<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.mobi Mobi] Kindle Format<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://amzn.to/1qds4Sj Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:PinD.PNG|100px|link=http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Programmieren in D'''<br><br />
German Language<br><br />
Tobias Wassermann, Christian Speer<br><br />
14. November 2007<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Die Sprache D bringt die Vorteile von C, C++, C#, Java und anderen Sprachen zusammen - verzichtet dabei jedoch auf die Makel.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<br />
[[Category:Contents]]</div>Notnahttps://wiki.dlang.org/?title=Books&diff=8577Books2017-08-09T19:53:54Z<p>Notna: </p>
<hr />
<div>PLEASE NOTE: The links to Amazon are affiliated with the D Language Foundation, so by simply following them you support the Foundation at no cost to you.<br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://amzn.to/1ZTDmqH]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1ZTDmqH Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:100px-PiD_1stEd_Cover.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
November 2015<br/><br />
with frequent online updates<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive book for beginners (free and available for purchase)<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1MJGyTL Amazon]<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_D_Web_Development.png|100px|link=https://www.packtpub.com/web-development/d-web-development]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Web Development'''<br><br />
Kai Nacke<br/><br />
January 2016<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the power of D and the vibe.d framework to develop web applications that are incredibly fast<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/web-development/d-web-development Publisher's page]<br />
* [http://amzn.to/1qdrvrH Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_Learning_D.png|100px|link=https://www.packtpub.com/application-development/learning-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learning D'''<br><br />
Michael Parker<br><br />
November 27, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the modern convenience and modelling power of the D programming language to develop software with native efficiency<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/application-development/learning-d Publisher's page]<br />
* [http://amzn.to/1IlQkZX Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:Twp-DCover.png|100px|link=https://leanpub.com/twp-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The way to program - Let's think like a D(eveloper)'''<br><br />
Richard Cattermole<br><br />
June 16, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Programming is a difficult subject to get into. Especially with a very wide variety of options available to learn from. In both book form and websites. The goal of this book is bring topics to your attention and introduce them in a practical manner.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/twp-d Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://d.readthedocs.org/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Quick Start With D'''<br><br />
Ilya Yaroshenko<br><br />
April 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice quick start introduction. Available on-line.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://d.readthedocs.org/ Read the docs]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:ctfebookcover1424127575.jpg|100px|link=https://leanpub.com/ctfe]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Developing with compile time in mind'''<br><br />
Richard Cattermole<br><br />
February 17, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Runtime execution is difficult enough, with compile time execution available as well it becomes unimaginable. This book describes design patterns and how to work with compile time function execution effectively.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/ctfe Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://www.tutorialspoint.com/d_programming/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D programming'''<br><br />
Unknown<br><br />
January 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice introductory tutorial to D programming. Available on-line and in the PDF format.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.tutorialspoint.com/d_programming/ Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://amzn.to/1ZTE47m Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf PDF]<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.chm CHM] Microsoft Compiled HTML Help<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.epub EPub] E-book Readers<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.mobi Mobi] Kindle Format<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://amzn.to/1qds4Sj Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:PinD.PNG|100px|link=http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Programmieren in D'''<br><br />
German Language<br><br />
Tobias Wassermann, Christian Speer<br><br />
14. November 2007<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Die Sprache D bringt die Vorteile von C, C++, C#, Java und anderen Sprachen zusammen - verzichtet dabei jedoch auf die Makel.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<br />
[[Category:Contents]]</div>Notnahttps://wiki.dlang.org/?title=Books&diff=8576Books2017-08-09T19:53:15Z<p>Notna: </p>
<hr />
<div>The links to Amazon are affiliated with the D Language Foundation, so by simply following them you support the Foundation at no cost to you.<br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://amzn.to/1ZTDmqH]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1ZTDmqH Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:100px-PiD_1stEd_Cover.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
November 2015<br/><br />
with frequent online updates<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive book for beginners (free and available for purchase)<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1MJGyTL Amazon]<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_D_Web_Development.png|100px|link=https://www.packtpub.com/web-development/d-web-development]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Web Development'''<br><br />
Kai Nacke<br/><br />
January 2016<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the power of D and the vibe.d framework to develop web applications that are incredibly fast<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/web-development/d-web-development Publisher's page]<br />
* [http://amzn.to/1qdrvrH Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_Learning_D.png|100px|link=https://www.packtpub.com/application-development/learning-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learning D'''<br><br />
Michael Parker<br><br />
November 27, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the modern convenience and modelling power of the D programming language to develop software with native efficiency<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/application-development/learning-d Publisher's page]<br />
* [http://amzn.to/1IlQkZX Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:Twp-DCover.png|100px|link=https://leanpub.com/twp-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The way to program - Let's think like a D(eveloper)'''<br><br />
Richard Cattermole<br><br />
June 16, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Programming is a difficult subject to get into. Especially with a very wide variety of options available to learn from. In both book form and websites. The goal of this book is bring topics to your attention and introduce them in a practical manner.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/twp-d Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://d.readthedocs.org/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Quick Start With D'''<br><br />
Ilya Yaroshenko<br><br />
April 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice quick start introduction. Available on-line.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://d.readthedocs.org/ Read the docs]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:ctfebookcover1424127575.jpg|100px|link=https://leanpub.com/ctfe]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Developing with compile time in mind'''<br><br />
Richard Cattermole<br><br />
February 17, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Runtime execution is difficult enough, with compile time execution available as well it becomes unimaginable. This book describes design patterns and how to work with compile time function execution effectively.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/ctfe Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://www.tutorialspoint.com/d_programming/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D programming'''<br><br />
Unknown<br><br />
January 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice introductory tutorial to D programming. Available on-line and in the PDF format.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.tutorialspoint.com/d_programming/ Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://amzn.to/1ZTE47m Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf PDF]<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.chm CHM] Microsoft Compiled HTML Help<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.epub EPub] E-book Readers<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.mobi Mobi] Kindle Format<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://amzn.to/1qds4Sj Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:PinD.PNG|100px|link=http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Programmieren in D'''<br><br />
German Language<br><br />
Tobias Wassermann, Christian Speer<br><br />
14. November 2007<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Die Sprache D bringt die Vorteile von C, C++, C#, Java und anderen Sprachen zusammen - verzichtet dabei jedoch auf die Makel.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<br />
[[Category:Contents]]</div>Notnahttps://wiki.dlang.org/?title=Books&diff=8575Books2017-08-09T19:52:25Z<p>Notna: </p>
<hr />
<div>{{Note_box|The links to Amazon are affiliated with the D Language Foundation, so by simply following them you support the Foundation at no cost to you.}}<br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://amzn.to/1ZTDmqH]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1ZTDmqH Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:100px-PiD_1stEd_Cover.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
November 2015<br/><br />
with frequent online updates<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive book for beginners (free and available for purchase)<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1MJGyTL Amazon]<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_D_Web_Development.png|100px|link=https://www.packtpub.com/web-development/d-web-development]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Web Development'''<br><br />
Kai Nacke<br/><br />
January 2016<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the power of D and the vibe.d framework to develop web applications that are incredibly fast<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/web-development/d-web-development Publisher's page]<br />
* [http://amzn.to/1qdrvrH Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_Learning_D.png|100px|link=https://www.packtpub.com/application-development/learning-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learning D'''<br><br />
Michael Parker<br><br />
November 27, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the modern convenience and modelling power of the D programming language to develop software with native efficiency<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/application-development/learning-d Publisher's page]<br />
* [http://amzn.to/1IlQkZX Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:Twp-DCover.png|100px|link=https://leanpub.com/twp-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The way to program - Let's think like a D(eveloper)'''<br><br />
Richard Cattermole<br><br />
June 16, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Programming is a difficult subject to get into. Especially with a very wide variety of options available to learn from. In both book form and websites. The goal of this book is bring topics to your attention and introduce them in a practical manner.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/twp-d Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://d.readthedocs.org/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Quick Start With D'''<br><br />
Ilya Yaroshenko<br><br />
April 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice quick start introduction. Available on-line.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://d.readthedocs.org/ Read the docs]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:ctfebookcover1424127575.jpg|100px|link=https://leanpub.com/ctfe]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Developing with compile time in mind'''<br><br />
Richard Cattermole<br><br />
February 17, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Runtime execution is difficult enough, with compile time execution available as well it becomes unimaginable. This book describes design patterns and how to work with compile time function execution effectively.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/ctfe Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://www.tutorialspoint.com/d_programming/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D programming'''<br><br />
Unknown<br><br />
January 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice introductory tutorial to D programming. Available on-line and in the PDF format.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.tutorialspoint.com/d_programming/ Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://amzn.to/1ZTE47m Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf PDF]<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.chm CHM] Microsoft Compiled HTML Help<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.epub EPub] E-book Readers<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.mobi Mobi] Kindle Format<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://amzn.to/1qds4Sj Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:PinD.PNG|100px|link=http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Programmieren in D'''<br><br />
German Language<br><br />
Tobias Wassermann, Christian Speer<br><br />
14. November 2007<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Die Sprache D bringt die Vorteile von C, C++, C#, Java und anderen Sprachen zusammen - verzichtet dabei jedoch auf die Makel.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<br />
[[Category:Contents]]</div>Notnahttps://wiki.dlang.org/?title=Books&diff=8574Books2017-08-09T19:52:10Z<p>Notna: </p>
<hr />
<div>{{Note_boy|The links to Amazon are affiliated with the D Language Foundation, so by simply following them you support the Foundation at no cost to you.}}<br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://amzn.to/1ZTDmqH]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1ZTDmqH Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:100px-PiD_1stEd_Cover.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
November 2015<br/><br />
with frequent online updates<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive book for beginners (free and available for purchase)<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://amzn.to/1MJGyTL Amazon]<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_D_Web_Development.png|100px|link=https://www.packtpub.com/web-development/d-web-development]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Web Development'''<br><br />
Kai Nacke<br/><br />
January 2016<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the power of D and the vibe.d framework to develop web applications that are incredibly fast<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/web-development/d-web-development Publisher's page]<br />
* [http://amzn.to/1qdrvrH Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_Learning_D.png|100px|link=https://www.packtpub.com/application-development/learning-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learning D'''<br><br />
Michael Parker<br><br />
November 27, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the modern convenience and modelling power of the D programming language to develop software with native efficiency<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/application-development/learning-d Publisher's page]<br />
* [http://amzn.to/1IlQkZX Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:Twp-DCover.png|100px|link=https://leanpub.com/twp-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The way to program - Let's think like a D(eveloper)'''<br><br />
Richard Cattermole<br><br />
June 16, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Programming is a difficult subject to get into. Especially with a very wide variety of options available to learn from. In both book form and websites. The goal of this book is bring topics to your attention and introduce them in a practical manner.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/twp-d Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://d.readthedocs.org/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Quick Start With D'''<br><br />
Ilya Yaroshenko<br><br />
April 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice quick start introduction. Available on-line.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://d.readthedocs.org/ Read the docs]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:ctfebookcover1424127575.jpg|100px|link=https://leanpub.com/ctfe]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Developing with compile time in mind'''<br><br />
Richard Cattermole<br><br />
February 17, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Runtime execution is difficult enough, with compile time execution available as well it becomes unimaginable. This book describes design patterns and how to work with compile time function execution effectively.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/ctfe Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://www.tutorialspoint.com/d_programming/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D programming'''<br><br />
Unknown<br><br />
January 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice introductory tutorial to D programming. Available on-line and in the PDF format.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.tutorialspoint.com/d_programming/ Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://amzn.to/1ZTE47m Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf PDF]<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.chm CHM] Microsoft Compiled HTML Help<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.epub EPub] E-book Readers<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.mobi Mobi] Kindle Format<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://amzn.to/1qds4Sj Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:PinD.PNG|100px|link=http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Programmieren in D'''<br><br />
German Language<br><br />
Tobias Wassermann, Christian Speer<br><br />
14. November 2007<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Die Sprache D bringt die Vorteile von C, C++, C#, Java und anderen Sprachen zusammen - verzichtet dabei jedoch auf die Makel.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<br />
[[Category:Contents]]</div>Notnahttps://wiki.dlang.org/?title=DMD_Source_Guide&diff=8068DMD Source Guide2016-11-26T13:00:51Z<p>Notna: /* Class hierarchy */</p>
<hr />
<div>== Overview ==<br />
<br />
=== Major components ===<br />
<br />
All D compilers are divided into two parts: the front-end and the back-end.<br />
<br />
The front-end (DMD-FE) implements all things D-specific: lexing and parsing D syntax, instantiating templates, producing error messages, etc. The same front-end code is used by [[DMD]], [[GDC]] and [[LDC]].<br />
<br />
The back-end is what emits machine code. It contains code generation, optimization, object file writing, etc. The back-end is specific to each D compiler: DMD uses a source-available but proprietary (and non-redistributable) backend, while e.g. LDC uses LLVM as the back-end.<br />
<br />
There is also a glue layer, which is the interface between the front-end and back-end. This component is custom for each D compiler.<br />
<br />
=== Compilation cycle ===<br />
<br />
D source code goes through the following stages when compiled:<br />
<br />
* First, the file is loaded into memory as-is, and converted to UTF-8 when necessary.<br />
* The lexer transforms the file into an array of tokens. There is no structure yet at this point - just a flat list of tokens. (lexer.c)<br />
* The parser then builds a simple AST out of the token stream. (parser.c)<br />
* The AST is then semantically processed. This is done in three stages (called semantic, semantic2 and semantic3). This is done in a loop in mars.c. Each pass transforms the AST to be closer to the final representation: types are resolved, templates are instantiated, etc.<br />
:1. The "semantic" phase will analyze the full signature of all declarations. For example:<br />
::* members of aggregate type<br />
::* function parameter types and return type<br />
::* variable types<br />
::* evaluation of pragma(msg)<br />
:<br />
:2. The "semantic2" phase will analyze some additional part of the declarations, For example:<br />
::* initializer of variable declarations<br />
::* evaluation of static assert condition<br />
:<br />
:3. The "semantic3" phase will analyze the body of function declarations.<br />
::If a function is declared in the module which is not directly compiled (== not listed in the command line), semantic3 pass won't analyze its body.<br />
:<br />
:4. During each phases, some declarations will partially invoke the subsequent phases due to resolve forward reference, For example:<br />
<br />
immutable string x = "hello";<br />
static if (x == "hello") { ... }<br />
// The static if condition will invoke semantic2 of the variable 'x'<br />
<br />
auto foo() { ... }<br />
typeof(&foo) fp;<br />
// "semantic" phase of the variable 'fp' will run "semantic3" of 'foo'<br />
// to demand the full signature of the function (== infer the return type)<br />
<br />
string foo() { ... }<br />
mixin(foo());<br />
// For CTFE, the mixin declaration will invoke the semantic3 of 'foo'<br />
* Finally, the AST is handed over to the glue layer, which feeds it into the back-end, which in turn produces machine code and object files.<br />
<br />
=== Runtime interoperability ===<br />
<br />
Non-trivial operations (e.g. memory allocation, array operations) are implemented in the D runtime. The compiler integrates with the runtime using a number of so-called hook functions (which by convention have the <tt>_d_</tt> name prefix).<br />
<br />
A list can be found here: [[Runtime_Hooks]]<br />
<br />
=== Details ===<br />
<br />
''Note: This section may be considerably outdated. Please bring it up to date where you can.''<br />
<br />
There are a number of types that are stored in various nodes that are never actually used in the front end. They are merely stored and passed around as pointers. <br />
<br />
* Symbol - Appears to have something to do with the names used by the linker. Appears to be used by Dsymbol and its subclasses.<br />
* dt_t - "Data to be added to the data segment of the output object file" ''source: todt.c''<br />
* elem - A node in the internal representation.<br />
<br />
The code generator is split among the various AST nodes. Certain methods of almost every AST node are part of the code generator.<br />
<br />
(it's an interesting solution to the problem. It would have never occurred to a Java programmer)<br />
<br />
Most notably:<br />
* all Statement subclasses must define a toIR method<br />
* All Expression subclasses must define a toElem method<br />
* Initializers and certain Expression subclasses must define toDt<br />
* Declarations must define toObjFile<br />
* Dsymbol subclasses must define toSymbol<br />
<br />
==== Other things ====<br />
Floating point libraries seem to be atrociously incompatible between compilers. Replacing strtold with strtod may be necessary, for instance. (this does "break" the compiler, however: it will lose precision on literals of type 'real')<br />
-- AndyFriesen<br />
<br />
==== Intermediate Representation ====<br />
<br />
'''From [http://www.digitalmars.com/webnews/newsgroups.php?art_group=D.gnu&article_id=762 NG:D.gnu/762]'''<br />
<br />
I've been looking at trying to hook the DMD frontend up to LLVM (www.llvm.org), but I've been having some trouble. The LLVM IR (Intermediate Representation) is very well documented, but I'm having a rough time figuring out how DMD holds its IR. Since at least three people (David, Ben, and Walter) seem to have understand, I thought I'd ask for guidance.<br />
<br />
What's the best way to traverse the DMD IR once I've run the three semantic phases? As far as I can tell it's all held in the SymbolTable as a bunch of Symbols. Is there a good way to traverse that and reconstruct it into another IR?<br />
<br />
----<br />
<br />
'''From [http://www.digitalmars.com/webnews/newsgroups.php?art_group=D.gnu&article_id=764 NG:D.gnu/764]'''<br />
<br />
There isn't a generic visitor interface. Instead, there are several methods with are responsible for emiting code/data and then calling that method for child objects. Start by implementing Module::genobjfile and loop over the 'members' array, calling each Dsymbol object's toObjFile method. From there, you will need to implement these methods:<br />
<br />
Dsymbol (and descendents) ::toObjFile -- Emits code and data for objects that have generally have a symbol name and storage in memory. Containers like ClassDeclaration also have a 'members' array with child Dsymbols. Most of these are descendents of the Declaration class.<br />
<br />
Statement (and descendents) ::toIR -- Emits instructions. Usually, you just call toObjFile, toIR, toElem, etc. on the statement's fields and string the results together in the IR.<br />
<br />
Expression (and descendents) ::toElem -- Returns a back end representation of numeric constants, variable references, and operations that expression trees are composed of. This was very simple for GCC because the back end already had the code to convert expression trees to ordered instructions. If LLVM doesn't do this, I think you could generate the instructions here since LLVM has SSA.<br />
<br />
Type (and descendents) ::toCtype -- Returns the back end representation of the type. Note that a lot of classes don't override this -- you just need to do a switch on the 'ty' field in Type::toCtype.<br />
<br />
Dsymbol (and descendents) ::toSymbol -- returns the back end reference to the object. For example, FuncDeclaration::toSymbol could return a llvm::Function. These are already implemented in tocsym.c, but you will probably rewrite them to create LLVM objects. <br />
<br />
----<br />
<br />
(Thread: http://digitalmars.com/d/archives/D/gnu/762.html)<br />
<br />
==== Inliner ====<br />
<br />
DMD's inliner is part of the frontend, existing entirely in the file '''inline.c'''.<br />
<br />
This inliner is conceptually quite simple: It traverses the AST looking for function calls. Each function found is analysed for cost by adding up the number of expression nodes in its body. Anything non-inlinable counts as "maximum cost". If the total cost is below the maximum, the function call is inlined.<br />
<br />
In DMD's AST, certain statements cannot currently be represented as expressions (such as non-unrolled loops and throwing). Because of this, the inliner makes a distinction between two main types of inlining:<br />
<br />
* Converting a function call to an inline expression: This must be used whenever the function's return value is actually used. Ex: "x = foo();" or "2 + foo()".<br />
* Converting a function call to an inline statement: Used when a function's return value is ignored, or when calling a void function.<br />
<br />
Those two scenarios are inlined by mostly separate codepaths. Cost analysis is mostly the same codepath, but "inlinable as a statement" and "inlinable as an expression" are separate decisions (again, due to certain statements not being representable as expressions).<br />
<br />
The inliner is divided into four main parts:<br />
<br />
* Main entry point: '''inlineScan''' (which utilizes class '''InlineScanVisitor''' and function '''expandInline''')<br />
* Cost analysis (to determine inlinability): '''canInline''' and class '''InlineCostVisitor'''<br />
* Inlining a function call as a statement: '''inlineAsStatement''' and its embedded class '''InlineAsStatement'''<br />
* Inlining a function call as an expression: '''doInline''' and its embedded class '''InlineStatement'''<br />
<br />
===== Inliner: Main Entry Point =====<br />
<br />
The whole inliner is driven by the '''inlineScan''' function and '''InlineScanVisitor''' class, but the bulk of the real work is performed by '''expandInline''' (described in this section) and the other three main parts of the inliner (described in the following sections).<br />
<br />
The global function '''inlineScan''' is the inliner's main entry point. This uses class '''InlineScanVisitor''' to traverse the AST looking for function calls to inline, and inlining them as they're found. Whenever '''InlineScanVisitor''' finds an inlinable function call (determined by the cost analyzer), it calls '''expandInline''' to start the inlining process.<br />
<br />
'''InlineScanVisitor''' also decides whether to inline as a statement or an expression based on the type of AST node found:<br />
<br />
* '''ExpStatement''': Implies the function either has no return value, or the return value is unused. Therefore, inline as a statement (if permitted by cost analysis).<br />
* '''CallExp''': Implies the function returns a value which is used. Therefore, inline as an expression (if permitted by cost analysis).<br />
<br />
Called by '''InlineScanVisitor''', '''expandInline''' drives the actual inlining for both "as statement" and "as expression" cases. It converts the function call scaffolding, parameters and return value (if any) into the appropriate inline statement or expression. To inline the function's body, '''expandInline''' hands over to either '''inlineAsStatement''' (if inlining the call as a statement) or '''doInline''' (if inlining the call as an expression).<br />
<br />
===== Inliner: Cost Analysis =====<br />
<br />
The function '''canInline''', unsurprisingly, determines if a function can be inlined. To decide this, it uses class '''InlineCostVisitor''', which traverses the AST calculating a sum of all costs involved.<br />
<br />
'''InlineCostVisitor''' is a '''Visitor''' class which works just like any other AST visitor class in DMD, or any other usage of the [http://en.wikipedia.org/wiki/Visitor_pattern visitor pattern]: It contains a '''visit''' function for each AST node type supported by the inliner. Each '''visit''' function traverses its children nodes (if any) by calling the child node's '''accept''' function, passing the visitor class itself as an argument. Then the node's '''accept''' automatically calls its corresponding '''visit''' function.<br />
<br />
Any type of node not supported by '''InlineCostVisitor''' automatically calls a default function '''InlineCostVisitor::visit(Statement *s)''', which flags the function being analyzed as non-inlinable.<br />
<br />
The actual '''cost''' variable is slightly complicated since it's really two packed values:<br />
<br />
The low 12-bits of '''cost''' are the actual accumulated cost. A value of 1 is added for every inlinable expression node in the function's body (ex: "a+b*c" has a cost of 2: One for the multiplication and one for the addition). Anything that can't be inlined, or that the cost analyzer knows nothing about, adds a cost of '''COST_MAX'''. If this total cost, in the low 12-bits, is at least '''COST_MAX''' (determined by the helper function '''tooCostly'''), the function is considered non-inlinable.<br />
<br />
The upper bits of '''cost''' (bits 13 and up) are separate from the actual cost and keep track of whether the function can be inlined as an expression. Whenever a statement is found which can be inlined ''only'' as a statement (and cannot be converted to an expression), this is flagged by adding '''STATEMENT_COST''' to '''cost'''.<br />
<br />
Note: It looks as if at one point in time there had been a limit (or perhaps plans to eventually limit) the number of statements allowed in inlined functions, just as there's currently a limit to the number of expression nodes. But this does not currently appear to be enforced, so '''STATEMENT_COST''' is essentially used as a "this can only be inlined as a statement" flag.<br />
<br />
Sometimes expressions are evaluated for cost by simply visiting the the expression node, via the node's '''accept''' function. Other times, the helper function '''InlineCostVisitor::expressionInlineCost''' is used instead. The benefit of '''expressionInlineCost''' is it automatically halts analysis of an expression as soon as it reaches '''COST_MAX'''.<br />
<br />
The '''canInline''' function caches its results in two members of '''FuncDeclaration''': In '''ILS inlineStatusStmt''' (for inlinability as a statement) and '''ILS inlineStatusExp''' (for inlinability as an expression). '''ILS''' is an enum defined in '''declaration.h''' supporting three states: '''ILSuninitialized''' (not yet cached), '''ILSno''' (not inlinable) and '''ILSyes''' (inlinable).<br />
<br />
===== Inliner: Inlining as a Statement =====<br />
<br />
Any functions DMD is capable of inlining, can be inlined as a statement. As explained above, this is performed whenever a function call ignores the return value, or has no return value. In this case, the function's body is inlined via '''inlineAsStatement'''. Internally, '''inlineAsStatement''' works using its embedded visitor class '''InlineAsStatement'''.<br />
<br />
To paraphrase a comment in '''inline.c''', this inlining is done by converting to a statement, copying the trees of the function to be inlined, and renaming the variables. Most of this is fairly straightforward: Much like the cost analyzer's '''InlineCostVisitor''' class, the '''InlineAsStatement''' class has a '''visit''' function for each supported type of statement and expression. Each of these visitors copies the node, makes any adjustments if necessary, and then visits all subnodes by calling their '''accept''' functions.<br />
<br />
There's also a default catch-all function which asserts, indicating the cost analyzer failed to disallow something which has no corresponding visitor in '''InlineAsStatement'''.<br />
<br />
===== Inliner: Inlining as an Expression =====<br />
<br />
''Some'', but not all, inlinable functions can be inlined as an expression. This must be done whenever a function call uses the return value (Ex: "x = foo();" or "2 + foo()"). In this case, inlining the function's body as an expression works very much like inlining it as a statement (see the section above), but with a separate code path and a few differences:<br />
<br />
* The function body is inlined by '''doInline''' instead of '''inlineAsStatement'''.<br />
* There are two overloads of '''doInline''': One to inline expressions ''as'' expressions, and one to convert statements ''to'' inline expressions.<br />
* As discussed in the sections above, not all statements can be converted to expressions. Because of this, these statements' corresponding '''visit''' functions are omitted from '''doInline''', since the cost analyzer should have already prevented the inliner from attempting to inline any offending functions.<br />
<br />
===== Inliner: How to Add More Support =====<br />
<br />
If a particular statement is unsupported by the inliner (thereby preventing any function using it from being inlined), support can be added like this:<br />
<br />
* Add an overload of '''InlineCostVisitor::visit''' for the type of AST node you wish to support. Following the example of the other visit functions:<br />
:* Increase '''cost''' however is appropriate.<br />
:* Add '''STATEMENT_COST''' to '''cost''' if the statement cannot be converted to an expression (ex: '''ForStatement''' and '''ThrowStatement'''). This allows you to omit a corresponding overload of '''doInline's''' '''InlineStatement::visit'''.<br />
:* Add '''COST_MAX''' to '''cost''' for any situations that are not inlinable.<br />
:* Call '''accept''' on all subnodes. If the subnode is an expression, it may be better to use '''expressionInlineCost''' instead since this will automatically halt analysis as soon as the expression's cost reaches the maximum.<br />
* In '''inlineAsStatement''', add an overload of '''InlineAsStatement::visit''' for the appropriate AST node type. Following the example of the other visit overloads: Copy the node, make any adjustments if necessary, and traverse to all subnodes.<br />
* If the statement can be converted to an expression (ex: '''IfStatement'''), then inside the '''Statement''' overload of '''doInline''', add an overload of '''InlineStatement::visit''' for the appropriate AST node type. Following the other examples, convert the node to an expression, make any adjustments if necessary, and traverse to all subnodes.<br />
<br />
==== The Back End ====<br />
<br />
DMD's internal representation uses expression trees with 'elem' nodes (defined in el.h). The "Rosetta Stone" for understanding the backend is enum OPER in oper.h. This lists all the types of nodes which can be in an expression tree.<br />
<br />
If you compile dmd with debug on, and compile with:<br />
<br />
-O --c<br />
<br />
you'll get reports of the various optimizations done.<br />
<br />
Other useful undocumented flags:<br />
<br />
--b show block optimisation<br />
--f full output<br />
--r show register allocation<br />
--x suppress predefined C++ stuff<br />
--y show output to Intermediate Language (IL) buffer<br />
<br />
Others which are present in the back-end but not exposed as DMD flags are:<br />
debuge show exception handling info<br />
debugs show common subexpression eliminator<br />
<br />
<br />
The most important entry point from the front-end to the backend is writefunc() in out.c, which optimises a function, and then generates code for it.<br />
<br />
* writefunc() sets up the parameters, then calls codgen() to generate the code inside the function.<br />
* it generates code for each block. Then puts vars in registers.<br />
* generates function start code, does pinhole optimisation. (cod3.pinholeopt()).<br />
* does jump optimisation<br />
* emit the generated code in codout().<br />
* writes switch tables<br />
* writes exception tables (nteh_gentables() or except_gentables()<br />
<br />
In cgcod.c, blcodgen() generates code for a basic block. Deals with the way the block ends (return, switch,<br />
if, etc).<br />
<br />
cod1.gencodelem() does the codegen inside the block. It just calls codelem().<br />
<br />
cgcod.codelem() generates code for an elem. This distributes code generation depending on elem type.<br />
<br />
Most x86 integer code generation happens in cod1,cod2, cod3, cod4, and cod5.c<br />
Floating-point code generation happens in cg87. Compared to the integer code generation, the x87 code generator is extremely simple. Most importantly, it cannot cope with common subexpressions. This is the primary reason why it is less efficient than compilers from many other vendors.<br />
<br />
===== Optimiser =====<br />
The main optimiser is in go.c, optfunc().<br />
This calls:<br />
* blockopt.c blockopt(iter) -- branch optimisation on basic blocks, iter = 0 or 1.<br />
* gother.c constprop() -- constant propagation<br />
* gother.c copyprop() -- copy propagation<br />
* gother.c rmdeadass() -- remove dead assignments<br />
* gother.c verybusyexp() -- very busy expressions<br />
* gother.c deadvar() -- eliminate dead variables<br />
<br />
* gloop.c loopopt() -- remove loop invariants and induction vars. Do loop rotation<br />
<br />
* gdag.c boolopt() -- optimize booleans.<br />
* gdag.c builddags() -- common subexpressions<br />
<br />
* el.c el_convert() -- Put float and string literals into the data segment<br />
* el.c el_combine() -- merges two expressions (uses a comma-expression to join them).<br />
* glocal.c localize() -- improve expression locality<br />
<br />
<br />
* cod3.c pinholeopt() -- Performs peephole optimisation. Doesn't do much, could do a lot more.<br />
<br />
===== Code generation =====<br />
The code generation for each function is done individually. Each function is placed into its own COMDAT segment in the obj file.<br />
The function is divided into blocks, which are linear sections of code ending with a jump or other control instruction (http://en.wikipedia.org/wiki/Basic_block).<br />
<br />
===== Scheduler (cgsched.c) =====<br />
<br />
Pentium only<br />
<br />
== Source files ==<br />
<br />
''Note: This section may be considerably outdated. If it's wrong, please correct it. If it's not here, please add it.''<br />
<br />
=== Front end ===<br />
{| class="wikitable" |<br />
! File || Function<br />
|-<br />
| access.d || Access check ('''private''', '''public''', '''package''' ...)<br />
|-<br />
| aliasthis.d || Implements the '''[http://digitalmars.com/d/2.0/class.html#AliasThis alias this]''' D symbol.<br />
|-<br />
| argtypes.d || Convert types for argument passing (e.g. '''char''' are passed as '''ubyte''').<br />
|-<br />
| arrayop.d || [http://digitalmars.com/d/2.0/arrays.html#array-operations Array operations] (e.g. ''a[] = b[] + c[]'').<br />
|-<br />
| attrib.d || [http://digitalmars.com/d/2.0/attribute.html Attributes] i.e. storage class ('''const''', '''@safe''' ...), linkage ('''extern(C)''' ...), protection ('''private''' ...), alignment ('''align(1)''' ...), anonymous aggregate, '''pragma''', '''static if''' and '''mixin'''.<br />
|-<br />
| bit.d || Generate bit-level read/write code. Requires backend support.<br />
|-<br />
| builtin.d || Identify and evaluate built-in functions (e.g. '''std.math.sin''')<br />
|-<br />
| cast.d || Implicit cast, implicit conversion, and explicit cast ('''cast(T)'''), combining type in binary expression, integer promotion, and value range propagation.<br />
|-<br />
| class.d || Class declaration<br />
|-<br />
| clone.d || Define the implicit '''opEquals''', '''opAssign''', post blit and destructor for struct if needed, and also define the copy constructor for struct.<br />
|-<br />
| cond.d || Evaluate compile-time conditionals, i.e. '''debug''', '''version''', and '''static if'''.<br />
|-<br />
| constfold.d || Constant folding<br />
|-<br />
| cppmangle.d || Mangle D types according to [http://mentorembedded.github.io/cxx-abi/abi.html#mangling Intel's Itanium C++ ABI].<br />
|-<br />
| declaration.d || Miscellaneous declarations, including '''typedef''', '''alias''', variable declarations including the implicit '''this''' declaration, type tuples, ClassInfo, ModuleInfo and various TypeInfos.<br />
|-<br />
| delegatize.d || Convert an expression ''expr'' to a delegate ''{ return expr; }'' (e.g. in '''lazy''' parameter). <br />
|-<br />
| doc.d || [http://digitalmars.com/d/ddoc.html Ddoc] documentation generator ([http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=1558 NG:digitalmars.D.announce/1558])<br />
|-<br />
| dsymbol.d || D symbols (i.e. variables, functions, modules, ... anything that has a name).<br />
|-<br />
| dump.d || Defines the ''Expression::dump'' method to print the content of the expression to console. Mainly for debugging.<br />
|-<br />
| e2ir.d || Expression to Intermediate Representation; requires backend support<br />
|-<br />
| eh.d || Generate exception handling tables<br />
|-<br />
| entity.d || Defines the named entities to support the ''"\&Entity;"'' escape sequence.<br />
|-<br />
| enum.d || Enum declaration<br />
|-<br />
| expression.h || Defines the bulk of the classes which represent the AST at the expression level.<br />
|-<br />
| func.d || Function declaration, also includes function/delegate literals, function alias, (static/shared) constructor/destructor/post-blit, '''invariant''', '''unittest''' and [http://digitalmars.com/d/2.0/class.html#allocators allocator/deallocator].<br />
|-<br />
| glue.d || Generate the object file for function declarations and critical sections; convert between backend types and frontend types<br />
|-<br />
| hdrgen.d || Generate headers (*.di files)<br />
|-<br />
| iasm.d || Inline assembler<br />
|-<br />
| identifier.d || Identifier (just the name).<br />
|-<br />
| idgen.d || Make id.h and id.c for defining built-in Identifier instances. Compile and run this before compiling the rest of the source. ([http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=17157 NG:digitalmars.D/17157])<br />
|-<br />
| impcvngen.d || Make impcnvtab.c for the implicit conversion table. Compile and run this before compiling the rest of the source. <br />
|-<br />
| imphint.d || Import hint, e.g. prompting to import ''std.stdio'' when using ''writeln''.<br />
|-<br />
| import.d || Import.<br />
|-<br />
| inifile.d || Read .ini file<br />
|-<br />
| init.d || [http://digitalmars.com/d/2.0/declaration.html#Initializer Initializers] (e.g. the ''3'' in ''int x = 3'').<br />
|-<br />
| inline.d || Compute the cost and perform inlining.<br />
|-<br />
| interpret.d || All the code which evaluates CTFE<br />
|-<br />
| irstate.d || Intermediate Representation state; requires backend support<br />
|-<br />
| json.d || Generate JSON output<br />
|-<br />
| lexer.d || Lexically analyzes the source (such as separate keywords from identifiers)<br />
|-<br />
| libelf.d || ELF object format functions<br />
|-<br />
| libmach.d || Mach-O object format functions<br />
|-<br />
| libomf.d || OMF object format functions<br />
|-<br />
| link.d || Call the linker<br />
|-<br />
| macro.d || Expand DDoc macros<br />
|-<br />
| mangle.d || Mangle D types and declarations<br />
|-<br />
| mars.d || Analyzes the command line arguments (also display command-line help)<br />
|-<br />
| module.d || ead modules.<br />
|-<br />
| msc.d || ?<br />
|-<br />
| mtype.d || All D types.<br />
|-<br />
| opover.d || Apply operator overloading<br />
|-<br />
| optimize.d || Optimize the AST<br />
|-<br />
| parse.d || Parse tokens into AST<br />
|-<br />
| ph.d || Custom allocator to replace malloc/free<br />
|-<br />
| root/aav.d || Associative array<br />
|-<br />
| root/array.d || Dynamic array<br />
|-<br />
| root/async.d || Asynchronous input<br />
|-<br />
| root/dchar.d || Convert UTF-32 character to UTF-8 sequence<br />
|-<br />
| root/gnuc.d || Implements functions missing from GCC, specifically ''stricmp'' and ''memicmp''.<br />
|-<br />
| root/lstring.d || Length-prefixed UTF-32 string.<br />
|-<br />
| root/man.d || Start the internet browser.<br />
|-<br />
| root/port.d || Portable wrapper around compiler/system specific things. The idea is to minimize #ifdef's in the app code.<br />
|-<br />
| root/response.d || ead the [http://digitalmars.com/d/2.0/dmd-windows.html#switches response file].<br />
|-<br />
| root/rmem.d || Implementation of the storage allocator uses the standard C allocation package.<br />
|-<br />
| root/root.d || Basic functions (deal mostly with strings, files, and bits)<br />
|-<br />
| root/speller.d || Spellchecker<br />
|-<br />
| root/stringtable.d || String table<br />
|-<br />
| s2ir.d || Statement to Intermediate Representation; requires backend support<br />
|-<br />
| scope.d || Scope<br />
|-<br />
| statement.d || Handles '''while''', '''do''', '''for''', '''foreach''', '''if''', '''pragma''', '''staticassert''', '''switch''', '''case''', '''default''' , '''break''', '''return''', '''continue''', '''synchronized''', '''try'''/'''catch'''/'''finally''', '''throw''', '''volatile''', '''goto''', and '''label'''<br />
|-<br />
| staticassert.d || '''static assert'''.<br />
|-<br />
| struct.d || Aggregate ('''struct''' and '''union''') declaration.<br />
|-<br />
| template.d || Everything related to '''template'''.<br />
|-<br />
| tk/ || ?<br />
|-<br />
| tocsym.d || o C symbol<br />
|-<br />
| toctype.d || Convert D type to C type for debug symbol<br />
|-<br />
| tocvdebug.d || [http://stackoverflow.com/questions/1418660/microsofts-codeview-format-specs CodeView4 debug format].<br />
|-<br />
| todt.d || ?; requires backend support<br />
|-<br />
| toelfdebug.d || Emit symbolic debug info in Dwarf2 format. Currently empty.<br />
|-<br />
| toir.d || o Intermediate Representation; requires backend support<br />
|-<br />
| toobj.d || Generate the object file for Dsymbol and declarations except functions.<br />
|-<br />
| traits.d || '''__traits'''.<br />
|-<br />
| typinf.d || Get TypeInfo from a type.<br />
|-<br />
| unialpha.d || Check if a character is a Unicode alphabet.<br />
|-<br />
| unittests.d || un functions related to unit test.<br />
|-<br />
| utf.d || UTF-8.<br />
|-<br />
| version.d || Handles '''version'''<br />
|}<br />
<br />
=== Back end ===<br />
{| class="wikitable" |<br />
! File || Function<br />
|-<br />
| html.c || Extracts D source code from .html files<br />
|}<br />
<br />
=== A few observations ===<br />
* idgen.c is not part of the compiler source at all. It is the source to a code generator which creates id.h and id.c, which defines a whole lot of Identifier instances. (presumably, these are used to represent various 'builtin' symbols that the language defines)<br />
* impcvngen.c follows the same pattern as idgen.c. It creates impcnvtab.c, which appears to describe casting rules between primitive types.<br />
* Unspurprisingly, the code is highly D-like in methodology. For instance, root.h defines an Object class which serves as a base class for most, if not all of the other classes used. Class instances are always passed by pointer and allocated on the heap.<br />
* root.h also defines String, Array, and File classes, as opposed to using STL. Curious. (a relic from the days when templates weren't as reliable as they are now?)<br />
* lots of files with .c suffixes contain C++ code. Very confusing.<br />
<br />
== Abbreviations ==<br />
<br />
You may find these abbreviations throughout the DMD source code (in identifiers and comments).<br />
<br />
==== Front-end ====<br />
; STC<br />
: STorage Class<br />
; ILS<br />
: InLine State<br />
; IR<br />
: Intermediate Representation<br />
<br />
==== Back-end ====<br />
; AE<br />
: Available Expressions <br />
; CP<br />
: Copy Propagation info.<br />
; CSE<br />
: Common Subexpression Elimination <br />
; VBE<br />
: Very Busy Expression (http://web.cs.wpi.edu/~kal/PLT/PLT9.6.html)<br />
<br />
See also: [[Commonly-Used Acronyms]]<br />
<br />
==Class hierarchy==<br />
<br />
Have a look at [[Media:dmd_ast.png]].<br />
<br />
* RootObject<br />
** Dsymbol<br />
*** AliasThis<br />
*** AttribDeclaration<br />
**** StorageClassDeclaration<br />
***** DeprecatedDeclaration<br />
**** LinkDeclaration<br />
**** ProtDeclaration<br />
**** AlignDeclaration<br />
**** AnonDeclaration<br />
**** PragmaDeclaration<br />
**** ConditionalDeclaration<br />
***** StaticIfDeclaration<br />
**** CompileDeclaration<br />
**** UserAttributeDeclaration<br />
*** Declaration<br />
**** TupleDeclaration<br />
**** AliasDeclaration<br />
**** VarDeclaration<br />
***** TypeInfoDeclaration<br />
****** TypeInfoStructDeclaration<br />
****** TypeInfoClassDeclaration<br />
****** TypeInfoInterfaceDeclaration<br />
****** TypeInfoPointerDeclaration<br />
****** TypeInfoArrayDeclaration<br />
****** TypeInfoStaticArrayDeclaration<br />
****** TypeInfoAssociativeArrayDeclaration<br />
****** TypeInfoEnumDeclaration<br />
****** TypeInfoFunctionDeclaration<br />
****** TypeInfoDelegateDeclaration<br />
****** TypeInfoTupleDeclaration<br />
****** TypeInfoConstDeclaration<br />
****** TypeInfoInvariantDeclaration<br />
****** TypeInfoSharedDeclaration<br />
****** TypeInfoWildDeclaration<br />
****** TypeInfoVectorDeclaration<br />
***** ThisDeclaration<br />
**** SymbolDeclaration<br />
**** FuncDeclaration<br />
***** FuncAliasDeclaration<br />
***** FuncLiteralDeclaration<br />
***** CtorDeclaration<br />
***** PostBlitDeclaration<br />
***** DtorDeclaration<br />
***** StaticCtorDeclaration<br />
****** SharedStaticCtorDeclaration<br />
***** StaticDtorDeclaration<br />
****** SharedStaticDtorDeclaration<br />
***** InvariantDeclaration<br />
***** UnitTestDeclaration<br />
***** NewDeclaration<br />
***** DeleteDeclaration<br />
*** ScopeDsymbol<br />
**** AggregateDeclaration<br />
***** StructDeclaration<br />
****** UnionDeclaration<br />
***** ClassDeclaration<br />
****** InterfaceDeclaration<br />
**** WithScopeSymbol<br />
**** ArrayScopeSymbol<br />
**** EnumDeclaration<br />
**** Package<br />
***** Module<br />
**** TemplateDeclaration<br />
**** TemplateInstance<br />
***** TemplateMixin<br />
*** OverloadSet<br />
*** EnumMember<br />
*** Import<br />
*** LabelDsymbol<br />
*** StaticAssert<br />
*** DebugSymbol<br />
*** VersionSymbol<br />
** Expression<br />
*** ClassReferenceExp<br />
*** VoidInitExp<br />
*** ThrownExceptionExp<br />
*** IntegerExp<br />
*** ErrorExp<br />
*** RealExp<br />
*** ComplexExp<br />
*** IdentifierExp<br />
**** DollarExp<br />
*** DsymbolExp<br />
*** ThisExp<br />
**** SuperExp<br />
*** NullExp<br />
*** StringExp<br />
*** TupleExp<br />
*** ArrayLiteralExp<br />
*** AssocArrayLiteralExp<br />
*** StructLiteralExp<br />
*** TypeExp<br />
*** ScopeExp<br />
*** TemplateExp<br />
*** NewExp<br />
*** NewAnonClassExp<br />
*** SymbolExp<br />
**** SymOffExp<br />
**** VarExp<br />
*** OverExp<br />
*** FuncExp<br />
*** DeclarationExp<br />
*** TypeidExp<br />
*** TraitsExp<br />
*** HaltExp<br />
*** IsExp<br />
*** UnaExp<br />
**** CompileExp<br />
**** AssertExp<br />
**** DotIdExp<br />
**** DotTemplateExp<br />
**** DotVarExp<br />
**** DotTemplateInstanceExp<br />
**** DelegateExp<br />
**** DotTypeExp<br />
**** CallExp<br />
**** AddrExp<br />
**** PtrExp<br />
**** NegExp<br />
**** UAddExp<br />
**** ComExp<br />
**** NotExp<br />
**** DeleteExp<br />
**** CastExp<br />
**** VectorExp<br />
**** SliceExp<br />
**** ArrayLengthExp<br />
**** ArrayExp<br />
**** PreExp<br />
*** BinExp<br />
**** BinAssignExp<br />
***** AddAssignExp<br />
***** MinAssignExp<br />
***** MulAssignExp<br />
***** DivAssignExp<br />
***** ModAssignExp<br />
***** AndAssignExp<br />
***** OrAssignExp<br />
***** XorAssignExp<br />
***** PowAssignExp<br />
***** ShlAssignExp<br />
***** ShrAssignExp<br />
***** UshrAssignExp<br />
***** CatAssignExp<br />
**** DotExp<br />
**** CommaExp<br />
**** IndexExp<br />
**** PostExp<br />
**** AssignExp<br />
***** ConstructExp<br />
**** AddExp<br />
**** MinExp<br />
**** CatExp<br />
**** MulExp<br />
**** DivExp<br />
**** ModExp<br />
**** PowExp<br />
**** ShlExp<br />
**** ShrExp<br />
**** UshrExp<br />
**** AndExp<br />
**** OrExp<br />
**** XorExp<br />
**** OrOrExp<br />
**** AndAndExp<br />
**** CmpExp<br />
**** InExp<br />
**** RemoveExp<br />
**** EqualExp<br />
**** IdentityExp<br />
**** CondExp<br />
*** DefaultInitExp<br />
**** FileInitExp<br />
**** LineInitExp<br />
**** ModuleInitExp<br />
**** FuncInitExp<br />
**** PrettyFuncInitExp<br />
** Identifier<br />
** Initializer<br />
*** VoidInitializer<br />
*** ErrorInitializer<br />
*** StructInitializer<br />
*** ArrayInitializer<br />
*** ExpInitializer<br />
** Type<br />
*** TypeError<br />
*** TypeNext<br />
**** TypeArray<br />
***** TypeSArray<br />
***** TypeDArray<br />
***** TypeAArray<br />
**** TypePointer<br />
**** TypeReference<br />
**** TypeFunction<br />
**** TypeDelegate<br />
**** TypeSlice<br />
*** TypeBasic<br />
*** TypeVector<br />
*** TypeQualified<br />
**** TypeIdentifier<br />
**** TypeInstance<br />
**** TypeTypeof<br />
**** TypeReturn<br />
*** TypeStruct<br />
*** TypeEnum<br />
*** TypeClass<br />
*** TypeTuple<br />
*** TypeNull<br />
** Parameter<br />
** Statement<br />
*** ErrorStatement<br />
*** PeelStatement<br />
*** ExpStatement<br />
**** DtorExpStatement<br />
*** CompileStatement<br />
*** CompoundStatement<br />
**** CompoundDeclarationStatement<br />
*** UnrolledLoopStatement<br />
*** ScopeStatement<br />
*** WhileStatement<br />
*** DoStatement<br />
*** ForStatement<br />
*** ForeachStatement<br />
*** ForeachRangeStatement<br />
*** IfStatement<br />
*** ConditionalStatement<br />
*** PragmaStatement<br />
*** StaticAssertStatement<br />
*** SwitchStatement<br />
*** CaseStatement<br />
*** CaseRangeStatement<br />
*** DefaultStatement<br />
*** GotoDefaultStatement<br />
*** GotoCaseStatement<br />
*** SwitchErrorStatement<br />
*** ReturnStatement<br />
*** BreakStatement<br />
*** ContinueStatement<br />
*** SynchronizedStatement<br />
*** WithStatement<br />
*** TryCatchStatement<br />
*** TryFinallyStatement<br />
*** OnScopeStatement<br />
*** ThrowStatement<br />
*** DebugStatement<br />
*** GotoStatement<br />
*** LabelStatement<br />
*** AsmStatement<br />
*** ImportStatement<br />
** Catch<br />
** Tuple<br />
** DsymbolTable<br />
** Condition<br />
*** DVCondition<br />
**** DebugCondition<br />
**** VersionCondition<br />
*** StaticIfCondition<br />
* Visitor<br />
** StoppableVisitor<br />
* Lexer<br />
** Parser<br />
* Library<br />
<br />
== DMD Hacking Tips & Tricks ==<br />
<br />
=== Use printf-style debugging without too much visual noise ===<br />
<br />
There are many commented-out '''printf''' statements in the DMD front-end. You can uncomment them<br />
during debugging, but often you may only want to enable them for a specific symbol. One simple<br />
workaround is to enable printing when the name of the symbol matches the symbol you're debugging,<br />
for example:<br />
<br />
<syntaxhighlight lang="cpp"><br />
void StructDeclaration::semantic(Scope *sc)<br />
{<br />
// only do printouts if this is our target symbol<br />
if (!strcmp(toChars(), "test_struct"));<br />
printf("this=%p, %s '%s', sizeok = %d\n", this, parent->toChars(), toChars(), sizeok);<br />
}<br />
</syntaxhighlight><br />
<br />
=== Find which module instantiated a specific template instance ===<br />
<br />
Templates have a '''instantiatingModule''' field which you can inspect. Here's an example from '''glue.c''':<br />
<br />
<syntaxhighlight lang="cpp"><br />
/* Skip generating code if this part of a TemplateInstance that is instantiated<br />
* only by non-root modules (i.e. modules not listed on the command line).<br />
*/<br />
TemplateInstance *ti = inTemplateInstance();<br />
if (!global.params.useUnitTests &&<br />
ti && ti->instantiatingModule && !ti->instantiatingModule->root)<br />
{<br />
//printf("instantiated by %s %s\n", ti->instantiatingModule->toChars(), ti->toChars());<br />
return;<br />
}<br />
</syntaxhighlight><br />
<br />
=== Determine if a DMD 'Type' is an actual type, expression, or a symbol ===<br />
<br />
You can use the '''resolve''' virtual function to determine this:<br />
<br />
<syntaxhighlight lang="cpp"><br />
RootObject *o = ...;<br />
Type *srcType = isType(o);<br />
<br />
if (srcType)<br />
{<br />
Type *t;<br />
Expression *e;<br />
Dsymbol *s;<br />
srcType->resolve(loc, sc, &e, &t, &s);<br />
<br />
if (t) { } // it's a type<br />
else if (e) { } // it's an expression<br />
else if (s) { } // it's a symbol<br />
}<br />
</syntaxhighlight><br />
<br />
You can see examples of this technique being used in the '''traits.c''' file.<br />
<br />
=== Get the string representation of a DSymbol ===<br />
<br />
A '''DSymbol''' has the two functions '''toChars()''' and '''toPrettyChars()''',<br />
which are useful for debugging. The former prints out the name of the symbol,<br />
while the latter may print out the fully-scoped name of the symbol. For example:<br />
<br />
<syntaxhighlight lang="cpp"><br />
StructDeclaration *sd = ...; // assuming struct named "Bar" inside module named "Foo"<br />
printf("name: %s\n", sd->toChars()); // prints out "Bar"<br />
printf("fully qualified name: %s\n", sd->toPrettyChars()); // prints out "Foo.Bar"<br />
</syntaxhighlight><br />
<br />
=== Get the string representation of the kind of a DSymbol ===<br />
<br />
All '''DSymbol'''-inherited classes implement the '''kind''' virtual method,<br />
which enable you to use printf-style debugging, e.g.:<br />
<br />
<syntaxhighlight lang="cpp"><br />
EnumDeclaration *ed = ...;<br />
DSymbol *s = ed;<br />
printf("%s\n", s->kind()); // prints "enum". See 'EnumDeclaration::kind'.<br />
</syntaxhighlight><br />
<br />
=== Get the string representation of an operator or token ===<br />
<br />
'''Expression''' objects hold an '''op''' field, which is a '''TOK''' type (a token).<br />
To print out the string representation of the token, index into the static array '''Token::tochars''':<br />
<br />
<syntaxhighlight lang="cpp"><br />
Expression *e = ...;<br />
printf("Expression op: %s ", Token::toChars(e->op));<br />
</syntaxhighlight><br />
<br />
=== Print the value of a floating-point literal ===<br />
<br />
To print the value of an expression which is a floating-point literal (a value known at compile-time),<br />
use the '''toReal()''' member function:<br />
<br />
<syntaxhighlight lang="cpp"><br />
if (exp->op == TOKfloat32 || exp->op == TOKfloat64 || exp->op == TOKfloat80)<br />
printf("%Lf", exp->toReal());<br />
</syntaxhighlight><br />
<br />
=== Check whether an expression is a compile-time known literal ===<br />
<br />
Use the '''isConst()''' method to check if an '''Expression''' is a compile-time known literal.<br />
The name '''isConst()''' is a misnomer, but this name predates D2 and was more relevant to D1.<br />
Please note that '''isConst()''' is also a method of '''Type''', but is unrelated to the<br />
equally named function in the '''Expression''' class.<br />
<br />
=== Note the difference between two mixin types: compile declarations and compile statements ===<br />
<br />
Take this example D code:<br />
<br />
<syntaxhighlight lang="D"><br />
mixin("int x;");<br />
<br />
void main()<br />
{<br />
mixin("int y;");<br />
}<br />
</syntaxhighlight><br />
<br />
The first mixin is a '''CompileDeclaration''', while the second is a '''CompileStatement'''.<br />
These are separate classes in the DMD front-end.<br />
<br />
<br />
[[Category:DMD Compiler]]</div>Notnahttps://wiki.dlang.org/?title=Template:Latest_DMD_Version_Raw&diff=8060Template:Latest DMD Version Raw2016-11-20T18:24:08Z<p>Notna: </p>
<hr />
<div>2.072.0</div>Notnahttps://wiki.dlang.org/?title=DMD_Widget&diff=7868DMD Widget2016-07-11T16:26:09Z<p>Notna: </p>
<hr />
<div><div style="background: #f9f9f9; padding: 0.5ex 1em; border-top: 1px solid #e0e0e0; margin: 5px 10px;"><br />
Latest DMD:<br />
<span style="background-color: #c4664a; border-bottom: 1px solid #964e39; color: #fff; font-family: monospace; padding: 2px 5px; border-radius: 5px; font-size: 13pt; line-height: 1.8em;">{{Latest_DMD_Version}}</span><!-- To edit, visit: /Template:Latest_DMD_Version_Raw --><br />
[http://dlang.org/download.html Download] &mdash;<br />
[http://dlang.org/changelog.html Changelog] &mdash; <br />
[https://github.com/D-Programming-Language Source code] &mdash; <br />
[http://d.puremagic.com/issues/ Bug tracker] &mdash;<br />
[[DMD|More &raquo;]]<br />
<span style="float:right; color:#ccc; font-size:0.9em; padding: 0.5em 0.5em;">[[DMD_Widget|&#9998;]]</span><br />
</div></div>Notnahttps://wiki.dlang.org/?title=Template:Latest_DMD_Version_Raw&diff=7867Template:Latest DMD Version Raw2016-07-11T16:24:35Z<p>Notna: </p>
<hr />
<div>2.071.1</div>Notnahttps://wiki.dlang.org/?title=Starting_as_a_Contributor&diff=7256Starting as a Contributor2016-02-11T20:50:26Z<p>Notna: /* Ancillary stuff */</p>
<hr />
<div>This page describes how to build D, put together a correct patch, and contribute it as a GitHub pull request.<br />
<br />
== Copyright assignment ==<br />
<br />
Please note that all contributions to DMD backend source code require that the copyright to that code be assigned to Digital Mars. This does not apply to the DMD frontend, Druntime, Phobos, or the official tools.<br />
<br />
==Existing tools==<br />
<br />
There exist tools which can do some of the below steps automatically:<br />
<br />
* [https://github.com/D-Programming-Language/tools/blob/master/update.sh tools/update.sh] is a simple script that either installs a new or updates an existing D development tree. Just download the script and run.<br />
* [https://github.com/CyberShadow/Digger Digger] - can download and build D from any point in its recent history.<br />
* [https://github.com/jacob-carlborg/dvm DVM] - can build and locally install D from source code.<br />
<br />
== Prerequisites ==<br />
<br />
=== POSIX ===<br />
<br />
To build D on POSIX, you will need to have <tt>make</tt>, <tt>g++</tt>, <tt>libcurl4-openssl-dev</tt>, and <tt>git</tt> installed on your system, as well as a working GitHub account. To install the appropriate dependencies on e.g. Ubuntu:<br />
<br />
sudo apt-get install curl git make g++ libcurl4-openssl-dev<br />
<br />
On OS X with Homebrew:<br />
<br />
$ xcode-select --install<br />
$ brew install git openssl<br />
<br />
To build the 32-bit phobos on a 64-bit machine, some 32-bit packages are also needed:<br />
<br />
sudo apt-get install gcc-multilib libc6-dev-i386 libcurl4-gnutls-dev:i386<br />
<br />
Other versions and variations of <tt>libcurl</tt> may work as well.<br />
<br />
=== Windows ===<br />
<br />
On Windows, you will need [https://git-scm.com/ Git for Windows], [http://ftp.digitalmars.com/dmc.zip the DigitalMars C++ compiler], and, for 64-bit or 32-bit COFF builds, the [https://www.microsoft.com/en-us/download/details.aspx?id=8279 Microsoft Windows SDK].<br />
<br />
== Building D ==<br />
<br />
=== Posix ===<br />
<br />
==== Fetch <tt>dmd</tt> from GitHub ====<br />
<br />
Let's start by getting the current development (master) branch of dmd from GitHub. Assume the root directory for everything D-related is <tt>~/code</tt> (replace appropriately). This is easily done by running at a command prompt:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ~/code<br />
git clone https://github.com/D-Programming-Language/dmd<br />
</syntaxhighlight><br />
<br />
After this step completes successfully, the directory <tt>~/code/dmd</tt> should be up and filled with good stuff.<br />
<br />
==== Bootstrap <tt>dmd</tt> ====<br />
<br />
This step is interesting because in order to build <tt>dmd</tt>, <tt>dmd</tt> is necessary. Fortunately, the steps of downloading and using a preexisting <tt>dmd</tt> compiler are automated. All you need to do is run this command:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ~/code/dmd<br />
make -f posix.mak AUTO_BOOTSTRAP=1<br />
</syntaxhighlight><br />
<br />
That's going to take a while. To make it faster, passing <tt>-j8</tt> accelerates things by running eight processes in parallel. The build produces the compiler binary <tt>~/code/dmd/src/dmd</tt>.<br />
<br />
To make <tt>dmd</tt> builds faster in the future, you need to obviate the need for bootstrapping. Install <tt>dmd</tt> from the [http://dlang.org/download.html download page] or simply put the freshly built <tt>dmd</tt> binary in a place accessible through <tt>$PATH</tt> (a popular choice is <tt>~/bin</tt>).<br />
<br />
On Windows, you will need <br />
<br />
==== Fetch and build <tt>druntime</tt> ====<br />
<br />
<tt>druntime</tt> is the core runtime library for D, needed for building most every D program, including the standard library itself. So it's the next step in the progression (note that it requires a properly built <tt>dmd</tt>, so make sure the above steps have completed successfully). To fetch and build druntime, issue these commands:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ~/code<br />
git clone https://github.com/D-Programming-Language/druntime<br />
cd druntime<br />
make -f posix.mak<br />
</syntaxhighlight><br />
<br />
All that should go pretty fast. The somewhat anticlimactic result of the build is a library called <tt>libdruntime.a</tt> situated in an OS-dependent directory such as <tt>~/code/druntime/generated/linux/release/64/</tt>. Make sure it's there. This library is made available to your applications through Phobos, so you must follow the next step to reflect any changes to druntime in your application.<br />
<br />
==== Fetch and build <tt>phobos</tt> ====<br />
<br />
Most D programs use D's standard library <tt>phobos</tt>. To get and build it, make sure you first fetch and build the latest <tt>dmd</tt> and <tt>druntime</tt>. Then:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ~/code<br />
git clone https://github.com/D-Programming-Language/phobos<br />
cd phobos<br />
make -f posix.mak<br />
</syntaxhighlight><br />
<br />
The build produces (with similar anticlimacticity) static and shared libraries such as <tt>~/code/phobos/generated/linux/release/64/libphobos2.a</tt> and <tt>~/code/phobos/generated/linux/release/64/libphobos2.so</tt>.<br />
<br />
=== Windows ===<br />
<br />
The following instructions work for win32. May or may not work with win64. This scheme is a suggestion. These instructions should work when building from a clean repository, however, this repository contains autogenerated code that may be left behind after switching branches so running a git clean after switching branches is a good idea:<br />
<br />
<syntaxhighlight lang=dos><br />
git clean -xfd<br />
</syntaxhighlight><br />
<br />
Assuming your sources are checked out {{code|C:\D}}, and that {{code|make}} from digital mars is in your path, you can do the following to build them:<br />
<br />
<syntaxhighlight lang=dos><br />
set DM_HOME=C:\D<br />
cd %DM_HOME%\dmd2\src\dmd\src<br />
make -fwin32.mak release<br />
</syntaxhighlight><br />
<br />
From there, it is suggested to move the built binaries into your {{code|%DM_HOME%\windows\bin}} directory, and add that to your path:<br />
<syntaxhighlight lang=dos><br />
copy *.exe %DM_HOME%\dmd2\windows\bin<br />
set path=%path%;%DM_HOME%\dmd2\windows\bin<br />
</syntaxhighlight><br />
<br />
From there, you have to create a {{code|sc.ini}} in your {{code|DMD.exe}} directory. It is suggested to just copy paste the one provided in the packaged {{Latest DMD Version Raw}}, instead of writing your own.<br />
<br />
Now build druntime:<br />
<syntaxhighlight lang=dos><br />
cd %DM_HOME%\dmd2\src\druntime<br />
make -fwin32.mak<br />
</syntaxhighlight><br />
<br />
And phobos:<br />
<syntaxhighlight lang=dos><br />
cd %DM_HOME%\dmd2\src\phobos<br />
make -fwin32.mak<br />
</syntaxhighlight><br />
<br />
You should copy the phobos lib into your {{code|windows\lib}} folder:<br />
<syntaxhighlight lang=dos><br />
copy phobos.lib %DM_HOME%\dmd2\windows\lib<br />
</syntaxhighlight><br />
<br />
Optionally, you can build rdmd from source if you have checked out {{code|tools}} in your sources:<br />
<syntaxhighlight lang=dos><br />
cd %DM_HOME%\dmd2\src\tools<br />
make -fwin32.mak rdmd.exe<br />
copy *.exe %DM_HOME%\dmd2\windows\bin<br />
</syntaxhighlight><br />
<br />
The last step is getting the additional libs. curl for D2 can be found at the bottom of the download section of dlang.org: [[http://dlang.org/download.html download]].<br />
<br />
Additional libs that are necessary can simply be copy pasted from the {{Latest DMD Version Raw}} package (without overwriting your {{code|phobos.lib}})<br />
<br />
The very last step is to verify that everything works by unittesting phobos:<br />
<br />
<syntaxhighlight lang=dos><br />
cd %DM_HOME%\dmd2\src\phobos<br />
make -fwin32.mak unittest<br />
</syntaxhighlight><br />
<br />
==== Common Windows issues ====<br />
<br />
===== Missing MASM386=====<br />
<br />
If when building druntime you get errors about missing MASM386, it's due to a required assembling of a file called '''minit.asm'''. However the druntime repository includes a prebuilt minit.obj file so you shouldn't need to assemble it again. As a workaround for the make error create an empty '''masm386.bat''' file and put it in a directory that's in your '''PATH'''.<br />
<br />
It's also recommended that you use the cmd.exe terminal. Others, like PowerShell, are known to experience issues with legacy tools.<br />
<br />
===== Intermediate files lead to several errors =====<br />
<br />
The three main components (dmd, druntime, phobos) should always be built together with matching versions. The intermediate files generated by a previous build can lead to a failure so it's advisable to run<br />
<br />
<syntaxhighlight lang=dos><br />
make -fwin32.mak clean<br />
</syntaxhighlight><br />
<br />
on each component before starting the process.<br />
<br />
== Unittest <tt>phobos</tt> ==<br />
<br />
If you want to work on phobos itself, you need to run unittests&mdash;either for the full library, a package, or a module. To unittest the entire library:<br />
<br />
<syntaxhighlight lang=bash><br />
make -j16 -f posix.mak unittest<br />
</syntaxhighlight><br />
<br />
Adjust the parameter passed to <tt>-j</tt> depending on your machine (beefier machines support larger parameters). This command unittests <tt>phobos</tt> in both debug and release mode. To only test one of them, add <tt>BUILD=debug</tt> or <tt>BUILD=release</tt> to the command line, for example:<br />
<br />
<syntaxhighlight lang=bash><br />
make -j16 -f posix.mak BUILD=debug unittest<br />
</syntaxhighlight><br />
<br />
Specifying <tt>BUILD</tt> makes unittesting faster so it is recommended in iterative development. Just make sure both debug and release builds are tested before e.g. submitting a pull request.<br />
<br />
While changing one specific package or module, it's useful to be able to only unittest that particular entity. The following two commands only unittest (in debug mode) the <tt>std.algorithm</tt> package and the <tt>std.conv</tt> module, respectively:<br />
<br />
<syntaxhighlight lang=bash><br />
make -j16 -f posix.mak BUILD=debug std/algorithm.test<br />
make -j16 -f posix.mak BUILD=debug std/conv.test<br />
</syntaxhighlight><br />
<br />
Several modules, packages, or mix thereof may be specified for testing in the same command line. For example, this command also tests (and also in debug mode) the <tt>std.algorithm</tt> package and the <tt>std.conv</tt> module, with better parallelism:<br />
<br />
<syntaxhighlight lang=bash><br />
make -j16 -f posix.mak BUILD=debug std/algorithm.test std/conv.test<br />
</syntaxhighlight><br />
<br />
The auto-tester will fail your PR if your changes contain trailing whitespace or incorrect line endings. You can run this test locally with the command:<br />
<br />
<syntaxhighlight lang=bash><br />
make -j16 -f posix.mak checkwhitespace<br />
</syntaxhighlight><br />
<br />
==Running Independent Programs==<br />
<br />
The rig created so far allows making changes and testing dmd, druntime, and phobos by using their respective makefiles. However, running independent programs (such as by using <tt>~/code/dmd/src/dmd ~/mytest</tt>) will not know where to pick up the libraries from, even though the compiler path is correctly specified. As a consequence such programs will not compile, or (worse) will pick up libraries of a preexisting dmd installation on the target system and will fail in mysterious ways.<br />
<br />
The remedy is to specify include and library paths properly. To build <tt>mytest.d</tt> using <tt>~/code/dmd</tt>, <tt>~/code/dmd</tt>, and <tt>~/code/dmd</tt>, use this command line:<br />
<br />
<syntaxhighlight lang=bash><br />
~/code/dmd/src/dmd -I~/code/druntime/import -I~/code/phobos -L-L$HOME/code/phobos/generated/*/release/64 mytest.d<br />
</syntaxhighlight><br />
<br />
The two <tt>-I</tt> uses bring the import files for druntime and phobos into visibility. The <tt>-L</tt> directive forwards the rest of the argument to the linker, i.e. the linker will get <tt>$HOME/code/phobos/generated/*/release/64/</tt> with <tt>$HOME</tt> expanded properly. Sadly we cannot use the tilde (<tt>~</tt>) for <tt>-L</tt> because it won't get expanded properly. (If you need a 32-bit build, replace <tt>/64</tt> with <tt>/32</tt> and of course use the <tt>-m32</tt> flag for the compiler.)<br />
<br />
Of course if you need to use this line often, you may want to put it into a batch file or a <tt>dmd.conf</tt> file (see more info about <tt>dmd.conf</tt> on [https://dlang.org/dmd-linux.html Linux], [https://dlang.org/dmd-windows.html Windows], [https://dlang.org/dmd-osx.html OSX], and [https://dlang.org/dmd-freebsd.html FreeBSD]).<br />
<br />
(What's with the <tt>*</tt> in the path provided to the linker? If you browse to <tt>/code/phobos/generated/</tt>, you'll see a directory with an OS name, such as <tt>linux</tt> or <tt>osx</tt>. Virtually always that directory is only for one operating system, so using <tt>*</tt> will simply navigate appropriately.)<br />
<br />
== Fetch and build <tt>dlang.org</tt> ==<br />
<br />
This step is optional. Significant changes to <tt>phobos</tt>' documentation require that the site (which includes automatically generated <tt>phobos</tt> documentation) builds successfully. The following will build all documentation in all forms (see the note below about building just the html documentation):<br />
<br />
<syntaxhighlight lang=bash><br />
cd ~/code<br />
git clone https://github.com/D-Programming-Language/dlang.org<br />
cd dlang.org<br />
make -f posix.mak<br />
</syntaxhighlight><br />
<br />
All of <tt>dmd</tt>, <tt>druntime</tt>, and <tt>phobos</tt> are needed for the site to build. Note that one of the first lines output during the <tt>make</tt> run looks like this:<br />
<br />
<tt>LATEST={{Latest DMD Version Raw}} <-- place in the command line to skip network traffic.</tt><br />
<br />
That's advice worth heeding because fetching <tt>LATEST</tt> automatically involves network traffic, which adds time to the build. So for future builds use this:<br />
<br />
make -f posix.mak LATEST={{Latest DMD Version Raw}}<br />
<br />
Of course, parallelizing with <tt>-j</tt> improves speed as well.<br />
<br />
The build produces the entire site at <tt>~/code/dlang.org/web</tt>. To informally test it, open the appropriate HTML documents in that directory. Note that the currently released phobos has documentation in <tt>~/code/dlang.org/web/phobos</tt>, whereas the current (fresh) build of phobos has documentation in <tt>~/code/dlang.org/web/phobos-prerelease</tt>. So, for example, if you change the embedded documentation in <tt>~/code/phobos/std/conv.d</tt>, the changes are visible in <tt>~/code/dlang.org/web/phobos-prerelease/std_conv.html</tt>. (The build process replaces the slashes in submodules with underscores.)<br />
<br />
Note that the above steps will build all of the documentation in all forms, including Kindle builds and various other things that may require installing additional tools, and may download/build old versions of DMD. To prevent that, you can add the '''html''' option:<br />
<br />
make -f posix.mak LATEST={{Latest DMD Version Raw}} html<br />
<br />
Alternatively to building the documentation locally, you can use the documentation autotester service, which will build documentation, generate a diff of the results, and add a link to your GitHub pull request.<br />
<br />
=== Ancillary stuff ===<br />
<br />
==== <tt>[https://github.com/D-Programming-Language/dconf.org dconf.org]</tt>, <tt>[https://github.com/D-Programming-Language/dub dub]</tt>, <tt>[https://github.com/D-Programming-Language/dub-registry dub-registry]</tt>, <tt>[https://github.com/D-Programming-Language/installer installer]</tt>, <tt>[https://github.com/D-Programming-Language/tools tools]</tt>, and <tt>[https://github.com/D-Programming-Language/visuald visuald]</tt> ====<br />
<br />
These ancillary repositories are of somewhat specific interest. Their installation mimics that of the repositories described above. If you get to the point where you need to work on one of these, chances are you're already versed in what needs doing. If not, [http://forum.dlang.org/group/digitalmars.D ask away].<br />
<br />
===Additional Tools===<br />
<br />
If you cloned {{code|D-Programming-Language/tools.git}}, you also have a {{code|tools}} folder where small helping programs live. There is no need to build them, you can just compile them using DMD:<br />
<br />
<syntaxhighlight lang=dos><br />
dmd rdmd.d;<br />
dmd ddemangle.d;<br />
dmd dtab;<br />
dmd tolf;<br />
</syntaxhighlight><br />
<br />
{{code|rdmd}} builds your D modules automatically, from the one containing {{code|main}}. It'll deduce dependencies and compile/link them for you.<br />
{{code|ddemangle}} will demangle its input, replacing all mangled D symbols with their unmangled form.<br />
{{code|dtab}} transforms tabs into spaces in source code.<br />
{{code|tolf}} replaces line endings with LF.<br />
<br />
Using {{code|dtab}} and {{code|tolf}} is a good idea if you want to contribute to the D-Programming-Language repos.<br />
<br />
== Typical Contributor Workflow ==<br />
<br />
There are many ways to use <tt>git</tt> and GitHub to contribute. Here's a typical one.<br />
<br />
First, fork the github repository or repositories you'd like to contribute to (<tt>dmd</tt>, <tt>druntime</tt>, <tt>phobos</tt> etc) by navigating to their respective pages on <tt>github.com</tt> and clicking "Fork". Then, set up your local git repository to reflect that. For example, consider you want to contribute to <tt>phobos</tt> and have forked it. Then run these commands:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ~/code/phobos<br />
git remote add myfork https://github.com/username/phobos.git<br />
git remote update<br />
</syntaxhighlight><br />
<br />
(Replace <tt>username</tt> with your actual github user name.) This adds the "myfork" repository and makes sure everything is synchronized between your local copy and the remote repositories. Then, it's best to work in branches as shown below:<br />
<br />
<syntaxhighlight lang=bash><br />
git checkout -b awesome-new-feature<br />
# ... get some good work done here ...<br />
git commit -am "Awesome new feature ..."<br />
git push -f myfork<br />
</syntaxhighlight><br />
<br />
With this, your work is in your github fork of the <tt>phobos</tt> (or whichever) repository. After that, visit your fork on <tt>github.com</tt>, which looks like <tt>https://github.com/username/phobos/tree/awesome-new-feature</tt>.<br />
<br />
== Create a pull request ==<br />
<br />
Once you have tested all your changes and pushed them to your fork on GitHub, you are ready to submit a pull request.<br />
<br />
* Navigate to your fork of the project on GitHub.<br />
* '''Important''': Select the branch that you made your changes in, say issue_1234.<br />
* Click on the "Pull Request" button.<br />
<br />
This will submit your changes for review by the D maintainers. If your changes are approved, they will be merged into the master branch. Otherwise, if the maintainers have some comments or feedback, you can refine your changes by editing and testing in your local workspace, and pushing the new changes to the same git branch. The new changes will be automatically included in your pull request.<br />
<br />
Choose a title for your pull request that clearly states what it does. When fixing a bug, the usual thing to do is to use the summary from the bugzilla report. Eg a title like "Fix 3797" or "Issue 3797" contains much less information than "Fix Issue 3797 - Regression(2.038): Implicit conversion between incompatible function pointers" and requires a lot more effort for the reviewers to determine if it is something they are interested in.<br />
<br />
Pull request descriptions should contain a hyperlink to the [[Bugzilla]] issue that is being fixed. This is usually added at the end of the description.<br />
<br />
After the pull request is created, add the 'pull' keyword to the corresponding Bugzilla issue and a link to the pull request posted in a comment.<br />
<br />
=== Autotester ===<br />
<br />
Pull requests are automatically picked up by the [[Git Commit Tester|autotester]], which compiles the code in the pull request and runs it through the dmd, druntime, and phobos unittests on all supported platforms. Generally, pull requests must pass all tests before they will be merged. The status of the tests can be monitored through the pull request page.<br />
<br />
Every user must be manually approved before the autotester will start testing their pull requests. Users can be approved by anyone with commit access.<br />
<br />
=== Rebasing ===<br />
<br />
Sometimes, if a particular change you are working on is taking a long time, or if you encounter a problem that is fixed by a new commit upstream, you may need to sync your local branch with master in order to keep the code up-to-date. In this case, it is recommended that you use git rebase to apply your changes ''on top of'' the latest git master, so that when you submit a pull request, the change history will be easier for the reviewers to follow. Using git merge is ''not'' recommended, as it may produce a lot of merge commits that may not be relevant to your changes.<br />
<br />
For example, you may be working on your changes:<br />
<br />
<syntaxhighlight lang=bash><br />
cd /usr/src/d/phobos<br />
git checkout mybranch<br />
vim std/algorithm.d # apply lots of cool changes here<br />
</syntaxhighlight><br />
<br />
First, before you resync with master, make sure all your changes are checked in (or stashed):<br />
<br />
<syntaxhighlight lang=bash><br />
git commit -a<br />
</syntaxhighlight><br />
<br />
If you forked from the official D programming language repositories you may need to add an upstream remote to pull in the latest official changes. If this is the case you can add an upstream remote like this:<br />
<br />
<syntaxhighlight lang=bash><br />
git remote add upstream git@github.com:D-Programming-Language/phobos<br />
</syntaxhighlight><br />
<br />
This adds another remote to your repository called upstream and only needs to be done once. Once the upstream remote is added, you can update your repository's master branch by running the following:<br />
<br />
<syntaxhighlight lang=bash><br />
git checkout master<br />
git pull --ff-only upstream master<br />
</syntaxhighlight><br />
<br />
The --ff-only option is to ensure that your master branch is identical to the official D sources' master branch, since otherwise you will end up with a very messy history that will be hard to clean up (and the reviewers will probably reject your pull request due to having unrelated merge commits).<br />
<br />
Now go back to your branch and rebase it:<br />
<br />
<syntaxhighlight lang=bash><br />
git checkout mybranch<br />
git rebase master<br />
</syntaxhighlight><br />
<br />
Now your sources should be up-to-date. Recompile and test everything to make sure it all works.<br />
<br />
Note that after rebasing, you will need to force an update to your fork on GitHub with the -f flag, otherwise it will fail because the histories don't match anymore:<br />
<br />
<syntaxhighlight lang=bash><br />
git push -f origin mybranch<br />
</syntaxhighlight><br />
<br />
You may wish to read up on [http://git-scm.com/book/en/Git-Branching-Rebasing how git rebase works] if you're not familiar with the concept.<br />
<br />
If, during the 'git rebase' command, you encounter conflicts, you may want to learn [http://stackoverflow.com/questions/8780257/git-rebase-a-branch-onto-master-failed-how-to-resolve how to resolve a conflict during git rebase].<br />
<br />
=== Stable Branch ===<br />
<br />
If you are working on a fix for a regression, chances are it should go into the next point release, and not the next major version (e.g. 2.067.1 instead of 2.068). In this case, you should check out the stable branch of each subproject BEFORE you create your topic branch:<br />
<br />
<syntaxhighlight lang=bash><br />
cd dmd<br />
git checkout stable<br />
cd ../druntime<br />
git checkout stable<br />
cd ../phobos<br />
git checkout stable<br />
</syntaxhighlight><br />
<br />
Then follow the instructions for [[#Make your changes in a branch|making a branch]].<br />
<br />
If you forget to do this, or didn't realize it, It's not possible to simply re-target your branch for pulling into the stable branch. GitHub will let you do this, but your branch will include many of the changes from the unstable branch!<br />
<br />
In order to fix such a problem, you can [[#Rebasing|rebase]] your changes from master on top of the stable branch. First you need to pull in the stable branch from your fork on github:<br />
<br />
<syntaxhighlight lang=bash><br />
git checkout stable<br />
</syntaxhighlight><br />
<br />
Then, you go back to your branch, and replay the changes from master using rebase:<br />
<br />
<syntaxhighlight lang=bash><br />
git checkout mybranch<br />
git fetch upstream<br />
git rebase --onto upstream/stable upstream/master mybranch<br />
</syntaxhighlight><br />
<br />
You may have to follow the instructions in the [[#Rebasing|Rebasing section]] on adding the upstream branch, substituting stable for master, if you need to update to the latest stable changes.<br />
<br />
This sometimes may not work, as the changes between the stable and master are too drastic. In this case, you may have to re create your changes after a clean checkout of the stable branch.<br />
<br />
When creating a pull request, you need to tell github to target the stable branch instead of master on the upstream repository. This is done via a drop-down at the top of the page, make sure to do this before submitting your pull request as this cannot be changed after the PR is created (you will have to close the PR and create a new one).<br />
<br />
If you notice in your PR a whole slew of changes that seem to have nothing to do with your changes, it's likely because you forgot one of these steps.<br />
<br />
=== Reviews ===<br />
<br />
Any pull requests that make language changes must be approved by Walter and Andrei. This includes druntime changes that implement the specification.<br />
<br />
Any pull requests that make significant changes to code should be reviewed by more than one person. This means that at least two people need to approve the pull request before it is merged. One person must be a person with commit rights, but the other need not be, as long as that person is trusted within the developer community.<br />
<br />
Pull requests that are trivial (typos, obvious minor bug fixes, etc.) may be pulled without a second review.<br />
<br />
Please note that any updates pushed to the candidate branch do not automatically notify a subscribed person. If you update your branch to correct an issue, please also put in a comment indicating it.<br />
<br />
== Contributing FAQ ==<br />
<br />
=== Someone asked me to squash my commits, what does that mean? ===<br />
<br />
After receiving feedback on your PR, it's common for it to have lots of commits that don't add much by being separate. For example, consider the following git history on a PR:<br />
<br />
commit [ffffff] Added new function: foobar<br />
commit [aaaaaa] Spelling error fix in foobar docs<br />
commit [cccccc] Clarified Docs for foobar<br />
<br />
Nothing is gained from having these as three separate commits as they are all focused on one feature. Instead, they should be one commit so the history looks like this<br />
<br />
commit [333333] Added new function: foobar<br />
<br />
while still retaining all of your changes. In order to perform this, please consult [http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html this tutorial].<br />
<br />
<br />
=== A file that I made a change on was modified by a different merged PR, and now my PR can't be merged, now what? ===<br />
<br />
What you need to do is rebase your git branch on the master branch. What this does is rewrite the history of your git branch to make it seem like it was merged off of the head of master rather than the older commit where you actually branched. This will include the new commits in your PR so your PR no longer conflicts. See [https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request this tutorial] for more details.<br />
<br />
== See Also ==<br />
<br />
* [http://wiki.dlang.org/Contributing_to_dlang.org Contributing to dlang.org]<br />
<br />
[[Category: Contribution Guidelines]]</div>Notnahttps://wiki.dlang.org/?title=Build_LDC_for_Android&diff=7220Build LDC for Android2016-01-24T17:12:14Z<p>Notna: </p>
<hr />
<div>This page will show you how to build a ldc cross-compiler for Android/ARM on linux, along with how to build and run both the druntime/phobos tests and an Android D app using the cross-compiler.<br />
<br />
Almost all the druntime/phobos unit tests pass on Android/ARM. One of the native OpenGL sample apps from the Android NDK has been ported to D, I'll port some more soon. Remaining work to be done is listed last.<br />
<br />
You can also try out [[Build DMD for Android|dmd for Android/x86]].<br />
<br />
==Prerequisites==<br />
<br />
* linux host, where you'll build and run ldc<br />
** You can use a virtual machine like VirtualBox/VMware, with at least 512 MB of memory and 1 GB of swap, particularly if building the phobos unit tests, and 10 GB of disk space.<br />
* C++ compiler and toolchain, to build ldc<br />
* Common development tools, such as CMake and git, and ldc uses libconfig++<br />
* ldc/druntime/phobos source<br />
** Get the source using git, as these Android patches were tested on the master branch of each repo.<br />
* llvm 3.6 source, either from the official release or git<br />
** llvm 3.7 or later will work too, but you'll have to modify the small llvm patch so it still applies. <br />
* Android native toolchain, [http://developer.android.com/ndk/index.html the NDK] and optionally [http://developer.android.com/sdk/index.html the SDK]<br />
** The SDK is necessary if you want to package a GUI app; the NDK is enough if you just want to build a command-line binary, such as a test runner. If you get the SDK, all that's needed is the "SDK Tools only" version, as long as you don't plan on using their IDE integration. I will only write about using the command-line tools. The SDK requires JDK 7: follow their instructions to make sure it's installed right.<br />
* Android/ARM, whether a device or emulator<br />
** The SDK comes with an emulator. I use actual hardware, so that's what I'll discuss.<br />
<br />
==Compile llvm==<br />
<br />
Get the source for llvm, either [http://llvm.org/releases/download.html#3.6.2 the last official 3.6.2 release] or [https://android.googlesource.com/toolchain/llvm/ a git repository like the official Android llvm], which has some modifications but shouldn't really change much. [https://gist.github.com/joakim-noah/1fb23fba1ba5b7e87e1a Download the patch for llvm], apply it, and then [http://llvm.org/docs/GettingStarted.html#getting-started-quickly-a-summary build llvm as you would normally], with the ARM target:<br />
<br />
<syntaxhighlight lang=bash><br />
curl -O http://llvm.org/releases/3.6.2/llvm-3.6.2.src.tar.xz<br />
tar xvf llvm-3.6.2.src.tar.xz<br />
cd llvm-3.6.2.src/<br />
curl -O https://gist.githubusercontent.com/joakim-noah/1fb23fba1ba5b7e87e1a/raw/edb8005d8e972b2c258cd4699e6ad1b8315a8af7/android_tls<br />
git apply android_tls<br />
<br />
mkdir build<br />
cd build/<br />
cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=ARM<br />
make -j5<br />
</syntaxhighlight><br />
<br />
==Build ldc for Android/ARM==<br />
<br />
Clone the ldc repository, [https://gist.github.com/joakim-noah/63693ead3aa62216e1d9 apply the Android patch], set the NDK environment variable to the location of your NDK and NDK_ARCH to its architecture, either x86 or x86_64, and [[Building LDC from source|build ldc as usual]]:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ../../<br />
git clone --recursive https://github.com/ldc-developers/ldc.git<br />
cd ldc/<br />
git submodule update<br />
curl -O https://gist.githubusercontent.com/joakim-noah/63693ead3aa62216e1d9/raw/b89d77d66a80206b4dd3d78bb10d83a7e368f3d4/ldc_android_arm<br />
git apply ldc_android_arm<br />
<br />
mkdir build<br />
cd build/<br />
export NDK=/path/to/your/android-ndk-r10e<br />
export NDK_ARCH=x86<br />
cmake .. -DLLVM_CONFIG=../../llvm-3.6.2.src/build/bin/llvm-config<br />
make ldc2 -j5<br />
</syntaxhighlight><br />
<br />
Download and apply [https://gist.github.com/joakim-noah/d936d6a339426ad1fac3 the patch for druntime] and [https://gist.github.com/joakim-noah/5c03801fa6c59b1e90df the patch for phobos] before building them:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ../runtime/druntime/<br />
curl -O https://gist.githubusercontent.com/joakim-noah/d936d6a339426ad1fac3/raw/9486de62c72a64111e079bda9d7a7b58b6729909/druntime_ldc_arm<br />
git apply druntime_ldc_arm<br />
<br />
cd ../phobos/<br />
curl -O https://gist.githubusercontent.com/joakim-noah/5c03801fa6c59b1e90df/raw/8ef824365d5dcc46fb47fabf7681e5425d81cc32/phobos_ldc_arm<br />
git apply phobos_ldc_arm<br />
<br />
cd ../../build/<br />
make druntime-ldc phobos2-ldc -j5<br />
</syntaxhighlight><br />
<br />
More info about the Android/ARM patches can be [https://github.com/joakim-noah/android/releases/tag/polish found with their release].<br />
<br />
==Build a command-line executable==<br />
<br />
Now that we have a D cross-compiler and cross-compiled the standard library for Android/ARM, let's try building a small program, the classic Sieve of Eratosthenes single-core benchmark:<br />
<br />
<syntaxhighlight lang=bash><br />
./bin/ldc2 -mtriple=armv7-none-linux-androideabi -relocation-model=pic<br />
-c ../tests/d2/dmd-testsuite/runnable/sieve.d<br />
<br />
$NDK/toolchains/llvm-3.6/prebuilt/linux-$NDK_ARCH/bin/clang -Wl,-z,nocopyreloc<br />
--sysroot=$NDK/platforms/android-9/arch-arm -lgcc<br />
-gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-$NDK_ARCH<br />
-target armv7-none-linux-androideabi -no-canonical-prefixes -fuse-ld=bfd<br />
-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro<br />
-Wl,-z,now -mthumb -Wl,--export-dynamic -lc -lm sieve.o lib/libphobos2-ldc.a<br />
lib/libdruntime-ldc.a -o sieve<br />
</syntaxhighlight><br />
<br />
The compiler and linker flags were taken from [http://wiki.dlang.org/Build_DMD_for_Android#Default_build_of_the_C_sample_app the output from running a NDK sample app's build scripts in verbose mode].<br />
<br />
Now we run this program on an Android device or emulator. I've solely run on actual Android devices, with either [https://play.google.com/store/apps/details?id=com.termux&hl=en a terminal app] or [https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid&hl=en an SSH server app]. Once you have either of those apps installed, copy the sieve program to the device, go to the app's local directory by typing 'cd' at its command-line, copy the program there, and run it:<br />
<br />
<syntaxhighlight lang=bash><br />
cd<br />
cp /sdcard/sieve .<br />
./sieve foobar<br />
</syntaxhighlight><br />
<br />
The program requires an argument, which is ignored. If it runs correctly, you'll see the following output, saying it ran 10 times and found 1899 primes in the first 8191 integers:<br />
<br />
<syntaxhighlight lang=bash><br />
10 iterations<br />
1899 primes<br />
</syntaxhighlight><br />
<br />
==Run the druntime and phobos unit tests==<br />
<br />
Go back to the linux host and build the tests for druntime and phobos (don't add the -j5 flag to build in parallel unless you have GBs of memory available, as compiling some of the phobos modules' tests takes a fair amount of RAM):<br />
<br />
<syntaxhighlight lang=bash><br />
make test-runner<br />
</syntaxhighlight><br />
<br />
Copy the test-runner and [https://github.com/joakim-noah/android/releases/download/polish/test.list this list of druntime and phobos modules] to your device and run it. I use the SSH server app on a random port, here's what I'd do (replace 192.168.35.7 with the IP address of your device and 20345 with the port you configured for the SSH service):<br />
<br />
<syntaxhighlight lang=bash><br />
scp -P 20345 test.list runtime/test-runner jo@192.168.35.7:<br />
ssh -p20345 jo@192.168.35.7<br />
./test-runner<br />
</syntaxhighlight><br />
<br />
The tests take about 40 seconds to run on my dual Cortex-A15 device: all of them pass. A handful of tests across four modules were disabled, either because they fail or, in the case of rt.lifetime, pass but cause problems for subsequent tests. One module, core.sync.semaphore, is not included in the list of modules, [https://github.com/D-Programming-Language/druntime/pull/784#issuecomment-42777328 because sem_destroy works differently in bionic] and triggers a segfault on the next GC run after its tests pass, which doesn't matter because that test assumes sem_destroy works in a certain way.<br />
<br />
==Build a sample OpenGL Android app ported to D==<br />
<br />
Clone [https://github.com/joakim-noah/android my android repository], which contains several headers and a C/OpenGL app from the NDK, translated to D:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ../../<br />
git clone https://github.com/joakim-noah/android.git<br />
</syntaxhighlight><br />
<br />
You can find more info about building using the NDK in [[Build DMD for Android#Build_an_Android_sample_app|my earlier instructions for Android/x86]]. This is just the essence, redone for ARM. You will build a pure native apk without any Java source, ie pure D along with the basic C glue/wrapper that comes with the NDK.<br />
<br />
First, you need to edit the C wrapper from the NDK, so that it initializes the D runtime properly for a shared library. Go to the sample app and copy android_native_app_glue.h and android_native_app_glue.c from the NDK:<br />
<br />
<syntaxhighlight lang=bash><br />
cd android/samples/native-activity/<br />
cp $NDK/sources/android/native_app_glue/android_native_app_glue.* .<br />
</syntaxhighlight><br />
<br />
Open android_native_app_glue.c in an editor and find the function android_main, then insert rt_init() and rt_term() around it, so it looks like this:<br />
<br />
<syntaxhighlight lang=C><br />
<br />
rt_init();<br />
android_main(android_app);<br />
rt_term();<br />
<br />
</syntaxhighlight><br />
<br />
Compile the D source and the file you just modified, then link them into a shared library and place it in the directory that the SDK expects:<br />
<br />
<syntaxhighlight lang=bash><br />
../../../ldc/build/bin/ldc2 -mtriple=armv7-none-linux-androideabi<br />
-relocation-model=pic -I../../ -c jni/main.d<br />
<br />
../../../ldc/build/bin/ldc2 -mtriple=armv7-none-linux-androideabi<br />
-relocation-model=pic -I../../ -c ../../android/sensor.d<br />
<br />
$NDK/toolchains/llvm-3.6/prebuilt/linux-$NDK_ARCH/bin/clang<br />
-gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-$NDK_ARCH<br />
-fpic -ffunction-sections -funwind-tables -fstack-protector-strong<br />
-Wno-invalid-command-line-argument -Wno-unused-command-line-argument<br />
-no-canonical-prefixes -fno-integrated-as -target armv7-none-linux-androideabi<br />
-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG<br />
-fomit-frame-pointer -fno-strict-aliasing -I$NDK/sources/android/native_app_glue<br />
-DANDROID -Wa,--noexecstack -Wformat -Werror=format-security<br />
-I$NDK/platforms/android-9/arch-arm/usr/include<br />
-c ./android_native_app_glue.c -o ./android_native_app_glue.o<br />
<br />
mkdir -p libs/armeabi-v7a/<br />
<br />
$NDK/toolchains/llvm-3.6/prebuilt/linux-$NDK_ARCH/bin/clang -Wl,-soname,libnative-activity.so<br />
-shared --sysroot=$NDK/platforms/android-9/arch-arm main.o sensor.o<br />
../../../ldc/build/lib/libphobos2-ldc.a ../../../ldc/build/lib/libdruntime-ldc.a<br />
android_native_app_glue.o -lgcc<br />
-gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-$NDK_ARCH<br />
-no-canonical-prefixes -fuse-ld=bfd -target armv7-none-linux-androideabi<br />
-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now<br />
-mthumb -L$NDK/platforms/android-9/arch-arm/usr/lib -llog -landroid -lEGL -lGLESv1_CM<br />
-lc -lm -o libs/armeabi-v7a/libnative-activity.so<br />
</syntaxhighlight><br />
<br />
Package the app as the SDK directs. I use the older Ant approach, which is being deprecated, replace it with the Gradle command from a newer SDK if needed. Set the path to your SDK, then package the apk using these commands:<br />
<br />
<syntaxhighlight lang=bash><br />
export SDK=/path/to/your/android-sdk-linux<br />
$SDK/tools/android update project -p . -s --target 1<br />
ant debug<br />
</syntaxhighlight><br />
<br />
Transfer the resulting bin/NativeActivity-debug.apk to your device, go to Settings->Security and allow installation of apps from unknown sources, ie outside the Play Store, then install it. Go to your app folder and run the app named NativeActivity: it'll show a black screen and start flashing a bunch of colors upon a touch.<br />
<br />
==Run the druntime and phobos unit tests in an apk==<br />
<br />
Copy and edit the C wrapper and create the libs/armeabi-v7a/ directory as shown in the last section, then download and apply [https://gist.github.com/joakim-noah/8ba3cd4958266f357295 the small patch to have the sample app invoke the test runner], and rebuild:<br />
<br />
<syntaxhighlight lang=bash><br />
curl -O https://gist.githubusercontent.com/joakim-noah/8ba3cd4958266f357295/raw/a52fcf1e63715f8b1bd3527afaa85872087b0f30/native_ldc_arm<br />
git apply native_ldc_arm<br />
<br />
cd ../../../ldc/build/<br />
make test-runner-apk<br />
</syntaxhighlight><br />
<br />
This assumes that the ldc and android repositories are in the same directory, as show in these instructions. If not, modify ANDROID_DIR in the CMake build script to use the path you want.<br />
<br />
Finally, package the test runner apk:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ../../android/samples/native-activity/<br />
ant debug<br />
</syntaxhighlight><br />
<br />
Transfer the resulting bin/NativeActivity-debug.apk to your device, and install it as before. Also, copy [https://github.com/joakim-noah/android/releases/download/polish/test.list the list of modules to test] to the /sdcard/ directory. The app will append its results to /sdcard/test.log, so if you happen to have a file with that name, move it.<br />
<br />
This time, it should show a black screen for about a minute, while all the tests run. A touch after that and it should start flashing a bunch of colors. If not, look at the output in /sdcard/test.log and check if the app hung after any particular tested module. You can remove that module from test.list and try running again.<br />
<br />
==Directions for future work==<br />
<br />
* Tests fail when llvm optimizations are applied to std.random and inlining enabled for two modules, std.exception and std.internal.math.errorfunction. The sources of these optimization issues have to be tracked down.<br />
<br />
* One custom range in std.datetime that is defined only for the unit tests, Rand3Letters, causes a memory leak when called, so it is disabled in the above phobos patch. Ldc's code generation for this range will need to be investigated.<br />
<br />
* Exceptions thrown across fiber switches are not properly chained, that'll need to be looked into.<br />
<br />
* A couple test cases related to underflow/overflow in std.math are disabled, I haven't looked into why they don't work.<br />
<br />
* Port the NDK support libraries and more of the sample apps to D, including apps that require using JNI, ie interfacing with Java.<br />
<br />
* I have not tried cross-compiling the ldc compiler test suite and running it. I'd like to get to that eventually.<br />
<br />
* [http://wiki.dlang.org/Build_DMD_for_Android#Directions_for_future_work All the further work mentioned for the earlier Android/x86 port also apply here].<br />
<br />
[[Category:LDC]]<br />
[[Category: Android]]</div>Notnahttps://wiki.dlang.org/?title=Build_DMD_for_Android&diff=7219Build DMD for Android2016-01-24T17:11:08Z<p>Notna: </p>
<hr />
<div>All druntime and phobos tests from 2.070 git master pass on Android/x86, I need to try the dmd test suite next. [[Build LDC for Android|Almost all of the druntime/phobos tests pass on Android/ARM with ldc]]. A C/OpenGLES 1.0 purely native sample app from the NDK has been ported to D. I list work that still needs to be done at the end.<br />
<br />
==Prerequisites==<br />
<br />
* linux host on which to build dmd<br />
** A virtual machine like VirtualBox/VMware will do fine, but you should have at least 512 MB of memory allocated and 1 GB of swap, particularly if building the phobos unit tests, and 10 GB of disk space.<br />
* C++ compiler and toolchain, to build dmd<br />
* A pre-built D compiler for linux, needed because the D frontend has been translated to D.<br />
* dmd/druntime/phobos source<br />
** Get the source from git, as the following Android patches have only been tested on the master branch of each repo.<br />
* Android native toolchain, [http://developer.android.com/tools/sdk/ndk/index.html the NDK] and optionally [http://developer.android.com/sdk/index.html the SDK]<br />
** You don't need the SDK if you only want to build command-line binaries, the SDK is only needed to package and sign GUI apps. The "SDK Tools only" version of the SDK is enough, if you don't plan on using their IDE integration. I will only write about using the command-line tools. The SDK requires JDK 7: follow their instructions to make sure it's installed right.<br />
* Android/x86, whether a device or VM<br />
** The SDK comes with an emulator and Intel puts out their own. I use [http://www.android-x86.org/download the builds put out by the android-x86 project] and recommend the deprecated 4.3 build, as it's the least buggy one I've dealt with. I run the iso in a VM with 512 MBs of memory without installing to disk.<br />
<br />
===To run Android/x86 in a VM===<br />
<br />
Download the Android-x86 iso and install as normal. It'll put you through a configuration process, but you can skip every step. Go to Settings->Security and disable the Verify Apps option, or it'll ask you about that every time you install a test app. Alt-F1 will take you to a root shell, which you'll want to do any time you're not using Android/x86 for a couple minutes, or the screen will eventually go black and the VM will freeze up. Alt-F7 takes you back to the normal GUI screen.<br />
<br />
==Build D for Android/x86==<br />
<br />
Download [https://patch-diff.githubusercontent.com/raw/D-Programming-Language/dmd/pull/3643.patch the patch for dmd], apply it, and [[Building DMD|build normally]]:<br />
<br />
<syntaxhighlight lang=bash><br />
cd dmd<br />
git apply 3643.patch<br />
make -f posix.mak -j5<br />
</syntaxhighlight><br />
<br />
This patch adds emulated TLS for Android/x86, more info can be found on [https://github.com/D-Programming-Language/dmd/pull/3643 the pull request].<br />
<br />
Assuming druntime and phobos are in the same directory as dmd, download and apply [https://gist.github.com/joakim-noah/f2f22dfcd2ef30880f14 the patch for druntime] and [https://gist.github.com/joakim-noah/5d399fdcd5e484d6aaa2 the patch for phobos], then set the NDK environment variable to the path of wherever you installed the NDK:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ../druntime<br />
export NDK=/path/to/your/android-ndk-r10<br />
git apply druntime_android<br />
make -f posix.mak<br />
<br />
cd ../phobos<br />
git apply phobos_android<br />
make -f posix.mak<br />
</syntaxhighlight><br />
<br />
Both patches avoid building druntime/phobos as a shared library and set the appropriate C compiler and linker path and flags, along with a couple small fixes for Android that haven't been upstreamed yet. The remaining changes are for the unit tests and are addressed below.<br />
<br />
==Build an Android sample app==<br />
<br />
I've put up [https://github.com/joakim-noah/android an android repository which contains several translated headers and a sample C app translated to D]. Clone it into the same directory as dmd/druntime/phobos:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ..<br />
git clone https://github.com/joakim-noah/android.git<br />
</syntaxhighlight><br />
<br />
===Default build of the C sample app===<br />
First, let's see how it's done by default by compiling the C version. Go to the sample native-activity app in my android repo, which is almost copied verbatim from the NDK/samples. The only differences are that it also contains a translation of the given jni/main.c source to jni/main.d, changes one line in jni/Application.mk to build for x86 by default, and includes a dmd.conf for building with dmd.<br />
<br />
Run the following commands to compile the C source into a debug app that you can install on Android, [http://developer.android.com/ndk/guides/index.html these commands are taken from the NDK instructions]:<br />
<br />
<syntaxhighlight lang=bash><br />
cd android/samples/native-activity<br />
NDK_TOOLCHAIN_VERSION=clang $NDK/ndk-build V=1<br />
</syntaxhighlight><br />
<br />
Looking at the output, it compiles jni/main.c, a small wrapper library called android_native_app_glue, and links everything together into a shared library. Let's look at the command that compiles jni/main.c:<br />
<br />
<syntaxhighlight lang=bash><br />
/opt/ndk/toolchains/llvm-3.5/prebuilt/linux-x86/bin/clang -MMD -MP -MF<br />
./obj/local/x86/objs/native-activity/main.o.d -gcc-toolchain<br />
/opt/ndk/toolchains/x86-4.8/prebuilt/linux-x86 -target i686-none-linux-android<br />
-ffunction-sections -funwind-tables -fstack-protector -fPIC<br />
-Wno-invalid-command-line-argument -Wno-unused-command-line-argument<br />
-no-canonical-prefixes -O2 -g -DNDEBUG -fomit-frame-pointer -fstrict-aliasing<br />
-I/opt/ndk/sources/android/native_app_glue -Ijni -DANDROID -Wa,--noexecstack<br />
-Wformat -Werror=format-security -I/opt/ndk/platforms/android-9/arch-x86/usr/include<br />
-c jni/main.c -o ./obj/local/x86/objs/native-activity/main.o<br />
</syntaxhighlight><br />
<br />
This is where I extracted the C compiler path and flags for the previous druntime/phobos patches, leaving out the dependency file (-MMD -MP -MF).<br />
<br />
This command links the shared library that gets packaged into the native app:<br />
<br />
<syntaxhighlight lang=bash><br />
/opt/ndk/toolchains/llvm-3.5/prebuilt/linux-x86/bin/clang++<br />
-Wl,-soname,libnative-activity.so -shared<br />
--sysroot=/opt/ndk/platforms/android-9/arch-x86<br />
./obj/local/x86/objs/native-activity/main.o<br />
./obj/local/x86/libandroid_native_app_glue.a -lgcc -gcc-toolchain<br />
/opt/ndk/toolchains/x86-4.8/prebuilt/linux-x86 -target i686-none-linux-android<br />
-no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro<br />
-Wl,-z,now -L/opt/ndk/platforms/android-9/arch-x86/usr/lib -llog -landroid<br />
-lEGL -lGLESv1_CM -llog -lc -lm -o ./obj/local/x86/libnative-activity.so<br />
</syntaxhighlight><br />
<br />
You'll use a modified version of the above command to link your D source later.<br />
<br />
Getting back to building the C app, set the SDK environment variable for the path to your SDK and run the commands to package an Android app/apk:<br />
<br />
<syntaxhighlight lang=bash><br />
export SDK=/path/to/your/android-sdk-linux<br />
$SDK/tools/android update project -p . -s --target 1<br />
ant debug<br />
</syntaxhighlight><br />
<br />
Now you'll push the final app, NativeActivity-debug.apk, to your Android/x86 environment. Connecting to Android will vary based on which Android/x86 you're using: I'll show you how I do it for Android/x86 installed in a VM, using [http://www.android-x86.org/documents/debug-howto the first method shown in the Android-x86 docs]. Hit Alt-F1 inside the VM to go to the root shell and type "netcfg" to get its IP address: let's say it's 192.168.0.1. Hit Alt-F7 to go back to the UI, then go to Settings->Apps. It should be empty.<br />
<br />
Going back to the linux host:<br />
<br />
<syntaxhighlight lang=bash><br />
$SDK/platform-tools/adb connect 192.168.0.1:5555<br />
$SDK/platform-tools/adb install bin/NativeActivity-debug.apk<br />
$SDK/platform-tools/adb logcat native-activity *:S<br />
</syntaxhighlight><br />
<br />
The NativeActivity app should show up in the Settings->Apps list in Android/x86. Go to the app launcher and click on NativeActivity to run it. Move the mouse and you should see a bunch of colors continuously flashing on the screen. Looking at the log dump in the linux host, you'll see some numbers from the accelerometer, which are being reported by the app.<br />
<br />
===Build the translated D app===<br />
<br />
I've translated jni/main.c to a D version, jni/main.d. First, you'll need to recompile the android_native_app_glue library so that it calls a couple functions necessary for a D shared library. Hit ctrl-c to get out of the Android log and open $NDK/sources/android/native_app_glue/android_native_app_glue.c in an editor. Find the android_main function and add the following rt_init()/rt_term() calls before and after it:<br />
<br />
<syntaxhighlight lang=D><br />
<br />
rt_init();<br />
android_main(android_app);<br />
rt_term();<br />
<br />
</syntaxhighlight><br />
<br />
Clean up and compile as before:<br />
<br />
<syntaxhighlight lang=bash><br />
$NDK/ndk-build clean<br />
NDK_TOOLCHAIN_VERSION=clang $NDK/ndk-build V=1<br />
</syntaxhighlight><br />
<br />
You should see the following linker error, as the linker can't find the rt_init and rt_term functions you just added:<br />
<br />
<syntaxhighlight lang=bash><br />
/home/joakim/android-ndk-r10/sources/android/native_app_glue/android_native_app_glue.c:232:<br />
error: undefined reference to 'rt_init'<br />
/home/joakim/android-ndk-r10/sources/android/native_app_glue/android_native_app_glue.c:234:<br />
error: undefined reference to 'rt_term'<br />
clang++: error: linker command failed with exit code 1 (use -v to see invocation)<br />
make: *** [obj/local/x86/libnative-activity.so] Error 1<br />
</syntaxhighlight><br />
<br />
That's fine, now let's build and link the D source in instead:<br />
<br />
<syntaxhighlight lang=bash><br />
../../../dmd/src/dmd -android -I../.. -ofobj/local/x86/objs/native-activity/main.o<br />
-c jni/main.d ../../android/sensor.d<br />
<br />
$NDK/toolchains/llvm-3.5/prebuilt/linux-x86/bin/clang<br />
-Wl,-soname,libnative-activity.so -shared<br />
--sysroot=$NDK/platforms/android-9/arch-x86<br />
./obj/local/x86/objs/native-activity/main.o<br />
./obj/local/x86/libandroid_native_app_glue.a -lgcc -gcc-toolchain <br />
$NDK/toolchains/x86-4.8/prebuilt/linux-x86 -target i686-none-linux-android<br />
-no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro<br />
-Wl,-z,now -L$NDK/platforms/android-9/arch-x86/usr/lib -llog -landroid<br />
-lEGL -lGLESv1_CM -llog -lc -lm -fuse-ld=bfd<br />
-L../../../phobos/generated/linux/release/32 -l:libphobos2.a <br />
-o ./libs/x86/libnative-activity.so<br />
</syntaxhighlight><br />
<br />
android/sensor.d is included in the first command to avoid [https://issues.dlang.org/show_bug.cgi?id=12238 a dmd bug with unions declared in a separate file]. Note the final linker command is a lightly modified version of the one issued when linking the C shared library above, with phobos added to the mix. -fuse-ld=bfd was added to force the use of the ld.bfd linker instead of the gold linker, because only ld.bfd works with the Android/x86 TLS patch.<br />
<br />
Finally, you can build an apk and install to the Android/x86 VM as before:<br />
<br />
<syntaxhighlight lang=bash><br />
ant debug<br />
$SDK/platform-tools/adb uninstall com.example.native_activity<br />
$SDK/platform-tools/adb install bin/NativeActivity-debug.apk<br />
$SDK/platform-tools/adb logcat native-activity *:S<br />
</syntaxhighlight><br />
<br />
Run the D app and you should see the same results.<br />
<br />
==Build a command-line executable==<br />
<br />
This might be useful if you want to run your unit tests on the command-line, as I'll show with the druntime/phobos unit tests later.<br />
<br />
Let's try building one of the sample files that come with dmd:<br />
<br />
<syntaxhighlight lang=bash><br />
../../../dmd/src/dmd -android -c ../../../dmd/samples/sieve.d<br />
<br />
$NDK/toolchains/llvm-3.5/prebuilt/linux-x86/bin/clang<br />
-Wl,-z,nocopyreloc --sysroot=$NDK/platforms/android-9/arch-x86 -lgcc <br />
-gcc-toolchain $NDK/toolchains/x86-4.8/prebuilt/linux-x86 -target<br />
i686-none-linux-android -no-canonical-prefixes -fuse-ld=bfd <br />
-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now<br />
-Wl,--export-dynamic -lc -lm sieve.o<br />
-L../../../phobos/generated/linux/release/32 -l:libphobos2.a -o ./sieve<br />
</syntaxhighlight><br />
<br />
The linker command was extracted by building the sample test-libstdc++ executable from the NDK and removing a handful of flags that weren't needed.<br />
<br />
Now we can push it to Android: there are some quirks however. Android doesn't allow you to run executables from the /sdcard partition, but you can only push files to the sdcard. I route around these restrictions by pushing to the sdcard and then copying the executable as root to the /data partition.<br />
<br />
<syntaxhighlight lang=bash><br />
$SDK/platform-tools/adb push sieve /sdcard/<br />
</syntaxhighlight><br />
<br />
Switch to the Android VM and hit Alt-F1 to get a root shell:<br />
<br />
<syntaxhighlight lang=bash><br />
mkdir /data/test<br />
cd /data/test<br />
cp /sdcard/sieve .<br />
chmod 755 sieve<br />
./sieve<br />
</syntaxhighlight><br />
<br />
You'll see the following output if everything went well:<br />
<br />
<syntaxhighlight lang=bash><br />
10 iterations<br />
1899 primes<br />
</syntaxhighlight><br />
<br />
==Run the druntime and phobos unit tests==<br />
<br />
Go back to the linux host and build the druntime and phobos unit tests:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ../../../druntime<br />
make -f posix.mak unittest<br />
</syntaxhighlight><br />
<br />
If everything went right, you should see the following error, as the tests were compiled but won't be run on the linux host:<br />
<br />
<syntaxhighlight lang=bash><br />
make: obj/32/test_runner: Command not found<br />
posix.mak:234: recipe for target 'obj/32/object_' failed<br />
make: *** [obj/32/object_] Error 127<br />
</syntaxhighlight><br />
<br />
The patch for phobos adds support for extracting timezone data from Android's concatenated tzdata file to std.datetime, includes some workarounds for Android, and makes a few function call and formatting changes because "long double" and "double" are both 64-bit on Android:<br />
<br />
<syntaxhighlight lang=bash><br />
cd ../phobos<br />
make -f posix.mak unittest BUILD=release<br />
</syntaxhighlight><br />
<br />
Again, it will error out as the resulting test_runner binary won't run on the linux host:<br />
<br />
<syntaxhighlight lang=bash><br />
make: generated/linux/release/32/unittest/test_runner: Command not found<br />
posix.mak:384: recipe for target 'unittest/std/array.run' failed<br />
make: *** [unittest/std/array.run] Error 127<br />
</syntaxhighlight><br />
<br />
Download these lists of tests for [https://gist.github.com/joakim-noah/15420d6a933727a96aba druntime] and [https://gist.github.com/joakim-noah/b471e303a43c2ba2d055 phobos] and push them and the test runners to the Android VM:<br />
<br />
<syntaxhighlight lang=bash><br />
$SDK/platform-tools/adb push ../druntime/test_runner /sdcard/druntime_test_runner<br />
$SDK/platform-tools/adb push druntime_tests /sdcard/<br />
$SDK/platform-tools/adb push phobos_tests /sdcard/<br />
$SDK/platform-tools/adb push test_runner /sdcard/<br />
</syntaxhighlight><br />
<br />
Switch to the root shell in the Android VM and run the tests:<br />
<br />
<syntaxhighlight lang=bash><br />
cp /sdcard/druntime_test_runner test_runner<br />
cp /sdcard/druntime_tests /sdcard/phobos_tests .<br />
chmod 755 test_runner<br />
source druntime_tests > druntime_tests.log<br />
<br />
cp /sdcard/test_runner .<br />
mkdir std<br />
echo test > std/string.d<br />
source phobos_tests > phobos_tests.log<br />
</syntaxhighlight><br />
<br />
I get the following results for [https://gist.github.com/joakim-noah/6784f95718f5554ad577 druntime] and [https://gist.github.com/joakim-noah/7f8cf4adf45d8c781569 phobos]: all modules pass their tests.<br />
<br />
==Directions for future work==<br />
<br />
* Two modules, core.thread and std.parallelism, have tests that cause the test runner to hang when run from inside an apk as opposed to on the command line. Trying to suspend a thread from another thread, either directly by calling thread_suspendAll() or indirectly when the GC runs a full collect on a multi-threaded app, fails, because pthread_kill doesn't return and hangs the calling thread. It appears that this is related to using SIGUSR1/2 for suspending and resuming threads: simply switching the two signals works around this issue for now.<br />
<br />
* You may notice that I added an empty main function in the D translation of the C sample app: that's a hack to build a shared library. Some of the linux shared library support in druntime's rt.sections_elf_shared may eventually be integrated with Android to get rid of that.<br />
<br />
* The android_native_app_glue C wrapper can probably be replaced by D startup code, so that little to no C wrapper is necessary.<br />
<br />
* Now that we can write D code for Android, it'll make building easier if the D cross-compilers are integrated with a build tool like [https://github.com/atilaneves/reggae reggae].<br />
<br />
* I want to try running the dmd test suite on Android/x86. Since dmd's tests depend on phobos, I couldn't run them till I got phobos passing its tests.<br />
<br />
[[Category: DMD Compiler]]<br />
[[Category: Android]]</div>Notnahttps://wiki.dlang.org/?title=File:Icon_D_Web_Development.png&diff=6353File:Icon D Web Development.png2015-07-22T21:36:57Z<p>Notna: </p>
<hr />
<div></div>Notnahttps://wiki.dlang.org/?title=Books&diff=6352Books2015-07-22T21:33:56Z<p>Notna: </p>
<hr />
<div><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:PiD_Cover.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
Frequent online updates<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive free online book for beginners<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf PDF]<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.chm CHM] Microsoft Compiled HTML Help<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.epub EPub] E-book Readers<br />
* [http://master.dl.sourceforge.net/project/d-apt/files/dlangspec/2.067.0/dlangspec-2.067.0.mobi Mobi] Kindle Format<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://www.amazon.com/Learn-Tango-FirstPress-Kris-Bell/dp/1590599608 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:PinD.PNG|100px|link=http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Programmieren in D'''<br><br />
German Language<br><br />
Tobias Wassermann, Christian Speer<br><br />
14. November 2007<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Die Sprache D bringt die Vorteile von C, C++, C#, Java und anderen Sprachen zusammen - verzichtet dabei jedoch auf die Makel.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:ctfebookcover1424127575.jpg|100px|link=https://leanpub.com/ctfe]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Developing with compile time in mind'''<br><br />
Richard Cattermole<br><br />
February 17, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Runtime execution is difficult enough, with compile time execution available as well it becomes unimaginable. This book describes design patterns and how to work with compile time function execution effectively.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/ctfe Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:Twp-DCover.png|100px|link=https://leanpub.com/twp-d]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The way to program - Let's think like a D(eveloper)'''<br><br />
Richard Cattermole<br><br />
June 16, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Programming is a difficult subject to get into. Especially with a very wide variety of options available to learn from. In both book form and websites. The goal of this book is bring topics to your attention and introduce them in a practical manner.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://leanpub.com/twp-d Website]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://www.tutorialspoint.com/d_programming/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D programming'''<br><br />
Unknown<br><br />
January 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice introductory tutorial to D programming. Available on-line and in the PDF format.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.tutorialspoint.com/d_programming/ Website]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://d.readthedocs.org/]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Quick Start With D'''<br><br />
Ilya Yaroshenko<br><br />
April 1, 2015<br />
<br />
</td><td style="padding: 5px 10px;"><br />
A nice quick start introduction. Available on-line.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://d.readthedocs.org/ Read the docs]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:icon_D_Web_Development.png|100px|link=https://www.packtpub.com/web-development/d-web-development]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Web Development'''<br><br />
Kai Nacke<br><br />
'''This title is available to pre-order now and is expected to be published in January 2016.'''<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Leverage the power of D and the vibe.d framework to develop web applications that are incredibly fast<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://www.packtpub.com/web-development/d-web-development '''pre-order''' on packtpub.com now!!! <br> Book is expected to be published in '''January 2016'''.]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
<br />
</table><br />
<br />
----<br />
<br />
[[Category::Books]]</div>Notnahttps://wiki.dlang.org/?title=Simplified_Release_Process_Proposal&diff=4730Simplified Release Process Proposal2014-09-09T23:39:53Z<p>Notna: /* Hotfixes */</p>
<hr />
<div>The following is just a preliminary proposal to simplify the Release Process. The aim is to keep it as simple as possible because there has been a lot of difficulty following the more sophisticated [[Release Process]] currently in place.<br />
<br />
<br />
<pre><br />
[Feature PRs] [Bugfix PRs] [ Emergency bug/regression fix PR]<br />
| | | | |<br />
| | | | |<br />
====*==*====*=====*=======*==========*====master=====*=========*============><br />
\ . . / . /<br />
\ . . / . /<br />
*--2.xx-------*---*---*----*---------------------*---*---------------><br />
\ \ \<br />
[tag v2.xxx.0-b1] [tag v2.xxx.0] [tag v2.xxx.x]<br />
<br />
<br />
<br />
| = pull request<br />
\ = fork\tag<br />
/ = merge<br />
. = cherry-pick<br />
</pre><br />
<br />
<br />
<br />
==Contributors==<br />
<br />
Just make pull requests to master.<br />
<br />
<br />
==Release Manager==<br />
<br />
===Releases===<br />
<br />
Only the Release Manager needs to do this and they only need to do this during a scheduled feature freeze for an upcoming release. The feature freeze window should be kept short to minimize the work involved.<br />
<br />
It's assumed they have a github.com/D-Programming-Language remote setup called "upstream" and master is up-to-date with it.<br />
<br />
When a scheduled feature freeze for an upcoming release is to happen just create the versioned release branch:<br />
<br />
<source lang="bash"><br />
git checkout -b 2.xxx master<br />
git push upstream 2.xxx<br />
</source><br />
<br />
As bugfixes come in cherry-pick them from master:<br />
<br />
<source lang="bash"><br />
# while "2.xxx" is checked out<br />
git cherry-pick <-m #> <commit-hash><br />
git push upstream 2.xxx<br />
</source><br />
<br />
<br />
As each beta is made:<br />
<br />
<source lang="bash"><br />
git tag -a v2.xxx.0-bx -m v2.xxx.0-bx 2.xxx<br />
git push upstream v2.xxx.0-bx<br />
</source><br />
<br />
<br />
When the final release has been built and is out the door:<br />
<br />
<source lang="bash"><br />
git tag -a v2.xxx.0 -m v2.xxx.0 2.xxx<br />
git push upstream v2.xxx.0<br />
git push upstream 2.xxx<br />
git checkout master<br />
git merge 2.xxx<br />
git push upstream master<br />
</source><br />
<br />
===Hotfixes===<br />
<br />
Hotfixes are emergency releases made because of some very serious bug or regression that cannot wait until the next release is made.<br />
<br />
After the regression/bug fix comes in cherry-pick it from master:<br />
<br />
<source lang="bash"><br />
# while the appropriate "2.xxx" is checked out<br />
git cherry-pick <-m #> <commit-hash><br />
git push upstream 2.xxx<br />
</source><br />
<br />
<br />
When the final hotfix release has been built and is out the door:<br />
<br />
<source lang="bash"><br />
git tag -a v2.xxx.x -m v2.xxx.x 2.xxx<br />
git push upstream v2.xxx.x<br />
git push upstream 2.xxx<br />
git checkout master<br />
git merge 2.xxx<br />
git push upstream master<br />
</source><br />
<br />
<br />
----<br />
<br />
[[Category:git]]<br />
[[Category:development]]<br />
[[Category:know-how]]</div>Notnahttps://wiki.dlang.org/?title=File:PinD.PNG&diff=4440File:PinD.PNG2014-07-25T00:01:59Z<p>Notna: </p>
<hr />
<div></div>Notnahttps://wiki.dlang.org/?title=Books&diff=4439Books2014-07-25T00:00:45Z<p>Notna: well, what can I say. Its old (2007) and German, but just in case someone wants it anyhow (I have them all ;) )</p>
<hr />
<div><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive free online book for beginners<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://www.amazon.com/Learn-Tango-FirstPress-Kris-Bell/dp/1590599608 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:PinD.PNG|100px|link=http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Programmieren in D'''<br><br />
German Language<br><br />
Tobias Wassermann, Christian Speer<br><br />
14. November 2007<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Die Sprache D bringt die Vorteile von C, C++, C#, Java und anderen Sprachen zusammen - verzichtet dabei jedoch auf die Makel.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.de/Programmieren-D-Tobias-Wassermann/dp/3939084697 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
</table><br />
<br />
----<br />
<br />
[[Category::Books]]</div>Notnahttps://wiki.dlang.org/?title=File:Icon_book_128_D.png&diff=4438File:Icon book 128 D.png2014-07-24T23:41:52Z<p>Notna: </p>
<hr />
<div></div>Notnahttps://wiki.dlang.org/?title=Books&diff=4437Books2014-07-24T23:41:05Z<p>Notna: </p>
<hr />
<div><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive free online book for beginners<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128_D.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://www.amazon.com/Learn-Tango-FirstPress-Kris-Bell/dp/1590599608 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
----<br />
<br />
[[Category::Books]]</div>Notnahttps://wiki.dlang.org/?title=Books&diff=4436Books2014-07-24T21:32:24Z<p>Notna: </p>
<hr />
<div><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|100px||link=http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|100px||link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive free online book for beginners<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png||100px|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|100px||link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|100px|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|100px|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|100px|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://www.amazon.com/Learn-Tango-FirstPress-Kris-Bell/dp/1590599608 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
----<br />
<br />
[[Category::Books]]</div>Notnahttps://wiki.dlang.org/?title=Books&diff=4435Books2014-07-24T21:22:16Z<p>Notna: </p>
<hr />
<div><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|link=http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive free online book for beginners<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://www.amazon.com/Learn-Tango-FirstPress-Kris-Bell/dp/1590599608 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
----<br />
<br />
[[Category::Books]]</div>Notnahttps://wiki.dlang.org/?title=File:LTWD.PNG&diff=4434File:LTWD.PNG2014-07-24T21:20:22Z<p>Notna: </p>
<hr />
<div></div>Notnahttps://wiki.dlang.org/?title=Books&diff=4433Books2014-07-24T21:19:33Z<p>Notna: added the Tango book, even if Tango isn't that popular in the recent D2 days ;)</p>
<hr />
<div><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|link=http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive free online book for beginners<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:d_cookbook.png|link=http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''D Cookbook'''<br/><br />
Adam D. Ruppe<br/><br />
May 26, 2014<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Code examples and explanations from the author's years of using D covering a variety of practical topics.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Publisher's page]<br />
* [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:LTWD.PNG|link=http://www.apress.com/9781590599600]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''Learn to Tango with D'''<br/><br />
Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker<br/><br />
January 7, 2008<br />
<br />
</td><td style="padding: 5px 10px;"><br />
Learn to Tango with D introduces you to the powerful D language, with special attention given to the '''Tango software library'''.<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.apress.com/9781590599600 Publisher's page]<br />
* [http://www.amazon.com/Learn-Tango-FirstPress-Kris-Bell/dp/1590599608 Amazon]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</table><br />
<br />
----<br />
<br />
[[Category::Books]]</div>Notnahttps://wiki.dlang.org/?title=Building_and_hacking_LDC_on_Windows_using_MSVC&diff=4092Building and hacking LDC on Windows using MSVC2014-04-27T12:18:31Z<p>Notna: </p>
<hr />
<div>LDC on Windows is work in progress. This page documents how to compile LDC2 on Windows 7 x64. It also provides hints on druntime and phobos.<br />
<br />
== Building LDC ==<br />
<br />
=== Required software ===<br />
<br />
* Windows 7 x64, of course!<br />
* [http://microsoft.com/en-us/download/details.aspx?id=17718 .NET Framework 4.0] (prerequisite for Windows SDK)<br />
* [http://microsoft.com/en-us/download/details.aspx?id=8279 Windows 7.1 SDK]<br />
* [http://python.org/download/ Python 2.7.x or Python 3.3.x] (I use 3.3.0)<br />
* [http://git-scm.com/download/win git 1.8.x] (I use 1.8.0.msysgit.0 installed with option &quot;Run Git from the Windows Command Prompt&quot;)<br />
* [http://cmake.org/cmake/resources/software.html CMake 2.8.x] (I use 2.8.12.1 installed with option &quot;Add cmake to the system PATH for all users&quot;)<br />
* a tool to extract .tgz files, e.g. [http://7-zip.org/ 7-Zip]<br />
<br />
=== Required source downloads ===<br />
<br />
* [http://hyperrealm.com/libconfig/ libconfig++] (Just use latest release 1.4.9.)<br />
* [http://redstar.de/ldc/win64eh_all_20140414.diff Patch adding Win64 SEH to LLVM 3.5]<br />
* Patches for LDC: (currently none)<br />
=== Environment check ===<br />
<br />
After installing the software, you can open a Windows SDK 7.1 Command Prompt. You should see that you are targeting &quot;Windows 7 x64 Debug&quot;. If not please execute the command <tt>setenv /x64 /Debug</tt>. Running <tt>cmake --version</tt> should display the banner from cmake. Running <tt>git --version</tt> should display the banner from git. Running <tt>msbuild /version</tt> should display the banner from msbuild. Running <tt>&lt;Python install path&gt;\python --version</tt> should display the banner from python.<br />
<br />
My working directory is <tt>C:\ldcenv</tt>. Every step starts in this directory. Please feel free to adjust this to your needs.<br />
<br />
=== Build LLVM ===<br />
<br />
To build LLVM from the command line, just execute the following steps:<br />
<br />
<ul><br />
<li><tt>md build-llvm-x64</tt></li><br />
<li><tt>git clone http://llvm.org/git/llvm.git llvm</tt></li><br />
<li><tt>cd llvm</tt></li><br />
<li>The next command is only required if LLVM 3.5 head is used and if you want Win64 SEH support:<br /><br />
<tt>git apply &lt;path to LLVM patch&gt;\win64eh_all_20130901.diff</tt></li><br />
<li>The next command is only required if LLVM 3.4 is used:<br /><br />
<tt>git checkout -t origin/release_34</tt><br /><br />
<li><tt>cd ..\build-llvm-x64</tt></li><br />
<li><p>Type the next command in one line:</p><br />
<pre>cmake -G &quot;Visual Studio 10 Win64&quot; -DCMAKE_INSTALL_PREFIX=&quot;C:\Program Files\LLVM-x64&quot; <br />
-DPYTHON_EXECUTABLE=&quot;C:\Program Files\Python33\python.exe&quot; -DLLVM_TARGETS_TO_BUILD=&quot;X86&quot;<br />
-DLLVM_INCLUDE_TESTS=OFF C:\ldcenv\llvm</pre></li><br />
<li><p><tt>msbuild ALL_BUILD.vcxproj</tt></p></li></ul><br />
<br />
Open a Windows SDK 7.1 Command Prompt as Administrator.<br />
<br />
* <tt>cd build-llvm-x64</tt><br />
* <tt>msbuild INSTALL.vcxproj</tt><br />
<br />
The [http://llvm.org/docs/CMake.html#id10 LLVM page on CMake] documents other variables you can change. The most common is to add more targets. E.g. to build a target for ARM you change the targets to build to <tt>-DLLVM_TARGETS_TO_BUILD=&quot;X86;ARM&quot;</tt>.<br />
<br />
=== Build libconfig++ ===<br />
<br />
Simple build instructions for libconfig++ are missing. You can do the following:<br />
<br />
* Install Visual Studio 2010 (e.g. [http://microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express Visual Studio 2010 Express])<br />
* Open the libconfig.sln solution<br />
* Create a profile for Win64 Debug<br />
* If you like to create a static library then change the configuration type of project <tt>libconfig++</tt> to 'Static library'.<br />
* Build the project <tt>libconfig++</tt><br />
<br />
=== Build LDC2 ===<br />
<br />
To build LDC2 from the command line, just execute the following steps:<br />
<br />
<ul><br />
<li><tt>md build-ldc2-x64</tt></li><br />
<li><tt>git clone --recursive git://github.com/ldc-developers/ldc.git ldc</tt></li><br />
<li><tt>cd ldc</tt></li><br />
<li>Now apply all the patches for LDC (see section 'Required source downloads' above):<br /><br />
<tt>git apply &lt;patch name&gt;</tt></li><br />
<li><tt>cd ..\build-ldc2-x64</tt></li><br />
<li><p>Type the next command in one line:</p><br />
<pre>cmake -G &quot;Visual Studio 10 Win64&quot; -DCMAKE_INSTALL_PREFIX=&quot;C:\Program Files\LDC&quot;<br />
-DLLVM_ROOT_DIR=&quot;C:/Program Files/LLVM-x64&quot;<br />
-DLIBCONFIG++_INCLUDE_DIR=&quot;C:/ldcenv/libconfig-1.4.9/lib&quot;<br />
-DLIBCONFIG++_LIBRARY=&quot;C:/ldcenv/libconfig-1.4.9/Debug/libconfig++.lib&quot; C:\ldcenv\ldc</pre><br />
<p>This assumes that you have a static compiled version of <tt>libconfig++.lib</tt>. If you use the DLL version then you have to add <tt>-DLIBCONFIG_DLL=ON</tt>.</p></li><br />
<li><p><tt>msbuild ALL_BUILD.vcxproj</tt></p></li></ul><br />
<br />
Open a Windows SDK 7.1 Command Prompt as Administrator.<br />
<br />
* <tt>cd build-llvm-x64</tt><br />
* <tt>msbuild INSTALL.vcxproj</tt><br />
<br />
Check that <tt>C:\Program Files\LDC\bin</tt> is in your path and type <tt>ldc2 -version</tt> to check that you can run <tt>LDC2</tt>.<br />
<br />
=== Troubleshooting ===<br />
<br />
* git 1.7.11 requires extra setup because of git-svn. Just use 1.7.10 or 1.8.0.<br />
* Using Visual Studio 2012: You do not need to install the Windows SDK. Just open the &quot;VS2012 x64 Native Tools Command Prompt&quot;. The CMake generator for VS 2012 is named <tt>Visual Studio 11 Win64</tt>.<br />
<br />
=== Known bugs ===<br />
<br />
* Structured Exception Handling is only available for LLVM 3.5 head with the patch above applied. Support has still alpha quality and is known to crash your application under certain circumstances.<br />
* Execution of tests with the <tt>RUN_TESTS</tt> project does not work.<br />
<br />
== Hacking druntime and phobos ==<br />
<br />
As of version 2.061 (still under development) Druntime and Phobos have support for Win64. The following issues are known:<br />
<br />
* <tt>ldc.eh2</tt>: Implementation has alpha quality. Only used together with LLVM 3.4.<br />
* Other missing functions: Most functions related to <tt>real</tt> type (<tt>long double</tt> in C) are missing because Visual C++ has dropped support for it (e.g. <tt>strtold()</tt>, <tt>sinl</tt>, <tt>cosl</tt>, ...). Some of them are already implemented (see e.g. <tt>std.math</tt>) but please be aware that there are still fake implementations present.<br />
<br />
If you link your modules you have to specify the libraries <tt>phobos-ldc.lib</tt> and <tt>shell32.lib</tt>. Due to a bug in LLVM you have to specifiy the flag <tt>/LARGEADDRESSAWARE:NO</tt>, too.<br />
<br />
== Example ==<br />
<br />
The simple D program <tt>hello.d</tt><br />
<br />
<source lang="d">import std.stdio;<br />
<br />
int main()<br />
{<br />
writefln("Hello LDC2");<br />
return 0;<br />
}</source><br />
can be compiled and linked with the commands:<br />
<br />
<pre><br />
ldc2 -c hello.d<br />
link hello2.obj phobos-ldc.lib shell32.lib /LARGEADDRESSAWARE:NO<br />
</pre><br />
<br />
or simply with: <tt>ldc2 hello.d</tt><br />
<br />
The resulting <tt>hello.exe</tt> produces the expected output.<br />
<br />
<br />
<br />
----<br />
<br />
[[Category:LDC]]<br />
[[Category::Windows]]<br />
[[Category::MSVC]]</div>Notnahttps://wiki.dlang.org/?title=Building_and_hacking_LDC_on_Windows_using_MSVC&diff=4091Building and hacking LDC on Windows using MSVC2014-04-27T12:17:56Z<p>Notna: </p>
<hr />
<div>LDC on Windows is work in progress. This page documents how to compile LDC2 on Windows 7 x64. It also provides hints on druntime and phobos.<br />
<br />
== Building LDC ==<br />
<br />
=== Required software ===<br />
<br />
* Windows 7 x64, of course!<br />
* [http://microsoft.com/en-us/download/details.aspx?id=17718 .NET Framework 4.0] (prerequisite for Windows SDK)<br />
* [http://microsoft.com/en-us/download/details.aspx?id=8279 Windows 7.1 SDK]<br />
* [http://python.org/download/ Python 2.7.x or Python 3.3.x] (I use 3.3.0)<br />
* [http://git-scm.com/download/win git 1.8.x] (I use 1.8.0.msysgit.0 installed with option &quot;Run Git from the Windows Command Prompt&quot;)<br />
* [http://cmake.org/cmake/resources/software.html CMake 2.8.x] (I use 2.8.12.1 installed with option &quot;Add cmake to the system PATH for all users&quot;)<br />
* a tool to extract .tgz files, e.g. [http://7-zip.org/ 7-Zip]<br />
<br />
=== Required source downloads ===<br />
<br />
* [http://hyperrealm.com/libconfig/ libconfig++] (Just use latest release 1.4.9.)<br />
* [http://redstar.de/ldc/win64eh_all_20140414.diff Patch adding Win64 SEH to LLVM 3.5]<br />
* Patches for LDC: (currently none)<br />
=== Environment check ===<br />
<br />
After installing the software, you can open a Windows SDK 7.1 Command Prompt. You should see that you are targeting &quot;Windows 7 x64 Debug&quot;. If not please execute the command <tt>setenv /x64 /Debug</tt>. Running <tt>cmake --version</tt> should display the banner from cmake. Running <tt>git --version</tt> should display the banner from git. Running <tt>msbuild /version</tt> should display the banner from msbuild. Running <tt>&lt;Python install path&gt;\python --version</tt> should display the banner from python.<br />
<br />
My working directory is <tt>C:\ldcenv</tt>. Every step starts in this directory. Please feel free to adjust this to your needs.<br />
<br />
=== Build LLVM ===<br />
<br />
To build LLVM from the command line, just execute the following steps:<br />
<br />
<ul><br />
<li><tt>md build-llvm-x64</tt></li><br />
<li><tt>git clone http://llvm.org/git/llvm.git llvm</tt></li><br />
<li><tt>cd llvm</tt></li><br />
<li>The next command is only required if LLVM 3.5 head is used and if you want Win64 SEH support:<br /><br />
<tt>git apply &lt;path to LLVM patch&gt;\win64eh_all_20130901.diff</tt></li><br />
<li>The next command is only required if LLVM 3.4 is used:<br /><br />
<tt>git checkout -t origin/release_34</tt><br /><br />
<li><tt>cd ..\build-llvm-x64</tt></li><br />
<li><p>Type the next command in one line:</p><br />
<pre>cmake -G &quot;Visual Studio 10 Win64&quot; -DCMAKE_INSTALL_PREFIX=&quot;C:\Program Files\LLVM-x64&quot; <br />
-DPYTHON_EXECUTABLE=&quot;C:\Program Files\Python33\python.exe&quot; -DLLVM_TARGETS_TO_BUILD=&quot;X86&quot;<br />
-DLLVM_INCLUDE_TESTS=OFF C:\ldcenv\llvm</pre></li><br />
<li><p><tt>msbuild ALL_BUILD.vcxproj</tt></p></li></ul><br />
<br />
Open a Windows SDK 7.1 Command Prompt as Administrator.<br />
<br />
* <tt>cd build-llvm-x64</tt><br />
* <tt>msbuild INSTALL.vcxproj</tt><br />
<br />
The [http://llvm.org/docs/CMake.html#id10 LLVM page on CMake] documents other variables you can change. The most common is to add more targets. E.g. to build a target for ARM you change the targets to build to <tt>-DLLVM_TARGETS_TO_BUILD=&quot;X86;ARM&quot;</tt>.<br />
<br />
=== Build libconfig++ ===<br />
<br />
Simple build instructions for libconfig++ are missing. You can do the following:<br />
<br />
* Install Visual Studio 2010 (e.g. [http://microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express Visual Studio 2010 Express])<br />
* Open the libconfig.sln solution<br />
* Create a profile for Win64 Debug<br />
* If you like to create a static library then change the configuration type of project <tt>libconfig++</tt> to 'Static library'.<br />
* Build the project <tt>libconfig++</tt><br />
<br />
=== Build LDC2 ===<br />
<br />
To build LDC2 from the command line, just execute the following steps:<br />
<br />
<ul><br />
<li><tt>md build-ldc2-x64</tt></li><br />
<li><tt>git clone --recursive git://github.com/ldc-developers/ldc.git ldc</tt></li><br />
<li><tt>cd ldc</tt></li><br />
<li>Now apply all the patches for LDC (see section 'Required source downloads' above):<br /><br />
<tt>git apply &lt;patch name&gt;</tt></li><br />
<li><tt>cd ..\build-ldc2-x64</tt></li><br />
<li><p>Type the next command in one line:</p><br />
<pre>cmake -G &quot;Visual Studio 10 Win64&quot; -DCMAKE_INSTALL_PREFIX=&quot;C:\Program Files\LDC&quot;<br />
-DLLVM_ROOT_DIR=&quot;C:/Program Files/LLVM-x64&quot;<br />
-DLIBCONFIG++_INCLUDE_DIR=&quot;C:/ldcenv/libconfig-1.4.9/lib&quot;<br />
-DLIBCONFIG++_LIBRARY=&quot;C:/ldcenv/libconfig-1.4.9/Debug/libconfig++.lib&quot; C:\ldcenv\ldc</pre><br />
<p>This assumes that you have a static compiled version of <tt>libconfig++.lib</tt>. If you use the DLL version then you have to add <tt>-DLIBCONFIG_DLL=ON</tt>.</p></li><br />
<li><p><tt>msbuild ALL_BUILD.vcxproj</tt></p></li></ul><br />
<br />
Open a Windows SDK 7.1 Command Prompt as Administrator.<br />
<br />
* <tt>cd build-llvm-x64</tt><br />
* <tt>msbuild INSTALL.vcxproj</tt><br />
<br />
Check that <tt>C:\Program Files\LDC\bin</tt> is in your path and type <tt>ldc2 -version</tt> to check that you can run <tt>LDC2</tt>.<br />
<br />
=== Troubleshooting ===<br />
<br />
* git 1.7.11 requires extra setup because of git-svn. Just use 1.7.10 or 1.8.0.<br />
* Using Visual Studio 2012: You do not need to install the Windows SDK. Just open the &quot;VS2012 x64 Native Tools Command Prompt&quot;. The CMake generator for VS 2012 is named <tt>Visual Studio 11 Win64</tt>.<br />
<br />
=== Known bugs ===<br />
<br />
* Structured Exception Handling is only available for LLVM 3.5 head with the patch above applied. Support has still alpha quality and is known to crash your application under certain circumstances.<br />
* Execution of tests with the <tt>RUN_TESTS</tt> project does not work.<br />
<br />
== Hacking druntime and phobos ==<br />
<br />
As of version 2.061 (still under development) Druntime and Phobos have support for Win64. The following issues are known:<br />
<br />
* <tt>ldc.eh2</tt>: Implementation has alpha quality. Only used together with LLVM 3.4.<br />
* Other missing functions: Most functions related to <tt>real</tt> type (<tt>long double</tt> in C) are missing because Visual C++ has dropped support for it (e.g. <tt>strtold()</tt>, <tt>sinl</tt>, <tt>cosl</tt>, ...). Some of them are already implemented (see e.g. <tt>std.math</tt>) but please be aware that there are still fake implementations present.<br />
<br />
If you link your modules you have to specify the libraries <tt>phobos-ldc.lib</tt> and <tt>shell32.lib</tt>. Due to a bug in LLVM you have to specifiy the flag <tt>/LARGEADDRESSAWARE:NO</tt>, too.<br />
<br />
== Example ==<br />
<br />
The simple D program <tt>hello.d</tt><br />
<br />
<source lang="d">import std.stdio;<br />
<br />
int main()<br />
{<br />
writefln("Hello LDC2");<br />
return 0;<br />
}</source><br />
can be compiled and linked with the commands:<br />
<br />
<pre><br />
ldc2 -c hello.d<br />
link hello2.obj phobos-ldc.lib shell32.lib /LARGEADDRESSAWARE:NO<br />
</pre><br />
<br />
or simply with: <tt>ldc2 hello.d</tt><br />
<br />
The resulting <tt>hello.exe</tt> produces the expected output.<br />
<br />
<pr><br />
<br />
----<br />
<br />
[[Category:LDC]]<br />
[[Category::Windows]]<br />
[[Category::MSVC]]</div>Notnahttps://wiki.dlang.org/?title=Building_and_hacking_LDC_on_Windows_using_MSVC&diff=4090Building and hacking LDC on Windows using MSVC2014-04-27T12:17:12Z<p>Notna: </p>
<hr />
<div>LDC on Windows is work in progress. This page documents how to compile LDC2 on Windows 7 x64. It also provides hints on druntime and phobos.<br />
<br />
== Building LDC ==<br />
<br />
=== Required software ===<br />
<br />
* Windows 7 x64, of course!<br />
* [http://microsoft.com/en-us/download/details.aspx?id=17718 .NET Framework 4.0] (prerequisite for Windows SDK)<br />
* [http://microsoft.com/en-us/download/details.aspx?id=8279 Windows 7.1 SDK]<br />
* [http://python.org/download/ Python 2.7.x or Python 3.3.x] (I use 3.3.0)<br />
* [http://git-scm.com/download/win git 1.8.x] (I use 1.8.0.msysgit.0 installed with option &quot;Run Git from the Windows Command Prompt&quot;)<br />
* [http://cmake.org/cmake/resources/software.html CMake 2.8.x] (I use 2.8.12.1 installed with option &quot;Add cmake to the system PATH for all users&quot;)<br />
* a tool to extract .tgz files, e.g. [http://7-zip.org/ 7-Zip]<br />
<br />
=== Required source downloads ===<br />
<br />
* [http://hyperrealm.com/libconfig/ libconfig++] (Just use latest release 1.4.9.)<br />
* [http://redstar.de/ldc/win64eh_all_20140414.diff Patch adding Win64 SEH to LLVM 3.5]<br />
* Patches for LDC: (currently none)<br />
=== Environment check ===<br />
<br />
After installing the software, you can open a Windows SDK 7.1 Command Prompt. You should see that you are targeting &quot;Windows 7 x64 Debug&quot;. If not please execute the command <tt>setenv /x64 /Debug</tt>. Running <tt>cmake --version</tt> should display the banner from cmake. Running <tt>git --version</tt> should display the banner from git. Running <tt>msbuild /version</tt> should display the banner from msbuild. Running <tt>&lt;Python install path&gt;\python --version</tt> should display the banner from python.<br />
<br />
My working directory is <tt>C:\ldcenv</tt>. Every step starts in this directory. Please feel free to adjust this to your needs.<br />
<br />
=== Build LLVM ===<br />
<br />
To build LLVM from the command line, just execute the following steps:<br />
<br />
<ul><br />
<li><tt>md build-llvm-x64</tt></li><br />
<li><tt>git clone http://llvm.org/git/llvm.git llvm</tt></li><br />
<li><tt>cd llvm</tt></li><br />
<li>The next command is only required if LLVM 3.5 head is used and if you want Win64 SEH support:<br /><br />
<tt>git apply &lt;path to LLVM patch&gt;\win64eh_all_20130901.diff</tt></li><br />
<li>The next command is only required if LLVM 3.4 is used:<br /><br />
<tt>git checkout -t origin/release_34</tt><br /><br />
<li><tt>cd ..\build-llvm-x64</tt></li><br />
<li><p>Type the next command in one line:</p><br />
<pre>cmake -G &quot;Visual Studio 10 Win64&quot; -DCMAKE_INSTALL_PREFIX=&quot;C:\Program Files\LLVM-x64&quot; <br />
-DPYTHON_EXECUTABLE=&quot;C:\Program Files\Python33\python.exe&quot; -DLLVM_TARGETS_TO_BUILD=&quot;X86&quot;<br />
-DLLVM_INCLUDE_TESTS=OFF C:\ldcenv\llvm</pre></li><br />
<li><p><tt>msbuild ALL_BUILD.vcxproj</tt></p></li></ul><br />
<br />
Open a Windows SDK 7.1 Command Prompt as Administrator.<br />
<br />
* <tt>cd build-llvm-x64</tt><br />
* <tt>msbuild INSTALL.vcxproj</tt><br />
<br />
The [http://llvm.org/docs/CMake.html#id10 LLVM page on CMake] documents other variables you can change. The most common is to add more targets. E.g. to build a target for ARM you change the targets to build to <tt>-DLLVM_TARGETS_TO_BUILD=&quot;X86;ARM&quot;</tt>.<br />
<br />
=== Build libconfig++ ===<br />
<br />
Simple build instructions for libconfig++ are missing. You can do the following:<br />
<br />
* Install Visual Studio 2010 (e.g. [http://microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express Visual Studio 2010 Express])<br />
* Open the libconfig.sln solution<br />
* Create a profile for Win64 Debug<br />
* If you like to create a static library then change the configuration type of project <tt>libconfig++</tt> to 'Static library'.<br />
* Build the project <tt>libconfig++</tt><br />
<br />
=== Build LDC2 ===<br />
<br />
To build LDC2 from the command line, just execute the following steps:<br />
<br />
<ul><br />
<li><tt>md build-ldc2-x64</tt></li><br />
<li><tt>git clone --recursive git://github.com/ldc-developers/ldc.git ldc</tt></li><br />
<li><tt>cd ldc</tt></li><br />
<li>Now apply all the patches for LDC (see section 'Required source downloads' above):<br /><br />
<tt>git apply &lt;patch name&gt;</tt></li><br />
<li><tt>cd ..\build-ldc2-x64</tt></li><br />
<li><p>Type the next command in one line:</p><br />
<pre>cmake -G &quot;Visual Studio 10 Win64&quot; -DCMAKE_INSTALL_PREFIX=&quot;C:\Program Files\LDC&quot;<br />
-DLLVM_ROOT_DIR=&quot;C:/Program Files/LLVM-x64&quot;<br />
-DLIBCONFIG++_INCLUDE_DIR=&quot;C:/ldcenv/libconfig-1.4.9/lib&quot;<br />
-DLIBCONFIG++_LIBRARY=&quot;C:/ldcenv/libconfig-1.4.9/Debug/libconfig++.lib&quot; C:\ldcenv\ldc</pre><br />
<p>This assumes that you have a static compiled version of <tt>libconfig++.lib</tt>. If you use the DLL version then you have to add <tt>-DLIBCONFIG_DLL=ON</tt>.</p></li><br />
<li><p><tt>msbuild ALL_BUILD.vcxproj</tt></p></li></ul><br />
<br />
Open a Windows SDK 7.1 Command Prompt as Administrator.<br />
<br />
* <tt>cd build-llvm-x64</tt><br />
* <tt>msbuild INSTALL.vcxproj</tt><br />
<br />
Check that <tt>C:\Program Files\LDC\bin</tt> is in your path and type <tt>ldc2 -version</tt> to check that you can run <tt>LDC2</tt>.<br />
<br />
=== Troubleshooting ===<br />
<br />
* git 1.7.11 requires extra setup because of git-svn. Just use 1.7.10 or 1.8.0.<br />
* Using Visual Studio 2012: You do not need to install the Windows SDK. Just open the &quot;VS2012 x64 Native Tools Command Prompt&quot;. The CMake generator for VS 2012 is named <tt>Visual Studio 11 Win64</tt>.<br />
<br />
=== Known bugs ===<br />
<br />
* Structured Exception Handling is only available for LLVM 3.5 head with the patch above applied. Support has still alpha quality and is known to crash your application under certain circumstances.<br />
* Execution of tests with the <tt>RUN_TESTS</tt> project does not work.<br />
<br />
== Hacking druntime and phobos ==<br />
<br />
As of version 2.061 (still under development) Druntime and Phobos have support for Win64. The following issues are known:<br />
<br />
* <tt>ldc.eh2</tt>: Implementation has alpha quality. Only used together with LLVM 3.4.<br />
* Other missing functions: Most functions related to <tt>real</tt> type (<tt>long double</tt> in C) are missing because Visual C++ has dropped support for it (e.g. <tt>strtold()</tt>, <tt>sinl</tt>, <tt>cosl</tt>, ...). Some of them are already implemented (see e.g. <tt>std.math</tt>) but please be aware that there are still fake implementations present.<br />
<br />
If you link your modules you have to specify the libraries <tt>phobos-ldc.lib</tt> and <tt>shell32.lib</tt>. Due to a bug in LLVM you have to specifiy the flag <tt>/LARGEADDRESSAWARE:NO</tt>, too.<br />
<br />
== Example ==<br />
<br />
The simple D program <tt>hello.d</tt><br />
<br />
<source lang="d">import std.stdio;<br />
<br />
int main()<br />
{<br />
writefln("Hello LDC2");<br />
return 0;<br />
}</source><br />
can be compiled and linked with the commands:<br />
<br />
<pre><br />
ldc2 -c hello.d<br />
link hello2.obj phobos-ldc.lib shell32.lib /LARGEADDRESSAWARE:NO<br />
</pre><br />
<br />
or simply with: <tt>ldc2 hello.d</tt><br />
<br />
The resulting <tt>hello.exe</tt> produces the expected output.<br />
<br />
<br />
<br />
[[Category:LDC]]<br />
[[Category::Windows]]<br />
[[Category::MSVC]]</div>Notnahttps://wiki.dlang.org/?title=Compiling_and_linking_with_DMD_on_Windows&diff=4089Compiling and linking with DMD on Windows2014-04-27T11:53:57Z<p>Notna: </p>
<hr />
<div>= Compiling and linking a simple D project =<br />
<br />
Make sure the directory path to DMD2 and Optlink is listed in your PATH environment variable. This directory is usually C:\DMD\dmd2\windows\bin on Windows.<br />
<br />
'''> dmd'''<br />
'''Digital Mars D Compiler v2.051'''<br />
<br />
'''> link'''<br />
'''OPTLINK (R) for Win32 Release 8.00.8'''<br />
Invoking dmd and optlink is shown above. If you get similar results, you're good to go. If you don't know what environment variable are, read the [http://support.microsoft.com/kb/310519 Environment Variables Guide]. Be aware that on Windows you might have to log out and log in again before any changes to the PATH variable are seen throughout the entire system.<br />
<br />
Our test project consists of two files:<br />
<br />
'''''project.d:'''''<br />
<syntaxhighlight lang="D"><br />
module project;<br />
import foo;<br />
void main()<br />
{<br />
callFoo("main", 10);<br />
}<br />
</syntaxhighlight><br />
<br />
'''''foo.d:'''''<br />
<syntaxhighlight lang="D"><br />
module foo;<br />
import std.stdio;<br />
void callFoo(string arg, int num)<br />
{<br />
writefln("Called from %s with number %s.", arg, num);<br />
}<br />
</syntaxhighlight><br />
There are multiple ways of compiling and linking the two modules. The straightforward way is to list all files to be compiled and linked on the command line when invoking DMD:<br />
<br />
'''dmd project.d foo.d'''<br />
This will produce an executable with the name of the first module provided on the command line ("project.exe" on Windows). Behind-the-scenes DMD compiles the two modules and links them together to form one object file ("project.obj" on Windows). To create the executable DMD will link the project.obj file with the Phobos standard library (\DMD\dmd2\windows\lib\phobos.lib on Windows, or DMD\dmd2\linux\lib\libphobos2.a on linux) and any OS-specific libraries which the executable needs to succesfully run.<br />
<br />
= Linking manually =<br />
<br />
DMD uses the '''-c''' switch to skip the linking process and only compile the .d files: <br />
<br />
'''dmd -c project.d foo.d'''<br />
This will produce one object file per each D module:<br />
'''project.obj'''<br />
'''foo.obj'''<br />
Now we need to link these two object files with the Phobos standard library and any essential Operating System libraries. There are two ways of doing this.<br />
<br />
The easy way is to let DMD call the linker automatically:<br />
'''dmd project.obj foo.obj'''<br />
The reason this works is because DMD parses its config file which specifies the directory paths of the Phobos and OS libraries in the LIB environment variable. Optlink will look for this variable in the linking process.<br />
<br />
The hard way of linking is invoking the linker manually. This implies learning a thing or two about Optlink's syntax and its switches.<br />
<br />
We know our project depends on the Phobos library, but how do we figure out which OS libraries we need to link in?<br />
A quick way to find that out is to invoke DMD with the '''-v''' (verbose) switch:<br />
'''dmd -v project.obj foo.obj'''<br />
'''binary D:\DMD\dmd2\windows\bin\dmd.exe'''<br />
'''version v2.051'''<br />
'''config D:\DMD\dmd2\windows\bin\sc.ini'''<br />
'''D:\DMD\dmd2\windows\bin\link.exe project+foo,,,user32+kernel32/noi;'''<br />
Note that we're calling DMD on object files, not .d files. Invoking DMD with .d files would compile the files and produce several pages of information due to the verbose switch. Using only .obj files DMD will know all it has to do is invoke the linker on the files.<br />
<br />
The last line shows how the linker was invoked. Optlink's syntax and switches are explained in the next section. To try your hand at linking on your own, delete any existing object files and executables, and use DMD to compile, Optlink to link:<br />
'''dmd -c project.d foo.d'''<br />
'''link.exe project+foo,,,user32+kernel32/noi;'''<br />
<br />
= Optlink's Syntax and Switches =<br />
<br />
Optlink has the following command-line form:<br />
'''link obj[,out[,map[,lib[,def[,res]]]]]'''<br />
Object files can be separated with either a blank space or a + sign. Their file extensions don't have to be provided.<br />
The full documentation on Optlink's syntax is provided [http://www.digitalmars.com/ctg/optlink.html#operational here]. <br />
<br />
Optlink also has numerous switches you can use. To list all of them, invoke the linker with the '''/h''' (help) switch:<br />
'''link /h'''<br />
Optlink's switches are described in detail [http://www.digitalmars.com/ctg/ctgLinkSwitches.html here].<br />
<br />
Now we're ready to decipher the linker command from the previous section:<br />
'''link.exe project+foo,,,user32+kernel32/noi;'''<br />
The first argument to Optlink is '''project+foo'''. These are two object files, separated by the + sign. Optlink automatically appends file extensions to any object or library names if you don't provide them yourself. The second and third arguments are not needed, and remain blank. The fourth argument are the libraries Optlink will link with. '''user32+kernel32''' will expand to '''user32.lib''' and '''kernel32.lib'''. These are located in '''\DMD\dmd2\windows\lib\''' by default.<br />
<br />
You'll notice that we didn't specify '''where''' the two library files (user32.lib and kernel32.lib) are located . This is because Optlink parses a special configuration file located at '''\DMD\dmd2\windows\bin\sc.ini'''. When parsed, this config file modifies the LIB environment variable and adds a couple of paths, specifically it adds the path to Phobos and some system libraries. Optlink then reads the LIB environment variable for any paths. These will be used to find any library files that were specified without an absolute path.<br />
<br />
The '''/noi''' switch forces the linker to not ignore the casing of identifiers and symbols found in object and library files.<br />
<br />
The semicolon at the end of the invocation can be ignored.<br />
<br />
= Static Libraries and Import Paths =<br />
When your project grows large you might start experiencing slow compilation times. A common cause of these slowdowns is the constant re-compilation of modules which haven't really changed since the last time they were compiled. These problems can be solved several ways, one of which is separating relevant modules to their own static libraries. Other solutions can be to use a good build system, but this is beyond the scope of this tutorial.<br />
<br />
Our project might have a collection of modules which belong to the '''libfoo''' library, and a front-end called '''driver.d'''. Here's what the directory structure might look like:<br />
<br />
C:\Project\libs\libfoo\foo.d<br />
C:\Project\libs\libfoo\bar.d<br />
C:\Project\driver.d<br />
Here are the file contents:<br />
<br />
'''''foo.d:'''''<br />
<syntaxhighlight lang="D"><br />
module libfoo.foo;<br />
import std.stdio : writeln;<br />
struct Rectangle<br />
{<br />
int width, height;<br />
void display()<br />
{<br />
writefln("w: %s, h: %s", width, height);<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
'''''bar.d:'''''<br />
<syntaxhighlight lang="D"><br />
module libfoo.bar;<br />
import libfoo.foo;<br />
<br />
Rectangle getRectangle()<br />
{<br />
return Rectangle(80, 40);<br />
}<br />
</syntaxhighlight><br />
<br />
'''''driver.d:'''''<br />
<syntaxhighlight lang="D"><br />
module driver;<br />
import std.stdio;<br />
import libfoo.bar;<br />
<br />
void main()<br />
{<br />
auto rect = getRectangle();<br />
rect.display();<br />
}<br />
</syntaxhighlight><br />
<br />
We'll build a single .lib file out of all the modules belonging to the '''libfoo''' package. To do this, we pass the -lib switch when building libfoo's modules with DMD:<br />
'''cd libs\libfoo'''<br />
'''dmd -lib -oflibfoo.lib foo.d bar.d'''<br />
The '''-of''' switch is used to set a custom output filename, in this case '''libfoo.lib'''.<br />
One nice consequence of having a .lib file is that we no longer have to specify all the .d files belonging to libfoo when invoking DMD. Instead, we can use the '''-I''' import switch.<br />
<br />
The import switch specifies a directory DMD will search for when it needs to find modules specified in import statements in your module files. We can use multiple import switches. In our driver.d file, we have these two import statements:<br />
<br />
'''import std.stdio;'''<br />
'''import libfoo.bar;'''<br />
The first one tells DMD that the stdio module belongs to the '''std''' package. A package is equivalent to a directory name, so '''stdio''' should be found in the '''std''' directory. <br />
<br />
Before compilation DMD parses the sc.ini config file, located in \DMD\dmd2\windows\bin\. The config file modifies the DFLAGS environment variable, and adds import switches with the paths to the Phobos and Druntime source code directories. The location of the Phobos source code is:<br />
<br />
'''\DMD\dmd2\src\phobos'''<br />
Inside this directory you will find the '''std''' subdirectory.<br />
<br />
We won't be changing our sc.ini file, instead we'll provide the import switch on the command line. Since our package name is '''libfoo''', we have to specify the directory it is contained within for the import switch.<br />
If you accidentally specify the wrong directory, you might get an error such as the following:<br />
<br />
'''dmd driver.d -I%cd%\'''<br />
driver.d(3): Error: module bar is in file 'libfoo\bar.d' which cannot be read<br />
import path[0] = D:\Project\<br />
import path[1] = D:\DMD\dmd2\windows\bin\..\..\src\phobos<br />
import path[2] = D:\DMD\dmd2\windows\bin\..\..\src\druntime\import<br />
(%cd% expands to the current directory before calling dmd).<br />
<br />
The libfoo directory is located in the '''libs''' subdirectory of our project, which explains the errors. The correct command is:<br />
'''dmd driver.d -I%cd%\libs\'''<br />
Unfortunately, now we're getting linker errors:<br />
OPTLINK (R) for Win32 Release 8.00.8<br />
Copyright (C) Digital Mars 1989-2010 All rights reserved.<br />
http://www.digitalmars.com/ctg/optlink.html<br />
driver.obj(driver)<br />
Error 42: Symbol Undefined _D6libfoo3bar12__ModuleInfoZ<br />
driver.obj(driver)<br />
Error 42: Symbol Undefined''' '''_D6libfoo3bar12getRectangleFZS6libfoo3foo9Rectangle<br />
driver.obj(driver)<br />
Error 42: Symbol Undefined _D6libfoo3foo9Rectangle7displayMFZv<br />
--- errorlevel 3<br />
The fix is to specify the prebuilt .lib file on the command line:<br />
'''dmd driver.d %cd%\libs\libfoo\libfoo.lib -I%cd%\libs\'''<br />
The reason you have to manually specify the .lib file is because DMD '''will not''' compile the modules found in packages specified by the import switch. For that reason, the import switch is useful when we want to avoid recompilation of modules that are already built. Hence, using the import switch can considerably speed up the build process.<br />
<br />
When you download 3rd party D static libraries, you will often find an '''import''' subdirectory within these libraries. This directory is normally used with the '''-I''' switch in your project. Some libraries don't come with this directory, in this case you can probably use their root directory with the import switch. A library might also come with some build scripts or instructions on how to create one or more .lib static library files. <br />
<br />
Once you're familiar with these concepts, all you have to do to take advantage of a 3rd party static library is:<br />
* Add the path to the import directory of the library by using the -I switch<br />
* Link with the required .lib files of the library when invoking DMD<br />
<br />
= Passing search directories for static library files to Optlink =<br />
<br />
To specify a search directory for static library files, use the '''-L+''' switch followed by the relative or absolute directory path.<br />
If you have this project directory:<br />
C:\Project\main.d<br />
C:\Project\lib\mylib.lib<br />
where '''main.d''' depends on the '''mylib''' library, you can compile via:<br />
dmd -L+.\lib\ driver.d mylib.lib<br />
The '''-L+''' switch needs to be followed by a valid directory specifier syntax. You cannot specify '''-L+lib''' or '''-L+lib\''', but '''-L+.\lib\''', '''-L+%cd%\lib\''' or another relative or absolute directory such as '''-L+..\..\''' will be accepted. <br />
<br />
'''Note''': The path must be followed by a backslash. E.g. '''-L+lib''' may not work, '''-L+lib\''' should be used instead.<br />
<br />
'''Note''': Using '-L+' will not work if you use it together with the -lib switch. This is normal since you do not need to specify any other static libraries when you're building a new static library.<br />
<br />
= Getting Symbolic Information =<br />
<br />
The DMC compiler comes with a useful utility called '''libunres'''. You can download DMC freely from [http://www.digitalmars.com/d/download.html here] (DMC should be listed in the third table).<br />
Once you have the compiler installed, you will find libunres inside the \dm\bin folder. You might want to add \dm\bin to your PATH, or alternatively copy libunres.exe to your DMD\bin directory.<br />
<br />
Using '''libunres''' is straightforward. Calling it on any object or library file will list most of its symbols. If we run it on the foo.obj file from the [http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/CompilingLinkingD#CompilingandlinkingasimpleDproject first] section, it will print out a large list of symbol names, some of which are displayed here:<br />
<br />
'''libunres foo.obj'''<br />
Unresolved externals:<br />
_D11TypeInfo_Aa6__initZ<br />
_D12TypeInfo_Aya6__initZ<br />
_D14TypeInfo_Const6__vtblZ<br />
_D15TypeInfo_Struct6__vtblZ<br />
_D3std3utf12isValidDcharFNaNbNfwZb <br />
...<br />
Being able to see the symbol names is important when you're trying to fix common linking errors. By examining the symbol table you might discover that you've accidentally forgot to add a calling convention specifier in your code. Another common error is specifying the wrong calling convention. This often happens when linking with <nowiki>WinAPI</nowiki> libraries, since some functions need the '''extern(Windows)''' specifier, while others might need the '''extern(C)''' specifier. Calling conventions are discussed in the next section.<br />
<br />
You can call libunres without any arguments to get a list of switches. <br />
<br />
Here's a sample call with the '''-d''' switch:<br />
'''libunres -d foo.obj'''<br />
_D3foo12__ModuleInfoZ<br />
_D3foo7callFooFAyaiZv<br />
_D3std4conv16__T5parseTkTAyaZ5parseFKAyaZk4signxi<br />
These are D2 mangled names. There are various reasons why D mangles names, compared to a typical ANSI C compiler which usually doesn't mangle its symbol names (although a C compiler might add an underscore before a symbol name).<br />
<br />
You can read more about why mangling is necessary and how it works [http://en.wikipedia.org/wiki/Name_mangling here].<br />
<br />
= Calling Conventions =<br />
<br />
A calling convention specifies how a function receives parameters and how it returns a result. Specifically, it specifies whether the parameters are stored in registers or the call stack, in which order the parameters are passed in, and who is responsible for the cleanup code (the caller or the callee). You can read more about calling conventions [http://en.wikipedia.org/wiki/Calling_convention here].<br />
<br />
On the Windows platform there are at least 3 calling conventions that you should be aware of: C, D and Windows.<br />
<br />
Here's an example project with two files that have functions with various calling conventions:<br />
<br />
foo.d:<br />
module foo;<br />
extern(C)<br />
{<br />
int sum(int x, int y)<br />
{<br />
return x + y;<br />
}<br />
}<br />
<br />
struct Rectangle<br />
{<br />
float width, height;<br />
}<br />
<br />
extern(Windows) Rectangle getRectangle(float size)<br />
{<br />
return Rectangle(size*2, size);<br />
}<br />
main.d:<br />
module main;<br />
extern(C) int sum(int x, int y);<br />
struct Rectangle<br />
{<br />
float width, height;<br />
}<br />
<br />
extern(Windows) Rectangle getRectangle(float size);<br />
<br />
void main()<br />
{<br />
assert(sum(5, 5) == 10);<br />
auto rect = getRectangle(25);<br />
assert(rect.width == 50);<br />
assert(rect.height == 25);<br />
}<br />
Notice that we did '''not''' import the foo module in our main module. Instead, we provide function prototypes with no body definitions. We did have to define the Rectangle structure again, otherwise we wouldn't be able to link to the getRectangle function since it returns an instance of a Rectangle structure. Without knowing what kind of type a function returns, the linker can't do its job properly.<br />
In D, the calling convention is set by using the linkage attribute '''extern( ident )'''. We can set the linkage on a function by function basis, or we can wrap multiple functions under a single calling convention block. We can even set a linkage attribute for an entire module. More about the linkage attribute syntax can be found [http://www.digitalmars.com/d/2.0/attribute.html#linkage here].<br />
<br />
Once we have the prototypes and the calling convention correctly set, we can compile and link the two modules:<br />
'''dmd -c foo.d'''<br />
'''dmd -c main.d'''<br />
'''dmd -fmain.exe main.obj foo.obj'''<br />
Note that it isn't necessary to separately compile the two modules, we can let DMD do all the work at once:<br />
'''dmd main.d foo.d'''<br />
If you run the resulting executable, all the asserts should pass.<br />
<br />
Of course, it doesn't make much sense to create functions with C linkage types in D if they're only going to be used in D programs. The real use case of C and Windows linkage types is being able to link to object or static library files created by other C compilers. It's also useful in cases where you want to build a D object or library that has an entry point function written in C. This would allow applications written in other languages to take advantage of the functionality of your D code. Functions that require the Windows linkage types are most often used with Microsoft Windows DLLs, these provide access to the Windows API. <br />
<br />
= Writing and Using D Interface Files =<br />
<br />
What if we didn't have the source code to the implementation of a D static library? Let's see what happens if we try to create a function prototype with the same name as a function in another D module, and try to link the two together:<br />
<br />
foo.d:<br />
module foo;<br />
extern(D)<br />
{<br />
string getString()<br />
{<br />
return "I'm just a D string.";<br />
}<br />
}<br />
main.d:<br />
module main;<br />
import std.stdio;<br />
extern(D) string getString();<br />
<br />
void main()<br />
{<br />
writeln(getString());<br />
}<br />
Notice we don't import the foo module in the main module.<br />
<br />
We attempt to compile and link:<br />
'''dmd -c main.d'''<br />
'''dmd -c foo.d'''<br />
'''dmd -ofmain.exe main.obj foo.obj'''<br />
OPTLINK (R) for Win32 Release 8.00.8<br />
main.obj(main)<br />
Error 42: Symbol Undefined _D4main9getStringFZAya<br />
But we get a linker error. Here's where [http://prowiki.org/wiki4d/wiki.cgi#GettingSymbolicInformation libunres] comes in handy. We can call libunres on both modules and compare their symbol names. By default libunres will show unresolved externals, but using the -d switch shows the symbols defined inside an object file:<br />
'''libunres main.obj'''<br />
_D4main9getStringFZAya<br />
...<br />
'''libunres -d foo.obj'''<br />
_D3foo9getStringFZAya<br />
...<br />
The getString function encodes the module name it belongs to in its mangled name. The two mangled names don't match, hence the linker error.<br />
<br />
So if we can't arbitrarily link D functions without knowing which module they belong to, how could one distribute static libraries with no implementation source code? <br />
<br />
The answer to that are D interface files. A D Interface file (.di extension) is similar to a C header file, however it is '''not''' part of the D language. It is exclusively a feature of the D compiler. Another difference compared to C header files is that D Interface files can be generated automatically by the compiler, so there is never a need to write them by hand.<br />
<br />
Let's say we are writing such a library, called '''libfoo'''. Here are two modules from our library:<br />
<br />
libfoo\foo.d:<br />
module libfoo.foo;<br />
string getFooString()<br />
{<br />
return "A string from libfoo.foo";<br />
}<br />
libfoo\bar.d:<br />
module libfoo.bar;<br />
string getBarString()<br />
{<br />
return "A string from libfoo.bar";<br />
}<br />
We want to compile and link these two modules into a single library file. We also want to generate the interface files. Ideally we would like to put the interface files to a separate import directory to be easily used in applications. We'll distribute the import directory with the resulting .lib file. Here's the full command that does just that:<br />
<br />
'''dmd -oflibfoo.lib -lib -H -Hd"%cd%"\import\libfoo\ bar.d foo.d"'''<br />
'''-oflibfoo.lib''' will name the output file as 'libfoo.lib'.<br />
<br />
'''-lib''' will create a static library instead of an executable.<br />
<br />
'''-H''' will generate D interface files.<br />
<br />
'''-Hd''' will output the D interface files in the specified directory. %cd% expands to the current directory, while the double quotes are used in case our directory has any spaces in its name.<br />
<br />
Now let's say we're the user who wants to statically link with libfoo. We're handed the libfoo.lib file and the libfoo directory which has the import directory, which holds the D interface files. We copy these inside our project directory where we have a simple main.d driver file. Here's what our project structure might look like:<br />
<br />
main.d<br />
libfoo.lib<br />
import\libfoo\foo.di<br />
import\libfoo\bar.di<br />
And our main file:<br />
main.d:<br />
module main;<br />
import std.stdio;<br />
import libfoo.foo;<br />
import libfoo.bar;<br />
<br />
void main()<br />
{<br />
writeln(getFooString());<br />
writeln(getBarString());<br />
}<br />
To compile and link with the library, we invoke DMD from within the same directory as main.d with the command:<br />
'''dmd -I"%cd%"\import\ main.d libfoo.lib'''<br />
'''-I''' is used to set the interface search path, as explained in the section on [http://prowiki.org/wiki4d/wiki.cgi#StaticLibrariesandImportPaths import files]. Since we might use other libraries in our project, we've made a single import directory. Inside, we have the interface files set in separate directories, depending on which library they belong to.<br />
Remember that we had to specify the library file (libfoo.lib) on the command line.<br />
<br />
The project should compile and link, and you can then invoke the application:<br />
'''main.exe'''<br />
A string from libfoo.foo<br />
A string from libfoo.bar <br />
A similar approach to using interface files is with libraries that are distributed as DLLs. These are discussed in the DLL tutorial (to be done).<br />
<br />
= More information about Linkers =<br />
[http://www.lurklurk.org/linkers/linkers.html Beginner's Guide to Linkers] (Uses C as example code, but it's still relevant.)<br />
<br />
----<br />
<br />
[[Category::Compiler]]<br />
[[Category::Compilers]]<br />
[[Category::Windows]]<br />
[[Category::DMD]]<br />
[[Category::know-how]]</div>Notnahttps://wiki.dlang.org/?title=Books&diff=4088Books2014-04-27T11:50:31Z<p>Notna: </p>
<hr />
<div><br />
<br />
<table style="border-collapse: collapse;"><br />
<br />
<tr style="background: #eee; font-size: 0.8em; color: #666; text-align: left;"><br />
<th style="width:128px; padding: 0px 10px;"></th><th style="width:25%; padding: 0px 10px;">Title / Author / Info</th><th style=" padding: 0px 10px;">Description</th><th style="width:20%; padding: 0px 10px;">Links</th><br />
</tr><br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px; text-align: center"><br />
<br />
[[File:book_tdpl_128.png|link=http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361]]<br />
<br />
</td><td style="padding: 5px 10px;"><br />
<br />
'''The D Programming Language'''<br/><br />
Andrei Alexandrescu<br/><br />
June 12, 2010<br />
<br />
</td><td style="padding: 5px 10px;"><br />
The definitive book on D<br />
<br />
“This is a book by a skilled author describing an interesting programming language. I’m sure you’ll find the read rewarding.”<br />
''~From the Foreword by Scott Meyers''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 Amazon]<br />
* [http://www.informit.com/articles/article.aspx?p=1381876 Read chapter 1 online - "D"iving In]<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Read chapter 13 online - Concurrency]<br />
* [http://erdani.com/tdpl/errata/ Errata]<br />
<br />
</td><br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://ddili.org/ders/d.en/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Programming in D'''<br/><br />
Ali Çehreli<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Comprehensive free online book for beginners<br />
<br />
“This book aims to teach the D language to readers who are new to computer programming. Although having experience in other programming languages would certainly be helpful, this book starts from the basics.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://ddili.org/ders/d.en/index.html The online book]<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=https://github.com/PhilippeSigaud/D-templates-tutorial/]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Templates: A Tutorial'''<br/><br />
Philippe Sigaud<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Free book (pdf) about templates<br />
<br />
“Templates are a central feature of D, giving you powerful compile-time code<br />
generation abilities that’ll make your code cleaner, more flexible and even more<br />
efficient.<br />
This document aims to be a kind of tutorial on D templates, to show the<br />
beginning D coder what can be achieved with them.”<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [https://github.com/PhilippeSigaud/D-templates-tutorial Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://qznc.github.io/d-tut/index.html]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''Pragmatic D Tutorial'''<br/><br />
Andreas Zwinkau<br/><br />
<br />
</td><td style="padding: 5px 10px;"><br />
Pragmatic introduction to the D Programming Language<br />
<br />
“This tutorial tries to provide pragmatic information to enable you to start coding ASAP.”<br />
<br />
''~From the Introduction''<br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://qznc.github.io/d-tut/index.html Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<tr style="border-bottom: 1px solid #ccc; vertical-align: top;"><br />
<td style="padding: 5px 10px;"><br />
<br />
[[File:icon_book_128.png|link=http://dlang.org/dlangspec.pdf]]<br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
'''D Programming Language Specification'''<br/><br />
<br/><br />
<br />
</td><br />
<td style="padding: 5px 10px;"><br />
<br />
</td><td style="padding: 5px 10px; "><br />
<br />
* [http://dlang.org/dlangspec.pdf Website]<br />
<br />
</td><br />
<br />
</tr><br />
<br />
<br />
</table><br />
<br />
----<br />
<br />
[[Category::Books]]</div>Notnahttps://wiki.dlang.org/?title=Win32_DLLs_in_D&diff=4087Win32 DLLs in D2014-04-27T11:47:34Z<p>Notna: </p>
<hr />
<div>DLLs (Dynamic Link Libraries) are one of the foundations of system programming for Windows. The D programming language enables the creation of several different types of DLLs.<br />
<br />
For background information on what DLLs are and how they work Chapter 11 of Jeffrey Richter's book [http://www.amazon.com/exec/obidos/ASIN/1572315482/classicempire Advanced Windows] is indispensible. <br />
<br />
This guide will show how to create DLLs of various types with D.<br />
<br />
== Compiling a DLL ==<br />
Use the [https://dlang.org/dmd-windows.html#switch-shared -shared] switch to tell the compiler that the generated code is to be put into a DLL. Code compiled for an EXE file will use the optimization assumption that '''_tls_index==0'''. Such code in a DLL will crash.<br />
<br />
== DLLs with a C Interface ==<br />
<br />
A DLL presenting a C interface can connect to any other code in a language that supports calling C functions in a DLL.<br />
<br />
DLLs can be created in D in roughly the same way as in C. A DllMain() is required, looking like:<br />
<br />
<syntaxhighlight lang="D"><br />
import std.c.windows.windows;<br />
import core.sys.windows.dll;<br />
<br />
__gshared HINSTANCE g_hInst;<br />
<br />
extern (Windows)<br />
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)<br />
{<br />
switch (ulReason)<br />
{<br />
case DLL_PROCESS_ATTACH:<br />
g_hInst = hInstance;<br />
dll_process_attach( hInstance, true );<br />
break;<br />
<br />
case DLL_PROCESS_DETACH:<br />
dll_process_detach( hInstance, true );<br />
break;<br />
<br />
case DLL_THREAD_ATTACH:<br />
dll_thread_attach( true, true );<br />
break;<br />
<br />
case DLL_THREAD_DETACH:<br />
dll_thread_detach( true, true );<br />
break;<br />
<br />
default:<br />
}<br />
return true;<br />
}<br />
</syntaxhighlight><br />
<br />
Notes:<br />
<br />
* DllMain simply forwards to the appropriate helper functions. These setup the runtime, create thread objects for interaction with the garbage collector and initialize thread local storage data.<br />
* The DLL does not share its runtime or memory with other DLLs.<br />
* The first boolean argument to the dll-helper functions specify whether all threads should be controlled by the garbage collector. You might need more control over this behaviour if there are threads in the process that must not be suspended. In this case pass false to disable the automatic handling of all threads.<br />
* The presence of '''DllMain()''' is recognized by the compiler causing it to emit a reference to [http://www.digitalmars.com/ctg/acrtused.html __acrtused_dll] and the '''phobos.lib''' runtime library.<br />
<br />
Link with a .def ([http://www.digitalmars.com/ctg/ctgDefFiles.html Module Definition File]) along the lines of:<br />
<br />
<pre><br />
LIBRARY MYDLL<br />
DESCRIPTION 'My DLL written in D'<br />
<br />
EXETYPE NT<br />
CODE PRELOAD DISCARDABLE<br />
DATA WRITE<br />
<br />
EXPORTS<br />
DllGetClassObject @2<br />
DllCanUnloadNow @3<br />
DllRegisterServer @4<br />
DllUnregisterServer @5<br />
</pre><br />
<br />
The functions in the EXPORTS list are for illustration. Replace them with the actual exported functions from MYDLL. Alternatively, use [http://www.digitalmars.com/ctg/implib.html implib]. Here's an example of a simple DLL with a function print() which prints a string:<br />
<br />
=== mydll.d: ===<br />
<syntaxhighlight lang="D"><br />
module mydll;<br />
import std.c.stdio;<br />
export void dllprint() { printf("hello dll world\n"); }<br />
</syntaxhighlight><br />
<br />
Note: We use '''printf'''s in these examples instead of '''writefln''' to make the examples as simple as possible.<br />
<br />
=== mydll.def: ===<br />
<br />
<pre><br />
LIBRARY "mydll.dll"<br />
EXETYPE NT<br />
SUBSYSTEM WINDOWS<br />
CODE SHARED EXECUTE<br />
DATA WRITE<br />
</pre><br />
<br />
Put the code above that contains '''DllMain()''' into a file '''dll.d'''. Compile and link the dll with the following command:<br />
<br />
<pre><br />
C:>dmd -ofmydll.dll -L/IMPLIB mydll.d dll.d mydll.def<br />
C:><br />
</pre><br />
<br />
which will create mydll.dll and mydll.lib. Now for a program, test.d, which will use the dll:<br />
<br />
=== test.d: ===<br />
<syntaxhighlight lang="D"><br />
import mydll;<br />
<br />
int main()<br />
{<br />
mydll.dllprint();<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
Create an interface file mydll.di that doesn't have the function bodies.<br />
<br />
=== mydll.di: ===<br />
<syntaxhighlight lang="D"><br />
export void dllprint();<br />
</syntaxhighlight><br />
<br />
Compile and link with the command:<br />
<br />
<pre><br />
C:>dmd test.d mydll.lib<br />
C:><br />
</pre><br />
<br />
and run:<br />
<br />
<pre><br />
C:>test<br />
hello dll world<br />
C:><br />
</pre><br />
<br />
=== Memory Allocation ===<br />
D DLLs use garbage collected memory management. The question is what happens when pointers to allocated data cross DLL boundaries? If the DLL presents a C interface, one would assume the reason for that is to connect with code written in other languages. Those other languages will not know anything about D's memory management. Thus, the C interface will have to shield the DLL's callers from needing to know anything about it.<br />
<br />
There are many approaches to solving this problem:<br />
<br />
* Do not return pointers to D gc allocated memory to the caller of the DLL. Instead, have the caller allocate a buffer, and have the DLL fill in that buffer.<br />
* Retain a pointer to the data within the D DLL so the GC will not free it. Establish a protocol where the caller informs the D DLL when it is safe to free the data.<br />
* Notify the GC about external references to a memory block by calling GC.addRange.<br />
* Use operating system primitives like VirtualAlloc() to allocate memory to be transferred between DLLs.<br />
* Use std.c.stdlib.malloc() (or another non-gc allocator) when allocating data to be returned to the caller. Export a function that will be used by the caller to free the data.<br />
<br />
== COM Programming ==<br />
Many Windows API interfaces are in terms of COM (Common Object Model) objects (also called OLE or ActiveX objects). A COM object is an object who's first field is a pointer to a vtbl[], and the first 3 entries in that vtbl[] are for QueryInterface(), AddRef(), and Release().<br />
<br />
For understanding COM, Kraig Brockshmidt's [http://www.amazon.com/exec/obidos/ASIN/1556158432/classicempire Inside OLE] is an indispensible resource.<br />
<br />
COM objects are analogous to D interfaces. Any COM object can be expressed as a D interface, and every D object with an interface X can be exposed as a COM object X. This means that D is compatible with COM objects implemented in other languages.<br />
<br />
While not strictly necessary, the Phobos library provides an Object useful as a super class for all D COM objects, called ComObject. ComObject provides a default implementation for QueryInterface(), AddRef(), and Release().<br />
<br />
Windows COM objects use the Windows calling convention, which is not the default for D, so COM functions need to have the attribute extern (Windows).<br />
<br />
So, to write a COM object:<br />
<br />
<syntaxhighlight lang="D"><br />
import std.c.windows.com;<br />
<br />
class MyCOMobject : ComObject<br />
{<br />
extern (Windows):<br />
...<br />
}<br />
</syntaxhighlight><br />
<br />
The sample code includes an example COM client program and server DLL.<br />
<br />
== D code calling D code in DLLs ==<br />
Having DLLs in D be able to talk to each other as if they were statically linked together is, of course, very desirable as code between applications can be shared, and different DLLs can be independently developed.<br />
<br />
The underlying difficulty is what to do about garbage collection (gc). Each EXE and DLL will have their own gc instance. While these gc's can coexist without stepping on each other, it's redundant and inefficient to have multiple gc's running. The idea explored here is to pick one gc and have the DLLs redirect their gc's to use that one. The one gc used here will be the one in the EXE file, although it's also possible to make a separate DLL just for the gc.<br />
<br />
The example will show both how to statically load a DLL, and to dynamically load/unload it.<br />
<br />
Starting with the code for the DLL, mydll.d:<br />
<br />
<syntaxhighlight lang="D"><br />
module mydll;<br />
<br />
/*<br />
* MyDll demonstration of how to write D DLLs.<br />
*/<br />
<br />
import core.runtime;<br />
import std.c.stdio;<br />
import std.c.stdlib;<br />
import std.string;<br />
import std.c.windows.windows;<br />
<br />
HINSTANCE g_hInst;<br />
<br />
extern (C)<br />
{<br />
void gc_setProxy(void* p);<br />
void gc_clrProxy();<br />
}<br />
<br />
extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)<br />
{<br />
switch (ulReason)<br />
{<br />
case DLL_PROCESS_ATTACH:<br />
printf("DLL_PROCESS_ATTACH\n");<br />
Runtime.initialize();<br />
break;<br />
<br />
case DLL_PROCESS_DETACH:<br />
printf("DLL_PROCESS_DETACH\n");<br />
Runtime.terminate();<br />
break;<br />
<br />
case DLL_THREAD_ATTACH:<br />
printf("DLL_THREAD_ATTACH\n");<br />
return false;<br />
<br />
case DLL_THREAD_DETACH:<br />
printf("DLL_THREAD_DETACH\n");<br />
return false;<br />
<br />
default:<br />
}<br />
g_hInst = hInstance;<br />
return true;<br />
}<br />
<br />
export void MyDLL_Initialize(void* gc)<br />
{<br />
printf("MyDLL_Initialize()\n");<br />
gc_setProxy(gc);<br />
}<br />
<br />
export void MyDLL_Terminate()<br />
{<br />
printf("MyDLL_Terminate()\n");<br />
gc_clrProxy();<br />
}<br />
<br />
static this()<br />
{<br />
printf("static this for mydll\n");<br />
}<br />
<br />
static ~this()<br />
{<br />
printf("static ~this for mydll\n");<br />
}<br />
<br />
/* --------------------------------------------------------- */<br />
<br />
class MyClass<br />
{<br />
string concat(string a, string b)<br />
{<br />
return a ~ " " ~ b;<br />
}<br />
}<br />
<br />
export MyClass getMyClass()<br />
{<br />
return new MyClass();<br />
}<br />
</syntaxhighlight><br />
<br />
<br />
'''DllMain'''<br />
<br />
This is the main entry point for any D DLL. It gets called by the C startup code (for DMC++, the source is \dm\src\win32\dllstart.c). The printf's are placed there so one can trace how it gets called. Notice that the initialization and termination code seen in the earlier DllMain sample code is in this version as well. This is because the same DLL should be usable from both C and D programs, so the same initialization process should work for both.<br />
<br />
<br />
'''MyDLL_Initialize'''<br />
<br />
When the DLL is dynamically linked via Runtime.loadLibrary() the runtime makes sure that any initialization steps required by the D program are executed after the library is loaded. If the library is statically linked, this routine is not called by the program, so to make sure the DLL is initialized properly we have to do some of the work ourselves. And because the library is being statically linked, we need a function specific to this DLL to perform the initialization. This function takes one argument, a handle to the caller's gc. We'll see how that handle is obtained later. To pass this handle to the runtime and override the DLL's built-in gc we'll call gc_setProxy(). The function is exported as that is how a function is made visible outside of a DLL.<br />
<br />
<br />
'''MyDLL_Terminate'''<br />
<br />
Correspondingly, this function terminates the DLL, and is called prior to unloading it. It has only one job: informing the runtime that the DLL will no longer be using the caller's gc via gc_clrProxy(). This is critical, as the DLL will be unmapped from memory, and if the gc continues to scan its data areas it will cause segment faults.<br />
<br />
<br />
'''static this, static ~this'''<br />
<br />
These are examples of the module's static constructor and destructor, here with a print in each to verify that they are running and when.<br />
<br />
<br />
'''MyClass'''<br />
<br />
This is an example of a class that can be exported from and used by the caller of a DLL. The '''concat''' member function allocates some gc memory, and free frees gc memory.<br />
<br />
<br />
'''getMyClass'''<br />
<br />
An exported factory that allocates an instance of '''MyClass''' and returns a reference to it.<br />
<br />
To build the '''mydll.dll''' DLL:<br />
<br />
1. <code>dmd -c mydll -g</code><br />
<br />
Compiles mydll.d into mydll.obj. -g turns on debug info generation.<br />
<br />
<br />
2. <code>dmd mydll.obj mydll.def -g -L/map</code><br />
<br />
Links mydll.obj into a DLL named mydll.dll. mydll.def is the [http://www.digitalmars.com/ctg/ctgDefFiles.html Module Definition File], and has the contents:<br />
<br />
<pre><br />
LIBRARY MYDLL<br />
DESCRIPTION 'MyDll demonstration DLL'<br />
EXETYPE NT<br />
CODE PRELOAD DISCARDABLE<br />
DATA PRELOAD MULTIPLE<br />
</pre><br />
<br />
<br />
'''-g''' turns on debug info generation, and '''-L/map''' generates a map file '''mydll.map'''.<br />
<br />
<br />
3. <code>implib /noi /system mydll.lib mydll.dll</code><br />
<br />
Creates an [http://www.digitalmars.com/ctg/implib.html import library] '''mydll.lib''' suitable for linking in with an application that will be statically loading '''mydll.dll'''.<br />
<br />
<br />
<br />
Here's '''test.d''', a sample application that makes use of '''mydll.dll'''. There are two versions, one statically binds to the DLL, and the other dynamically loads it.<br />
<br />
<syntaxhighlight lang="D"><br />
import core.runtime;<br />
import std.stdio;<br />
import core.memory;<br />
<br />
import mydll;<br />
<br />
//version=DYNAMIC_LOAD;<br />
<br />
version (DYNAMIC_LOAD)<br />
{<br />
import std.c.windows.windows;<br />
<br />
alias MyClass function() getMyClass_fp;<br />
<br />
int main()<br />
{<br />
HMODULE h;<br />
FARPROC fp;<br />
<br />
getMyClass_fp getMyClass;<br />
MyClass c;<br />
<br />
printf("Start Dynamic Link...\n");<br />
<br />
h = cast(HMODULE) Runtime.loadLibrary("mydll.dll");<br />
if (h is null)<br />
{<br />
printf("error loading mydll.dll\n");<br />
return 1;<br />
}<br />
<br />
fp = GetProcAddress(h, "D5mydll10getMyClassFZC5mydll7MyClass");<br />
if (fp is null)<br />
{ printf("error loading symbol getMyClass()\n");<br />
return 1;<br />
}<br />
<br />
getMyClass = cast(getMyClass_fp) fp;<br />
c = (*getMyClass)();<br />
foo(c);<br />
<br />
if (!Runtime.unloadLibrary(h))<br />
{ printf("error freeing mydll.dll\n");<br />
return 1;<br />
}<br />
<br />
printf("End...\n");<br />
return 0;<br />
}<br />
}<br />
else<br />
{ // static link the DLL<br />
extern (C)<br />
{<br />
void* gc_getProxy();<br />
}<br />
<br />
int main()<br />
{<br />
printf("Start Static Link...\n");<br />
MyDLL_Initialize(gc_getProxy());<br />
foo(getMyClass());<br />
MyDLL_Terminate();<br />
printf("End...\n");<br />
return 0;<br />
}<br />
}<br />
<br />
void foo(MyClass c)<br />
{<br />
string s = c.concat("Hello", "world!");<br />
writeln(s);<br />
}<br />
</syntaxhighlight><br />
<br />
Let's start with the statically linked version, which is simpler. It's compiled and linked with the command:<br />
<br />
<pre><br />
C:>dmd test mydll.lib -g<br />
</pre><br />
<br />
Note how it is linked with '''mydll.lib''', the import library for '''mydll.dll'''. The code is straightforward, it initializes mydll.lib with a call to '''MyDLL_Initialize()''', passing the handle to test.exe's gc. Then, we can use the DLL and call its functions just as if it were part of '''test.exe'''. In '''foo()''', gc memory is allocated and freed both by '''test.exe''' and '''mydll.dll'''. When we're done using the DLL, it is terminated with '''MyDLL_Terminate()'''. <br />
<br />
Running it looks like this:<br />
<br />
<pre><br />
C:>test<br />
DLL_PROCESS_ATTACH<br />
Start Static Link...<br />
MyDLL_Initialize()<br />
static this for mydll<br />
Hello world!<br />
MyDLL_Terminate()<br />
static ~this for mydll<br />
End...<br />
C:><br />
</pre><br />
<br />
The dynamically linked version is a little harder to set up. Compile and link it with the command:<br />
<br />
<pre><br />
C:>dmd test -version=DYNAMIC_LOAD -g<br />
</pre><br />
<br />
The import library '''mydll.lib''' is not needed. The DLL is loaded with a call to '''Runtime.loadLibrary()''', and each exported function has to be retrieved via a call to '''GetProcAddress()'''. An easy way to get the decorated name to pass to '''GetProcAddress()''' is to copy and paste it from the generated '''mydll.map''' file under the '''Export''' heading. Once this is done, we can use the member functions of the DLL classes as if they were part of '''test.exe'''. When done, release the DLL with '''Runtime.unloadLibrary()'''.<br />
<br />
Running it looks like this:<br />
<br />
<pre><br />
C:>test<br />
Start Dynamic Link...<br />
DLL_PROCESS_ATTACH<br />
static this for mydll<br />
Hello world!<br />
static ~this for mydll<br />
DLL_PROCESS_DETACH<br />
End...<br />
C:><br />
</pre><br />
<br />
<br />
----<br />
<br />
[[Category::Windows]]<br />
[[Category::DLL]]<br />
[[Category::know-how]]<br />
[[Category::Development]]</div>Notnahttps://wiki.dlang.org/?title=GDC_Cross_Compiler&diff=4086GDC Cross Compiler2014-04-27T11:45:48Z<p>Notna: </p>
<hr />
<div>{{ParentArticle|[[GDC]]}} <br />
<br />
Building cross compilers is always a tricky task. And building canadian-cross compilers can easily drive you crazy. This page provides an overview of working GDC cross compilers and tutorials on how to build your own.<br />
<br />
__TOC__<br />
<br />
<!-- Introduction --><br />
<!-- Binary releases --><br />
<!-- Toolchains with GDC support --><br />
<br />
== Building from source ==<br />
=== Existing system root ===<br />
If you have an existing file system for you target or access to the target via SSH, see<br />
[[GDC/Cross_Compiler/Existing_Sysroot]]<br />
<br />
=== Crosstool-NG ===<br />
The preferred way to build cross compilers is crosstool-NG. Crosstool-NG supports many different architectures and advanced build configurations (e.g. canadian-cross compilers). The latest crosstool-NG release currently only supports gcc 4.7 though, so we have to use the gdc-4.7 branch there. Newer crosstool-NG hg snapshots do support gcc-4.8.<br />
<br />
See [[GDC/Cross Compiler/crosstool-NG|Cross Compiler/crosstool-NG]] for more information.<br />
<br />
=== Making tools step by step ===<br />
If it is not possible to use crosstools, the toolchain can be made manually step by step. This can also be used to make a native compiler.<br />
<br />
See [[GDC/Cross Compiler/Generic|Cross Compiler/Generic]] for more information.<br />
<br />
=== Bare metal ARM Cortex-M ===<br />
See [[Bare Metal ARM Cortex-M GDC Cross Compiler]] for instructions specific to building a bare metal ARM Cortex-M GDC cross compiler.<br />
<br />
<!-- Using GDC cross compilers --><br />
<br />
<!-- Known bugs and issues --><br />
<br />
----<br />
<br />
[[Category::Compiler]]<br />
[[Category::Compilers]]<br />
[[Category::GDC]]</div>Notnahttps://wiki.dlang.org/?title=DMD_Source_Guide&diff=4085DMD Source Guide2014-04-27T11:42:49Z<p>Notna: </p>
<hr />
<div>== Overview ==<br />
<br />
=== Major components ===<br />
<br />
All D compilers are divided into two parts: the front-end and the back-end.<br />
<br />
The front-end (DMD-FE) implements all things D-specific: lexing and parsing D syntax, instantiating templates, producing error messages, etc. The same front-end code is used by [[DMD]], [[GDC]] and [[LDC]].<br />
<br />
The back-end is what emits machine code. It contains code generation, optimization, object file writing, etc. The back-end is specific to each D compiler: DMD uses a source-available but proprietary (and non-redistributable) backend, while e.g. LDC uses LLVM as the back-end.<br />
<br />
There is also a glue layer, which is the interface between the front-end and back-end. This component is custom for each D compiler.<br />
<br />
=== Compilation cycle ===<br />
<br />
D source code goes through the following stages when compiled:<br />
<br />
* First, the file is loaded into memory as-is, and converted to UTF-8 when necessary.<br />
* The lexer transforms the file into an array of tokens. There is no structure yet at this point - just a flat list of tokens. (lexer.c)<br />
* The parser then builds a simple AST out of the token stream. (parser.c)<br />
* The AST is then semantically processed. This is done in three stages (called semantic, semantic2 and semantic3). This is done in a loop in mars.c. Each pass transforms the AST to be closer to the final representation: types are resolved, templates are instantiated, etc.<br />
:1. The "semantic" phase will analyze the full signature of all declarations. For example:<br />
::* members of aggregate type<br />
::* function parameter types and return type<br />
::* variable types<br />
::* evaluation of pragma(msg)<br />
:<br />
:2. The "semantic2" phase will analyze some additional part of the declarations, For example:<br />
::* initializer of variable declarations<br />
::* evaluation of static assert condition<br />
:<br />
:3. The "semantic3" phase will analyze the body of function declarations.<br />
::If a function is declared in the module which is not directly compiled (== not listed in the command line), semantic3 pass won't analyze its body.<br />
:<br />
:4. During each phases, some declarations will partially invoke the subsequent phases due to resolve forward reference, For example:<br />
<br />
immutable string x = "hello";<br />
static if (x == "hello") { ... }<br />
// The static if condition will invoke semantic2 of the variable 'x'<br />
<br />
auto foo() { ... }<br />
typeof(&foo) fp;<br />
// "semantic" phase of the variable 'fp' will run "semantic3" of 'foo'<br />
// to demand the full signature of the function (== infer the return type)<br />
<br />
string foo() { ... }<br />
mixin(foo());<br />
// For CTFE, the mixin declaration will invoke the semantic3 of 'foo'<br />
* Finally, the AST is handed over to the glue layer, which feeds it into the back-end, which in turn produces machine code and object files.<br />
<br />
=== Runtime interoperability ===<br />
<br />
Non-trivial operations (e.g. memory allocation, array operations) are implemented in the D runtime. The compiler integrates with the runtime using a number of so-called hook functions (which by convention have the <tt>_d_</tt> name prefix).<br />
<br />
A list can be found here: [[Runtime_Hooks]]<br />
<br />
=== Details ===<br />
<br />
''Note: This section may be considerably outdated. Please bring it up to date where you can.''<br />
<br />
There are a number of types that are stored in various nodes that are never actually used in the front end. They are merely stored and passed around as pointers. <br />
<br />
* Symbol - Appears to have something to do with the names used by the linker. Appears to be used by Dsymbol and its subclasses.<br />
* dt_t - "Data to be added to the data segment of the output object file" ''source: todt.c''<br />
* elem - A node in the internal representation.<br />
<br />
The code generator is split among the various AST nodes. Certain methods of almost every AST node are part of the code generator.<br />
<br />
(it's an interesting solution to the problem. It would have never occurred to a Java programmer)<br />
<br />
Most notably:<br />
* all Statement subclasses must define a toIR method<br />
* All Expression subclasses must define a toElem method<br />
* Initializers and certain Expression subclasses must define toDt<br />
* Declarations must define toObjFile<br />
* Dsymbol subclasses must define toSymbol<br />
<br />
==== Other things ====<br />
Floating point libraries seem to be atrociously incompatible between compilers. Replacing strtold with strtod may be necessary, for instance. (this does "break" the compiler, however: it will lose precision on literals of type 'real')<br />
-- AndyFriesen<br />
<br />
==== Intermediate Representation ====<br />
<br />
'''From [http://www.digitalmars.com/webnews/newsgroups.php?art_group=D.gnu&article_id=762 NG:D.gnu/762]'''<br />
<br />
I've been looking at trying to hook the DMD frontend up to LLVM (www.llvm.org), but I've been having some trouble. The LLVM IR (Intermediate Representation) is very well documented, but I'm having a rough time figuring out how DMD holds its IR. Since at least three people (David, Ben, and Walter) seem to have understand, I thought I'd ask for guidance.<br />
<br />
What's the best way to traverse the DMD IR once I've run the three semantic phases? As far as I can tell it's all held in the SymbolTable as a bunch of Symbols. Is there a good way to traverse that and reconstruct it into another IR?<br />
<br />
----<br />
<br />
'''From [http://www.digitalmars.com/webnews/newsgroups.php?art_group=D.gnu&article_id=764 NG:D.gnu/764]'''<br />
<br />
There isn't a generic visitor interface. Instead, there are several methods with are responsible for emiting code/data and then calling that method for child objects. Start by implementing Module::genobjfile and loop over the 'members' array, calling each Dsymbol object's toObjFile method. From there, you will need to implement these methods:<br />
<br />
Dsymbol (and descendents) ::toObjFile -- Emits code and data for objects that have generally have a symbol name and storage in memory. Containers like ClassDeclaration also have a 'members' array with child Dsymbols. Most of these are descendents of the Declaration class.<br />
<br />
Statement (and descendents) ::toIR -- Emits instructions. Usually, you just call toObjFile, toIR, toElem, etc. on the statement's fields and string the results together in the IR.<br />
<br />
Expression (and descendents) ::toElem -- Returns a back end representation of numeric constants, variable references, and operations that expression trees are composed of. This was very simple for GCC because the back end already had the code to convert expression trees to ordered instructions. If LLVM doesn't do this, I think you could generate the instructions here since LLVM has SSA.<br />
<br />
Type (and descendents) ::toCtype -- Returns the back end representation of the type. Note that a lot of classes don't override this -- you just need to do a switch on the 'ty' field in Type::toCtype.<br />
<br />
Dsymbol (and descendents) ::toSymbol -- returns the back end reference to the object. For example, FuncDeclaration::toSymbol could return a llvm::Function. These are already implemented in tocsym.c, but you will probably rewrite them to create LLVM objects. <br />
<br />
----<br />
<br />
(Thread: http://digitalmars.com/d/archives/D/gnu/762.html)<br />
<br />
==== Inliner ====<br />
<br />
DMD's inliner is part of the frontend, existing entirely in the file '''inline.c'''.<br />
<br />
This inliner is conceptually quite simple: It traverses the AST looking for function calls. Each function found is analysed for cost by adding up the number of expression nodes in its body. Anything non-inlinable counts as "maximum cost". If the total cost is below the maximum, the function call is inlined.<br />
<br />
In DMD's AST, certain statements cannot currently be represented as expressions (such as non-unrolled loops and throwing). Because of this, the inliner makes a distinction between two main types of inlining:<br />
<br />
* Converting a function call to an inline expression: This must be used whenever the function's return value is actually used. Ex: "x = foo();" or "2 + foo()".<br />
* Converting a function call to an inline statement: Used when a function's return value is ignored, or when calling a void function.<br />
<br />
Those two scenarios are inlined by mostly separate codepaths. Cost analysis is mostly the same codepath, but "inlinable as a statement" and "inlinable as an expression" are separate decisions (again, due to certain statements not being representable as expressions).<br />
<br />
The inliner is divided into four main parts:<br />
<br />
* Main entry point: '''inlineScan''' (which utilizes class '''InlineScanVisitor''' and function '''expandInline''')<br />
* Cost analysis (to determine inlinability): '''canInline''' and class '''InlineCostVisitor'''<br />
* Inlining a function call as a statement: '''inlineAsStatement''' and its embedded class '''InlineAsStatement'''<br />
* Inlining a function call as an expression: '''doInline''' and its embedded class '''InlineStatement'''<br />
<br />
===== Inliner: Main Entry Point =====<br />
<br />
The whole inliner is driven by the '''inlineScan''' function and '''InlineScanVisitor''' class, but the bulk of the real work is performed by '''expandInline''' (described in this section) and the other three main parts of the inliner (described in the following sections).<br />
<br />
The global function '''inlineScan''' is the inliner's main entry point. This uses class '''InlineScanVisitor''' to traverse the AST looking for function calls to inline, and inlining them as they're found. Whenever '''InlineScanVisitor''' finds an inlinable function call (determined by the cost analyzer), it calls '''expandInline''' to start the inlining process.<br />
<br />
'''InlineScanVisitor''' also decides whether to inline as a statement or an expression based on the type of AST node found:<br />
<br />
* '''ExpStatement''': Implies the function either has no return value, or the return value is unused. Therefore, inline as a statement (if permitted by cost analysis).<br />
* '''CallExp''': Implies the function returns a value which is used. Therefore, inline as an expression (if permitted by cost analysis).<br />
<br />
Called by '''InlineScanVisitor''', '''expandInline''' drives the actual inlining for both "as statement" and "as expression" cases. It converts the function call scaffolding, parameters and return value (if any) into the appropriate inline statement or expression. To inline the function's body, '''expandInline''' hands over to either '''inlineAsStatement''' (if inlining the call as a statement) or '''doInline''' (if inlining the call as an expression).<br />
<br />
===== Inliner: Cost Analysis =====<br />
<br />
The function '''canInline''', unsurprisingly, determines if a function can be inlined. To decide this, it uses class '''InlineCostVisitor''', which traverses the AST calculating a sum of all costs involved.<br />
<br />
'''InlineCostVisitor''' is a '''Visitor''' class which works just like any other AST visitor class in DMD, or any other usage of the [http://en.wikipedia.org/wiki/Visitor_pattern visitor pattern]: It contains a '''visit''' function for each AST node type supported by the inliner. Each '''visit''' function traverses its children nodes (if any) by calling the child node's '''accept''' function, passing the visitor class itself as an argument. Then the node's '''accept''' automatically calls its corresponding '''visit''' function.<br />
<br />
Any type of node not supported by '''InlineCostVisitor''' automatically calls a default function '''InlineCostVisitor::visit(Statement *s)''', which flags the function being analyzed as non-inlinable.<br />
<br />
The actual '''cost''' variable is slightly complicated since it's really two packed values:<br />
<br />
The low 12-bits of '''cost''' are the actual accumulated cost. A value of 1 is added for every inlinable expression node in the function's body (ex: "a+b*c" has a cost of 2: One for the multiplication and one for the addition). Anything that can't be inlined, or that the cost analyzer knows nothing about, adds a cost of '''COST_MAX'''. If this total cost, in the low 12-bits, is at least '''COST_MAX''' (determined by the helper function '''tooCostly'''), the function is considered non-inlinable.<br />
<br />
The upper bits of '''cost''' (bits 13 and up) are separate from the actual cost and keep track of whether the function can be inlined as an expression. Whenever a statement is found which can be inlined ''only'' as a statement (and cannot be converted to an expression), this is flagged by adding '''STATEMENT_COST''' to '''cost'''.<br />
<br />
Note: It looks as if at one point in time there had been a limit (or perhaps plans to eventually limit) the number of statements allowed in inlined functions, just as there's currently a limit to the number of expression nodes. But this does not currently appear to be enforced, so '''STATEMENT_COST''' is essentially used as a "this can only be inlined as a statement" flag.<br />
<br />
Sometimes expressions are evaluated for cost by simply visiting the the expression node, via the node's '''accept''' function. Other times, the helper function '''InlineCostVisitor::expressionInlineCost''' is used instead. The benefit of '''expressionInlineCost''' is it automatically halts analysis of an expression as soon as it reaches '''COST_MAX'''.<br />
<br />
The '''canInline''' function caches its results in two members of '''FuncDeclaration''': In '''ILS inlineStatusStmt''' (for inlinability as a statement) and '''ILS inlineStatusExp''' (for inlinability as an expression). '''ILS''' is an enum defined in '''declaration.h''' supporting three states: '''ILSuninitialized''' (not yet cached), '''ILSno''' (not inlinable) and '''ILSyes''' (inlinable).<br />
<br />
===== Inliner: Inlining as a Statement =====<br />
<br />
Any functions DMD is capable of inlining, can be inlined as a statement. As explained above, this is performed whenever a function call ignores the return value, or has no return value. In this case, the function's body is inlined via '''inlineAsStatement'''. Internally, '''inlineAsStatement''' works using its embedded visitor class '''InlineAsStatement'''.<br />
<br />
To paraphrase a comment in '''inline.c''', this inlining is done by converting to a statement, copying the trees of the function to be inlined, and renaming the variables. Most of this is fairly straightforward: Much like the cost analyzer's '''InlineCostVisitor''' class, the '''InlineAsStatement''' class has a '''visit''' function for each supported type of statement and expression. Each of these visitors copies the node, makes any adjustments if necessary, and then visits all subnodes by calling their '''accept''' functions.<br />
<br />
There's also a default catch-all function which asserts, indicating the cost analyzer failed to disallow something which has no corresponding visitor in '''InlineAsStatement'''.<br />
<br />
===== Inliner: Inlining as an Expression =====<br />
<br />
''Some'', but not all, inlinable functions can be inlined as an expression. This must be done whenever a function call uses the return value (Ex: "x = foo();" or "2 + foo()"). In this case, inlining the function's body as an expression works very much like inlining it as a statement (see the section above), but with a separate code path and a few differences:<br />
<br />
* The function body is inlined by '''doInline''' instead of '''inlineAsStatement'''.<br />
* There are two overloads of '''doInline''': One to inline expressions ''as'' expressions, and one to convert statements ''to'' inline expressions.<br />
* As discussed in the sections above, not all statements can be converted to expressions. Because of this, these statements' corresponding '''visit''' functions are omitted from '''doInline''', since the cost analyzer should have already prevented the inliner from attempting to inline any offending functions.<br />
<br />
===== Inliner: How to Add More Support =====<br />
<br />
If a particular statement is unsupported by the inliner (thereby preventing any function using it from being inlined), support can be added like this:<br />
<br />
* Add an overload of '''InlineCostVisitor::visit''' for the type of AST node you wish to support. Following the example of the other visit functions:<br />
:* Increase '''cost''' however is appropriate.<br />
:* Add '''STATEMENT_COST''' to '''cost''' if the statement cannot be converted to an expression (ex: '''ForStatement''' and '''ThrowStatement'''). This allows you to omit a corresponding overload of '''doInline's''' '''InlineStatement::visit'''.<br />
:* Add '''COST_MAX''' to '''cost''' for any situations that are not inlinable.<br />
:* Call '''accept''' on all subnodes. If the subnode is an expression, it may be better to use '''expressionInlineCost''' instead since this will automatically halt analysis as soon as the expression's cost reaches the maximum.<br />
* In '''inlineAsStatement''', add an overload of '''InlineAsStatement::visit''' for the appropriate AST node type. Following the example of the other visit overloads: Copy the node, make any adjustments if necessary, and traverse to all subnodes.<br />
* If the statement can be converted to an expression (ex: '''IfStatement'''), then inside the '''Statement''' overload of '''doInline''', add an overload of '''InlineStatement::visit''' for the appropriate AST node type. Following the other examples, convert the node to an expression, make any adjustments if necessary, and traverse to all subnodes.<br />
<br />
==== The Back End ====<br />
<br />
DMD's internal representation uses expression trees with 'elem' nodes (defined in el.h). The "Rosetta Stone" for understanding the backend is enum OPER in oper.h. This lists all the types of nodes which can be in an expression tree.<br />
<br />
If you compile dmd with debug on, and compile with:<br />
<br />
-O --c<br />
<br />
you'll get reports of the various optimizations done.<br />
<br />
Other useful undocumented flags:<br />
<br />
--b show block optimisation<br />
--f full output<br />
--r show register allocation<br />
--x suppress predefined C++ stuff<br />
--y show output to Intermediate Language (IL) buffer<br />
<br />
Others which are present in the back-end but not exposed as DMD flags are:<br />
debuge show exception handling info<br />
debugs show common subexpression eliminator<br />
<br />
<br />
The most important entry point from the front-end to the backend is writefunc() in out.c, which optimises a function, and then generates code for it.<br />
<br />
* writefunc() sets up the parameters, then calls codgen() to generate the code inside the function.<br />
* it generates code for each block. Then puts vars in registers.<br />
* generates function start code, does pinhole optimisation. (cod3.pinholeopt()).<br />
* does jump optimisation<br />
* emit the generated code in codout().<br />
* writes switch tables<br />
* writes exception tables (nteh_gentables() or except_gentables()<br />
<br />
In cgcod.c, blcodgen() generates code for a basic block. Deals with the way the block ends (return, switch,<br />
if, etc).<br />
<br />
cod1.gencodelem() does the codegen inside the block. It just calls codelem().<br />
<br />
cgcod.codelem() generates code for an elem. This distributes code generation depending on elem type.<br />
<br />
Most x86 integer code generation happens in cod1,cod2, cod3, cod4, and cod5.c<br />
Floating-point code generation happens in cg87. Compared to the integer code generation, the x87 code generator is extremely simple. Most importantly, it cannot cope with common subexpressions. This is the primary reason why it is less efficient than compilers from many other vendors.<br />
<br />
===== Optimiser =====<br />
The main optimiser is in go.c, optfunc().<br />
This calls:<br />
* blockopt.c blockopt(iter) -- branch optimisation on basic blocks, iter = 0 or 1.<br />
* gother.c constprop() -- constant propagation<br />
* gother.c copyprop() -- copy propagation<br />
* gother.c rmdeadass() -- remove dead assignments<br />
* gother.c verybusyexp() -- very busy expressions<br />
* gother.c deadvar() -- eliminate dead variables<br />
<br />
* gloop.c loopopt() -- remove loop invariants and induction vars. Do loop rotation<br />
<br />
* gdag.c boolopt() -- optimize booleans.<br />
* gdag.c builddags() -- common subexpressions<br />
<br />
* el.c el_convert() -- Put float and string literals into the data segment<br />
* el.c el_combine() -- merges two expressions (uses a comma-expression to join them).<br />
* glocal.c localize() -- improve expression locality<br />
<br />
<br />
* cod3.c pinholeopt() -- Performs peephole optimisation. Doesn't do much, could do a lot more.<br />
<br />
===== Code generation =====<br />
The code generation for each function is done individually. Each function is placed into its own COMDAT segment in the obj file.<br />
The function is divided into blocks, which are linear sections of code ending with a jump or other control instruction (http://en.wikipedia.org/wiki/Basic_block).<br />
<br />
===== Scheduler (cgsched.c) =====<br />
<br />
Pentium only<br />
<br />
== Source files ==<br />
<br />
''Note: This section may be considerably outdated. If it's wrong, please correct it. If it's not here, please add it.''<br />
<br />
=== Front end ===<br />
{| class="wikitable" |<br />
! File || Function<br />
|-<br />
| access.c || Access check ('''private''', '''public''', '''package''' ...)<br />
|-<br />
| aliasthis.c || Implements the '''[http://digitalmars.com/d/2.0/class.html#AliasThis alias this]''' D symbol.<br />
|-<br />
| argtypes.c || Convert types for argument passing (e.g. '''char''' are passed as '''ubyte''').<br />
|-<br />
| arrayop.c || [http://digitalmars.com/d/2.0/arrays.html#array-operations Array operations] (e.g. ''a[] = b[] + c[]'').<br />
|-<br />
| attrib.c || [http://digitalmars.com/d/2.0/attribute.html Attributes] i.e. storage class ('''const''', '''@safe''' ...), linkage ('''extern(C)''' ...), protection ('''private''' ...), alignment ('''align(1)''' ...), anonymous aggregate, '''pragma''', '''static if''' and '''mixin'''.<br />
|-<br />
| bit.c || Generate bit-level read/write code. Requires backend support.<br />
|-<br />
| builtin.c || Identify and evaluate built-in functions (e.g. '''std.math.sin''')<br />
|-<br />
| cast.c || Implicit cast, implicit conversion, and explicit cast ('''cast(T)'''), combining type in binary expression, integer promotion, and value range propagation.<br />
|-<br />
| class.c || Class declaration<br />
|-<br />
| clone.c || Define the implicit '''opEquals''', '''opAssign''', post blit and destructor for struct if needed, and also define the copy constructor for struct.<br />
|-<br />
| cond.c || Evaluate compile-time conditionals, i.e. '''debug''', '''version''', and '''static if'''.<br />
|-<br />
| constfold.c || Constant folding<br />
|-<br />
| cppmangle.c || Mangle D types according to [http://mentorembedded.github.io/cxx-abi/abi.html#mangling Intel's Itanium C++ ABI].<br />
|-<br />
| declaration.c || Miscellaneous declarations, including '''typedef''', '''alias''', variable declarations including the implicit '''this''' declaration, type tuples, ClassInfo, ModuleInfo and various TypeInfos.<br />
|-<br />
| delegatize.c || Convert an expression ''expr'' to a delegate ''{ return expr; }'' (e.g. in '''lazy''' parameter). <br />
|-<br />
| doc.c || [http://digitalmars.com/d/ddoc.html Ddoc] documentation generator ([http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=1558 NG:digitalmars.D.announce/1558])<br />
|-<br />
| dsymbol.c || D symbols (i.e. variables, functions, modules, ... anything that has a name).<br />
|-<br />
| dump.c || Defines the ''Expression::dump'' method to print the content of the expression to console. Mainly for debugging.<br />
|-<br />
| e2ir.c || Expression to Intermediate Representation; requires backend support<br />
|-<br />
| eh.c || Generate exception handling tables<br />
|-<br />
| entity.c || Defines the named entities to support the ''"\&Entity;"'' escape sequence.<br />
|-<br />
| enum.c || Enum declaration<br />
|-<br />
| expression.h || Defines the bulk of the classes which represent the AST at the expression level.<br />
|-<br />
| func.c || Function declaration, also includes function/delegate literals, function alias, (static/shared) constructor/destructor/post-blit, '''invariant''', '''unittest''' and [http://digitalmars.com/d/2.0/class.html#allocators allocator/deallocator].<br />
|-<br />
| glue.c || Generate the object file for function declarations and critical sections; convert between backend types and frontend types<br />
|-<br />
| hdrgen.c || Generate headers (*.di files)<br />
|-<br />
| iasm.c || Inline assembler<br />
|-<br />
| identifier.c || Identifier (just the name).<br />
|-<br />
| idgen.c || Make id.h and id.c for defining built-in Identifier instances. Compile and run this before compiling the rest of the source. ([http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=17157 NG:digitalmars.D/17157])<br />
|-<br />
| impcvngen.c || Make impcnvtab.c for the implicit conversion table. Compile and run this before compiling the rest of the source. <br />
|-<br />
| imphint.c || Import hint, e.g. prompting to import ''std.stdio'' when using ''writeln''.<br />
|-<br />
| import.c || Import.<br />
|-<br />
| inifile.c || Read .ini file<br />
|-<br />
| init.c || [http://digitalmars.com/d/2.0/declaration.html#Initializer Initializers] (e.g. the ''3'' in ''int x = 3'').<br />
|-<br />
| inline.c || Compute the cost and perform inlining.<br />
|-<br />
| interpret.c || All the code which evaluates CTFE<br />
|-<br />
| irstate.c || Intermediate Representation state; requires backend support<br />
|-<br />
| json.c || Generate JSON output<br />
|-<br />
| lexer.c || Lexically analyzes the source (such as separate keywords from identifiers)<br />
|-<br />
| libelf.c || ELF object format functions<br />
|-<br />
| libmach.c || Mach-O object format functions<br />
|-<br />
| libomf.c || OMF object format functions<br />
|-<br />
| link.c || Call the linker<br />
|-<br />
| macro.c || Expand DDoc macros<br />
|-<br />
| mangle.c || Mangle D types and declarations<br />
|-<br />
| mars.c || Analyzes the command line arguments (also display command-line help)<br />
|-<br />
| module.c || Read modules.<br />
|-<br />
| msc.c || ?<br />
|-<br />
| mtype.c || All D types.<br />
|-<br />
| opover.c || Apply operator overloading<br />
|-<br />
| optimize.c || Optimize the AST<br />
|-<br />
| parse.c || Parse tokens into AST<br />
|-<br />
| ph.c || Custom allocator to replace malloc/free<br />
|-<br />
| root/aav.c || Associative array<br />
|-<br />
| root/array.c || Dynamic array<br />
|-<br />
| root/async.c || Asynchronous input<br />
|-<br />
| root/dchar.c || Convert UTF-32 character to UTF-8 sequence<br />
|-<br />
| root/gnuc.c || Implements functions missing from GCC, specifically ''stricmp'' and ''memicmp''.<br />
|-<br />
| root/lstring.c || Length-prefixed UTF-32 string.<br />
|-<br />
| root/man.c || Start the internet browser.<br />
|-<br />
| root/port.c || Portable wrapper around compiler/system specific things. The idea is to minimize #ifdef's in the app code.<br />
|-<br />
| root/response.c || Read the [http://digitalmars.com/d/2.0/dmd-windows.html#switches response file].<br />
|-<br />
| root/rmem.c || Implementation of the storage allocator uses the standard C allocation package.<br />
|-<br />
| root/root.c || Basic functions (deal mostly with strings, files, and bits)<br />
|-<br />
| root/speller.c || Spellchecker<br />
|-<br />
| root/stringtable.c || String table<br />
|-<br />
| s2ir.c || Statement to Intermediate Representation; requires backend support<br />
|-<br />
| scope.c || Scope<br />
|-<br />
| statement.c || Handles '''while''', '''do''', '''for''', '''foreach''', '''if''', '''pragma''', '''staticassert''', '''switch''', '''case''', '''default''' , '''break''', '''return''', '''continue''', '''synchronized''', '''try'''/'''catch'''/'''finally''', '''throw''', '''volatile''', '''goto''', and '''label'''<br />
|-<br />
| staticassert.c || '''static assert'''.<br />
|-<br />
| struct.c || Aggregate ('''struct''' and '''union''') declaration.<br />
|-<br />
| template.c || Everything related to '''template'''.<br />
|-<br />
| tk/ || ?<br />
|-<br />
| tocsym.c || To C symbol<br />
|-<br />
| toctype.c || Convert D type to C type for debug symbol<br />
|-<br />
| tocvdebug.c || [http://stackoverflow.com/questions/1418660/microsofts-codeview-format-specs CodeView4 debug format].<br />
|-<br />
| todt.c || ?; requires backend support<br />
|-<br />
| toelfdebug.c || Emit symbolic debug info in Dwarf2 format. Currently empty.<br />
|-<br />
| toir.c || To Intermediate Representation; requires backend support<br />
|-<br />
| toobj.c || Generate the object file for Dsymbol and declarations except functions.<br />
|-<br />
| traits.c || '''__traits'''.<br />
|-<br />
| typinf.c || Get TypeInfo from a type.<br />
|-<br />
| unialpha.c || Check if a character is a Unicode alphabet.<br />
|-<br />
| unittests.c || Run functions related to unit test.<br />
|-<br />
| utf.c || UTF-8.<br />
|-<br />
| version.c || Handles '''version'''<br />
|}<br />
<br />
=== Back end ===<br />
{| class="wikitable" |<br />
! File || Function<br />
|-<br />
| html.c || Extracts D source code from .html files<br />
|}<br />
<br />
=== A few observations ===<br />
* idgen.c is not part of the compiler source at all. It is the source to a code generator which creates id.h and id.c, which defines a whole lot of Identifier instances. (presumably, these are used to represent various 'builtin' symbols that the language defines)<br />
* impcvngen.c follows the same pattern as idgen.c. It creates impcnvtab.c, which appears to describe casting rules between primitive types.<br />
* Unspurprisingly, the code is highly D-like in methodology. For instance, root.h defines an Object class which serves as a base class for most, if not all of the other classes used. Class instances are always passed by pointer and allocated on the heap.<br />
* root.h also defines String, Array, and File classes, as opposed to using STL. Curious. (a relic from the days when templates weren't as reliable as they are now?)<br />
* lots of files with .c suffixes contain C++ code. Very confusing.<br />
<br />
== Abbreviations ==<br />
<br />
You may find these abbreviations throughout the DMD source code (in identifiers and comments).<br />
<br />
==== Front-end ====<br />
; STC<br />
: STorage Class<br />
; ILS<br />
: InLine State<br />
; IR<br />
: Intermediate Representation<br />
<br />
==== Back-end ====<br />
; AE<br />
: Available Expressions <br />
; CP<br />
: Copy Propagation info.<br />
; CSE<br />
: Common Subexpression Elimination <br />
; VBE<br />
: Very Busy Expression (http://web.cs.wpi.edu/~kal/PLT/PLT9.6.html)<br />
<br />
See also: [[Commonly-Used Acronyms]]<br />
<br />
==Class hierarchy==<br />
* RootObject (The root object of all AST classes. Similar to D's Object.)<br />
** Dsymbol (A "D symbol". Serves as an abstract base for anything which is declared, such as classes/structs and variable declarations. Most (all?) objects which inherit from Dsymbol wind up getting written to the ouput object file.)<br />
*** AliasThis<br />
*** AttribDeclaration (Base class for things like access modifiers, pragma, debug (which is in turn the base class of version).)<br />
**** StorageClassDeclaration<br />
***** DeprecatedDeclaration<br />
**** LinkDeclaration<br />
**** ProtDeclaration<br />
**** AlignDeclaration<br />
**** AnonDeclaration<br />
**** PragmaDeclaration<br />
**** ConditionalDeclaration<br />
***** StaticIfDeclaration<br />
**** CompileDeclaration<br />
**** UserAttributeDeclaration<br />
*** Declaration (Base class for pretty much all declarations.)<br />
**** TupleDeclaration<br />
**** TypedefDeclaration<br />
**** AliasDeclaration<br />
**** VarDeclaration<br />
***** ClassInfoDeclaration<br />
***** TypeInfoDeclaration<br />
****** TypeInfoStructDeclaration, TypeInfoClassDeclaration, TypeInfoInterfaceDeclaration, TypeInfoTypedefDeclaration, TypeInfoPointerDeclaration, TypeInfoArrayDeclaration, TypeInfoStaticArrayDeclaration, TypeInfoAssociativeArrayDeclaration, TypeInfoEnumDeclaration, TypeInfoFunctionDeclaration, TypeInfoDelegateDeclaration, TypeInfoTupleDeclaration, TypeInfoConstDeclaration, TypeInfoInvariantDeclaration, TypeInfoSharedDeclaration, TypeInfoWildDeclaration, TypeInfoVectorDeclaration<br />
***** ThisDeclaration<br />
**** SymbolDeclaration<br />
**** FuncDeclaration<br />
***** FuncAliasDeclaration<br />
***** FuncLiteralDeclaration<br />
***** CtorDeclaration<br />
***** PostBlitDeclaration<br />
***** DtorDeclaration<br />
***** StaticCtorDeclaration<br />
****** SharedStaticCtorDeclaration<br />
***** StaticDtorDeclaration<br />
****** SharedStaticDtorDeclaration<br />
***** InvariantDeclaration<br />
***** UnitTestDeclaration<br />
***** NewDeclaration<br />
***** DeleteDeclaration<br />
*** ScopeDsymbol (A symbol which creates a scope for its children. Base class of with blocks, enum declarations, and templates.)<br />
**** AggregateDeclaration<br />
***** StructDeclaration<br />
****** UnionDeclaration<br />
***** ClassDeclaration<br />
****** InterfaceDeclaration<br />
**** WithScopeSymbol<br />
**** ArrayScopeSymbol<br />
**** EnumDeclaration<br />
**** Package<br />
***** Module<br />
**** TemplateDeclaration<br />
**** TemplateInstance<br />
***** TemplateMixin<br />
*** OverloadSet<br />
*** EnumMember<br />
*** Import<br />
*** LabelDsymbol<br />
*** StaticAssert<br />
*** DebugSymbol<br />
*** VersionSymbol<br />
<br />
** Expression (Nodes for operations, assignments, and the like derive Expression. All expressions have an interpret method which does CTFE.)<br />
*** ClassReferenceExp<br />
*** VoidInitExp<br />
*** ThrownExceptionExp<br />
*** IntegerExp<br />
*** ErrorExp<br />
*** RealExp<br />
*** ComplexExp<br />
*** IdentifierExp<br />
**** DollarExp<br />
*** DsymbolExp (An expression that points to a Dsymbol.)<br />
*** ThisExp<br />
**** SuperExp<br />
*** NullExp<br />
*** StringExp<br />
*** TupleExp<br />
*** ArrayLiteralExp<br />
*** AssocArrayLiteralExp<br />
*** StructLiteralExp<br />
*** TypeExp<br />
*** ScopeExp<br />
*** TemplateExp<br />
*** NewExp<br />
*** NewAnonClassExp<br />
*** SymbolExp (Points to a Declaration.)<br />
**** SymOffExp (Offset from symbol.)<br />
**** VarExp (A variable referenced in an expression.)<br />
*** OverExp<br />
*** FuncExp<br />
*** DeclarationExp<br />
*** TypeidExp<br />
*** TraitsExp<br />
*** HaltExp<br />
*** IsExp<br />
*** UnaExp (All unary expressions - expressions which wrap one subexpression.)<br />
**** CompileExp<br />
**** FileExp<br />
**** AssertExp<br />
**** DotIdExp<br />
**** DotTemplateExp<br />
**** DotVarExp<br />
**** DotTemplateInstanceExp<br />
**** DelegateExp<br />
**** DotTypeExp<br />
**** CallExp<br />
**** AddrExp<br />
**** PtrExp<br />
**** NegExp<br />
**** UAddExp<br />
**** ComExp<br />
**** NotExp<br />
**** BoolExp<br />
**** DeleteExp<br />
**** CastExp<br />
**** VectorExp<br />
**** SliceExp<br />
**** ArrayLengthExp<br />
**** ArrayExp<br />
**** PreExp<br />
*** BinExp (All binary expressions - expressions which have two subexpressions.)<br />
**** BinAssignExp<br />
***** AddAssignExp, MinAssignExp, MulAssignExp, DivAssignExp, ModAssignExp, AndAssignExp, OrAssignExp, XorAssignExp, PowAssignExp, ShlAssignExp, ShrAssignExp, UshrAssignExp, CatAssignExp<br />
**** DotExp<br />
**** CommaExp<br />
**** IndexExp<br />
**** PostExp<br />
**** AssignExp<br />
***** ConstructExp<br />
**** AddExp, MinExp, CatExp, MulExp, DivExp, ModExp, PowExp, ShlExp, ShrExp, UshrExp, AndExp, OrExp, XorExp, OrOrExp, AndAndExp<br />
**** CmpExp<br />
**** InExp<br />
**** RemoveExp<br />
**** EqualExp<br />
**** IdentityExp<br />
**** CondExp<br />
*** DefaultInitExp<br />
**** FileInitExp<br />
**** LineInitExp<br />
**** ModuleInitExp<br />
**** FuncInitExp<br />
**** PrettyFuncInitExp<br />
<br />
** Identifier<br />
<br />
** Initializer<br />
*** VoidInitializer<br />
*** ErrorInitializer<br />
*** StructInitializer<br />
*** ArrayInitializer<br />
*** ExpInitializer<br />
<br />
** Type<br />
*** TypeError<br />
*** TypeNext<br />
**** TypeArray<br />
***** TypeSArray<br />
***** TypeDArray<br />
***** TypeAArray<br />
**** TypePointer<br />
**** TypeReference<br />
**** TypeFunction<br />
**** TypeDelegate<br />
**** TypeSlice<br />
*** TypeBasic<br />
*** TypeVector<br />
*** TypeQualified<br />
**** TypeIdentifier<br />
**** TypeInstance<br />
**** TypeTypeof<br />
**** TypeReturn<br />
*** TypeStruct<br />
*** TypeEnum<br />
*** TypeTypedef<br />
*** TypeClass<br />
*** TypeTuple<br />
*** TypeNull<br />
<br />
** Parameter<br />
<br />
** Statement (Base class for top-level function statements. Among these is ExpStatement, which is a statement which wraps an expression. For example, a function call or an assignment is an Expression / ExpStatement.)<br />
*** ErrorStatement<br />
*** PeelStatement<br />
*** ExpStatement<br />
**** DtorExpStatement<br />
*** CompileStatement<br />
*** CompoundStatement<br />
**** CompoundDeclarationStatement<br />
*** UnrolledLoopStatement<br />
*** ScopeStatement<br />
*** WhileStatement<br />
*** DoStatement<br />
*** ForStatement<br />
*** ForeachStatement<br />
*** ForeachRangeStatement<br />
*** IfStatement<br />
*** ConditionalStatement<br />
*** PragmaStatement<br />
*** StaticAssertStatement<br />
*** SwitchStatement<br />
*** CaseStatement<br />
*** CaseRangeStatement<br />
*** DefaultStatement<br />
*** GotoDefaultStatement<br />
*** GotoCaseStatement<br />
*** SwitchErrorStatement<br />
*** ReturnStatement<br />
*** BreakStatement<br />
*** ContinueStatement<br />
*** SynchronizedStatement<br />
*** WithStatement<br />
*** TryCatchStatement<br />
*** TryFinallyStatement<br />
*** OnScopeStatement<br />
*** ThrowStatement<br />
*** DebugStatement<br />
*** GotoStatement<br />
*** LabelStatement<br />
*** AsmStatement<br />
*** ImportStatement<br />
<br />
** Catch<br />
** Tuple<br />
** DsymbolTable<br />
<br />
* TemplateParameter<br />
** TemplateTypeParameter<br />
*** TemplateThisParameter<br />
** TemplateValueParameter<br />
** TemplateAliasParameter<br />
** TemplateTupleParameter<br />
<br />
* Visitor<br />
** StoppableVisitor<br />
<br />
* Condition<br />
** DVCondition<br />
*** DebugCondition<br />
*** VersionCondition<br />
** StaticIfCondition<br />
<br />
* Lexer<br />
** Parser<br />
<br />
* Library<br />
<br />
== DMD Hacking Tips & Tricks ==<br />
<br />
=== Use printf-style debugging without too much visual noise ===<br />
<br />
There are many commented-out '''printf''' statements in the DMD front-end. You can uncomment them<br />
during debugging, but often you may only want to enable them for a specific symbol. One simple<br />
workaround is to enable printing when the name of the symbol matches the symbol you're debugging,<br />
for example:<br />
<br />
<syntaxhighlight lang="cpp"><br />
void StructDeclaration::semantic(Scope *sc)<br />
{<br />
// only do printouts if this is our target symbol<br />
if (!strcmp(toChars(), "test_struct"));<br />
printf("this=%p, %s '%s', sizeok = %d\n", this, parent->toChars(), toChars(), sizeok);<br />
}<br />
</syntaxhighlight><br />
<br />
=== Find which module instantiated a specific template instance ===<br />
<br />
Templates have a '''instantiatingModule''' field which you can inspect. Here's an example from '''glue.c''':<br />
<br />
<syntaxhighlight lang="cpp"><br />
/* Skip generating code if this part of a TemplateInstance that is instantiated<br />
* only by non-root modules (i.e. modules not listed on the command line).<br />
*/<br />
TemplateInstance *ti = inTemplateInstance();<br />
if (!global.params.useUnitTests &&<br />
ti && ti->instantiatingModule && !ti->instantiatingModule->root)<br />
{<br />
//printf("instantiated by %s %s\n", ti->instantiatingModule->toChars(), ti->toChars());<br />
return;<br />
}<br />
</syntaxhighlight><br />
<br />
=== Determine if a DMD 'Type' is an actual type, expression, or a symbol ===<br />
<br />
You can use the '''resolve''' virtual function to determine this:<br />
<br />
<syntaxhighlight lang="cpp"><br />
RootObject *o = ...;<br />
Type *srcType = isType(o);<br />
<br />
if (srcType)<br />
{<br />
Type *t;<br />
Expression *e;<br />
Dsymbol *s;<br />
srcType->resolve(loc, sc, &e, &t, &s);<br />
<br />
if (t) { } // it's a type<br />
else if (e) { } // it's an expression<br />
else if (s) { } // it's a symbol<br />
}<br />
</syntaxhighlight><br />
<br />
You can see examples of this technique being used in the '''traits.c''' file.<br />
<br />
=== Get the string representation of a DSymbol ===<br />
<br />
A '''DSymbol''' has the two functions '''toChars()''' and '''toPrettyChars()''',<br />
which are useful for debugging. The former prints out the name of the symbol,<br />
while the latter may print out the fully-scoped name of the symbol. For example:<br />
<br />
<syntaxhighlight lang="cpp"><br />
StructDeclaration *sd = ...; // assuming struct named "Bar" inside module named "Foo"<br />
printf("name: %s\n", sd->toChars()); // prints out "Bar"<br />
printf("fully qualified name: %s\n", sd->toPrettyChars()); // prints out "Foo.Bar"<br />
</syntaxhighlight><br />
<br />
=== Get the string representation of the kind of a DSymbol ===<br />
<br />
All '''DSymbol'''-inherited classes implement the '''kind''' virtual method,<br />
which enable you to use printf-style debugging, e.g.:<br />
<br />
<syntaxhighlight lang="cpp"><br />
EnumDeclaration *ed = ...;<br />
DSymbol *s = ed;<br />
printf("%s\n", s->kind()); // prints "enum". See 'EnumDeclaration::kind'.<br />
</syntaxhighlight><br />
<br />
=== Get the string representation of an operator or token ===<br />
<br />
'''Expression''' objects hold an '''op''' field, which is a '''TOK''' type (a token).<br />
To print out the string representation of the token, index into the static array '''Token::tochars''':<br />
<br />
<syntaxhighlight lang="cpp"><br />
Expression *e = ...;<br />
printf("Expression op: %s ", Token::toChars(e->op));<br />
</syntaxhighlight><br />
<br />
=== Print the value of a floating-point literal ===<br />
<br />
To print the value of an expression which is a floating-point literal (a value known at compile-time),<br />
use the '''toReal()''' member function:<br />
<br />
<syntaxhighlight lang="cpp"><br />
if (exp->op == TOKfloat32 || exp->op == TOKfloat64 || exp->op == TOKfloat80)<br />
printf("%Lf", exp->toReal());<br />
</syntaxhighlight><br />
<br />
=== Check whether an expression is a compile-time known literal ===<br />
<br />
Use the '''isConst()''' method to check if an '''Expression''' is a compile-time known literal.<br />
The name '''isConst()''' is a misnomer, but this name predates D2 and was more relevant to D1.<br />
Please note that '''isConst()''' is also a method of '''Type''', but is unrelated to the<br />
equally named function in the '''Expression''' class.<br />
<br />
=== Note the difference between two mixin types: compile declarations and compile statements ===<br />
<br />
Take this example D code:<br />
<br />
<syntaxhighlight lang="D"><br />
mixin("int x;");<br />
<br />
void main()<br />
{<br />
mixin("int y;");<br />
}<br />
</syntaxhighlight><br />
<br />
The first mixin is a '''CompileDeclaration''', while the second is a '''CompileStatement'''.<br />
These are separate classes in the DMD front-end.<br />
<br />
----<br />
<br />
[[Category:development]]<br />
[[Category:know-how]]</div>Notnahttps://wiki.dlang.org/?title=Development_and_Release_Process&diff=4084Development and Release Process2014-04-27T11:42:19Z<p>Notna: </p>
<hr />
<div><!--<br />
Copy/Paste colored markup for branch names:<br />
<br />
<span style="color:#EEAD0E">feature</span><br />
<span style="color:#458B00">master</span><br />
<span style="color:#CD2626">version</span><br />
<span style="color:#00008B">staging</span><br />
<br />
--><br />
'''If you're an experienced git user, skip to the [[#Short Summary|summary]].'''<br />
<br />
==Definitions==<br />
===Version numbers===<br />
We follow the traditional dmd versioning: ''2.061''. Tags have a ''v'' prepended, so the tag for version ''2.061.1'' is ''v2.061.1''. Versions where the third part is bigger than zero are called ''Minor Releases''. Versions where the third part is equal zero are ''Major Releases''. ''Minor Releases'' will only contain regression fixes, ''Major Releases'' will contain bug fixes and new features.<br />
<br />
The third digit can be omitted for ''Major Releases'': ''2.061'' is the same as ''2.061.0''.<br />
<br />
Meta: The dmd contributors should choose one style for all offical statements: Tags, packages, Notes on the download page. Either '''always''' write out the ''.0'' part or '''always''' omit it.<br />
<br />
===Regression fix vs. Bug fix===<br />
A regression fix for release '''X''' is a fix for a bug which was newly introduced in release '''X'''. We distinguish between regression fixes and bug fixes to avoid introducing more regressions in minor releases. A regression fix especially should not make code invalid which was valid before the regression occurred. As an example: If we have releases 2.061 and 2.061.1 then 2.061.1 should always be "better" than 2.061. It should be tried heavily not to introduce new regressions in minor releases. Code which compiled with 2.061 should still compile in 2.061.1 (there's one rare exception: If a regression allowed code to work in 2.061 which did not work in 2.060 and which is not supposed to work, it can be disabled again in 2.061.1).<br />
<br />
So a regression fix is a bug fix which should not have side-effects, doesn't introduce new features and fixes a bug which only recently appeared.<br />
<br />
Long standing bugs are especially not regressions! (Or technically probably a regression in a very old release, but as we support only 1 major release we can treat those like bugs. We only care about new regressions)<br />
<br />
===Small enhancement vs. Big feature===<br />
We later suggest different workflows for those two enhancements. Those are easily distinguishable: If you implement the feature by yourself and don't need help / someone to participate / extended review and the code changes are ''reasonably'' small, it's a small enhancement. Otherwise it's a big feature.<br />
<br />
The workflow for big features allows other contributors to participate in that feature, make special test releases for that feature, etc. If you want / need those, use the Big Feature workflow.<br />
<br />
===Stable===<br />
When is a release stable and therefore ready to be released?<br />
<br />
The workflow already guarantees that when a release can be made there has been a feature freeze for a long time. So only bug fixes and regression fixes where allowed for some time which should already stabilize the release. But we should add some more criteria:<br />
<br />
* All bugs marked as critical in bugzilla have been fixed<br />
** For practical reasons we allow exceptions from this rule for the first releases after this workflow has been established<br />
* There are no newly introduced (known) regressions<br />
** This is a hard rule, there are no exceptions to it. Have a regression? Don't release!<br />
* Later a yet to be determined percentage of non-critical bug will need to be fixed (or new features introduced)<br />
** This is to make sure a new release actually provides something new and prevent us from releasing too often. Currently this is not an issue.<br />
<br />
Apart from these criteria, the final decision is made by the release manager.<br />
<br />
=== <span style="color:#CD2626">Version</span> / <span style="color:#CD2626">Release</span> branch ===<br />
This wiki page defines <span style="color:#CD2626">version</span> branches, other projects often call those branches <span style="color:#CD2626">release</span> branches. This wiki page will call them <span style="color:#CD2626">version</span> branches for now, but a <span style="color:#CD2626">release</span> branch and a <span style="color:#CD2626">version</span> branch is exactly the same thing.<br />
<br />
==Don'ts==<br />
* do not ''cherry pick'' from one official branch into another<br />
* do not ''rebase'' official branches<br />
* do not rewrite git history on official branches<br />
* do not merge <span style="color:#458B00">master</span> into a <span style="color:#CD2626">version</span> branch (The only time when commits go from <span style="color:#458B00">master</span> to a <span style="color:#CD2626">version</span> branch is when the <span style="color:#CD2626">version</span> branch is being created)<br />
* do not merge <span style="color:#EEAD0E">feature</span> branches into <span style="color:#CD2626">version</span> branches. <span style="color:#EEAD0E">Feature</span> branches are always merged into <span style="color:#458B00">master</span>.<br />
<br />
==Release Schedule==<br />
<pre><br />
<x> = time in weeks<br />
vxxx = Tag for version xxx (Marks the release)<br />
rest = branches<br />
\ = merge<br />
------------------------------------------------------------------------------------ master branch. development is never stopped<br />
\ \ <br />
\ ------------------------- 2.063 release branch<br />
\ | | <2> |<br />
\ v2.063.0-b1 | |<br />
\ | |<br />
\ v2.063.0 v2.063.1<br />
\ <br />
----------------------------------------------------------------- 2.062 release branch<br />
| | <2> | <2> |<br />
v2.062.0-b1 v2.062.0 v2.062.1 v2.062.2<br />
</pre><br />
<br />
A new release is made approximately every 2 months. Releases are stabilized in the <span style="color:#CD2626">version</span> branch and beta releases are tagged as part of <span style="color:#CD2626">version</span>.<br />
<br />
Once the initial major release on the <span style="color:#CD2626">version</span> branch is done, only regression fixes will be pushed to the <span style="color:#CD2626">version</span> branch, then a minor release is published every 2 weeks from that <span style="color:#CD2626">version</span> branch as long as it's supported (see [[#Preparing a new minor release]]). <br />
<br />
<br />
Feature Previews: A <span style="color:#EEAD0E">feature</span> branch may need it's own beta release before being merged into <span style="color:#458B00">master</span>. These are unplanned, announced on the NG, and highly volatile.<br />
<br />
''As an example we would see these releases for things like 64bit support and User Defined Attributes.''<br />
<br />
===Support times===<br />
Currently only the most recent major release is supported. (This might change in the future)<br />
<br />
As an example:<br />
version <span style="color:#CD2626">2.061</span> is released. <span style="color:#CD2626">2.061</span> will get updates until <span style="color:#CD2626">2.062</span> is released. Then <span style="color:#CD2626">2.062</span> will get updates until <span style="color:#CD2626">2.063</span> is released etc.<br />
<br />
Only supported <span style="color:#CD2626">releases</span> receive minor update releases.<br />
<br />
==Branching model==<br />
<br />
=== Official branches ===<br />
The following branches will be available on the official (upstream) [https://github.com/D-Programming-Language/dmd dmd], [https://github.com/D-Programming-Language/druntime druntime] and [https://github.com/D-Programming-Language/phobos phobos] repositories:<br />
<br />
* '''<span style="color:#EEAD0E">feature branches</span>''': New features, in general, are '''not''' developed directly on the <span style="color:#458B00">master</span> branch, but in a dedicated <span style="color:#EEAD0E">feature</span> branch. An example for such a branch would be an ''UDA'' branch for user defined attributes. Contributors can collaborate on the feature by opening pull request targeting that <span style="color:#EEAD0E">feature</span> branch. When the feature's implementation is more-or-less complete, the <span style="color:#EEAD0E">feature</span> branch will be merged into the <span style="color:#458B00">master</span> branch. The <span style="color:#458B00">master</span> branch is also sporadically merged into the '''<span style="color:#EEAD0E">feature</span>''' branches to get regression fixes and bug fixes and to make sure the '''<span style="color:#EEAD0E">feature</span>''' branch can be merged into <span style="color:#458B00">master</span> later on without problems.<br />
<pre><br />
<br />
--------------------------------------------------------\ feature64BitWindows<br />
/ / / \<br />
/ / / \<br />
/ / / \<br />
------------------------------------------------------------------------------------ master branch. development is never stopped<br />
</pre><br />
<br />
* '''<span style="color:#458B00">master</span>''': The <span style="color:#EEAD0E">feature</span> branches are merged into this branch if they are considered complete. So the <span style="color:#458B00">master</span> branch will contain new features and may have breaking changes. Regression fixes and bug fixes may be merged from <span style="color:#CD2626">version</span> branches into <span style="color:#458B00">master</span>.<br />
<pre><br />
<br />
--------------------------------------------------------\ feature64BitWindows<br />
\<br />
-------------------\ featureUDA \<br />
\ \<br />
------------------------------------------------------------------------------------ master branch. development is never stopped<br />
/<br />
/<br />
------------------------------------------------------------------------------------ 2.063 branch<br />
/<br />
fixEvilRegression<br />
</pre><br />
<br />
* '''<span style="color:#CD2626">version branches</span>''': Once we determine it's time to do a new release, a <span style="color:#CD2626">version</span> branch is made by branching from the <span style="color:#458B00">master</span> branch. A version branch will not receive any new features, only regression and important bug fixes. To determine to which <span style="color:#CD2626">version</span> branch regression fixes should go, see [[#Regression fix]]. <span style="color:#CD2626">Version</span> branches are used to support the version for an extended period of time to enable updated minor releases which fix regressions.<br />
<br />
===Suggested local branches===<br />
How user repositories are managed is up to the end user, but we propose these branches:<br />
* '''<span style="color:#EEAD0E">feature branches</span>''': Tracking upstream <span style="color:#EEAD0E">feature</span> branches. You only need a <span style="color:#EEAD0E">feature</span> branch if you want to work on that feature. To work on a feature, make changes to the <span style="color:#EEAD0E">feature</span> branch, push to your repository and file a pull request on github '''targeting the <span style="color:#EEAD0E">feature</span> branch'''<br />
<br />
* '''<span style="color:#458B00">master</span>''': Tracking the upstream <span style="color:#458B00">master</span> branch. New feature branches should be branched from this branch.<br />
<br />
* '''<span style="color:#CD2626">version branches</span>''': Tracking the upstream <span style="color:#CD2626">version</span> branches. If you want to push a regression fix to an older release. (See [[#Regression fix]])<br />
<br />
* '''bugfix/small feature branches''': based on <span style="color:#458B00">master</span>. Used to develop bugfixes and small features (see [[#Bug fix (not a regression!)|Bug fix]])<br />
<br />
==Git workflow==<br />
<br />
===Local repository setup===<br />
All instructions on this page assume the following setup for the local repository. Experienced git users of course may use different setups.<br />
<br />
First, create a fork of the official repository (if not already done) on github. Then follow these instructions:<br />
<br />
<source lang="bash"><br />
#We use your own fork repository, not the official one!!!!<br />
git clone git://github.com/yourname/dmd.git<br />
#Now add the official repository as a remote<br />
git remote add upstream git://github.com/D-Programming-Language/dmd.git<br />
git remote update<br />
<br />
#sync / create branches on origin<br />
git push origin upstream/master:refs/heads/master<br />
<br />
#Repeat this for every release & feature branch you want to use<br />
git push origin upstream/2.061:refs/heads/2.061<br />
<br />
#Now checkout / create local branches<br />
#Repeat for every release & feature branch you want to use<br />
git checkout -b 2.061 origin/2.061<br />
</source><br />
<br />
The above instructions have to be executed only once. But if a new feature/release branch is available and you want to use it, you have to repeat this part:<br />
<source lang="bash"><br />
git remote update<br />
<br />
#Repeat this for every release & feature branch you want to use<br />
git push origin upstream/2.061:refs/heads/2.061<br />
<br />
#Repeat for every release & feature branch you want to use<br />
git checkout -b 2.061 origin/2.061<br />
</source><br />
<br />
Note:<br />
Before creating new branches, or doing similar stuff you should always do this:<br />
<source lang="bash"><br />
git remote update<br />
</source><br />
The instructions on this page always explicitly mention when you have to use this command.<br />
<br />
===Working on code updates===<br />
<br />
====What type of update?====<br />
To determine to which branch an update should be made, we have to consider the type of the change:<br />
<br />
* It's a new, big feature: This will need to get a <span style="color:#EEAD0E">feature</span> branch. See [[#New feature / Big enhancement]]<br />
* It's a small enhancement: This will go to <span style="color:#458B00">master</span>. See [[#Small enhancement]]<br />
* It's a bug fix: This will usually go to <span style="color:#458B00">master</span>. See [[#Bug fix (not a regression!) | Bug fix]]. If the bug fix must be part of a specific release it may also be merged into a <span style="color:#CD2626">version</span> branch.<br />
* It's a regression fix: This will need to go to the oldest '''supported''' <span style="color:#CD2626">version</span> branch which is affected by the regression. See [[#Regression fix]]<br />
<br />
====New feature / Big enhancement====<br />
We need to create a new branch based on <span style="color:#458B00">master</span>. As a normal user you can't create <span style="color:#EEAD0E">feature</span> branches on the official repository though.<br />
<br />
Step-By-Step:<br />
The one implementing the feature has to do this:<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout master #This is the branch we base feature on<br />
git pull origin master #Fetch changes from origin<br />
git pull upstream master #Fetch changes from upstream<br />
<br />
git branch coolFeature<br />
#Make your changes<br />
git commit -m "Implement cool feature"<br />
#Push to your fork on github<br />
git push origin coolFeature<br />
<br />
#Now request in the digitalmars.D newsgroup that someone creates a coolFeature feature branch on the official repository.<br />
<br />
#Now go to github and file a pull request for coolFeature. The pull request must target the new official feature branch (here also called coolFeature)!<br />
</source><br />
<br />
If someone requests a new <span style="color:#EEAD0E">feature</span> branch the dmd staff has to do this:<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout master #This is the branch we base features on<br />
git pull upstream master #Fetch changes from upstream<br />
<br />
git branch coolFeature #Use a useful name<br />
git push upstream coolFeature<br />
</source><br />
<br />
====Small enhancement====<br />
We merge directly into <span style="color:#458B00">master</span>.<br />
<br />
Step-By-Step:<br />
The one implementing the enhancement has to do this:<br />
<source lang="bash"><br />
#We use your own fork repository, not the official one!!!!<br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout master #This is the branch we base feature on<br />
git branch coolEnhancement<br />
#Make your changes<br />
git commit -m "Implement cool enhancement"<br />
#Push to your fork on github<br />
git push origin coolEnhancement<br />
<br />
#Now go to github and file a pull request for coolEnhancement. The pull request must target the master branch!<br />
</source><br />
<br />
====Bug fix (not a regression!)====<br />
If this bug fix should be part of a specific release, follow the instructions for regression fixes: [[#Regression fix]]<br />
<br />
We need to create a local branch based on <span style="color:#458B00">master</span>. Then file a pull request on github targeting <span style="color:#458B00">master</span>.<br />
<br />
Step-By-Step:<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout master #This is the branch we base bugfix on<br />
git pull origin master<br />
git pull upstream master<br />
<br />
git branch bugFixNNN<br />
#Make your changes<br />
git commit -m "Implement bugfix #NNN"<br />
#Push to your fork on github<br />
git push origin bugFixNNN<br />
<br />
#Now go to github and file a pull request for bugFixNNN. The pull request must target the master branch!<br />
</source><br />
<br />
====Regression fix====<br />
The regression fix must be pushed to the oldest, still supported <span style="color:#CD2626">version</span> branch affected by the regression. To determine if a <span style="color:#CD2626">version</span> is still supported, see [[#Support times]]. For now only the last release is supported.<br />
<br />
'''Note''': Regression fixes are always based on an <span style="color:#CD2626">version</span> branch, never on <span style="color:#458B00">master</span>!<br />
<br />
Step-By-Step:<br />
The one fixing the regression has to do this:<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout 2.062 #This is the branch we base our fix on<br />
git pull origin 2.062<br />
git pull upstream 2.062<br />
<br />
git branch fixRegressionNNN<br />
#Edit and fix the regression<br />
git commit -m "Fix regression #nnn"<br />
#Push to your fork on github<br />
git push origin fixRegressionNNN<br />
#Now go to github and file a pull request for fixRegressionNNN. The pull request must target our base branch, e.g. 2.062!<br />
</source><br />
<br />
The dmd staff now has to merge that pull request. The regression fix will be applied to the <span style="color:#CD2626">2.062</span> branch. The dmd staff now also has to make sure this fix is also applied to all newer release branches (as we only support one release this is never the case right now) and to <span style="color:#458B00">master</span>.<br />
<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout 2.062 #This is the branch the fix was based on<br />
git pull upstream 2.062 #Fetch changes from upstream<br />
<br />
#Repeat for all newer release branches (not necessary as long as only latest release is supported)<br />
#git checkout 2.063<br />
#git pull upstream 2.063 #Fetch remote changes from upstream first<br />
#git merge 2.062 #Now merge 2.062 branch into newer branch<br />
#git push upstream 2.063 #Now publish those changes<br />
<br />
#We have to repeat that for master<br />
git checkout master<br />
git pull upstream master #Fetch remote changes from upstream first<br />
git merge 2.062 #Now merge 2.062 branch into master branch<br />
git push upstream master #Now publish those changes<br />
</source><br />
<br />
===Preparing a new major release===<br />
As described in [[#Release Schedule]] every 2 months a new major <span style="color:#CD2626">release</span> will be made based on a <span style="color:#CD2626">version</span> branch.<br />
<br />
To start the release process (This is always done after a major release has been made) create a new <span style="color:#CD2626">version</span> branch for the next release:<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout master<br />
git pull upstream master<br />
<br />
git branch 2.063<br />
git push upstream 2.063<br />
</source><br />
<br />
Once a beta release is made, the dmd staff adds a tag on the <span style="color:#CD2626">version</span> branch!<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout 2.063<br />
git pull upstream 2.063<br />
<br />
git tag v2.063-b1 #b1=>first beta<br />
git push upstream v2.063-b1<br />
</source><br />
<br />
For the final release, create a new "v2.063" tag just as for betas.<br />
<br />
===Preparing a new minor release===<br />
As described in [[#Release Schedule]] every 2 weeks a new minor release will be prepared for all supported releases.<br />
<br />
To put further regression fixes into this release <span style="color:#CD2626">version</span> follow the descriptions in [[#Regression fix]]<br />
<br />
Once the release is ready, the dmd staff adds a tag!<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout 2.063 #checkout the base branch where a new release is made<br />
git pull upstream 2.063<br />
<br />
git tag v2.063.1 #.1=>first minor update<br />
git push upstream v2.063.1<br />
</source><br />
<br />
===Merging a feature branch===<br />
If a feature's implementation is ''sufficiently'' complete and has been tested ''well enough'', the <span style="color:#EEAD0E">feature</span> branch can be merged into <span style="color:#458B00">master</span>.<br />
<br />
DMD staff:<br />
<source lang="bash"><br />
#Make sure you've read "Local repository setup"<br />
git remote update<br />
<br />
git checkout featureXXX #checkout the feature branch<br />
git pull upstream featureXXX<br />
<br />
git checkout master<br />
git pull upstream master<br />
git merge featureXXX #if merge fails, do not fix it yourself. contact the maintainer of the feature branch <br />
git push upstream master<br />
</source><br />
<br />
==Short Summary==<br />
===Contributors===<br />
* Regression fixes go into <span style="color:#CD2626">version</span> branches<br />
* Bug fixes usually go into the <span style="color:#458B00">master</span> branch. If the bugfix should be included in a specific release, it's pushed to a <span style="color:#CD2626">version</span> branch.<br />
* Big new features are developed in <span style="color:#EEAD0E">feature</span> branches and merged into <span style="color:#458B00">master</span><br />
* Small enhancements can go directly into <span style="color:#458B00">master</span><br />
<br />
===DMD staff===<br />
* Merge regression fixes into <span style="color:#CD2626">version</span> branch asap.<br />
* Merge regressions fixes from <span style="color:#CD2626">version</span> to <span style="color:#458B00">master</span> branch immediately.<br />
* Merge bug fixes and small features into <span style="color:#458B00">master</span> regularly.<br />
* Merge <span style="color:#EEAD0E">feature</span> branches into <span style="color:#458B00">master</span> on demand.<br />
<br />
==Rationale==<br />
=== <span style="color:#00008B">Staging</span> ===<br />
This is the common branch model used by many projects. While an additional staging branch could be useful in some corner cases it would complicate the process.<br />
<br />
=== Regression vs bug fix===<br />
<blockquote style="background-color: lightgrey; border: solid thin grey;"><br />
we need to differentiate between bug fixes <br />
that do not introduce new bugs vs bug fixes that may introduce <br />
new bugs *or* break existing code for the current release <br />
version. We also *have* to prevent new features and structural <br />
changes (destabilizers) from leaking into a stable release.<br />
</blockquote><br />
http://forum.dlang.org/post/dticrdtkkqdatdnhtzrc@forum.dlang.org<br />
<br />
*The regression/bug differentiation is therefore a very strict model. It's needed for dmd as every bug fix has a probability of breaking user code and therefore we should keep the changes as few as possible. In dmd we also have the issue that we have long-standing bugs: Bugs that were not introduced, but are differences between dmd and the specification. We don't want to get any of these fixed in minor releases. For druntime and phobos there are few such bugs: Every bug has been introduced in some version. The risk of a bug fix causing regressions also seems to be lower for phobos and druntime, so we could allow bug fixes in release branches for phobos/druntime after the process has been well established.<br />
<br />
=== Regression fixes in release branches ===<br />
<blockquote style="background-color: lightgrey; border: solid thin grey;"><br />
Now why we fix regressions in the release branches:<br />
Let's say we have dmd 2.061, 2.062, 2.062.1. A regression was<br />
introduced in 2.062 and my code that compiled fine in 2.061 doesn't work<br />
in 2.062 anymore. But then the regression fix is pushed to the 2.062<br />
release branch, a minor release is made and 2.062.1 successfully<br />
compiles that code again.<br />
<br />
If the regression already occured in 2.061 should it be fixed in 2.062?<br />
This is a different question, but that situation can't happen as long<br />
as we only support 1 release and only fix newly introduced regressions.<br />
</blockquote><br />
http://forum.dlang.org/post/kc90k0$2jue$1@digitalmars.com<br />
<br />
=== Stable ===<br />
* http://forum.dlang.org/post/fbtxyjvpqqrxskptcvgk@forum.dlang.org<br />
* http://forum.dlang.org/post/noycjddhpobnnxkqsytx@forum.dlang.org<br />
<br />
==Possible optimization==<br />
<br />
===Simplification===<br />
[[Simplified Release Process Proposal]]<br />
<br />
===Release version numbering===<br />
* When we start shipping shared libraries of druntime and phobos we might have to adjust our versioning scheme as those dictate special rules. (Think of ABI compatibility between minor releases, max 3 numbers for a version, etc)<br />
<br />
===rebasing===<br />
I guess we should have a hard stance on not rebasing any of the official branches. (this especially includes feature branches where this might seem to be useful, but probably is still a bad idea)<br />
<br />
----<br />
<br />
[[Category:git]]<br />
[[Category:development]]<br />
[[Category:know-how]]</div>Notnahttps://wiki.dlang.org/?title=Reporting_LDC_issues&diff=4083Reporting LDC issues2014-04-27T11:36:41Z<p>Notna: </p>
<hr />
<div>The single best way of contributing to any open source project is to pick an open issue and submitting a patch to fix it. But even if you are not interested in compiler development, you can still contribute to the [[LDC]] project by filing high-quality bug reports for any issue you encounter. This article details a few important aspects of what makes a bug report useful for the developers.<br />
<br />
== Which issues to report? ==<br />
<br />
Actually, the most important point here is what kind of bugs ''not'' to report: As soon as you run into an issue with LDC, the first thing to do should be to check whether the corresponding DMD version also shows the same problem (see <tt>ldc2 -version</tt> for the DMD release your LDC build is based on). If so, do ''not'' open an issue on the LDC issue tracker. Instead, please file a bug at the [http://d.puremagic.com/issues/ general D Bugzilla]. Once the problem has been addressed in DMD, the fix will also make its way into LDC.<br />
<br />
But besides that, please report any and all issues where LDC does not respect the D specification, behaves in an unexpected way, or generates problematic code.<br />
<br />
In particular, note that we are also keen to hear about cases where the binaries generated by LDC run any slower than the DMD-generated code, or the performance is significantly worse than GDC. In such cases, LDC likely contains a glitch annihilating the benefits of LLVM's elaborate optimization passes.<br />
<br />
== What information to include? ==<br />
<br />
The single most important piece of information for any compiler bug report is a '''test case''' allowing the developers to reproduce the issue in order to work on a fix. Ideally, you are able to provide a test case which is »reduced«, i.e. not longer than absolutely necessary for the bug to appear, without any external dependencies (such as Phobos!). For this, using a [[Troubleshooting Tools|code minimization tool]] such as '''[https://github.com/CyberShadow/DustMite/wiki DustMite]''' is highly recommended.<br />
<br />
But even if you can't provide a test case which fits on a single screen page, please at least provide some instructions on how to reproduce the issue. Otherwise, your report will likely not even get looked at.<br />
<br />
That being said, in order to efficiently handle bug reports, '''it is crucial that the developers know the environment''' you are using LDC in, '''particularly the LDC version/revision''' in which you are encountering the issue. In order to streamline the process, you might thus want to use the following bug report template (in cases where it makes sense, please don't forget to apply common sense):<br />
<br />
<pre><br />
System: <OS name/version, including distro name if any><br />
Architecture: <x86/x86_64/…><br />
LLVM: <version? from distro packages or compiled from source?><br />
LDC: <distro package/release package/compiled from sources><br />
LDC Git revision: <skip if not building from source><br />
<br />
Issue description:<br />
<br />
<br />
Test case(s), stack traces and other relevant information:<br />
</pre> <br />
<br />
== Submitting the issue ==<br />
<br />
When you are ready to submit your issue to the LDC developers, head over to the [https://github.com/ldc-developers/ldc/issues issue tracker on GitHub], click on '''New Issue''', and fill out the form. A GitHub account will be required.<br />
<br />
----<br />
<br />
[[Category:LDC]]<br />
[[Category:Compiler]]<br />
[[Category:Compilers]]</div>Notnahttps://wiki.dlang.org/?title=D_for_Win32&diff=4082D for Win322014-04-27T11:34:49Z<p>Notna: </p>
<hr />
<div>= Introduction =<br />
This describes the D implementation for 32 bit Windows systems. Naturally, Windows specific D features are not portable to other platforms.<br />
<br />
Instead of the:<br />
<syntaxhighlight lang="C"><br />
#include <windows.h><br />
</syntaxhighlight><br />
<br />
of C, in D there is:<br />
<syntaxhighlight lang="D"><br />
import core.sys.windows.windows;<br />
</syntaxhighlight><br />
<br />
= Calling Conventions =<br />
In C, the Windows API calling conventions are '''__stdcall'''. In D, it is simply:<br />
<br />
<syntaxhighlight lang="C"><br />
extern (Windows)<br />
{<br />
/* ... function declarations ... */<br />
}<br />
</syntaxhighlight><br />
<br />
The Windows linkage attribute sets both the calling convention and the name mangling scheme to be compatible with Windows.<br />
<br />
For functions that in C would be '''__declspec(dllimport)''' or '''__declspec(dllexport)''', use the export attribute:<br />
<br />
<syntaxhighlight lang="C"><br />
export void func(int foo);<br />
</syntaxhighlight><br />
<br />
If no function body is given, it's imported. If a function body is given, it's exported.<br />
<br />
= Windows Executables =<br />
Windows GUI applications can be written with D. A sample such can be found in \samples\d\winsamp.d<br />
<br />
These are required:<br />
<br />
1. Instead of a '''main''' function serving as the entry point, a '''WinMain''' function is needed.<br />
<br />
2. '''WinMain''' must follow this form:<br />
<br />
<syntaxhighlight lang="D"><br />
import core.runtime;<br />
import core.sys.windows.windows;<br />
import std.string;<br />
<br />
extern (Windows)<br />
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
int result;<br />
<br />
try<br />
{<br />
Runtime.initialize();<br />
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);<br />
Runtime.terminate();<br />
}<br />
catch (Throwable e) <br />
{<br />
MessageBoxA(null, e.toString().toStringz(), "Error",<br />
MB_OK | MB_ICONEXCLAMATION);<br />
result = 0; // failed<br />
}<br />
<br />
return result;<br />
}<br />
<br />
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
// ... insert user code here ...<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
The '''myWinMain()''' function is where the user code goes, the rest of '''WinMain''' is boilerplate to initialize and shut down the D runtime system.<br />
<br />
3. A '''.def''' ([http://www.digitalmars.com/ctg/ctgDefFiles.html Module Definition File]) with at least the following two lines in it:<br />
<pre><br />
EXETYPE NT<br />
SUBSYSTEM WINDOWS<br />
</pre><br />
Without those, Win32 will open a text console window whenever the application is run.<br />
<br />
4. The presence of '''WinMain()''' is recognized by the compiler causing it to emit a reference to [http://www.digitalmars.com/ctg/acrtused.html __acrtused_dll] and the phobos.lib runtime library.<br />
<br />
= Windows Programming Examples =<br />
A collection of over 140 Windows D programming code examples is available at [https://github.com/AndrejMitrovic/DWinProgramming this Github repository].<br />
<br />
----<br />
[[Category:Windows]]</div>Notnahttps://wiki.dlang.org/?title=Curl_on_Windows&diff=4081Curl on Windows2014-04-27T11:31:43Z<p>Notna: </p>
<hr />
<div>==Building libcurl on Windows==<br />
<br />
===Required tools===<br />
* MinGW (http://www.mingw.org)<br />
* Digital Mars' implib (http://ftp.digitalmars.com/bup.zip)<br />
* MinGW-w64 (http://mingw-w64.sourceforge.net/)<br />
* Microsoft Librarian (lib.exe)<br />
* pexports (http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/)<br />
* Sample program app.d<br />
<syntaxhighlight lang=d><br />
import std.net.curl;<br />
import std.stdio;<br />
<br />
void main()<br />
{<br />
writeln(get("https://google.com/"));<br />
}<br />
</syntaxhighlight><br />
<br />
===Building libcurl 32 bit===<br />
# Create directory C:\BUILD<br />
# Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD<br />
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD<br />
# Save the following batch file as C:\BUILD\build-curl32.bat<br />
# Run build-curl32 from Windows command prompt<br />
<br />
<syntaxhighlight lang=winbatch><br />
@echo off<br />
<br />
:: 1) Path to MinGW\bin<br />
:: 2) Path to Digital Mars's implib.exe<br />
SET PATH=C:\Dev\MinGW\bin;C:\Dev\dm\bin;<br />
SET ZLIB_PATH=C:\BUILD\zlib-1.2.8<br />
SET INSTALL_DIR=C:\D\dmd2\windows<br />
:: ---------------------------------------------------------------<br />
<br />
:: Delete object files from previous build<br />
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res<br />
<br />
cd zlib-1.2.8<br />
mingw32-make -fwin32/Makefile.gcc<br />
cd ..<br />
<br />
cd curl-7.36.0<br />
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static<br />
strip -s lib\libcurl.dll<br />
<br />
mkdir %INSTALL_DIR%\bin %INSTALL_DIR%\lib<br />
copy lib\libcurl.dll %INSTALL_DIR%\bin<br />
implib /system %INSTALL_DIR%\lib\curl.lib lib\libcurl.dll<br />
cd ..<br />
<br />
:: Build sample<br />
SET PATH=%INSTALL_DIR%\bin<br />
dmd app.d -ofapp32.exe<br />
app32<br />
</syntaxhighlight><br />
<br />
===Building libcurl 64 bit===<br />
# Create directory C:\BUILD<br />
# Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD<br />
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD<br />
# Save the following batch file as C:\BUILD\build-curl64.bat<br />
# Run build-curl64 from Windows command prompt<br />
<br />
<syntaxhighlight lang=winbatch><br />
@echo off<br />
<br />
:: 1) Path to MinGW-w64\bin<br />
:: 2) Path to Microsoft LIB.exe<br />
:: 3) Path to pexports.exe (http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/)<br />
SET PATH=C:\Dev\MinGW64\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64;C:\Dev\MinGW\bin<br />
SET ZLIB_PATH=C:\BUILD\zlib-1.2.8<br />
SET INSTALL_DIR=C:\D\dmd2\windows<br />
:: ---------------------------------------------------------------<br />
<br />
:: Delete object files from previous build<br />
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res<br />
<br />
cd zlib-1.2.8<br />
mingw32-make -fwin32/Makefile.gcc<br />
cd ..<br />
<br />
cd curl-7.36.0<br />
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static<br />
strip -s lib\libcurl.dll<br />
<br />
mkdir %INSTALL_DIR%\bin64 %INSTALL_DIR%\lib64<br />
copy lib\libcurl.dll %INSTALL_DIR%\bin64<br />
pexports lib\libcurl.dll > curl.def<br />
lib /MACHINE:X64 /DEF:curl.def /OUT:%INSTALL_DIR%\lib64\curl.lib<br />
cd ..<br />
<br />
:: Build sample<br />
SET PATH=%INSTALL_DIR%\bin64;%INSTALL_DIR%\bin<br />
dmd -m64 app.d -ofapp64.exe<br />
app64<br />
</syntaxhighlight><br />
<br />
<br />
----<br />
[[Category:curl]]<br />
[[Category:Windows]]</div>Notnahttps://wiki.dlang.org/?title=Curl_on_Windows&diff=4080Curl on Windows2014-04-27T11:31:21Z<p>Notna: </p>
<hr />
<div>==Building libcurl on Windows==<br />
<br />
===Required tools===<br />
* MinGW (http://www.mingw.org)<br />
* Digital Mars' implib (http://ftp.digitalmars.com/bup.zip)<br />
* MinGW-w64 (http://mingw-w64.sourceforge.net/)<br />
* Microsoft Librarian (lib.exe)<br />
* pexports (http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/)<br />
* Sample program app.d<br />
<syntaxhighlight lang=d><br />
import std.net.curl;<br />
import std.stdio;<br />
<br />
void main()<br />
{<br />
writeln(get("https://google.com/"));<br />
}<br />
</syntaxhighlight><br />
<br />
===Building libcurl 32 bit===<br />
# Create directory C:\BUILD<br />
# Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD<br />
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD<br />
# Save the following batch file as C:\BUILD\build-curl32.bat<br />
# Run build-curl32 from Windows command prompt<br />
<br />
<syntaxhighlight lang=winbatch><br />
@echo off<br />
<br />
:: 1) Path to MinGW\bin<br />
:: 2) Path to Digital Mars's implib.exe<br />
SET PATH=C:\Dev\MinGW\bin;C:\Dev\dm\bin;<br />
SET ZLIB_PATH=C:\BUILD\zlib-1.2.8<br />
SET INSTALL_DIR=C:\D\dmd2\windows<br />
:: ---------------------------------------------------------------<br />
<br />
:: Delete object files from previous build<br />
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res<br />
<br />
cd zlib-1.2.8<br />
mingw32-make -fwin32/Makefile.gcc<br />
cd ..<br />
<br />
cd curl-7.36.0<br />
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static<br />
strip -s lib\libcurl.dll<br />
<br />
mkdir %INSTALL_DIR%\bin %INSTALL_DIR%\lib<br />
copy lib\libcurl.dll %INSTALL_DIR%\bin<br />
implib /system %INSTALL_DIR%\lib\curl.lib lib\libcurl.dll<br />
cd ..<br />
<br />
:: Build sample<br />
SET PATH=%INSTALL_DIR%\bin<br />
dmd app.d -ofapp32.exe<br />
app32<br />
</syntaxhighlight><br />
<br />
===Building libcurl 64 bit===<br />
# Create directory C:\BUILD<br />
# Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD<br />
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD<br />
# Save the following batch file as C:\BUILD\build-curl64.bat<br />
# Run build-curl64 from Windows command prompt<br />
<br />
<syntaxhighlight lang=winbatch><br />
@echo off<br />
<br />
:: 1) Path to MinGW-w64\bin<br />
:: 2) Path to Microsoft LIB.exe<br />
:: 3) Path to pexports.exe (http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/)<br />
SET PATH=C:\Dev\MinGW64\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64;C:\Dev\MinGW\bin<br />
SET ZLIB_PATH=C:\BUILD\zlib-1.2.8<br />
SET INSTALL_DIR=C:\D\dmd2\windows<br />
:: ---------------------------------------------------------------<br />
<br />
:: Delete object files from previous build<br />
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res<br />
<br />
cd zlib-1.2.8<br />
mingw32-make -fwin32/Makefile.gcc<br />
cd ..<br />
<br />
cd curl-7.36.0<br />
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static<br />
strip -s lib\libcurl.dll<br />
<br />
mkdir %INSTALL_DIR%\bin64 %INSTALL_DIR%\lib64<br />
copy lib\libcurl.dll %INSTALL_DIR%\bin64<br />
pexports lib\libcurl.dll > curl.def<br />
lib /MACHINE:X64 /DEF:curl.def /OUT:%INSTALL_DIR%\lib64\curl.lib<br />
cd ..<br />
<br />
:: Build sample<br />
SET PATH=%INSTALL_DIR%\bin64;%INSTALL_DIR%\bin<br />
dmd -m64 app.d -ofapp64.exe<br />
app64<br />
</syntaxhighlight><br />
<br />
<br />
----<br />
[[Category:curl]]<br />
[[Category:Winwows]]</div>Notnahttps://wiki.dlang.org/?title=GDC_Development&diff=4079GDC Development2014-04-27T11:28:42Z<p>Notna: </p>
<hr />
<div>{{ParentArticle| [[GDC]]}}<br />
<br />
= Developer Documentation =<br />
<br />
At the moment, documentation for GDC, especially the internals, is sparse.<br />
The DMD frontend and the GCC internals aren't very well documented either.<br />
This page will hopefully help provide insight on GDC's internals.<br />
<br />
== GDC Internals ==<br />
<br />
GDC is essentially divided into 3 parts.<br />
<br />
* The DMD Frontend<br />
* GCC's Internals<br />
* GDC's glue code<br />
<br />
=== The DMD frontend ===<br />
<br />
* The dmd and dmd2 subfolders contain D1 and D2 frontend source code respectively.<br />
* On Wiki4D, there is the start of a [//prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide DMD Source Guide] to look at for now.<br />
* In DMD, mars.c holds the main function for compiler. In GDC, this is surrounded #ifndef IN_GCC, meaning that if we are using GCC, don't compile that part in. The main for GDC function can be found gcc/main.c. It calls the toplev_main() function in gcc/toplev.c, which uses a generic main function for GCC front ends that don't implement their own.<br />
<br />
=== GCC's Internals ===<br />
<br />
* http://gcc.gnu.org/wiki/GettingStarted<br />
<br />
=== GDC's glue code ===<br />
<br />
* This is the bridge between the DMD frontend and GCC<br />
* Read the [//prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide DMD Source Guide], especially section Intermediate representation as a start.<br />
* Also look at the [[GDC/Hacking|GDC/Hacking]] entry for information about GDC's glue code.<br />
<br />
==== Files ====<br />
<br />
* d-codegen[.cc/.h]:<br />
** Implements IRState.<br />
<br />
* d-glue.cc:<br />
** Implements all the methods described there in the DMD source guide, including all Statement::toIR and Expression::toElem methods thus, replacing dmd's toelem.c, e2ir.c, s2ir.c, etc.<br />
<br />
* d-irstate[.cc/.h]:<br />
** Simliar to irstate[.c/.h] in DMD's source, but not quite. In DMD, irstate[.c/.h] are only for the struct IRState, and do not inherit from any other structs. In GDC, d-irstate[.cc/.h] implements "IRBase", which inherits from Object. In d-codegen[.cc/.h], IRState is then implemented.<br />
<br />
== Updating GDC ==<br />
<br />
=== Merging a new DMD/Phobos version ===<br />
<br />
When a new DMD version is out, we will try to get GDC up to date as soon as possible. The instructions are as follows: (From David Friedman)<br />
<br />
<pre><br />
1. Extract the new dmd-xxx.zip package.<br />
<br />
2. Diff the compiler source from the previously merged dmd version (not <br />
gdc's d/dmd or d/dmd2 directory). You may have to fix line endings in <br />
the new dmd source to get a clean diff.<br />
<br />
3. Depending on the nature of the changes, it may be possible to simply <br />
apply the changes to the gdc version as a patch. Otherwise, make <br />
changes manually. <br />
<br />
Because some of the changes I made a pretty drastic, it will probably be <br />
easier to applies these incremental changes to gdc rather than try to <br />
re-apply my changes to the original dmd code.<br />
<br />
4. Get the new compiler working and run regression tests.<br />
<br />
5. Do steps 2 and 3 for Phobos. It helps to work on the compiler and <br />
Phobos separately. Sometimes compiler changes will require the new <br />
runtime library to work correctly, however.<br />
<br />
Also, I don't merge too many versions at a time. For example, I would <br />
probably do 2.015, 2.016+2.017, and then 2.018. The array operations <br />
in 2.018 should well tested before moving on.<br />
<br />
I don't really have any other documentation. I do have some scripts to <br />
help with the diffing process.<br />
<br />
David<br />
</pre><br />
<br />
If you are using D2, you will also need to repeat the process for Druntime.<br />
<br />
You can find all the DMD, Phobos, and Druntime versions in the [//ftp.digitalmars.com Digitalmars FTP].<br />
<br />
To create a more readable diff you can use this command:<br />
<syntaxhighlight lang="bash"><br />
diff -Naruw dmdX dmdX+1 > dmdX-to-dmdX+1.patch<br />
</syntaxhighlight><br />
<br />
Where **X** is a dmd version.<br />
<br />
To apply the generated patch in the most automatic way run patch as follows in the corresponding DMD or Phobos dir:<br />
<syntaxhighlight lang="bash"><br />
patch -p4 -l -F 3 --verbose < dmdX-to-dmdX+1.patch<br />
</syntaxhighlight> <br />
<br />
It will patch all the files it can, and will place all the statement that can't be merged in **file.rej** where file is a filename.<br />
<br />
=== Merging a new GCC version ===<br />
<br />
New GCC versions come out on occasion as well, but can require a bit more work to set up than a new DMD version. Usually, you only need to make patches for a 4.x version, and not for every 4.x.x version. Here are the instructions given from David Friedman:<br />
<br />
<pre><br />
The first thing to do is modify d/setup-gcc.sh to allow building with <br />
the new version.<br />
<br />
Next, you should try to apply the set of patches in d/patches/ for the <br />
previous version. For the top-level-xxx patch, just manually apply the <br />
changes to Makefile.def and configure.ac. You will need to get the <br />
autogen package to rebuild Makefile.in. Rebuilding the top-level <br />
'configure' script with autoconf may be tricky, so you just apply the <br />
one-line change directly to 'configure'.<br />
<br />
You probably will need to create a d-bi-attrs-4x.h. This is select <br />
portion of gcc/c-common.c modified to for D. (Conditionally) included <br />
it in d-builtins.c.<br />
<br />
Most of the work is then getting GDC to work correctly. Any changes you <br />
make that are version specific should probably involve the use of the <br />
D_GCC_VER macro. Search for "D_GCC_VER" to get a feel for what you will <br />
need to do.<br />
<br />
Once you gotten everything working and are done making changes to the <br />
GCC sources, you need to create a set of patches for the new version. <br />
The for FSF GCC, there are two patches: One is the top-level, <br />
'patch-toplev-<version>'. The other is for thee gcc/ directory <br />
'patch-gcc-<version>'.<br />
</pre><br />
<br />
You can find GCC versions in the [//ftp.gnu.org/gnu/gcc GNU FTP].<br />
<br />
== Repository Guidelines ==<br />
<br />
These are the repository guidelines that a committer should follow while committing to the GDC repository.<br />
<br />
The '''default''' branch must never be broken but should contain a working version of the compiler. If you want to develop a new feature or do a merging with a newer GCC or DMD or Phobos, it's strongly encuraged that you create your own branch. If you don't know about mercurial branches, [//hgbook.red-bean.com/read/managing-releases-and-branchy-development.html this small tutorial] will fill all the knowledge requirements to create a new branch. <br />
<br />
It's better if you give to your branch a short name representing the topic of that branch. You can commit in anytime to that branch and broke it, people interested in the same feature will work in the same branch. When a feature is fully developed and stable, where stable means that it compiles, it can be merged to the '''default''' branch. After the merging, before the default branch is committed to the central repository, you have to build and test that the '''default''' branch compiles too.<br />
<br />
After that you can delete your branch from the repository.<br />
<br />
== External Links ==<br />
<br />
For what may not have been explained here well enough, here are some other links that have some useful information:<br />
* [[GDC/Hacking|GDC Hacking]]<br />
* [//prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide DMD Source Guide]<br />
* [//gcc.gnu.org/wiki GCC Wiki]<br />
* [//blog.lxgcc.net/?page_id=116 GCC front-end guide]<br />
<br />
[[Category:Compiler]]<br />
[[Category:GDC]]</div>Notnahttps://wiki.dlang.org/?title=LLVM_issues_affecting_LDC&diff=4078LLVM issues affecting LDC2014-04-27T11:22:26Z<p>Notna: </p>
<hr />
<div>This page lists issues in certain versions of LLVM known to affect [[LDC]].<br />
<br />
Because of such issues, use of the latest LLVM release is highly recommended in general. If there are no recent LLVM packages for your distribution, see [[Building LDC from source]]. LLVM is statically linked by default and can thus be removed again after building LDC. It does not have to be installed system-wide.<br />
<br />
== LLVM 3.3 ==<br />
* TLS globals with weak linkage (as generated for static variables in D templates) [http://llvm.org/bugs/show_bug.cgi?id=15972 are completely broken in LLVM 3.3] ''on OS X'' (causing LDC to crash when e.g. building Phobos). Thus, please use LLVM 3.2 on OS X for the time being.<br />
<br />
== LLVM 3.1 ==<br />
* There is an infinite recursion bug in the scalar evolution optimization pass in LLVM 3.1 (LLVM PR: TBD). It is known to be triggered by the std.exception unit tests on x86_64. In GDB, the cycle looks similar to this:<br />
<pre><br />
[…]<br />
#2 llvm::ScalarEvolution::isKnownPredicate(llvm::CmpInst::Predicate, llvm::SCEV const*, llvm::SCEV const*) ()<br />
#3 llvm::ScalarEvolution::getUMaxExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&) ()<br />
#4 llvm::ScalarEvolution::getUMaxExpr(llvm::SCEV const*, llvm::SCEV const*) ()<br />
#5 llvm::ScalarEvolution::createSCEV(llvm::Value*) ()<br />
#6 llvm::ScalarEvolution::getSCEV(llvm::Value*) ()<br />
#7 llvm::ScalarEvolution::isImpliedCond(llvm::CmpInst::Predicate, llvm::SCEV const*, llvm::SCEV const*, llvm::Value*, bool) ()<br />
#8 llvm::ScalarEvolution::isKnownPredicate(llvm::CmpInst::Predicate, llvm::SCEV const*, llvm::SCEV const*) ()<br />
[…]<br />
</pre><br />
: The issue does not occur on LLVM 3.0 and 3.2. Because of this, the release-mode std.exception unittests are executed [https://github.com/ldc-developers/ldc/commit/d33bfb0d42a117f0495f304921343a209a2441a4 with reduced optimizations] on x86_64 LLVM 3.1.<br />
<br />
== LLVM 3.0 ==<br />
* There seems to be a bug in the MC code leading to crashes similar to this in rare cases (https://github.com/ldc-developers/ldc/issues/281):<br />
<pre><br />
[…]<br />
3 ldc2 0x0000000000df9a6b llvm::MCAsmLayout::EnsureValid(llvm::MCFragment const*) const + 27<br />
4 ldc2 0x0000000000dfa119 llvm::MCAsmLayout::getFragmentOffset(llvm::MCFragment const*) const + 9<br />
5 ldc2 0x0000000000dfb23c llvm::MCAsmLayout::getSymbolOffset(llvm::MCSymbolData const*) const + 460<br />
6 ldc2 0x0000000000dfb506 llvm::MCAssembler::EvaluateFixup(llvm::MCAsmLayout const&, llvm::MCFixup const&, llvm::MCFragment const*, llvm::MCValue&, unsigned long&) const + 310<br />
7 ldc2 0x0000000000dfbb39 llvm::MCAssembler::HandleFixup(llvm::MCAsmLayout const&, llvm::MCFragment&, llvm::MCFixup const&) + 57<br />
8 ldc2 0x0000000000dfeee3 llvm::MCAssembler::Finish() + 595<br />
9 ldc2 0x00000000009781d5 llvm::AsmPrinter::doFinalization(llvm::Module&) <br />
[…]<br />
</pre><br />
<br />
<br />
[[Category:LDC]]<br />
[[Category:LLVM]]</div>Notnahttps://wiki.dlang.org/?title=GDC&diff=3403GDC2014-01-12T22:08:46Z<p>Notna: /* Getting Involved */</p>
<hr />
<div>{{:Compilers_Widget}}<br />
<table cellspacing= "10" style="width:100%"><br />
<tr><br />
<td style="width:70%; vertical-align:top;"><br />
Welcome to GDC. This project aims to continue the development of GDC, a GCC frontend for the D programming language.<br />
__TOC__<br />
</td><br />
<td style="margin:0; margin-top:10px; margin-right:10px; border:1px solid #c0d9e2; border-bottom: 2px solid #a0b9c2; border-top: 1px solid #fff; padding:0 1em 1em 1em; background-color: #e4f4f9; align:right;vertical-align:top;"><br />
=== Useful Links ===<br />
* [https://github.com/D-Programming-GDC/GDC Source code (GitHub)]<br />
* [http://www.gdcproject.org/ Project website]<br />
* [http://bugzilla.gdcproject.org Bug tracker]<br />
* [http://www.gdcproject.org/wiki Old project wiki]<br />
</td><br />
</tr><br />
</table><br />
<br />
== Introduction ==<br />
=== What is GDC? ===<br />
GDC is a frontend for the [//dlang.org D programming language]. By using GCC as a backend, it gives us the ability to target the same platforms that GCC targets.<br />
<br />
This project was originally started by David Friedman. His original project page can be found [//dgcc.sourceforge.net here]. Unfortunately, he disappeared from the D scene, and was no longer able to maintain GDC. This project was the result of an effort to help continue David Friedman's work on GDC.<br />
<br />
=== Status ===<br />
D2 Frontend Version: [//www.digitalmars.com/d/2.0/changelog.html#new2_064 2.064]<br />
<br />
=== Supported GCC versions ===<br />
* [//gcc.gnu.org/gcc-4.7 GCC 4.7.x]<br />
* [//gcc.gnu.org/gcc-4.8 GCC 4.8.x]<br />
* [//gcc.gnu.org/snapshots.html GCC 4.9.x Development]<br />
<br />
== Documentation ==<br />
=== Installation Guide ===<br />
[[GDC/Installation|This documentation page]] includes information on building and installing GDC alongside your system's host compilers.<br />
<br />
=== Developer Documentation ===<br />
[[GDC/Development|This documentation page]] includes information about the internals of GDC, and will most likely only be of use to you if you want to help with the development of GDC.<br />
<br />
=== User Documentation ===<br />
[[GDC/Using_GDC|This documentation page]] aims to explain a couple of aspects of GDC to user, such as its usage, differences from DMD, and known issues. If can't figure out how to use GDC, take a look here.<br />
<br />
== Target Documentation ==<br />
=== MinGW ===<br />
[[GDC/MinGW|This documentation page]] aims to explain aspects of the MinGW port of GDC. Such as MinGW specific features, Windows specific topics and known issues.<br />
<br />
== Support ==<br />
Support can be found in a couple of different places:<br />
<br />
* On irc.freenode.net, there is a GDC irc channel. It is channel #d.gdc.<br />
* The D.gnu newsgroup, located [//forum.dlang.org/group/D.gnu here].<br />
* Sending an inbox message to one of the maintainers.<br />
<br />
The D.gnu newsgroup should also be used for general discussion about GDC. A bug, proposal, or enhancement can go to the [//gdcproject.org/bugzilla issue tracker]. If you choose to use the issue tracker, please label the issue appropriately. (bug, proposal, enhancement)<br />
<br />
=== Bugs ===<br />
A list of open bugs can be found [//bitbucket.org/goshawk/gdc/issues?status=new&status=open here.] Bugs created before this repository was made can be found [//d.puremagic.com/issues/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&product=DGCC+aka+GDC&content= here.] These lists are still maintained, however, new bugs should be submitted to the GDC Bugzilla site. A simple comment saying "This also happens/doesn't happen on Mac\Windows\Linux under GCC x.x.x(GCC version)" can be useful in helping solve the bug.<br />
<br />
If you have found a possible bug in GDC, please submit it! Here are some guidelines that you should follow when submitting a bug:<br />
<br />
# Make sure the bug has not already been submitted to GDC.<br />
# Include the GCC version. (e.g. 4.7.0, etc)<br />
# Include the git changeset you are using for GDC. (e.g. changset 6f03952ff48f)<br />
# Include your operating system.(Mac/Windows/flavour of Linux)<br />
# Include a simple test case demonstrating the issue.<br />
# if possible, include a patch to fix the issue.<br />
<br />
== Getting Involved ==<br />
There are a lot of things that you can do to get involved and help out with GDC. They vary from making simple documentation for some of the files, finding and submitting bugs, testing out bugs on different platforms, or submitting patches for GDC. Any help is appreciated.<br />
<br />
----</div>Notnahttps://wiki.dlang.org/?title=GDC&diff=3402GDC2014-01-12T22:08:06Z<p>Notna: </p>
<hr />
<div>{{:Compilers_Widget}}<br />
<table cellspacing= "10" style="width:100%"><br />
<tr><br />
<td style="width:70%; vertical-align:top;"><br />
Welcome to GDC. This project aims to continue the development of GDC, a GCC frontend for the D programming language.<br />
__TOC__<br />
</td><br />
<td style="margin:0; margin-top:10px; margin-right:10px; border:1px solid #c0d9e2; border-bottom: 2px solid #a0b9c2; border-top: 1px solid #fff; padding:0 1em 1em 1em; background-color: #e4f4f9; align:right;vertical-align:top;"><br />
=== Useful Links ===<br />
* [https://github.com/D-Programming-GDC/GDC Source code (GitHub)]<br />
* [http://www.gdcproject.org/ Project website]<br />
* [http://bugzilla.gdcproject.org Bug tracker]<br />
* [http://www.gdcproject.org/wiki Old project wiki]<br />
</td><br />
</tr><br />
</table><br />
<br />
== Introduction ==<br />
=== What is GDC? ===<br />
GDC is a frontend for the [//dlang.org D programming language]. By using GCC as a backend, it gives us the ability to target the same platforms that GCC targets.<br />
<br />
This project was originally started by David Friedman. His original project page can be found [//dgcc.sourceforge.net here]. Unfortunately, he disappeared from the D scene, and was no longer able to maintain GDC. This project was the result of an effort to help continue David Friedman's work on GDC.<br />
<br />
=== Status ===<br />
D2 Frontend Version: [//www.digitalmars.com/d/2.0/changelog.html#new2_064 2.064]<br />
<br />
=== Supported GCC versions ===<br />
* [//gcc.gnu.org/gcc-4.7 GCC 4.7.x]<br />
* [//gcc.gnu.org/gcc-4.8 GCC 4.8.x]<br />
* [//gcc.gnu.org/snapshots.html GCC 4.9.x Development]<br />
<br />
== Documentation ==<br />
=== Installation Guide ===<br />
[[GDC/Installation|This documentation page]] includes information on building and installing GDC alongside your system's host compilers.<br />
<br />
=== Developer Documentation ===<br />
[[GDC/Development|This documentation page]] includes information about the internals of GDC, and will most likely only be of use to you if you want to help with the development of GDC.<br />
<br />
=== User Documentation ===<br />
[[GDC/Using_GDC|This documentation page]] aims to explain a couple of aspects of GDC to user, such as its usage, differences from DMD, and known issues. If can't figure out how to use GDC, take a look here.<br />
<br />
== Target Documentation ==<br />
=== MinGW ===<br />
[[GDC/MinGW|This documentation page]] aims to explain aspects of the MinGW port of GDC. Such as MinGW specific features, Windows specific topics and known issues.<br />
<br />
== Support ==<br />
Support can be found in a couple of different places:<br />
<br />
* On irc.freenode.net, there is a GDC irc channel. It is channel #d.gdc.<br />
* The D.gnu newsgroup, located [//forum.dlang.org/group/D.gnu here].<br />
* Sending an inbox message to one of the maintainers.<br />
<br />
The D.gnu newsgroup should also be used for general discussion about GDC. A bug, proposal, or enhancement can go to the [//gdcproject.org/bugzilla issue tracker]. If you choose to use the issue tracker, please label the issue appropriately. (bug, proposal, enhancement)<br />
<br />
=== Bugs ===<br />
A list of open bugs can be found [//bitbucket.org/goshawk/gdc/issues?status=new&status=open here.] Bugs created before this repository was made can be found [//d.puremagic.com/issues/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&product=DGCC+aka+GDC&content= here.] These lists are still maintained, however, new bugs should be submitted to the GDC Bugzilla site. A simple comment saying "This also happens/doesn't happen on Mac\Windows\Linux under GCC x.x.x(GCC version)" can be useful in helping solve the bug.<br />
<br />
If you have found a possible bug in GDC, please submit it! Here are some guidelines that you should follow when submitting a bug:<br />
<br />
# Make sure the bug has not already been submitted to GDC.<br />
# Include the GCC version. (e.g. 4.7.0, etc)<br />
# Include the git changeset you are using for GDC. (e.g. changset 6f03952ff48f)<br />
# Include your operating system.(Mac/Windows/flavour of Linux)<br />
# Include a simple test case demonstrating the issue.<br />
# if possible, include a patch to fix the issue.<br />
<br />
== Getting Involved ==<br />
There are a lot of things that you can do to get involved and help out with GDC. They vary from making simple documentation for some of the files, finding and submitting bugs, testing out bugs on different platforms, or submitting patches for GDC. Any help is appreciated.<br />
<br />
<br />
----<br />
[[Category::Compiler]]<br />
[[Category::GDC]]</div>Notnahttps://wiki.dlang.org/?title=GDC_Cross_Compiler&diff=3401GDC Cross Compiler2014-01-12T22:04:52Z<p>Notna: </p>
<hr />
<div>{{ParentArticle|[[GDC]]}} <br />
<br />
Building cross compilers is always a tricky task. And building canadian-cross compilers can easily drive you crazy. This page provides an overview of working GDC cross compilers and tutorials on how to build your own.<br />
<br />
__TOC__<br />
<br />
<!-- Introduction --><br />
<!-- Binary releases --><br />
<!-- Toolchains with GDC support --><br />
<br />
== Building from source ==<br />
=== Crosstool-NG ===<br />
The preferred way to build cross compilers is crosstool-NG. Crosstool-NG supports many different architectures and advanced build configurations (e.g. canadian-cross compilers). The latest crosstool-NG release currently only supports gcc 4.7 though, so we have to use the gdc-4.7 branch there. Newer crosstool-NG hg snapshots do support gcc-4.8.<br />
<br />
See [[GDC/Cross Compiler/crosstool-NG|Cross Compiler/crosstool-NG]] for more information.<br />
<br />
=== Making tools step by step ===<br />
If it is not possible to use crosstools, the toolchain can be made manually step by step. This can also be used to make a native compiler.<br />
<br />
See [[GDC/Cross Compiler/Generic|Cross Compiler/Generic]] for more information.<br />
<br />
<!-- Using GDC cross compilers --><br />
<br />
<!-- Known bugs and issues --><br />
<br />
<br />
----<br />
[[Category::Compiler]]<br />
[[Category::GDC]]</div>Notnahttps://wiki.dlang.org/?title=GDC/Cross_Compiler/crosstool-NG&diff=3400GDC/Cross Compiler/crosstool-NG2014-01-12T22:01:57Z<p>Notna: </p>
<hr />
<div>{{ParentArticle|[[GDC]] > [[GDC/Cross Compiler|Cross Compiler]]}} <br />
<br />
== First things first ==<br />
=== Read the crosstool-NG website ===<br />
Have a look at http://www.crosstool-ng.org/ and see if crosstool-NG fits you needs (Architecture, C library, OS, ...).<br />
<br />
=== Install crosstool-NG ===<br />
Download crosstool-NG from http://www.crosstool-ng.org/ . Install as described on it's homepage.<br />
<br />
=== Read the documentation ===<br />
crosstool-NG includes some useful documentation in it's source tarball. Have a look at the "docs" directory.<br />
<br />
=== Build a C cross compiler ===<br />
Before even trying to build a D cross compiler, built a C cross compiler with the desired configuration. Creating cross compilers is difficult, so you should first get a simple C compiler working before trying to build D.<br />
<br />
== Obtaining GDC sources ==<br />
=== Checkout GDC ===<br />
First clone the git repository. We'll use the gdc-4.7 branch.<br />
<br />
<syntaxhighlight lang="bash"><br />
mkdir -p gdc/dev<br />
git clone https://github.com/D-Programming-GDC/GDC.git gdc/dev<br />
cd gdc/dev<br />
git checkout gdc-4.7<br />
cd ../<br />
</syntaxhighlight><br />
=== Get GCC sources ===<br />
Grab GCC sources from a mirror. You will need the full gcc archives. Unpack the archives in the gdc dir. This creates something like gdc/gcc-4.7.1. If you want to keep the original GCC sources, rename the gcc-4.7.1 tarball.<br />
<br />
=== Patch GCC sources ===<br />
<syntaxhighlight lang="bash"><br />
cd gdc/dev<br />
./update-gcc.sh ../gcc-4.7.1<br />
cd ../<br />
</syntaxhighlight><br />
<br />
=== Package GCC sources ===<br />
We'll now package the GCC sources again, so we'll have a ready to use GCC '''gcc-4.7.1.tar.bz2''' source tarball with the GDC sources included.<br />
<br />
<syntaxhighlight lang="bash"><br />
tar -hcjf gcc-4.7.1.tar.bz2 gcc-4.7.1/<br />
</syntaxhighlight><br />
<br />
== Configure crosstool-NG for D ==<br />
We assume you already have a configuration for your target system which produces a working C compiler so you only need to add D support.<br />
<br />
=== Make crosstool-NG use our patched sources ===<br />
Start '''ct-ng menuconfig'''. Select '''Paths and misc options''', '''Local tarballs directory''' and enter the path to the directory which contains the patched GCC sources: ''/home/jpf/gdc''. Also make sure '''Try features marked as EXPERIMENTAL''' is set. Select '''C compiler''' in the main menu and make sure '''GCC version''' is set to '''4.7.1'''<br />
<br />
=== Enable D language ===<br />
Go to '''C compiler''', select '''Other languages''' and enter '''d'''<br />
<br />
=== Disabling druntime & phobos ===<br />
If druntime & phobos do not yet compile for your target you can disable them:<br />
<br />
Start ct-ng menuconfig, go to "C compiler" and add "--disable-libphobos" to "Core gcc extra config" and "gcc extra config".<br />
<br />
== Build the cross compiler ==<br />
We have to make sure crosstool-NG uses our new sources instead of reusing already extracted or downloaded sources. So if you've already built a plain C cross compiler in your working directory, you'll have to delete the extracted / downloaded sources:<br />
<br />
<syntaxhighlight lang="bash"><br />
rm .build/src/.gcc-4.7.1.extracted<br />
rm .build/src/.gcc-4.7.1.patched<br />
rm .build/tarballs/gcc-4.7.1.tar.bz2<br />
rm -rf .build/src/gcc-4.7.1<br />
</syntaxhighlight><br />
<br />
=== Build it ===<br />
<syntaxhighlight lang="bash"><br />
ct-ng build<br />
</syntaxhighlight><br />
<br />
== Running the test suite ==<br />
The object directory in which you'll run make check is ''".build/TARGET-TRIPLET/build/build-cc-final/"'' relative to the folder where you ran ''ct-ng build''. An example would be ''.build/arm-unknown-linux-gnueabihf/build/build-cc-final/''.<br />
<br />
Change to this directory then follow [[GDC/Test_Suite#Testing_Cross-compilers]].<br />
<br />
<br />
----<br />
[[Category::Compiler]]<br />
[[Category::GDC]]</div>Notnahttps://wiki.dlang.org/?title=GDC_Development&diff=3399GDC Development2014-01-12T21:48:07Z<p>Notna: </p>
<hr />
<div>{{ParentArticle| [[GDC]]}}<br />
<br />
= Developer Documentation =<br />
<br />
At the moment, documentation for GDC, especially the internals, is sparse.<br />
The DMD frontend and the GCC internals aren't very well documented either.<br />
This page will hopefully help provide insight on GDC's internals.<br />
<br />
----<br />
<br />
== GDC Internals ==<br />
<br />
GDC is essentially divided into 3 parts.<br />
<br />
* The DMD Frontend<br />
* GCC's Internals<br />
* GDC's glue code<br />
<br />
=== The DMD frontend ===<br />
<br />
* The dmd and dmd2 subfolders contain D1 and D2 frontend source code respectively.<br />
* On Wiki4D, there is the start of a [//prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide DMD Source Guide] to look at for now.<br />
* In DMD, mars.c holds the main function for compiler. In GDC, this is surrounded #ifndef IN_GCC, meaning that if we are using GCC, don't compile that part in. The main for GDC function can be found gcc/main.c. It calls the toplev_main() function in gcc/toplev.c, which uses a generic main function for GCC front ends that don't implement their own.<br />
<br />
=== GCC's Internals ===<br />
<br />
* http://gcc.gnu.org/wiki/GettingStarted<br />
<br />
=== GDC's glue code ===<br />
<br />
* This is the bridge between the DMD frontend and GCC<br />
* Read the [//prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide DMD Source Guide], especially section Intermediate representation as a start.<br />
* Also look at the [[GDC/Hacking|GDC/Hacking]] entry for information about GDC's glue code.<br />
<br />
==== Files ====<br />
<br />
* d-codegen[.cc/.h]:<br />
** Implements IRState.<br />
<br />
* d-glue.cc:<br />
** Implements all the methods described there in the DMD source guide, including all Statement::toIR and Expression::toElem methods thus, replacing dmd's toelem.c, e2ir.c, s2ir.c, etc.<br />
<br />
* d-irstate[.cc/.h]:<br />
** Simliar to irstate[.c/.h] in DMD's source, but not quite. In DMD, irstate[.c/.h] are only for the struct IRState, and do not inherit from any other structs. In GDC, d-irstate[.cc/.h] implements "IRBase", which inherits from Object. In d-codegen[.cc/.h], IRState is then implemented.<br />
<br />
----<br />
<br />
== Updating GDC ==<br />
<br />
=== Merging a new DMD/Phobos version ===<br />
<br />
When a new DMD version is out, we will try to get GDC up to date as soon as possible. The instructions are as follows: (From David Friedman)<br />
<br />
<pre><br />
1. Extract the new dmd-xxx.zip package.<br />
<br />
2. Diff the compiler source from the previously merged dmd version (not <br />
gdc's d/dmd or d/dmd2 directory). You may have to fix line endings in <br />
the new dmd source to get a clean diff.<br />
<br />
3. Depending on the nature of the changes, it may be possible to simply <br />
apply the changes to the gdc version as a patch. Otherwise, make <br />
changes manually. <br />
<br />
Because some of the changes I made a pretty drastic, it will probably be <br />
easier to applies these incremental changes to gdc rather than try to <br />
re-apply my changes to the original dmd code.<br />
<br />
4. Get the new compiler working and run regression tests.<br />
<br />
5. Do steps 2 and 3 for Phobos. It helps to work on the compiler and <br />
Phobos separately. Sometimes compiler changes will require the new <br />
runtime library to work correctly, however.<br />
<br />
Also, I don't merge too many versions at a time. For example, I would <br />
probably do 2.015, 2.016+2.017, and then 2.018. The array operations <br />
in 2.018 should well tested before moving on.<br />
<br />
I don't really have any other documentation. I do have some scripts to <br />
help with the diffing process.<br />
<br />
David<br />
</pre><br />
<br />
If you are using D2, you will also need to repeat the process for Druntime.<br />
<br />
You can find all the DMD, Phobos, and Druntime versions in the [//ftp.digitalmars.com Digitalmars FTP].<br />
<br />
To create a more readable diff you can use this command:<br />
<syntaxhighlight lang="bash"><br />
diff -Naruw dmdX dmdX+1 > dmdX-to-dmdX+1.patch<br />
</syntaxhighlight><br />
<br />
Where **X** is a dmd version.<br />
<br />
To apply the generated patch in the most automatic way run patch as follows in the corresponding DMD or Phobos dir:<br />
<syntaxhighlight lang="bash"><br />
patch -p4 -l -F 3 --verbose < dmdX-to-dmdX+1.patch<br />
</syntaxhighlight> <br />
<br />
It will patch all the files it can, and will place all the statement that can't be merged in **file.rej** where file is a filename.<br />
<br />
=== Merging a new GCC version ===<br />
<br />
New GCC versions come out on occasion as well, but can require a bit more work to set up than a new DMD version. Usually, you only need to make patches for a 4.x version, and not for every 4.x.x version. Here are the instructions given from David Friedman:<br />
<br />
<pre><br />
The first thing to do is modify d/setup-gcc.sh to allow building with <br />
the new version.<br />
<br />
Next, you should try to apply the set of patches in d/patches/ for the <br />
previous version. For the top-level-xxx patch, just manually apply the <br />
changes to Makefile.def and configure.ac. You will need to get the <br />
autogen package to rebuild Makefile.in. Rebuilding the top-level <br />
'configure' script with autoconf may be tricky, so you just apply the <br />
one-line change directly to 'configure'.<br />
<br />
You probably will need to create a d-bi-attrs-4x.h. This is select <br />
portion of gcc/c-common.c modified to for D. (Conditionally) included <br />
it in d-builtins.c.<br />
<br />
Most of the work is then getting GDC to work correctly. Any changes you <br />
make that are version specific should probably involve the use of the <br />
D_GCC_VER macro. Search for "D_GCC_VER" to get a feel for what you will <br />
need to do.<br />
<br />
Once you gotten everything working and are done making changes to the <br />
GCC sources, you need to create a set of patches for the new version. <br />
The for FSF GCC, there are two patches: One is the top-level, <br />
'patch-toplev-<version>'. The other is for thee gcc/ directory <br />
'patch-gcc-<version>'.<br />
</pre><br />
<br />
You can find GCC versions in the [//ftp.gnu.org/gnu/gcc GNU FTP].<br />
<br />
----<br />
<br />
== Repository Guidelines ==<br />
<br />
These are the repository guidelines that a committer should follow while committing to the GDC repository.<br />
<br />
The '''default''' branch must never be broken but should contain a working version of the compiler. If you want to develop a new feature or do a merging with a newer GCC or DMD or Phobos, it's strongly encuraged that you create your own branch. If you don't know about mercurial branches, [//hgbook.red-bean.com/read/managing-releases-and-branchy-development.html this small tutorial] will fill all the knowledge requirements to create a new branch. <br />
<br />
It's better if you give to your branch a short name representing the topic of that branch. You can commit in anytime to that branch and broke it, people interested in the same feature will work in the same branch. When a feature is fully developed and stable, where stable means that it compiles, it can be merged to the '''default''' branch. After the merging, before the default branch is committed to the central repository, you have to build and test that the '''default''' branch compiles too.<br />
<br />
After that you can delete your branch from the repository.<br />
<br />
----<br />
<br />
== External Links ==<br />
<br />
For what may not have been explained here well enough, here are some other links that have some useful information:<br />
[//prowiki.org/wiki4d/wiki.cgi?GdcHacking GDC Hacking]<br />
[//prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide DMD Source Guide]<br />
[//gcc.gnu.org/wiki GCC Wiki]<br />
[//blog.lxgcc.net/?page_id=116 GCC front-end guide]<br />
<br />
----<br />
[[Category:Compiler]]</div>Notna