Merge pull request #997

1c7d3b0 cmake: define ARM var for all ARM arch variants (redfish)
6fe543d cmake: ARM: exclude libunwind in static build (redfish)
397b720 make: remove NO_AES from arm targets (redfish)
57ca3f3 make: make the ARM release targets statically linked (redfish)
43c07a1 readme: editted install/build instructions for clarity (redfish)
a0d4058 Revert "makefile: remove unnecessary ARM-specific targets" (redfish)
c2bc34b Revert "Interpret x86_64 as x86-64 for architecture" (redfish)
c54b9a1 cmake: don't set ARCH from CMAKE_SYSTEM_PROCESSOR (redfish)
This commit is contained in:
Riccardo Spagni 2016-08-28 22:49:09 +02:00
commit 53a0997a26
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
3 changed files with 135 additions and 120 deletions

View file

@ -45,34 +45,33 @@ function (die msg)
message(FATAL_ERROR "${BoldRed}${msg}${ColourReset}")
endfunction ()
if ("${ARCH}" STREQUAL "" OR "${ARCH}" STREQUAL "native")
set(ARCH ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "Building natively on ${ARCH}")
# ARCH defines the target architecture, either by an explicit identifier or
# one of the following two keywords. By default, ARCH a value of 'native':
# target arch = host arch, binary is not portable. When ARCH is set to the
# string 'default', no -march arg is passed, which creates a binary that is
# portable across processors in the same family as host processor. In cases
# when ARCH is not set to an explicit identifier, cmake's builtin is used
# to identify the target architecture, to direct logic in this cmake script.
# Since ARCH is a cached variable, it will not be set on first cmake invocation.
if (NOT ARCH OR ARCH STREQUAL "" OR ARCH STREQUAL "native" OR ARCH STREQUAL "default")
set(ARCH_ID "${CMAKE_SYSTEM_PROCESSOR}")
else()
set(ARCH_ID "${ARCH}")
endif()
if (NOT "${ARCH}" STREQUAL "")
string(SUBSTRING ${ARCH} 0 3 IS_ARM)
string(TOLOWER ${IS_ARM} IS_ARM)
if (${IS_ARM} STREQUAL "arm")
string(SUBSTRING ${ARCH} 0 5 ARM_TEST)
string(TOLOWER ${ARM_TEST} ARM_TEST)
if (${ARM_TEST} STREQUAL "armv6")
string(TOLOWER ${ARCH_ID} ARM_ID)
string(SUBSTRING ${ARCH_ID} 0 3 ARM_TEST)
if (ARM_TEST STREQUAL "arm")
set(ARM 1)
string(SUBSTRING ${ARCH_ID} 0 5 ARM_TEST)
if (ARM_TEST STREQUAL "armv6")
set(ARM6 1)
else()
set(ARM6 0)
endif()
if (${ARM_TEST} STREQUAL "armv7")
if (ARM_TEST STREQUAL "armv7")
set(ARM7 1)
else()
set(ARM7 0)
endif()
endif()
endif()
if(WIN32 OR ARM7 OR ARM6)
if(WIN32 OR ARM)
set(OPT_FLAGS_RELEASE "-O2")
else()
set(OPT_FLAGS_RELEASE "-Ofast")
@ -247,7 +246,8 @@ add_definitions("-DBLOCKCHAIN_DB=${BLOCKCHAIN_DB}")
find_package(Libunwind)
# Can't install hook in static build on OSX, because OSX linker does not support --wrap
if(LIBUNWIND_FOUND AND NOT (STATIC AND APPLE))
# On ARM, having libunwind package (with .so's only) installed breaks static link.
if(LIBUNWIND_FOUND AND NOT (STATIC AND (APPLE OR ARM)))
set(DEFAULT_STACK_TRACE ON)
else()
set(DEFAULT_STACK_TRACE OFF)
@ -308,24 +308,20 @@ if(MSVC)
endif()
include_directories(SYSTEM src/platform/msc)
else()
set(ARCH native CACHE STRING "CPU to build for: -march value or default")
# -march=armv7-a conflicts with -mcpu=cortex-a7
if(ARCH STREQUAL "default" OR ARM7 OR ARM6)
set(ARCH native CACHE STRING "CPU to build for: -march value or 'default' to not pass -march at all")
message(STATUS "Building on ${CMAKE_SYSTEM_PROCESSOR} for ${ARCH}")
if(ARCH STREQUAL "default")
set(ARCH_FLAG "")
else()
if(ARCH STREQUAL "x86_64")
set(ARCH_FLAG "-march=x86-64")
else()
set(ARCH_FLAG "-march=${ARCH}")
endif()
endif()
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
if(NOT MINGW)
set(WARNINGS_AS_ERRORS_FLAG "-Werror")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(WARNINGS "${WARNINGS} -Wno-deprecated-register -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration")
if(ARM6 OR ARM7)
if(ARM)
set(WARNINGS "${WARNINGS} -Wno-error=inline-asm")
endif()
else()
@ -362,11 +358,11 @@ else()
option(NO_AES "Explicitly disable AES support" ${NO_AES})
if(NOT NO_AES AND NOT (ARM6 OR ARM7))
if(NOT NO_AES AND NOT ARM)
message(STATUS "AES support enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
elseif(ARM7 OR ARM6)
elseif(ARM)
message(STATUS "AES support disabled (not available on ARM)")
else()
message(STATUS "AES support disabled")

View file

@ -58,6 +58,14 @@ release-all:
mkdir -p build/release
cd build/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)
release-static-arm6:
mkdir -p build/release
cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)
release-static-arm7:
mkdir -p build/release
cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)
release-static: release-static-64
release-static-64:

173
README.md
View file

@ -57,11 +57,22 @@ There are also several mining pools that kindly donate a portion of their fees,
See [LICENSE](LICENSE).
## Compiling Monero
## Installing Monero from a Package
### Overview:
Packages are available for
Dependencies:
* Arch Linux via AUR: [`bitmonero-git`](https://aur.archlinux.org/packages/bitmonero-git)
* OS X via [Homebrew](http://brew.sh)
brew tap sammy007/cryptonight
brew install bitmonero --build-from-source
Packaging for your favorite distribution would be a welcome contribution!
## Compiling Monero from Source
### Dependencies
* GCC `>=4.7.3`
* CMake `>=3.0.0`
@ -73,113 +84,95 @@ Dependencies:
* BerkeleyDB `>=4.8` (note: on Ubuntu this means installing libdb-dev and libdb++-dev)
* libunwind (optional, for stack trace on exception)
* miniupnpc (optional, for NAT punching)
* ldns `>=1.6.17` (optional, for statically-linked binaries)
* expat `>=1.1` (optional, for statically-linked binaries)
* bison or yacc (optional, for statically-linked binaries)
* Doxygen (optional, for generating documentation)
* graphviz (optional, for generating documentation)
Additional dependencies for statically-linked build:
### Build instructions
* ldns `>=1.6.17`
* expat `>=1.1`
* bison or yacc
Monero uses the CMake build system and a top-level [Makefile](Makefile) that
invokes cmake commands as needed.
Additional dependencies for building documentation:
#### On Linux and OS X
* Doxygen
* graphviz
* Install the dependencies
* Change to the root of the source code directory and build:
**Basic Process:**
cd bitmonero
make
* Install the dependencies (see below for more detailed instructions for your OS)
* To build, change to the root of the source code directory, and run `make`. Please note that Windows systems follow a slightly different process, outlined below.
* The resulting executables can be found in `build/release/bin` or `build/debug/bin`, depending on what you're building.
*Optional*: If your machine has several cores and enough memory, enable
parallel build by running `make -j<number of threads>` instead of `make`. For
this to be worthwhile, the machine should have one core and about 2GB of RAM
available per thread.
**Advanced options:**
* The resulting executables can be found in `build/release/bin`.
* Parallel build: run `make -j<number of threads>` instead of `make`.
* Statically linked release build: run `make release-static`.
* Debug build: run `make debug`.
* Test suite: run `make release-test` to run tests in addition to building. Running `make debug-test` will do the same to the debug version.
* **Optional**: build and run the test suite to verify the binaries:
**Makefile Targets for Static Builds:**
make release-test
For static builds there are a number of Makefile targets to make the build process easier.
*NOTE*: `coretests` test may take a few hours to complete.
* ```make release-static-win64``` builds statically for 64-bit Windows systems
* ```make release-static-win32``` builds statically for 32-bit Windows systems
* ```make release-static-64``` the default, builds statically for 64-bit non-Windows systems
* ```make release-static-32``` builds statically for 32-bit non-Windows systems
* ```make release-static-arm6``` builds statically for ARMv6 devices, such as the Raspberry Pi
* **Optional**: to build binaries suitable for debugging:
### On Linux:
make debug
The instructions above should provide enough detail.
* **Optional**: to build statically-linked binaries:
### On OS X:
make release-static
**Basic Process:**
#### On Windows:
The project can be built from scratch by following instructions for Unix and Linux above.
**Alternate Process:**
Alternatively, it can be built in an easier and more automated fashion using Homebrew:
* Ensure Homebrew is installed, it can be found at http://brew.sh
* Add the repository to brew: `brew tap sammy007/cryptonight`
* Build Monero: `brew install bitmonero --build-from-source`
### On Windows:
Dependencies:
* mingw-w64
* msys2
* CMake `>=3.0.0`
* libunbound `>=1.4.16` (note: Unbound is not a dependency, libunbound is)
* Boost `>=1.58`
* BerkeleyDB `>=4.8`
Binaries for Windows are built on Windows using the MinGW toolchain within
[MSYS2 environment](http://msys2.github.io). The MSYS2 environment emulates a
POSIX system. The toolchain runs within the environment and *cross-compiles*
binaries that can run outside of the environment as a regular Windows
application.
**Preparing the Build Environment**
* Download the [MSYS2 installer](http://msys2.github.io), 64-bit or 32-bit as needed, and run it.
* Use the shortcut associated with your architecture to launch the MSYS2 environment. On 64-bit systems that would be the MinGW-w64 Win64 Shell shortcut. Note that if you are running 64-bit Windows, you will have both 64-bit and 32-bit environments.
* Download and install the [MSYS2 installer](http://msys2.github.io), either the 64-bit or the 32-bit package, depending on your system.
* Open the MSYS shell via the `MSYS2 Shell` shortcut
* Update the packages in your MSYS2 install:
```
pacman -Sy
pacman -Su --ignoregroup base
pacman -Su
```
* For those of you already familiar with pacman, you can run the normal `pacman -Syu` to update, but you may get errors and need to restart MSYS2 if pacman's dependencies are updated.
* Install dependencies: `pacman -S mingw-w64-x86_64-gcc make mingw-w64-x86_64-cmake mingw-w64-x86_64-expat mingw-w64-x86_64-boost`
For those of you already familiar with pacman, you can run the normal `pacman -Syu` to update, but you may get errors and need to restart MSYS2 if pacman's dependencies are updated.
* Install dependencies:
To build for 64-bit Windows:
pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost
To build for 32-bit Windows:
pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost
* Open the MingW shell via `MinGW-w64-Win64 Shell` shortcut on 64-bit Windows
or `MinGW-w64-Win64 Shell` shortcut on 32-bit Windows. Note that if you are
running 64-bit Windows, you will have both 64-bit and 32-bit MinGW shells.
**Building**
* From the root of the source code directory run:
```
mkdir build
cd build
```
* If you are on a 64-bit system, run:
```
cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_TOOLCHAIN_FILE=../cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys64 ..
```
make release-static-win64
* If you are on a 32-bit system, run:
```
cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D ARCH="i686" -D BUILD_64=OFF -D CMAKE_TOOLCHAIN_FILE=../cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys32 ..
```
* You can now run `make` to have it build
* The resulting executables can be found in `build/release/bin` or `build/debug/bin`, depending on what you're building.
If you installed MSYS2 in a folder other than c:/msys64, make the appropriate substitution above.
make release-static-win32
**Advanced options:**
* Parallel build: run `make -j<number of threads>` instead of `make`.
* Statically linked release build: run `make release-static`.
* Debug build: run `make debug`.
* Test suite: run `make release-test` to run tests in addition to building. Running `make debug-test` will do the same to the debug version.
* The resulting executables can be found in `build/release/bin`
### On FreeBSD:
The project can be built from scratch by following instructions for Unix and Linux above.
The project can be built from scratch by following instructions for Linux above.
We expect to add Monero into the ports tree in the near future, which will aid in managing installations using ports or packages.
@ -198,14 +191,32 @@ You will have to add the serialization, date_time, and regex modules to Boost wh
To build: `env CC=egcc CXX=eg++ CPP=ecpp DEVELOPER_LOCAL_TOOLS=1 BOOST_ROOT=/path/to/the/boost/you/built make release-static-64`
## Building Documentation
### Building Portable Statically Linked Binaries
By default, in either dynamically or statically linked builds, binaries target the specific host processor on which the build happens and are not portable to other processors. Portable binaries can be built using the following targets:
* ```make release-static-64``` builds binaries on Linux on x86_64 portable across POSIX systems on x86_64 processors
* ```make release-static-32``` builds binaries on Linux on x86_64 or i686 portable across POSIX systems on i686 processors
* ```make release-static-arm7``` builds binaries on Linux on armv7 portable across POSIX systesm on armv7 processors
* ```make release-static-arm6``` builds binaries on Linux on armv7 or armv6 portable across POSIX systems on armv6 processors, such as the Raspberry Pi
* ```make release-static-win64``` builds binaries on 64-bit Windows portable across 64-bit Windows systems
* ```make release-static-win32``` builds binaries on 64-bit or 32-bit Windows portable across 32-bit Windows systems
### Building Documentation
Monero developer documentation uses Doxygen, and is currently a work-in-progress.
Dependencies: Doxygen 1.8.0 or later, Graphviz 2.28 or later (optional).
Dependencies: Doxygen `>=1.8.0`, Graphviz `>=2.28` (optional).
* To build the HTML documentation without diagrams, change
to the root of the source code directory, and run
doxygen Doxyfile
* To build the HTML documentation with diagrams (Graphviz required):
HAVE_DOT=YES doxygen Doxyfile
* To build, change to the root of the source code directory, and run `doxygen Doxyfile`
* If you have installed Graphviz, you can also generate in-doc diagrams by instead running `HAVE_DOT=YES doxygen Doxyfile`
* The output will be built in doc/html/
## Running bitmonerod