Any takers for http://d.puremagic.com/issues/show_bug.cgi?id=9673?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun Mar 10 12:50:08 PDT 2013


On 3/10/13, Rainer Schuetze <r.sagitario at gmx.de> wrote:
> I think this is because without using di-files, a
> lot more code has to be analyzed for each compilation unit.

I used to think otherwise, and I wasn't wrong, however DMD has gotten
progressively faster at compiling all at once:

2.050:
E:\dev\projects\WindowsAPI>timeit build.exe fullbuild
Elapsed Time:     0:00:28.370

2.050:
E:\dev\projects\WindowsAPI>timeit build.exe multicore
Elapsed Time:     0:00:14.210

It would seem like parallel builds are the way to go. But if you use a
newer compiler:

2.062:
E:\dev\projects\WindowsAPI>timeit build.exe fullbuild
Elapsed Time:     0:00:14.971

2.062:
E:\dev\projects\WindowsAPI>timeit build.exe multicore
Elapsed Time:     0:00:15.061

So now full builds have become faster.

The repository: https://github.com/AndrejMitrovic/WindowsAPI

Here's the build script, which you first have to compile with a
relatively recent compiler (2.050 didn't have std.parallelism or
lambda syntax): http://dpaste.dzfl.pl/083247a2

Also pasted here:

import std.algorithm;
import std.array;
import std.exception;
import std.file;
import std.parallelism;
import std.path;
import std.process;
import std.string;

alias std.string.join join;

void main(string[] args)
{
    args.popFront();
    enforce(args.length);

    string[] mods = map!(a => a.name)(dirEntries(r".\win32",
SpanMode.shallow)).array;
    string flags = "-version=Unicode -version=WindowsXP";

    if (args.front == "multicore")
    {
        foreach (mod; parallel(mods))
        {
            string cmd = format("dmd -c %s %s", mod, flags);
            system(cmd);
        }

        auto objs = map!(a => a.baseName.setExtension(".obj"))(mods);
        string cmd = format("dmd -lib -ofmulti_win32.lib %s %s",
flags, objs.join(" "));
        system(cmd);
    }
    else
    if (args.front == "fullbuild")
    {
        string cmd = format("dmd -lib -offull_win32.lib %s %s", flags,
mods.join(" "));
        system(cmd);
    }
}


More information about the Digitalmars-d mailing list