diff --git a/depends/README.md b/depends/README.md index 42b8af007..68d1d5eca 100644 --- a/depends/README.md +++ b/depends/README.md @@ -1,61 +1,115 @@ ### Usage To build dependencies for the current arch+OS: make To build for another arch/OS: - make HOST=host-platform-triplet + make build- -For example: +Where `` is one of the following: + - linux64 + - linux32 + - linux-arm + - linux-aarch64 + - osx + - win32 + - win64 - make HOST=x86_64-w64-mingw32 +For example, building the dependencies for macOS: -A prefix will be generated that's suitable for plugging into Bitcoin's -configure. In the above example, a dir named x86_64-w64-mingw32 will be -created. To use it for bitcoin-abc: + make build-osx - ./configure --prefix=`pwd`/depends/x86_64-w64-mingw32 +Note that it will use all the CPU cores available on the machine by default. +This behavior can be changed by setting the `JOBS` environment variable (see +below). -Common `host-platform-triplets` for cross compilation are: +To use the dependencies for building Bitcoin ABC, you need to set the platform +file to be used by `cmake`. +The platform files are located under `cmake/platforms/`. +For example, cross-building for macOS (run from the project root): -- `i686-w64-mingw32` for Win32 -- `x86_64-w64-mingw32` for Win64 -- `x86_64-apple-darwin14` for macOS -- `arm-linux-gnueabihf` for Linux ARM 32 bit -- `aarch64-linux-gnu` for Linux ARM 64 bit + mkdir build_osx + cd build_osx + cmake -GNinja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/OSX.cmake + ninja No other options are needed, the paths are automatically configured. -Dependency Options: +### Install the required dependencies: Ubuntu & Debian + +#### Common to all arch/OS + + sudo apt-get install build-essential autoconf automake cmake curl git libtool ninja-build patch pkg-config python3 + +#### For macOS cross compilation + + sudo apt-get install imagemagick libbz2-dev libcap-dev librsvg2-bin libtiff-tools python3-setuptools + +#### For Win32/Win64 cross compilation + +- see [build-windows.md](../doc/build-windows.md#cross-compilation-for-ubuntu-and-windows-subsystem-for-linux) + +#### For linux cross compilation + +Common linux dependencies: + + sudo apt-get install gperf + +For linux 32 bits cross compilation: + +First add the i386 architecture to `dpkg`: + + sudo dpkg --add-architecture i386 + sudo apt-get update + +Then install the dependencies: + + sudo apt-get install lib32stdc++-8-dev libc6-dev:i386 + +For linux ARM cross compilation: + + sudo apt-get install g++-arm-linux-gnueabihf + +For linux AARCH64 cross compilation: + + sudo apt-get install g++-aarch64-linux-gnu + + +### Dependency Options + The following can be set when running make: make FOO=bar SOURCES_PATH: downloaded sources will be placed here BASE_CACHE: built packages will be placed here SDK_PATH: Path where sdk's can be found (used by macOS) FALLBACK_DOWNLOAD_PATH: If a source file can't be fetched, try here before giving up NO_QT: Don't download/build/cache qt and its dependencies NO_WALLET: Don't download/build/cache libs needed to enable the wallet NO_UPNP: Don't download/build/cache packages needed for enabling upnp DEBUG: disable some optimizations and enable more runtime checking RAPIDCHECK: build rapidcheck (experimental, requires cmake) HOST_ID_SALT: Optional salt to use when generating host package ids BUILD_ID_SALT: Optional salt to use when generating build package ids JOBS: Number of jobs to use for each package build -If some packages are not built, for example `make NO_WALLET=1`, the appropriate -options will be passed to bitcoin's configure. In this case, `--disable-wallet`. +If some packages are not built, for example by building the depends with +`make NO_WALLET=1`, the appropriate options should be set when building Bitcoin +ABC using these dependencies. +In this example, `-DBUILD_BITCOIN_WALLET=OFF` should be passed to the `cmake` +command line to ensure that the build will not fail due to missing dependencies. Additional targets: download: run 'make download' to fetch all sources without building them download-osx: run 'make download-osx' to fetch all sources needed for macOS builds download-win: run 'make download-win' to fetch all sources needed for win builds download-linux: run 'make download-linux' to fetch all sources needed for linux builds + build-all: build the dependencies for all the arch/OS ### Other documentation - [description.md](description.md): General description of the depends system - [packages.md](packages.md): Steps for adding packages diff --git a/doc/build-unix.md b/doc/build-unix.md index 14c8f2761..4b0f6ff0e 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -1,254 +1,257 @@ UNIX BUILD NOTES ==================== Some notes on how to build Bitcoin ABC in Unix. (For FreeBSD specific instructions, see `build-freebsd.md` in this directory.) To Build --------------------- Before you start building, please make sure that your compiler supports C++14. It is recommended to create a build directory to build out-of-tree. ```bash mkdir build cd build cmake -GNinja .. ninja ninja install # optional ``` This will build bitcoin-qt as well. Dependencies --------------------- These dependencies are required: Library | Purpose | Description ------------|------------------|---------------------- libssl | Crypto | Random Number Generation, Elliptic Curve Cryptography libboost | Utility | Library for threading, data structures, etc libevent | Networking | OS independent asynchronous networking Optional dependencies: Library | Purpose | Description ------------|------------------|---------------------- miniupnpc | UPnP Support | Firewall-jumping support libdb | Berkeley DB | Wallet storage (only needed when wallet enabled) qt | GUI | GUI toolkit (only needed when GUI enabled) protobuf | Payments in GUI | Data interchange format used for payment protocol (only needed when GUI enabled) libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled) univalue | Utility | JSON parsing and encoding (bundled version will be used unless --with-system-univalue passed to configure) libzmq3 | ZMQ notification | Optional, allows generating ZMQ notifications (requires ZMQ version >= 4.x) For the versions used, see [dependencies.md](dependencies.md) Memory Requirements -------------------- C++ compilers are memory-hungry. It is recommended to have at least 1.5 GB of memory available when compiling Bitcoin ABC. On systems with less, gcc can be tuned to conserve memory with additional CXXFLAGS: cmake -GNinja .. -DCXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" Dependency Build Instructions: Ubuntu & Debian ---------------------------------------------- Build requirements: sudo apt-get install bsdmainutils build-essential libssl-dev libevent-dev ninja-build python3 On Debian Buster (10) or Ubuntu 19.04 and later: sudo apt-get install cmake On previous Ubuntu versions, the `cmake` package is too old and needs to be installed from the Kitware APT repository: sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - Add the repository corresponding to your version (see [instructions from Kitware](https://apt.kitware.com)). For Ubuntu Bionic (18.04): sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' Then update the package list and install `cmake`: sudo apt update sudo apt install cmake +Now, you can either build from self-compiled [depends](/depends/README.md) or +install the required dependencies with the following instructions. + Options when installing required Boost library files: 1. On at least Ubuntu 16.04+ and Debian 9+ there are generic names for the individual boost development packages, so the following can be used to only install necessary parts of boost: sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev 2. If that doesn't work, you can install all boost development packages with: sudo apt-get install libboost-all-dev BerkeleyDB 5.3 or later is required for the wallet. This can be installed with: sudo apt-get install libdb-dev libdb++-dev See the section "Disable-wallet mode" to build Bitcoin ABC without wallet. Minipupnc dependencies (can be disabled by passing `-DENABLE_UPNP=OFF` on the cmake command line): sudo apt-get install libminiupnpc-dev ZMQ dependencies (provides ZMQ API 4.x, can be disabled by passing `-BUILD_BITCOIN_ZMQ=OFF` on the cmake command line): sudo apt-get install libzmq3-dev Dependencies for the GUI: Ubuntu & Debian ----------------------------------------- If you want to build bitcoin-qt, make sure that the required packages for Qt development are installed. Qt 5 is necessary to build the GUI. To build without GUI pass `-DBUILD_BITCOIN_QT=OFF` on the cmake command line. To build with Qt 5 you need the following: sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libqrencode dependencies (can be disabled by passing `-DENABLE_QRCODE=OFF` on the cmake command line): sudo apt-get install libqrencode-dev Dependency Build Instructions: Fedora ------------------------------------- Build requirements: sudo dnf install boost-devel cmake gcc-c++ libdb-cxx-devel libdb-devel libevent-devel ninja-build openssl-devel python3 Minipupnc dependencies (can be disabled by passing `-DENABLE_UPNP=OFF` on the cmake command line): sudo dnf install miniupnpc-devel ZMQ dependencies (can be disabled by passing `-BUILD_BITCOIN_ZMQ=OFF` on the cmake command line): sudo dnf install zeromq-devel To build with Qt 5 you need the following: sudo dnf install qt5-qttools-devel qt5-qtbase-devel protobuf-devel libqrencode dependencies (can be disabled by passing `-DENABLE_QRCODE=OFF`): sudo dnf install qrencode-devel Notes ----- The release is built with GCC and then "strip bitcoind" to strip the debug symbols, which reduces the executable size by about 90%. miniupnpc --------- [miniupnpc](http://miniupnp.free.fr/) may be used for UPnP port mapping. It can be downloaded from [here]( http://miniupnp.tuxfamily.org/files/). UPnP support is compiled in and turned off by default. See the cmake options for upnp behavior desired: ENABLE_UPNP Enable UPnP support (miniupnp required, default ON) START_WITH_UPNP UPnP support turned on by default at runtime (default OFF) Boost ----- For documentation on building Boost look at their official documentation: http://www.boost.org/build/doc/html/bbv2/installation.html Security -------- To help make your Bitcoin ABC installation more secure by making certain attacks impossible to exploit even if a vulnerability is found, binaries are hardened by default. This can be disabled by passing `-DENABLE_HARDENING=OFF`. Hardening enables the following features: * _Position Independent Executable_: Build position independent code to take advantage of Address Space Layout Randomization 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. The stack and heap are randomly located by default, but this allows the code section to be randomly located as well. On an AMD64 processor where a library was not compiled with -fPIC, this will cause an error 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: scanelf -e ./bitcoin The output should contain: TYPE ET_DYN * _Non-executable Stack_: If the stack is executable then trivial stack-based buffer overflow exploits are possible if vulnerable buffers are found. By default, Bitcoin ABC should be built with a non-executable stack, 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: scanelf -e ./bitcoin The output should contain: STK/REL/PTL RW- R-- RW- The `STK RW-` means that the stack is readable and writeable but not executable. Disable-wallet mode -------------------- When the intention is to run only a P2P node without a wallet, Bitcoin ABC may be compiled in disable-wallet mode by passing `-DBUILD_BITCOIN_WALLET=OFF` on the cmake command line. Mining is also possible in disable-wallet mode using the `getblocktemplate` RPC call. Additional cmake options -------------------------- A list of the cmake options and their current value can be displayed. From the build subdirectory (see above), run `cmake -LH ..`. Setup and Build Example: Arch Linux ----------------------------------- This example lists the steps necessary to setup and build a command line only, non-wallet distribution of the latest changes on Arch Linux: pacman -S boost cmake git libevent ninja python git clone https://github.com/Bitcoin-ABC/bitcoin-abc.git cd bitcoin-abc/ mkdir build cd build cmake -GNinja .. -DBUILD_BITCOIN_WALLET=OFF -DBUILD_BITCOIN_QT=OFF -DENABLE_UPNP=OFF -DBUILD_BITCOIN_ZMQ=OFF ninja ARM Cross-compilation ------------------- These steps can be performed on, for example, a Debian VM. The depends system will also work on other Linux distributions, however the commands for installing the toolchain will be different. Make sure you install all the build requirements mentioned above. Then, install the toolchain and some additional dependencies: sudo apt-get install autoconf automake curl g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf gperf pkg-config To build executables for ARM: cd depends make build-linux-arm cd .. mkdir build cd build cmake -GNinja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/LinuxARM.cmake -DENABLE_GLIBC_BACK_COMPAT=ON -DENABLE_STATIC_LIBSTDCXX=ON ninja For further documentation on the depends system see [README.md](../depends/README.md) in the depends directory.