Skip to content

Commit a5430f7

Browse files
committed
Add a configure option to disable assembly code
1 parent ab6d34e commit a5430f7

12 files changed

+26
-16
lines changed

Makefile.am

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dist_man_MANS = minerd.1
1818
minerd_SOURCES = elist.h miner.h compat.h \
1919
cpu-miner.c util.c \
2020
sha2.c scrypt.c
21+
if USE_ASM
2122
if ARCH_x86
2223
minerd_SOURCES += sha2-x86.S scrypt-x86.S
2324
endif
@@ -27,6 +28,7 @@ endif
2728
if ARCH_ARM
2829
minerd_SOURCES += sha2-arm.S scrypt-arm.S
2930
endif
31+
endif
3032
minerd_LDFLAGS = $(PTHREAD_FLAGS)
3133
minerd_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@
3234
minerd_CPPFLAGS = @LIBCURL_CPPFLAGS@

configure.ac

+8-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ case $target in
6161
;;
6262
esac
6363

64-
if test x$have_x86 = xtrue -o x$have_x86_64 = xtrue
64+
AC_ARG_ENABLE([assembly],
65+
AS_HELP_STRING([--disable-assembly], [disable assembly-language routines]))
66+
if test x$enable_assembly != xno; then
67+
AC_DEFINE([USE_ASM], [1], [Define to 1 if assembly routines are wanted.])
68+
fi
69+
70+
if test x$enable_assembly != xno -a x$have_x86_64 = xtrue
6571
then
6672
AC_MSG_CHECKING(whether we can compile AVX code)
6773
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[asm ("vmovdqa %ymm0, %ymm1");])],
@@ -98,6 +104,7 @@ AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS="-lpthread",
98104

99105
AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
100106
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
107+
AM_CONDITIONAL([USE_ASM], [test x$enable_assembly != xno])
101108
AM_CONDITIONAL([ARCH_x86], [test x$have_x86 = xtrue])
102109
AM_CONDITIONAL([ARCH_x86_64], [test x$have_x86_64 = xtrue])
103110
AM_CONDITIONAL([ARCH_ARM], [test x$have_arm = xtrue])

cpu-miner.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1395,13 +1395,13 @@ static void *stratum_thread(void *userdata)
13951395
static void show_version_and_exit(void)
13961396
{
13971397
printf(PACKAGE_STRING "\n built on " __DATE__ "\n features:"
1398-
#if defined(__i386__)
1398+
#if defined(USE_ASM) && defined(__i386__)
13991399
" i386"
14001400
#endif
1401-
#if defined(__x86_64__)
1401+
#if defined(USE_ASM) && defined(__x86_64__)
14021402
" x86_64"
14031403
#endif
1404-
#if defined(__i386__) || defined(__x86_64__)
1404+
#if defined(USE_ASM) && (defined(__i386__) || defined(__x86_64__))
14051405
" SSE2"
14061406
#endif
14071407
#if defined(__x86_64__) && defined(USE_AVX)
@@ -1413,7 +1413,7 @@ static void show_version_and_exit(void)
14131413
#if defined(__x86_64__) && defined(USE_XOP)
14141414
" XOP"
14151415
#endif
1416-
#if defined(__arm__) && defined(__APCS_32__)
1416+
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
14171417
" ARM"
14181418
#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
14191419
defined(__ARM_ARCH_5TEJ__) || defined(__ARM_ARCH_6__) || \

miner.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,20 @@ void sha256_init(uint32_t *state);
136136
void sha256_transform(uint32_t *state, const uint32_t *block, int swap);
137137
void sha256d(unsigned char *hash, const unsigned char *data, int len);
138138

139+
#ifdef USE_ASM
139140
#if defined(__ARM_NEON__) || defined(__i386__) || defined(__x86_64__)
140141
#define HAVE_SHA256_4WAY 1
141142
int sha256_use_4way();
142143
void sha256_init_4way(uint32_t *state);
143144
void sha256_transform_4way(uint32_t *state, const uint32_t *block, int swap);
144145
#endif
145-
146146
#if defined(__x86_64__) && defined(USE_AVX2)
147147
#define HAVE_SHA256_8WAY 1
148148
int sha256_use_8way();
149149
void sha256_init_8way(uint32_t *state);
150150
void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
151151
#endif
152+
#endif
152153

153154
extern int scanhash_sha256d(int thr_id, uint32_t *pdata,
154155
const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done);

scrypt-arm.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "cpuminer-config.h"
1111

12-
#if defined(__arm__) && defined(__APCS_32__)
12+
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
1313

1414
#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
1515
defined(__ARM_ARCH_5TEJ__) || defined(__ARM_ARCH_6__) || \

scrypt-x64.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
.section .note.GNU-stack,"",%progbits
3131
#endif
3232

33-
#if defined(__x86_64__)
33+
#if defined(USE_ASM) && defined(__x86_64__)
3434

3535
.text
3636
.p2align 6

scrypt-x86.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
.section .note.GNU-stack,"",%progbits
3131
#endif
3232

33-
#if defined(__i386__)
33+
#if defined(USE_ASM) && defined(__i386__)
3434

3535
.macro scrypt_shuffle src, so, dest, do
3636
movl \so+60(\src), %eax

scrypt.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static inline void PBKDF2_SHA256_128_32_8way(uint32_t *tstate,
378378
#endif /* HAVE_SHA256_8WAY */
379379

380380

381-
#if defined(__x86_64__)
381+
#if defined(USE_ASM) && defined(__x86_64__)
382382

383383
#define SCRYPT_MAX_WAYS 12
384384
#define HAVE_SCRYPT_3WAY 1
@@ -392,13 +392,13 @@ void scrypt_core_3way(uint32_t *X, uint32_t *V);
392392
void scrypt_core_6way(uint32_t *X, uint32_t *V);
393393
#endif
394394

395-
#elif defined(__i386__)
395+
#elif defined(USE_ASM) && defined(__i386__)
396396

397397
#define SCRYPT_MAX_WAYS 4
398398
#define scrypt_best_throughput() 1
399399
void scrypt_core(uint32_t *X, uint32_t *V);
400400

401-
#elif defined(__arm__) && defined(__APCS_32__)
401+
#elif defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
402402

403403
void scrypt_core(uint32_t *X, uint32_t *V);
404404
#if defined(__ARM_NEON__)

sha2-arm.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "cpuminer-config.h"
1111

12-
#if defined(__arm__) && defined(__APCS_32__)
12+
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
1313

1414
.macro sha256_k
1515
.align 2

sha2-x64.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.section .note.GNU-stack,"",%progbits
1414
#endif
1515

16-
#if defined(__x86_64__)
16+
#if defined(USE_ASM) && defined(__x86_64__)
1717

1818
.data
1919
.p2align 7

sha2-x86.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.section .note.GNU-stack,"",%progbits
1414
#endif
1515

16-
#if defined(__i386__)
16+
#if defined(USE_ASM) && defined(__i386__)
1717

1818
.data
1919
.p2align 7

sha2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <string.h>
1515
#include <inttypes.h>
1616

17-
#if defined(__arm__) && defined(__APCS_32__)
17+
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
1818
#define EXTERN_SHA256
1919
#endif
2020

0 commit comments

Comments
 (0)