Difference between revisions of "Building under Posix"
m (Remove partial phrase 'On Windows, you will need') |
(→Building D: Advise to git clone all four repos and adjust the content respectively) |
||
Line 18: | Line 18: | ||
== Building D == | == Building D == | ||
− | + | === Fetch repositories from GitHub ==== | |
− | Let's start by getting the current development (master) branch of | + | Let's start by getting the current development (master) branch of the D repositories from GitHub. Assume the root directory for everything D-related is <tt>~/dlang</tt> (replace appropriately). This is easily done by running at a command prompt: |
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | cd ~/ | + | cd ~/dlang |
git clone https://github.com/dlang/dmd | git clone https://github.com/dlang/dmd | ||
+ | git clone https://github.com/dlang/druntime | ||
+ | git clone https://github.com/dlang/phobos | ||
+ | git clone https://github.com/dlang/tools | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | After this step completes successfully, the | + | After this step completes successfully, the <tt>~/dlang</tt> should be up and filled with good stuff. |
− | + | === Bootstrap <tt>dmd</tt> === | |
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: | 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: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | cd ~/ | + | cd ~/dlang/dmd |
− | make -f posix.mak AUTO_BOOTSTRAP=1 | + | make -f posix.mak -j8 AUTO_BOOTSTRAP=1 |
</syntaxhighlight> | </syntaxhighlight> | ||
− | That's going to take a while | + | That's going to take a while. The build produces the compiler binary situated in an OS-dependent directory such as <tt>~/dlang/dmd/generated/linux/release/64/dmd</tt>. |
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>). | 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>). | ||
− | === | + | === Build <tt>phobos</tt> === |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Most D programs use D's standard library <tt>phobos</tt>. To build it, run: | |
− | |||
− | Most D programs use D's standard library <tt>phobos</tt>. To | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | cd ~ | + | cd ~/dlang/phobos |
− | + | make -f posix.mak -j8 | |
− | |||
− | make -f posix.mak | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | The build produces (with similar anticlimacticity) static and shared libraries such as <tt>~/ | + | The build produces (with similar anticlimacticity) static and shared libraries such as <tt>~/dlang/phobos/generated/linux/release/64/libphobos2.a</tt> and <tt>~/code/phobos/generated/linux/release/64/libphobos2.so</tt>. |
+ | As part of the build <tt>druntime</tt> will be built automatically, e.g. the generated <tt>druntime</tt> interfaces can be found at <tt>~/dlang/druntime/import</tt>. | ||
+ | The generated <tt>druntime</tt> libraries like <tt>~/dlang/druntime/generated/linux/release/64/libdruntime.a</tt> get bundled with built <tt>phobos</tt> libraries. | ||
== Where to go from here == | == Where to go from here == |
Revision as of 23:34, 3 March 2017
Contents
Prerequisites
To build D on POSIX, you will need to have make, g++, libcurl4-openssl-dev, and git installed on your system, as well as a working GitHub account. To install the appropriate dependencies on e.g. Ubuntu:
sudo apt-get install curl git make g++ libcurl4-openssl-dev
On OS X with Homebrew:
$ xcode-select --install $ brew install git openssl
To build the 32-bit phobos on a 64-bit machine, some 32-bit packages are also needed:
sudo apt-get install gcc-multilib libc6-dev-i386 linux-libc-dev:i386 libcurl4-gnutls-dev:i386
Other versions and variations of libcurl may work as well.
Building D
Fetch repositories from GitHub =
Let's start by getting the current development (master) branch of the D repositories from GitHub. Assume the root directory for everything D-related is ~/dlang (replace appropriately). This is easily done by running at a command prompt:
cd ~/dlang
git clone https://github.com/dlang/dmd
git clone https://github.com/dlang/druntime
git clone https://github.com/dlang/phobos
git clone https://github.com/dlang/tools
After this step completes successfully, the ~/dlang should be up and filled with good stuff.
Bootstrap dmd
This step is interesting because in order to build dmd, dmd is necessary. Fortunately, the steps of downloading and using a preexisting dmd compiler are automated. All you need to do is run this command:
cd ~/dlang/dmd
make -f posix.mak -j8 AUTO_BOOTSTRAP=1
That's going to take a while. The build produces the compiler binary situated in an OS-dependent directory such as ~/dlang/dmd/generated/linux/release/64/dmd.
To make dmd builds faster in the future, you need to obviate the need for bootstrapping. Install dmd from the download page or simply put the freshly built dmd binary in a place accessible through $PATH (a popular choice is ~/bin).
Build phobos
Most D programs use D's standard library phobos. To build it, run:
cd ~/dlang/phobos
make -f posix.mak -j8
The build produces (with similar anticlimacticity) static and shared libraries such as ~/dlang/phobos/generated/linux/release/64/libphobos2.a and ~/code/phobos/generated/linux/release/64/libphobos2.so. As part of the build druntime will be built automatically, e.g. the generated druntime interfaces can be found at ~/dlang/druntime/import. The generated druntime libraries like ~/dlang/druntime/generated/linux/release/64/libdruntime.a get bundled with built phobos libraries.
Where to go from here
If you want to contribute to a D project, please continue with the starting as a contributor guide. If you want to contribute to Phobos, you may also read the contributing to Phobos guide.