From c54b9a1a05fca44703e5a3359c2725d26ff60bc4 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 01:37:34 -0400 Subject: [PATCH 1/8] cmake: don't set ARCH from CMAKE_SYSTEM_PROCESSOR It is not correct to do so, because ARCH should only take values supported by the -march argument, with the exception of 'default' which denotes not passing -march at all. ARCH defines the target architecture for builds that are intended to be portable to other machines. --- CMakeLists.txt | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ac4a2f95..fc546c007 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,31 +45,26 @@ 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") - set(ARM6 1) - else() - set(ARM6 0) - endif() - - if (${ARM_TEST} STREQUAL "armv7") - set(ARM7 1) - else() - set(ARM7 0) - endif() - endif() +string(SUBSTRING ${ARCH_ID} 0 5 ARM_TEST) +string(TOLOWER ${ARM_TEST} ARM_TEST) +if (${ARM_TEST} STREQUAL "armv6") + set(ARM6 1) +endif() +if (${ARM_TEST} STREQUAL "armv7") + set(ARM7 1) endif() if(WIN32 OR ARM7 OR ARM6) @@ -312,9 +307,9 @@ 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") From c2bc34b7366e9f5dcb62603bf3ac79b88357c2b0 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 01:42:59 -0400 Subject: [PATCH 2/8] Revert "Interpret x86_64 as x86-64 for architecture" This reverts commit 86234921506944dddab4e2f5edf96bf747be6c73. Let's restrict ARCH to values accepted by -march to keep things clear and consistent. ARCH is -march, with only one exception: a value of "default" indicates to not pass -march at all. --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc546c007..ed5fc142d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,11 +312,7 @@ else() 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() + set(ARCH_FLAG "-march=${ARCH}") 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) From a0d40587ea0b7bdc4084bcd7727d876948d30d7d Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 01:44:33 -0400 Subject: [PATCH 3/8] Revert "makefile: remove unnecessary ARM-specific targets" This reverts commit ecd0f2dde7b2d8f3ff820d1190c00401c436384a. These targets that are not native builds. They are for builds portable within processors of a given family. 'make release' used to not work to build a native build on ARM, but that has been fixed. These targets are unrelated to the native build. --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 69d1127de..b02f92ad5 100644 --- a/Makefile +++ b/Makefile @@ -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-arm6: + mkdir -p build/release + cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D BUILD_64=OFF -D NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + +release-arm7: + mkdir -p build/release + cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D BUILD_64=OFF -D NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + release-static: release-static-64 release-static-64: From 43c07a1cfa4799921f507b4afbbca9fdd7a781ea Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 04:15:55 -0400 Subject: [PATCH 4/8] readme: editted install/build instructions for clarity * some re-org of sections to make things more concise * dedicated section for installing from packages vs building from source * for Windows, instruct to run the top-level makefile targets, because I don't see any reason not to -- advanced users will look into the makefile and find the cmake command there if they need to. * for Windows, instruct to install *-toolchain meta package which includes expat * added some context info here and there to aid -- I tried to clarify things that confused me, e.g. Windows build is cross-compilation to be precise; motivation for targets that are meant for generating portable binaries as opposed to binaries optimized to host CPU. --- README.md | 179 +++++++++++++++++++++++++++++------------------------- 1 file changed, 95 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index 394bee2d6..24243322c 100644 --- a/README.md +++ b/README.md @@ -56,11 +56,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` @@ -72,113 +83,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` 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` 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` + + 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: + + 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` 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. @@ -197,14 +190,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 From 57ca3f3f64ebfcd83af899cbff58e683198152a0 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 05:35:27 -0400 Subject: [PATCH 5/8] make: make the ARM release targets statically linked I think, in this context, dynamically linked builds make sense only for native builds, not these builds that target arch families to produce portable binaries. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b02f92ad5..d1dea23a3 100644 --- a/Makefile +++ b/Makefile @@ -58,13 +58,13 @@ release-all: mkdir -p build/release cd build/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) -release-arm6: +release-static-arm6: mkdir -p build/release - cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D BUILD_64=OFF -D NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D STATIC=ON -D BUILD_64=OFF -D NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) -release-arm7: +release-static-arm7: mkdir -p build/release - cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D BUILD_64=OFF -D NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) release-static: release-static-64 From 397b720069e4c6011e20c6f9d4848c6092f002f3 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 05:42:06 -0400 Subject: [PATCH 6/8] make: remove NO_AES from arm targets cmake sets that appropriately based on the target architecture --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d1dea23a3..1b52fe2d0 100644 --- a/Makefile +++ b/Makefile @@ -60,11 +60,11 @@ release-all: 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 NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + 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 NO_AES=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + 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 From 6fe543dcd4b0fbb8b01162e4d65ee1d6f093b6c0 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 07:12:36 -0400 Subject: [PATCH 7/8] cmake: ARM: exclude libunwind in static build Else error in build with STATIC=ON: cd /home/redfish/bitmonero/build/release/src/miner && /usr/bin/cmake -E cmake_link_script CMakeFiles/simpleminer.dir/link.txt --verbose=1 /usr/bin/c++ -std=c++11 -D_GNU_SOURCE -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 -Wlogical-op -Wno-error=maybe-uninitialized -Wno-reorder -Wno-missing-field-initializers -march=armv7-a -fno-strict-aliasing -mfloat-abi=hard -DNDEBUG -O2 -flto -ffat-lto-objects -static-libgcc -static-libstdc++ -Wl,--wrap=__cxa_throw CMakeFiles/simpleminer.dir/simpleminer.cpp.o -o ../../bin/simpleminer -rdynamic -Wl,-Bstatic -lrt -Wl,-Bdynamic -ldl ../cryptonote_core/libcryptonote_core.a ../common/libcommon.a -Wl,-Bstatic -lboost_filesystem -lboost_program_options -lboost_regex -lboost_chrono -lboost_system -lboost_thread -Wl,-Bdynamic -pthread -Wl,-Bstatic -lrt -Wl,-Bdynamic -ldl ../blockchain_db/libblockchain_db.a ../cryptonote_core/libcryptonote_core.a ../blockchain_db/libblockchain_db.a ../../contrib/otshell_utils/libotshell_utils.a ../blocks/libblocks.a ../common/libcommon.a ../../external/unbound/libunbound.a -lssl -lcrypto -lunwind -Wl,-Bstatic -lboost_program_options ../crypto/libcrypto.a -lboost_date_time -lboost_serialization -lboost_filesystem ../../external/db_drivers/liblmdb/liblmdb.a -Wl,-Bdynamic -pthread -Wl,-Bstatic -lboost_chrono -lboost_system -lboost_thread -lrt -Wl,-Bdynamic -ldl /usr/bin/ld: ../../bin/simpleminer: hidden symbol `__aeabi_unwind_cpp_pr0' in /usr/lib/gcc/armv7l-unknown-linux-gnueabihf/6.1.1/libgcc_eh.a(unwind-arm.o) is referenced by DSO /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed5fc142d..80f03a168 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,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 ARM6 OR ARM7))) set(DEFAULT_STACK_TRACE ON) else() set(DEFAULT_STACK_TRACE OFF) From 1c7d3b05a9bd35c66fd12b6f0ea6e56bb7d46a89 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 28 Aug 2016 07:28:05 -0400 Subject: [PATCH 8/8] cmake: define ARM var for all ARM arch variants This is refactoring only. No behavior change. --- CMakeLists.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f03a168..26a3211d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,16 +58,20 @@ if (NOT ARCH OR ARCH STREQUAL "" OR ARCH STREQUAL "native" OR ARCH STREQUAL "def else() set(ARCH_ID "${ARCH}") endif() -string(SUBSTRING ${ARCH_ID} 0 5 ARM_TEST) -string(TOLOWER ${ARM_TEST} ARM_TEST) -if (${ARM_TEST} STREQUAL "armv6") - set(ARM6 1) -endif() -if (${ARM_TEST} STREQUAL "armv7") - set(ARM7 1) +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) + endif() + if (ARM_TEST STREQUAL "armv7") + set(ARM7 1) + 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 +251,7 @@ 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 # On ARM, having libunwind package (with .so's only) installed breaks static link. -if(LIBUNWIND_FOUND AND NOT (STATIC AND (APPLE OR ARM6 OR ARM7))) +if(LIBUNWIND_FOUND AND NOT (STATIC AND (APPLE OR ARM))) set(DEFAULT_STACK_TRACE ON) else() set(DEFAULT_STACK_TRACE OFF) @@ -321,7 +325,7 @@ else() 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() @@ -358,11 +362,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")