www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Building dmd from source guid

reply "monarch_dodra" <monarchdodra gmail.com> writes:
I'm trying to write a complete guide to building the alpha
version of dmd.

I myself am using something that only partially works, and
requires a lot of hacks by hand.

I thought that I'd post what I have, and with the help of the
news group, make it better and once it is 100% accurate and full,
post it to the wiki, or (maybe better yet) submit it to the
How-tos/Articles section of dlang.

...Anyways..., I'll start from the start:

==== STEP 0                   ====
==== PREPARE YOUR ENVIRONMENT ====

Our goal is to mostly replicate what you get when you download a
release version of D. We'll start by creating a root directory
for our instal. In this how-to, we'll create the directory called
"C:\D2". We will set this path as DM_HOME:
set DM_HOME=C:\D2

You can use any path you want, but it is EXTREMELLY important
that you set this variable, as the makefiles rely on it.
Inside this directory, we want to create two subdirectories:
* %DM_HOME%\dm
* %DM_HOME%\dmd2

inside dm, we want to put the digital mars C compiler. This can
be obtained from the digital mars website:
http://www.digitalmars.com/. Extract it inside %DM_HOME% to the
dm folder.

inside dmd2, we want to create these folders:
* %DM_HOME%\dmd2\windows
* %DM_HOME%\dmd2\windows\bin
* %DM_HOME%\dmd2\windows\lib
* %DM_HOME%\dmd2\src

That's just about it actually...

==== STEP 1         ====
==== GET YOUR FILES ====
What we want to do is get the sources. To do this, we use github.
You need to instal github shell.

    From the github shell, navigate to "C:\dmd2\src". Our goal is 
to
clone the dmd, druntime, phobos and tools repositories. Simply
type these commands, and wait for completion.

git clone https://github.com/D-Programming-Language/dmd
git clone https://github.com/D-Programming-Language/druntime
git clone https://github.com/D-Programming-Language/phobos
git clone https://github.com/D-Programming-Language/tools

This should give you the structure:

* %DM_HOME%\dmd2\windows
* %DM_HOME%\dmd2\windows\bin
* %DM_HOME%\dmd2\windows\lib
* %DM_HOME%\dmd2\src
* %DM_HOME%\dmd2\src\dmd
* %DM_HOME%\dmd2\src\druntime
* %DM_HOME%\dmd2\src\phobos
* %DM_HOME%\dmd2\src\tools

==== STEP 2   ====
==== MAKE DMD ====
First, we need to set up our paths variables and environment.
First, our path variable. To make sure we don't have any noise,
we just set it to the only two paths that are of interest to us:
the C compiler, and our bin path:
set path=C:\D2\dm\bin;C:\D2\dmd2\windows\bin;
Don't forget to set your DM_HOME environment variable.

Once this is done, making dmd is pretty straight forward. First,
we navigate to %DM_HOME%\dmd2\src\dmd\src:
cd %DM_HOME%\dmd2\src\dmd\src
and make dmd:
make -fwin32.mak release
And that should be all there is to do. I recommend you build the
compiler in release directly.

Once this is done, we copy the new files to our bin path. The
make file has options to do this automatically, but for now,
we'll do it by hand the first time:
copy *.exe %DM_HOME%\dmd2\windows\bin

==== STEP 2.5 ====
==== sc.ini   ====
First, we navigate to our bin path. Our goal is to write the
sc.ini which will tell dmd where to look for its libs and stuff.
YOu can either give it abosulte paths that start at %DM_HOME%, or
use relative paths. Relative paths are harder to get right, but
they don't rely on env variables either. Anyways, your file
should look like either of:

```
[Environment]
LIB="%DM_HOME%\dmd2\windows\lib"
DFLAGS="-I%DM_HOME%\dmd2\src\phobos"
"-I%DM_HOME%\dmd2\src\druntime\import"
LINKCMD=%DM_HOME%\dm\bin\link.exe
```

```
[Environment]
LIB="% P%\..\lib"
DFLAGS="-I% P%\..\..\src\phobos"
"-I% P%\..\..\src\druntime\import"
LINKCMD=% P%\..\..\..\dm\bin\link.exe
```

================
I'll stop here because this is where my first doubts start:
The packaged dmd defines LIB as:
LIB="% P%\..\lib";\dm\lib

What exactly is "\dm\lib"? I understand it is *meant* to link to
the C compiler's lib, but the path is just bogus...

Other than that, any feed back before I continue?
Dec 06 2012
next sibling parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Thursday, 6 December 2012 at 14:50:04 UTC, monarch_dodra wrote:
 git clone https://github.com/D-Programming-Language/dmd
 git clone https://github.com/D-Programming-Language/druntime
 git clone https://github.com/D-Programming-Language/phobos
 git clone https://github.com/D-Programming-Language/tools
Well... first typo here. This should be: git clone https://github.com/D-Programming-Language/dmd.git git clone https://github.com/D-Programming-Language/druntime.git git clone https://github.com/D-Programming-Language/phobos.git git clone https://github.com/D-Programming-Language/tools.git
Dec 06 2012
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2012-12-06 15:50, monarch_dodra wrote:
 I'm trying to write a complete guide to building the alpha
 version of dmd.
I have this guide I'm writing on, it's basically done: https://dl.dropbox.com/u/18386187/contribute.html -- /Jacob Carlborg
Dec 06 2012
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 12/6/12, Jacob Carlborg <doob me.com> wrote:
 I have this guide I'm writing on, it's basically done:
 https://dl.dropbox.com/u/18386187/contribute.html
 /Jacob Carlborg
Note that you can't run the test-suite via a command shell on Windows, you need to install MSYS. monarch: I've written a Windows-specific guide recently that helps set up Console2, which makes using Git and MSYS easier (including automatically copying DMD.exe and not editing sc.ini): http://dwiki.kimsufi.thecybershadow.net/Using_Git_on_Windows
Dec 06 2012
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 12/6/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:
  monarch:

 I've written a Windows-specific guide recently that helps set up
 Console2, which makes using Git and MSYS easier (including
 automatically copying DMD.exe and not editing sc.ini):
 http://dwiki.kimsufi.thecybershadow.net/Using_Git_on_Windows
Now I've noticed it's a little bit incomplete, but thankfully it's a wiki. :)
Dec 06 2012
prev sibling parent reply "monarch_dodra" <monarchdodra gmail.com> writes:
On Thursday, 6 December 2012 at 15:06:29 UTC, Jacob Carlborg 
wrote:
 On 2012-12-06 15:50, monarch_dodra wrote:
 I'm trying to write a complete guide to building the alpha
 version of dmd.
I have this guide I'm writing on, it's basically done: https://dl.dropbox.com/u/18386187/contribute.html
On Thursday, 6 December 2012 at 15:36:25 UTC, Andrej Mitrovic wrote:
 On 12/6/12, Jacob Carlborg <doob me.com> wrote:
 I have this guide I'm writing on, it's basically done:
 https://dl.dropbox.com/u/18386187/contribute.html
 /Jacob Carlborg
Note that you can't run the test-suite via a command shell on Windows, you need to install MSYS. monarch: I've written a Windows-specific guide recently that helps set up Console2, which makes using Git and MSYS easier (including automatically copying DMD.exe and not editing sc.ini): http://dwiki.kimsufi.thecybershadow.net/Using_Git_on_Windows
Wow, both are good ressources. Now I can finally test dmd without haking by hand. I still have 1 issue: when I want to test phobos with "make -fwin32.mak unittest", I error out because I don't have "curl.lib". The worst part is that in the packaged 2.060 release, if I go into src\phobos, and try to test phobos, I'll get the same issue. I've found *very* little info on building dmd/phobos on windows. Am I supposed to build this myself...? Import it...? Should it just "be there"...? These are most probably related: http://d.puremagic.com/issues/show_bug.cgi?id=8756 http://d.puremagic.com/issues/show_bug.cgi?id=9007 I just want to know if I'm hacking at it when it should have worked, or if you are supposed to do it by hand...
Dec 06 2012
next sibling parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
12/7/2012 12:02 AM, monarch_dodra пишет:
 On Thursday, 6 December 2012 at 15:06:29 UTC, Jacob Carlborg wrote:
 On 2012-12-06 15:50, monarch_dodra wrote:
 I'm trying to write a complete guide to building the alpha
 version of dmd.
I have this guide I'm writing on, it's basically done: https://dl.dropbox.com/u/18386187/contribute.html
On Thursday, 6 December 2012 at 15:36:25 UTC, Andrej Mitrovic wrote:
 On 12/6/12, Jacob Carlborg <doob me.com> wrote:
 I have this guide I'm writing on, it's basically done:
 https://dl.dropbox.com/u/18386187/contribute.html
 /Jacob Carlborg
Note that you can't run the test-suite via a command shell on Windows, you need to install MSYS. monarch: I've written a Windows-specific guide recently that helps set up Console2, which makes using Git and MSYS easier (including automatically copying DMD.exe and not editing sc.ini): http://dwiki.kimsufi.thecybershadow.net/Using_Git_on_Windows
Wow, both are good ressources. Now I can finally test dmd without haking by hand. I still have 1 issue: when I want to test phobos with "make -fwin32.mak unittest", I error out because I don't have "curl.lib". The worst part is that in the packaged 2.060 release, if I go into src\phobos, and try to test phobos, I'll get the same issue.
The fact that curl is not shipped by default sucks. And the link is at the very bottom of http://dlang.org/download.html is not handy. Anyway here it is: https://github.com/downloads/D-Programming-Language/dmd/curl-7.24.0-dmd-win32.zip
 I've found *very* little info on building dmd/phobos on windows. Am I
 supposed to build this myself...? Import it...? Should it just "be
 there"...?

 These are most probably related:
 http://d.puremagic.com/issues/show_bug.cgi?id=8756
 http://d.puremagic.com/issues/show_bug.cgi?id=9007
 I just want to know if I'm hacking at it when it should have worked, or
 if you are supposed to do it by hand...
-- Dmitry Olshansky
Dec 06 2012
parent reply "monarch_dodra" <monarchdodra gmail.com> writes:
On Thursday, 6 December 2012 at 20:11:52 UTC, Dmitry Olshansky 
wrote:
 The fact that curl is not shipped by default sucks. And the 
 link is at the very bottom of  http://dlang.org/download.html 
 is not handy.

 Anyway here it is:
 https://github.com/downloads/D-Programming-Language/dmd/curl-7.24.0-dmd-win32.zip
OK: So I'm *supposed* to download it by hand. Good to know. I'd be nice if this was also mentioned in windows\lib\README.txt I'd add it myself, but I don't think there is a github repo to contribute to the packaging?
Dec 06 2012
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-12-06 21:23, monarch_dodra wrote:

 I'd add it myself, but I don't think there is a github repo to
 contribute to the packaging?
The only thing there is is the installer repository, it's referenced from my guide: https://github.com/D-Programming-Language/installer Otherwise it's Walter that package the zip files and uploads them. -- /Jacob Carlborg
Dec 06 2012
prev sibling parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Thursday, 6 December 2012 at 20:23:44 UTC, monarch_dodra wrote:
 On Thursday, 6 December 2012 at 20:11:52 UTC, Dmitry Olshansky 
 wrote:
 The fact that curl is not shipped by default sucks. And the 
 link is at the very bottom of  http://dlang.org/download.html 
 is not handy.

 Anyway here it is:
 https://github.com/downloads/D-Programming-Language/dmd/curl-7.24.0-dmd-win32.zip
OK: So I'm *supposed* to download it by hand. Good to know. I'd be nice if this was also mentioned in windows\lib\README.txt I'd add it myself, but I don't think there is a github repo to contribute to the packaging?
This morning, the curl link in the downloads section was a 404. I thought it was just a fluke, and left it at that. However, tonight, the curl entry is simply missing from the downloads section. Just thought I'd report it. Is this permanent?
Jan 15 2013
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-12-06 21:02, monarch_dodra wrote:

 I still have 1 issue:
 when I want to test phobos with "make -fwin32.mak unittest", I error out
 because I don't have "curl.lib". The worst part is that in the packaged
 2.060 release, if I go into src\phobos, and try to test phobos, I'll get
 the same issue.
Right, I completely forgot about curl. -- /Jacob Carlborg
Dec 06 2012