From bcc25dee1b1ea5b0c31c36d8c366b591875d5d1c Mon Sep 17 00:00:00 2001 From: Jethro Grassie Date: Wed, 21 Aug 2019 19:35:30 -0400 Subject: [PATCH] ease building with / without randomx --- Makefile | 14 ++++++++++++-- src/pool.c | 5 +++++ src/xmr.cpp | 4 +++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 76748ac..c48f2f2 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,9 @@ MONERO_LIBS = \ ${MONERO_BUILD_ROOT}/src/ringct/libringct_basic.a \ ${MONERO_BUILD_ROOT}/src/device/libdevice.a \ ${MONERO_BUILD_ROOT}/contrib/epee/src/libepee.a \ - ${MONERO_BUILD_ROOT}/external/easylogging++/libeasylogging.a \ - ${MONERO_BUILD_ROOT}/external/randomx/librandomx.a + ${MONERO_BUILD_ROOT}/external/easylogging++/libeasylogging.a + +LIBRX = ${MONERO_BUILD_ROOT}/external/randomx/librandomx.a DIRS = src data rxi/log/src @@ -65,6 +66,15 @@ OS := $(shell uname -s) CPPDEFS = _GNU_SOURCE AUTO_INITIALIZE_EASYLOGGINGPP LOG_USE_COLOR +ifeq ($(wildcard ${LIBRX}),${LIBRX}) + MONERO_LIBS += ${LIBRX} + CPPDEFS += HAVE_RX +else + ifneq ($(MAKECMDGOALS),clean) + $(warning Building without RandomX!) + endif +endif + W = -W -Wall -Wno-unused-parameter -Wuninitialized OPT = -maes -fPIC CFLAGS = $(W) -Wbad-function-cast $(OPT) -std=c99 diff --git a/src/pool.c b/src/pool.c index 1f90da3..4c38ffc 100644 --- a/src/pool.c +++ b/src/pool.c @@ -248,8 +248,13 @@ static FILE *fd_log; static unsigned char sec_view[32]; static unsigned char pub_spend[32]; +#ifdef HAVE_RX extern void rx_stop_mining(); extern void rx_slow_hash_free_state(); +#else +void rx_stop_mining(){} +void rx_slow_hash_free_state(){} +#endif #define JSON_GET_OR_ERROR(name, parent, type, client) \ json_object *name = NULL; \ diff --git a/src/xmr.cpp b/src/xmr.cpp index 44b238b..fa9afe0 100644 --- a/src/xmr.cpp +++ b/src/xmr.cpp @@ -105,13 +105,15 @@ void get_rx_hash(const unsigned char *input, const size_t in_size, unsigned char *output, const unsigned char *seed_hash, const uint64_t height) { - static unsigned max_concurrency = 1;//tools::get_max_concurrency(); +#ifdef HAVE_RX + static unsigned max_concurrency = tools::get_max_concurrency(); uint64_t seed_height; if (rx_needhash(height, &seed_height)) { rx_seedhash(seed_height, (const char*)seed_hash, max_concurrency); } rx_slow_hash((const char*)input, in_size, (char*)output, max_concurrency); +#endif } int validate_block_from_blob(const char *blob_hex,