2010-08-29 18:58:15 +02:00
|
|
|
UNIX BUILD NOTES
|
2013-05-20 06:30:00 +02:00
|
|
|
====================
|
2016-02-02 16:28:56 +01:00
|
|
|
Some notes on how to build Dash Core in Unix.
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2018-01-31 10:34:17 +01:00
|
|
|
(For BSD specific instructions, see [build-openbsd.md](build-openbsd.md) and/or
|
|
|
|
[build-netbsd.md](build-netbsd.md))
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
Base build dependencies
|
|
|
|
-----------------------
|
|
|
|
Building the dependencies and Dash Core requires some essential build tools and libraries to be installed before.
|
2014-05-19 12:42:57 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
Run the following commands to install required packages:
|
2011-01-25 15:29:13 +01:00
|
|
|
|
2018-10-15 13:53:38 +02:00
|
|
|
##### Debian/Ubuntu:
|
2014-09-30 19:48:40 +02:00
|
|
|
```bash
|
2021-03-26 13:32:31 +01:00
|
|
|
$ sudo apt-get install curl build-essential libtool autotools-dev automake pkg-config python3 bsdmainutils
|
2014-09-30 19:48:40 +02:00
|
|
|
```
|
2011-04-23 11:49:47 +02:00
|
|
|
|
2018-10-15 13:53:38 +02:00
|
|
|
##### Fedora:
|
2014-05-01 09:56:36 +02:00
|
|
|
```bash
|
2021-03-26 13:32:31 +01:00
|
|
|
$ sudo dnf install gcc-c++ libtool make autoconf automake python3 libstdc++-static patch
|
2014-05-01 09:56:36 +02:00
|
|
|
```
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2018-10-15 13:53:38 +02:00
|
|
|
##### Arch Linux:
|
2018-09-28 09:55:46 +02:00
|
|
|
```bash
|
2021-03-26 13:32:31 +01:00
|
|
|
$ pacman -S base-devel python3
|
2018-09-28 09:55:46 +02:00
|
|
|
```
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2019-09-27 20:25:58 +02:00
|
|
|
##### Alpine Linux:
|
|
|
|
```sh
|
2021-03-26 13:32:31 +01:00
|
|
|
$ sudo apk --update --no-cache add autoconf automake curl g++ gcc libexecinfo-dev libexecinfo-static libtool make perl pkgconfig python3 patch linux-headers
|
2019-09-27 20:25:58 +02:00
|
|
|
```
|
|
|
|
|
2018-10-15 13:53:38 +02:00
|
|
|
##### FreeBSD/OpenBSD:
|
2018-09-28 09:55:46 +02:00
|
|
|
```bash
|
2021-03-26 13:32:31 +01:00
|
|
|
pkg_add gmake libtool
|
2018-09-28 09:55:46 +02:00
|
|
|
pkg_add autoconf # (select highest version, e.g. 2.69)
|
|
|
|
pkg_add automake # (select highest version, e.g. 1.15)
|
|
|
|
pkg_add python # (select highest version, e.g. 3.5)
|
|
|
|
```
|
2013-05-20 06:30:00 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
Building
|
|
|
|
--------
|
2011-09-08 18:50:54 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
Follow the instructions in [build-generic](build-generic.md)
|
2011-09-08 18:50:54 +02:00
|
|
|
|
|
|
|
Security
|
|
|
|
--------
|
2018-08-02 16:22:47 +02:00
|
|
|
To help make your Dash Core installation more secure by making certain attacks impossible to
|
2013-05-28 01:55:01 +02:00
|
|
|
exploit even if a vulnerability is found, binaries are hardened by default.
|
|
|
|
This can be disabled with:
|
|
|
|
|
2013-12-09 11:08:08 +01:00
|
|
|
Hardening Flags:
|
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
./configure --prefix=<prefix> --enable-hardening
|
|
|
|
./configure --prefix=<prefix> --disable-hardening
|
2013-05-28 01:55:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
Hardening enables the following features:
|
2011-09-08 18:50:54 +02:00
|
|
|
|
|
|
|
* Position Independent Executable
|
|
|
|
Build position independent code to take advantage of Address Space Layout Randomization
|
2015-04-28 16:48:28 +02:00
|
|
|
offered by some kernels. Attackers who can cause execution of code at an arbitrary memory
|
|
|
|
location are thwarted if they don't know where anything useful is located.
|
2018-08-02 16:22:47 +02:00
|
|
|
The stack and heap are randomly located by default, but this allows the code section to be
|
2011-09-08 18:50:54 +02:00
|
|
|
randomly located as well.
|
|
|
|
|
2015-04-28 16:48:28 +02:00
|
|
|
On an AMD64 processor where a library was not compiled with -fPIC, this will cause an error
|
2011-09-08 18:50:54 +02:00
|
|
|
such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;"
|
|
|
|
|
|
|
|
To test that you have built PIE executable, install scanelf, part of paxutils, and use:
|
2013-05-20 06:30:00 +02:00
|
|
|
|
2015-05-22 05:10:13 +02:00
|
|
|
scanelf -e ./dashd
|
2011-09-08 18:50:54 +02:00
|
|
|
|
|
|
|
The output should contain:
|
2015-11-04 13:22:45 +01:00
|
|
|
|
2011-09-08 18:50:54 +02:00
|
|
|
TYPE
|
|
|
|
ET_DYN
|
|
|
|
|
|
|
|
* Non-executable Stack
|
2018-08-02 16:22:47 +02:00
|
|
|
If the stack is executable then trivial stack-based buffer overflow exploits are possible if
|
|
|
|
vulnerable buffers are found. By default, Dash Core should be built with a non-executable stack,
|
2011-09-08 18:50:54 +02:00
|
|
|
but if one of the libraries it uses asks for an executable stack or someone makes a mistake
|
|
|
|
and uses a compiler extension which requires an executable stack, it will silently build an
|
|
|
|
executable without the non-executable stack protection.
|
|
|
|
|
|
|
|
To verify that the stack is non-executable after compiling use:
|
2015-05-22 05:10:13 +02:00
|
|
|
`scanelf -e ./dashd`
|
2011-09-08 18:50:54 +02:00
|
|
|
|
2018-08-02 16:22:47 +02:00
|
|
|
The output should contain:
|
2013-05-20 06:30:00 +02:00
|
|
|
STK/REL/PTL
|
|
|
|
RW- R-- RW-
|
2011-09-08 18:50:54 +02:00
|
|
|
|
|
|
|
The STK RW- means that the stack is readable and writeable but not executable.
|
2013-11-29 18:37:29 +01:00
|
|
|
|
|
|
|
Disable-wallet mode
|
|
|
|
--------------------
|
2016-08-19 13:46:30 +02:00
|
|
|
When the intention is to run only a P2P node without a wallet, Dash Core may be compiled in
|
2013-11-29 18:37:29 +01:00
|
|
|
disable-wallet mode with:
|
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
./configure --prefix=<prefix> --disable-wallet
|
2013-11-29 18:37:29 +01:00
|
|
|
|
|
|
|
In this case there is no dependency on Berkeley DB 4.8.
|
2013-12-08 15:26:08 +01:00
|
|
|
|
2018-09-07 14:24:19 +02:00
|
|
|
Mining is also possible in disable-wallet mode using the `getblocktemplate` RPC call.
|
2016-03-30 16:29:56 +02:00
|
|
|
|
|
|
|
Additional Configure Flags
|
|
|
|
--------------------------
|
|
|
|
A list of additional configure flags can be displayed with:
|
|
|
|
|
|
|
|
./configure --help
|
|
|
|
|
2016-10-13 10:19:29 +02:00
|
|
|
Building on FreeBSD
|
|
|
|
--------------------
|
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
(TODO, this is untested, please report if it works and if changes to this documentation are needed)
|
2016-10-13 10:19:29 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
Building on FreeBSD is basically the same as on Linux based systems, with the difference that you have to use `gmake`
|
|
|
|
instead of `make`.
|
2016-10-13 10:19:29 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
*Note on debugging*: The version of `gdb` installed by default is [ancient and considered harmful](https://wiki.freebsd.org/GdbRetirement).
|
|
|
|
It is not suitable for debugging a multi-threaded C++ program, not even for getting backtraces. Please install the package `gdb` and
|
|
|
|
use the versioned gdb command e.g. `gdb7111`.
|
2016-10-13 10:19:29 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
Building on OpenBSD
|
|
|
|
-------------------
|
2016-10-13 10:19:29 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
(TODO, this is untested, please report if it works and if changes to this documentation are needed)
|
2016-10-13 10:19:29 +02:00
|
|
|
|
2019-09-25 11:03:06 +02:00
|
|
|
**Important**: From OpenBSD 6.2 onwards a C++11-supporting clang compiler is
|
|
|
|
part of the base image, and while building it is necessary to make sure that this
|
|
|
|
compiler is used and not ancient g++ 4.2.1. This is done by appending
|
|
|
|
`CC=cc CXX=c++` to configuration commands. Mixing different compilers
|
|
|
|
within the same executable will result in linker errors.
|
2016-10-13 10:19:29 +02:00
|
|
|
|
2018-09-28 09:55:46 +02:00
|
|
|
```bash
|
|
|
|
$ cd depends
|
2019-09-25 11:03:06 +02:00
|
|
|
$ make CC=cc CXX=c++
|
2018-09-28 09:55:46 +02:00
|
|
|
$ cd ..
|
|
|
|
$ export AUTOCONF_VERSION=2.69 # replace this with the autoconf version that you installed
|
|
|
|
$ export AUTOMAKE_VERSION=1.15 # replace this with the automake version that you installed
|
|
|
|
$ ./autogen.sh
|
2019-09-25 11:03:06 +02:00
|
|
|
$ ./configure --prefix=<prefix> CC=cc CXX=c++
|
|
|
|
$ gmake # use -jX here for parallelism
|
2018-10-15 13:53:38 +02:00
|
|
|
```
|
2019-09-25 11:03:06 +02:00
|
|
|
|
|
|
|
OpenBSD Resource limits
|
|
|
|
-------------------
|
|
|
|
If the build runs into out-of-memory errors, the instructions in this section
|
|
|
|
might help.
|
|
|
|
|
|
|
|
The standard ulimit restrictions in OpenBSD are very strict:
|
|
|
|
|
|
|
|
data(kbytes) 1572864
|
|
|
|
|
|
|
|
This, unfortunately, in some cases not enough to compile some `.cpp` files in the project,
|
|
|
|
(see issue [#6658](https://github.com/bitcoin/bitcoin/issues/6658)).
|
|
|
|
If your user is in the `staff` group the limit can be raised with:
|
|
|
|
|
|
|
|
ulimit -d 3000000
|
|
|
|
|
|
|
|
The change will only affect the current shell and processes spawned by it. To
|
|
|
|
make the change system-wide, change `datasize-cur` and `datasize-max` in
|
2018-09-07 14:24:19 +02:00
|
|
|
`/etc/login.conf`, and reboot.
|