Clone wiki

xfBuild / Home


xfBuild is a fast build tool for D. Its main strength lies in the fact that it caches dependencies between modules, as well as their modification times. Hence, it may exactly and trivially infer what to compile when a file is changed. It will usually do its job with just one compiler run (two in rare cases). Normally xfBuild is more than twice as fast as ReBuild in incremental builds. To achieve these merits, it uses a recently added frontend feature, which outputs a file with inter-module dependencies. This feature is supported in DMD >= 1.047, DMD >= 2.031 and LDC >= 0.9.1. xfBuild has been tested on projects with 300+ modules and achieves build times of around 2–3 seconds when just a few modules need to be recompiled therein (on a 1.7GHz Intel Centrino CPU with DMD-Win).


xfbuild.exe Main.d +v +profile +oR:\Main.exe -version=TangoTrace3 -I../ext/ddl -L/M -L/NOPACKFUNCTIONS -g -I../../ -I../ext TangoTrace3.obj -version=DogNoExtSupportAsserts

Options prefixed with + are for xfBuild. The rest is for the compiler.

    +x=PACKAGE      Don't compile any modules within the package
    +full           Perform a full build
    +clean          Remove object files
    +redep          Remove the dependency file
    +v              Print the compilation commands
    +h              Manage headers for faster compilation
    +mod-limit=NUM  Compile max NUM modules at a time
    +D=DEPS         Put the resulting dependencies into DEPS [default: .deps]
    +O=OBJS         Put compiled objects into OBJS [default: .objs]
    +q              Use -oq when compiling (only supported by ldc)
    +noop           Don't use -op when compiling
    +nolink         Don't link
    +o=OUTPUT       Link objects into the resulting binary OUTPUT
    +c=COMPILER     Use the D Compiler COMPILER [default: dmd]
    +C=EXT          Extension of the compiler-generated object files
                    [default: .obj on Windows, .o otherwise]
    +rmo            Reverse Module Order
                    (when compiling - might uncrash OPTLINK)
    +R              Recursively scan directories for modules
    +nodeps         Don't use dependencies' file
    +keeprsp        Don't remove .rsp files upon errors

Multithreading options:
    +threads=NUM           Number of theads to use [default: CPU core count]
    +no-affinity           Do NOT manage process affinity (New feature which
                           should prevent DMD hanging on multi-core systems)
    +linker-affinity=MASK  Process affinity mask for the linker
                           (hexadecimal) [default: 1 (OS-dependent)]

Environment Variables:
        XFBUILDFLAGS You can put any option from above into that variable
                       Note: Keep in mind that command line options override
        D_COMPILER   The D Compiler to use [default: dmd]
                       Note: XFBUILDFLAGS and command line options override

xfBuild creates a .deps file to cache dependencies between modules. If something goes wrong (linker crashes, xfBuild crashes), delete this file and cross fingers.

Building xfBuild

Prerequisite: fresh Tango off the trunk and a recent D compiler.

    hg clone
    cd xfbuild

then just run ./ or ./ or build.bat


Tested on:

  • Windows XP SP3 x86
  • Debian Lenny x86_64
  • Arch 2009.02 x86 Patches of all sorts are welcome. Future plans for xfBuild include flexible configuration and multi-threaded builds.