Skip to content

Commit cc05fa9

Browse files
committed
Squashed 'src/secp256k1/' changes from 0b70241..ee99f12
ee99f12 Merge bitcoin#599: Switch x86_64 asm to use "i" instead of "n" for immediate values. d58bc93 Switch x86_64 asm to use "i" instead of "n" for immediate values. 05362ee Merge bitcoin#597: Add $(COMMON_LIB) to exhaustive tests to fix ARM asm build 8348386 Add $(COMMON_LIB) to exhaustive tests to fix ARM asm build aa15154 Merge bitcoin#568: Fix integer overflow in ecmult_multi_var when n is large 2277af5 Fix integer overflow in ecmult_multi_var when n is large 85d0e1b Merge bitcoin#591: Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing. 1419637 Merge bitcoin#580: Add trivial ecmult_multi algorithm which does not require a scratch space a697d82 Add trivial ecmult_multi to the benchmark tool bade617 Add trivial ecmult_multi algorithm. It is selected when no scratch space is given and just multiplies and adds the points. 5545e13 Merge bitcoin#584: configure: Use CFLAGS_FOR_BUILD when checking native compiler 20c5869 Merge bitcoin#516: improvements to random seed in src/tests.c b76e45d Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing. 870a977 Merge bitcoin#562: Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse be40c4d Fixup for C90 mixed declarations. c71dd2c Merge bitcoin#509: Fix algorithm selection in bench_ecmult 6492bf8 Merge bitcoin#518: Summarize build options after running configure 0e9ada1 Merge bitcoin#567: Correct order of libs returned on pkg-config --libs --static libsecp2… e96901a Merge bitcoin#587: Make randomization of a non-signing context a noop 58df8d0 Merge bitcoin#511: Portability fix for the configure scripts generated 2ebdad7 Merge bitcoin#552: Make constants static: 1c131af Merge bitcoin#551: secp256k1_fe_sqrt: Verify that the arguments don't alias. ba698f8 Merge bitcoin#539: Assorted minor corrections 949e85b Merge bitcoin#550: Optimize secp256k1_fe_normalize_weak calls. a34bcaa Actually pass CFLAGS_FOR_BUILD and LDFLAGS_FOR_BUILD to linker 2d5f4ce configure: Use CFLAGS_FOR_BUILD when checking native compiler b408c6a Merge bitcoin#579: Use __GNUC_PREREQ for detecting __builtin_expect 6198375 Make randomization of a non-signing context a noop c663397 Use __GNUC_PREREQ for detecting __builtin_expect e34ceb3 Merge bitcoin#557: Eliminate scratch memory used when generating contexts b3bf5f9 ecmult_impl: expand comment to explain how effective affine interacts with everything efa783f Store z-ratios in the 'x' coord they'll recover ffd3b34 add `secp256k1_ge_set_all_gej_var` test which deals with many infinite points 84740ac ecmult_impl: save one fe_inv_var 4704527 ecmult_impl: eliminate scratch memory used when generating context 7f7a2ed ecmult_gen_impl: eliminate scratch memory used when generating context 314a61d Merge bitcoin#553: add static context object which has no capabilities 89a20a8 Correct order of libs returned on pkg-config --libs --static libsecp256k1 call. 1086fda Merge bitcoin#354: [ECDH API change] Support custom hash function d3cb1f9 Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse 40fde61 prevent attempts to modify `secp256k1_context_no_precomp` ed7c084 add static context object which has no capabilities 496c5b4 Make constants static: static const secp256k1_ge secp256k1_ge_const_g; static const int CURVE_B; bf8b86c secp256k1_fe_sqrt: Verify that the arguments don't alias. 9bd89c8 Optimize secp256k1_fe_normalize_weak calls. Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead. 52ab96f clean dependendies in field_*_impl.h deff5ed Correct math typos in field_*.h 4efb3f8 Add check that restrict pointers don't alias with all parameters. 1e6f1f5 Merge bitcoin#529: fix tests.c in the count == 0 case c8fbc3c [ECDH API change] Allow pass arbitrary data to hash function b00be65 [ECDH API change] Support custom hash function 95e99f1 fix tests.c in the count == 0 case 452d8e4 Merge bitcoin#523: scratch: add stack frame support 6fe5043 scratch: add stack frame support 9bc2e26 Merge bitcoin#522: parameterize ecmult_const over input size 7c1b91b parameterize ecmult_const over input size dbc3ddd Merge bitcoin#513: Increase sparsity of pippenger fixed window naf representation 3965027 Summarize build options in configure script 0f05173 Fix algorithm selection in bench_ecmult fb9271d Merge bitcoin#510: add a couple missing `const`s to ecmult_pippenger_wnaf cd5f602 Merge bitcoin#515: Fix typo 09146ae Merge bitcoin#512: secp256k1_ec_privkey_negate - fix documentation ec0a7b3 Don't touch leading zeros in wnaf_fixed. 9e36d1b Fix bug in wnaf_fixed where the wnaf array is not completely zeroed when given a 0 scalar. 96f68a0 Don't invert scalar in wnaf_fixed when it is even because a caller might intentionally give a scalar with many leading zeros. 8b3841c fix bug in fread() failure check cddef0c tests: add warning message when /dev/urandom fails 9b7c47a Fix typo 6dbb007 Increase sparsity of pippenger fixed window naf representation 1646ace secp256k1_ec_privkey_negate - fix documentation 270f6c8 Portability fix for the configure scripts generated 9b3ff03 add a couple missing `const`s to ecmult_pippenger_wnaf cd329db Merge bitcoin#460: [build] Update ax_jni_include_dir.m4 macro 7f9c1a1 Merge bitcoin#498: tests: Avoid calling fclose(...) with an invalid argument f99aa8d Merge bitcoin#499: tests: Make sure we get the requested number of bytes from /dev/urandom b549d3d Merge bitcoin#472: [build] Set --enable-jni to no by default instead of auto. d333521 Merge bitcoin#494: Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS 2ef8ea5 Merge bitcoin#495: Add bench_ecmult to .gitignore 82a96e4 tests: Make sure we get the requested number of bytes from /dev/urandom 5aae5b5 Avoid calling fclose(...) with an invalid argument cb32940 Add bench_ecmult to .gitignore 31abd3a Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS c95f6f1 Merge bitcoin#487: fix tests typo, s/changed/unchanged fb46c83 Merge bitcoin#463: Reduce usage of hardcoded size constants 02f5001 Merge bitcoin#490: Disambiguate bench functions and types 1f46d60 Disambiguate bench functions and types f54c6c5 Merge bitcoin#480: Enable benchmark building by default c77fc08 Merge bitcoin#486: Add pippenger_wnaf for multi-multiplication d2f9c6b Use more precise pippenger bucket windows 4c950bb Save some additions per window in _pippenger_wnaf a58f543 Add flags for choosing algorithm in ecmult_multi benchmark 36b22c9 Use scratch space dependent batching in ecmult_multi 355a38f Add pippenger_wnaf ecmult_multi bc65aa7 Add bench_ecmult dba5471 Add ecmult_multi tests 8c1c831 Generalize Strauss to support multiple points 548de42 add resizeable scratch space API 0e96cdc fix typo, s/changed/unchanged c7680e5 Reduce usage of hardcoded size constants 6ad5cdb Merge bitcoin#479: Get rid of reserved _t in type names 7a78f60 Print whether we're building benchmarks 4afec9f Build benchmarks by default d1dc9df Get rid of reserved _t in type names 57752d2 [build] Set --enable-jni to no by default instead of auto. e7daa9b [build] Tweak JNI macro to warn instead of error for JNI not found. 5b22977 [build] Update ax_jni_include_dir.m4 macro to deal with recent versions of macOS git-subtree-dir: src/secp256k1 git-subtree-split: ee99f12
1 parent fd86f99 commit cc05fa9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2414
-414
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bench_inv
22
bench_ecdh
3+
bench_ecmult
34
bench_sign
45
bench_verify
56
bench_schnorr_verify

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cache:
1111
- src/java/guava/
1212
env:
1313
global:
14-
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no
14+
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no JNI=no
1515
- GUAVA_URL=https://search.maven.org/remotecontent?filepath=com/google/guava/guava/18.0/guava-18.0.jar GUAVA_JAR=src/java/guava/guava-18.0.jar
1616
matrix:
1717
- SCALAR=32bit RECOVERY=yes
@@ -29,7 +29,7 @@ env:
2929
- BUILD=distcheck
3030
- EXTRAFLAGS=CPPFLAGS=-DDETERMINISTIC
3131
- EXTRAFLAGS=CFLAGS=-O0
32-
- BUILD=check-java ECDH=yes EXPERIMENTAL=yes
32+
- BUILD=check-java JNI=yes ECDH=yes EXPERIMENTAL=yes
3333
matrix:
3434
fast_finish: true
3535
include:
@@ -65,5 +65,5 @@ before_script: ./autogen.sh
6565
script:
6666
- if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi
6767
- if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi
68-
- ./configure --enable-experimental=$EXPERIMENTAL --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --enable-module-ecdh=$ECDH --enable-module-recovery=$RECOVERY $EXTRAFLAGS $USE_HOST && make -j2 $BUILD
68+
- ./configure --enable-experimental=$EXPERIMENTAL --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --enable-module-ecdh=$ECDH --enable-module-recovery=$RECOVERY --enable-jni=$JNI $EXTRAFLAGS $USE_HOST && make -j2 $BUILD
6969
os: linux

Makefile.am

+9-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ noinst_HEADERS += src/field_5x52_asm_impl.h
4242
noinst_HEADERS += src/java/org_bitcoin_NativeSecp256k1.h
4343
noinst_HEADERS += src/java/org_bitcoin_Secp256k1Context.h
4444
noinst_HEADERS += src/util.h
45+
noinst_HEADERS += src/scratch.h
46+
noinst_HEADERS += src/scratch_impl.h
4547
noinst_HEADERS += src/testrand.h
4648
noinst_HEADERS += src/testrand_impl.h
4749
noinst_HEADERS += src/hash.h
@@ -79,14 +81,17 @@ libsecp256k1_jni_la_CPPFLAGS = -DSECP256K1_BUILD $(JNI_INCLUDES)
7981

8082
noinst_PROGRAMS =
8183
if USE_BENCHMARK
82-
noinst_PROGRAMS += bench_verify bench_sign bench_internal
84+
noinst_PROGRAMS += bench_verify bench_sign bench_internal bench_ecmult
8385
bench_verify_SOURCES = src/bench_verify.c
8486
bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
8587
bench_sign_SOURCES = src/bench_sign.c
8688
bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
8789
bench_internal_SOURCES = src/bench_internal.c
8890
bench_internal_LDADD = $(SECP_LIBS) $(COMMON_LIB)
8991
bench_internal_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES)
92+
bench_ecmult_SOURCES = src/bench_ecmult.c
93+
bench_ecmult_LDADD = $(SECP_LIBS) $(COMMON_LIB)
94+
bench_ecmult_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES)
9095
endif
9196

9297
TESTS =
@@ -109,7 +114,7 @@ exhaustive_tests_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/src $(SECP_INCLUDE
109114
if !ENABLE_COVERAGE
110115
exhaustive_tests_CPPFLAGS += -DVERIFY
111116
endif
112-
exhaustive_tests_LDADD = $(SECP_LIBS)
117+
exhaustive_tests_LDADD = $(SECP_LIBS) $(COMMON_LIB)
113118
exhaustive_tests_LDFLAGS = -static
114119
TESTS += exhaustive_tests
115120
endif
@@ -146,19 +151,19 @@ endif
146151

147152
if USE_ECMULT_STATIC_PRECOMPUTATION
148153
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir)
149-
CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function
150154

151155
gen_context_OBJECTS = gen_context.o
152156
gen_context_BIN = gen_context$(BUILD_EXEEXT)
153157
gen_%.o: src/gen_%.c
154158
$(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@
155159

156160
$(gen_context_BIN): $(gen_context_OBJECTS)
157-
$(CC_FOR_BUILD) $^ -o $@
161+
$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $^ -o $@
158162

159163
$(libsecp256k1_la_OBJECTS): src/ecmult_static_context.h
160164
$(tests_OBJECTS): src/ecmult_static_context.h
161165
$(bench_internal_OBJECTS): src/ecmult_static_context.h
166+
$(bench_ecmult_OBJECTS): src/ecmult_static_context.h
162167

163168
src/ecmult_static_context.h: $(gen_context_BIN)
164169
./$(gen_context_BIN)

build-aux/m4/ax_jni_include_dir.m4

+26-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===========================================================================
2-
# http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
2+
# https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
33
# ===========================================================================
44
#
55
# SYNOPSIS
@@ -44,7 +44,7 @@
4444
# and this notice are preserved. This file is offered as-is, without any
4545
# warranty.
4646

47-
#serial 10
47+
#serial 14
4848

4949
AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR])
5050
AC_DEFUN([AX_JNI_INCLUDE_DIR],[
@@ -66,40 +66,45 @@ else
6666
fi
6767
6868
case "$host_os" in
69-
darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
70-
_JINC="$_JTOPDIR/Headers";;
71-
*) _JINC="$_JTOPDIR/include";;
69+
darwin*) # Apple Java headers are inside the Xcode bundle.
70+
macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p')
71+
if @<:@ "$macos_version" -gt "7" @:>@; then
72+
_JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
73+
_JINC="$_JTOPDIR/Headers"
74+
else
75+
_JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
76+
_JINC="$_JTOPDIR/Headers"
77+
fi
78+
;;
79+
*) _JINC="$_JTOPDIR/include";;
7280
esac
7381
_AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR])
7482
_AS_ECHO_LOG([_JINC=$_JINC])
7583
7684
# On Mac OS X 10.6.4, jni.h is a symlink:
7785
# /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h
7886
# -> ../../CurrentJDK/Headers/jni.h.
79-
8087
AC_CACHE_CHECK(jni headers, ac_cv_jni_header_path,
8188
[
82-
if test -f "$_JINC/jni.h"; then
83-
ac_cv_jni_header_path="$_JINC"
84-
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
85-
else
86-
_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
87-
if test -f "$_JTOPDIR/include/jni.h"; then
88-
ac_cv_jni_header_path="$_JTOPDIR/include"
89+
if test -f "$_JINC/jni.h"; then
90+
ac_cv_jni_header_path="$_JINC"
8991
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
9092
else
91-
ac_cv_jni_header_path=none
93+
_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
94+
if test -f "$_JTOPDIR/include/jni.h"; then
95+
ac_cv_jni_header_path="$_JTOPDIR/include"
96+
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
97+
else
98+
ac_cv_jni_header_path=none
99+
fi
92100
fi
93-
fi
94101
])
95102
96-
97-
98103
# get the likely subdirectories for system specific java includes
99104
case "$host_os" in
100105
bsdi*) _JNI_INC_SUBDIRS="bsdos";;
101-
darwin*) _JNI_INC_SUBDIRS="darwin";;
102106
freebsd*) _JNI_INC_SUBDIRS="freebsd";;
107+
darwin*) _JNI_INC_SUBDIRS="darwin";;
103108
linux*) _JNI_INC_SUBDIRS="linux genunix";;
104109
osf*) _JNI_INC_SUBDIRS="alpha";;
105110
solaris*) _JNI_INC_SUBDIRS="solaris";;
@@ -112,9 +117,9 @@ if test "x$ac_cv_jni_header_path" != "xnone"; then
112117
# add any subdirectories that are present
113118
for JINCSUBDIR in $_JNI_INC_SUBDIRS
114119
do
115-
if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
116-
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
117-
fi
120+
if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
121+
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
122+
fi
118123
done
119124
fi
120125
])

build-aux/m4/bitcoin_secp.m4

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then
4848
EC_KEY_free(eckey);
4949
ECDSA_SIG *sig_openssl;
5050
sig_openssl = ECDSA_SIG_new();
51-
(void)sig_openssl->r;
5251
ECDSA_SIG_free(sig_openssl);
5352
]])],[has_openssl_ec=yes],[has_openssl_ec=no])
5453
AC_MSG_RESULT([$has_openssl_ec])

configure.ac

+60-29
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
8585
])
8686

8787
AC_ARG_ENABLE(benchmark,
88-
AS_HELP_STRING([--enable-benchmark],[compile benchmark (default is no)]),
88+
AS_HELP_STRING([--enable-benchmark],[compile benchmark (default is yes)]),
8989
[use_benchmark=$enableval],
90-
[use_benchmark=no])
90+
[use_benchmark=yes])
9191

9292
AC_ARG_ENABLE(coverage,
9393
AS_HELP_STRING([--enable-coverage],[enable compiler flags to support kcov coverage analysis]),
@@ -135,9 +135,9 @@ AC_ARG_ENABLE(module_recovery,
135135
[enable_module_recovery=no])
136136

137137
AC_ARG_ENABLE(jni,
138-
AS_HELP_STRING([--enable-jni],[enable libsecp256k1_jni (default is auto)]),
138+
AS_HELP_STRING([--enable-jni],[enable libsecp256k1_jni (default is no)]),
139139
[use_jni=$enableval],
140-
[use_jni=auto])
140+
[use_jni=no])
141141

142142
AC_ARG_WITH([field], [AS_HELP_STRING([--with-field=64bit|32bit|auto],
143143
[Specify Field Implementation. Default is auto])],[req_field=$withval], [req_field=auto])
@@ -153,12 +153,6 @@ AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|arm|no|auto]
153153

154154
AC_CHECK_TYPES([__int128])
155155

156-
AC_MSG_CHECKING([for __builtin_expect])
157-
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])],
158-
[ AC_MSG_RESULT([yes]);AC_DEFINE(HAVE_BUILTIN_EXPECT,1,[Define this symbol if __builtin_expect is available]) ],
159-
[ AC_MSG_RESULT([no])
160-
])
161-
162156
if test x"$enable_coverage" = x"yes"; then
163157
AC_DEFINE(COVERAGE, 1, [Define this symbol to compile out all VERIFY code])
164158
CFLAGS="$CFLAGS -O0 --coverage"
@@ -168,27 +162,54 @@ else
168162
fi
169163

170164
if test x"$use_ecmult_static_precomputation" != x"no"; then
165+
# Temporarily switch to an environment for the native compiler
171166
save_cross_compiling=$cross_compiling
172167
cross_compiling=no
173-
TEMP_CC="$CC"
168+
SAVE_CC="$CC"
174169
CC="$CC_FOR_BUILD"
175-
AC_MSG_CHECKING([native compiler: ${CC_FOR_BUILD}])
170+
SAVE_CFLAGS="$CFLAGS"
171+
CFLAGS="$CFLAGS_FOR_BUILD"
172+
SAVE_CPPFLAGS="$CPPFLAGS"
173+
CPPFLAGS="$CPPFLAGS_FOR_BUILD"
174+
SAVE_LDFLAGS="$LDFLAGS"
175+
LDFLAGS="$LDFLAGS_FOR_BUILD"
176+
177+
warn_CFLAGS_FOR_BUILD="-Wall -Wextra -Wno-unused-function"
178+
saved_CFLAGS="$CFLAGS"
179+
CFLAGS="$CFLAGS $warn_CFLAGS_FOR_BUILD"
180+
AC_MSG_CHECKING([if native ${CC_FOR_BUILD} supports ${warn_CFLAGS_FOR_BUILD}])
181+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
182+
[ AC_MSG_RESULT([yes]) ],
183+
[ AC_MSG_RESULT([no])
184+
CFLAGS="$saved_CFLAGS"
185+
])
186+
187+
AC_MSG_CHECKING([for working native compiler: ${CC_FOR_BUILD}])
176188
AC_RUN_IFELSE(
177-
[AC_LANG_PROGRAM([], [return 0])],
189+
[AC_LANG_PROGRAM([], [])],
178190
[working_native_cc=yes],
179191
[working_native_cc=no],[dnl])
180-
CC="$TEMP_CC"
192+
193+
CFLAGS_FOR_BUILD="$CFLAGS"
194+
195+
# Restore the environment
181196
cross_compiling=$save_cross_compiling
197+
CC="$SAVE_CC"
198+
CFLAGS="$SAVE_CFLAGS"
199+
CPPFLAGS="$SAVE_CPPFLAGS"
200+
LDFLAGS="$SAVE_LDFLAGS"
182201

183202
if test x"$working_native_cc" = x"no"; then
203+
AC_MSG_RESULT([no])
184204
set_precomp=no
205+
m4_define([please_set_for_build], [Please set CC_FOR_BUILD, CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD, and/or LDFLAGS_FOR_BUILD.])
185206
if test x"$use_ecmult_static_precomputation" = x"yes"; then
186-
AC_MSG_ERROR([${CC_FOR_BUILD} does not produce working binaries. Please set CC_FOR_BUILD])
207+
AC_MSG_ERROR([native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build])
187208
else
188-
AC_MSG_RESULT([${CC_FOR_BUILD} does not produce working binaries. Please set CC_FOR_BUILD])
209+
AC_MSG_WARN([Disabling statically generated ecmult table because the native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build])
189210
fi
190211
else
191-
AC_MSG_RESULT([ok])
212+
AC_MSG_RESULT([yes])
192213
set_precomp=yes
193214
fi
194215
else
@@ -441,17 +462,6 @@ if test x"$use_external_asm" = x"yes"; then
441462
AC_DEFINE(USE_EXTERNAL_ASM, 1, [Define this symbol if an external (non-inline) assembly implementation is used])
442463
fi
443464

444-
AC_MSG_NOTICE([Using static precomputation: $set_precomp])
445-
AC_MSG_NOTICE([Using assembly optimizations: $set_asm])
446-
AC_MSG_NOTICE([Using field implementation: $set_field])
447-
AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
448-
AC_MSG_NOTICE([Using scalar implementation: $set_scalar])
449-
AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism])
450-
AC_MSG_NOTICE([Building for coverage analysis: $enable_coverage])
451-
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
452-
AC_MSG_NOTICE([Building ECDSA pubkey recovery module: $enable_module_recovery])
453-
AC_MSG_NOTICE([Using jni: $use_jni])
454-
455465
if test x"$enable_experimental" = x"yes"; then
456466
AC_MSG_NOTICE([******])
457467
AC_MSG_NOTICE([WARNING: experimental build])
@@ -481,7 +491,7 @@ AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
481491
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
482492
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
483493
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
484-
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" == x"yes"])
494+
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" = x"yes"])
485495
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
486496
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
487497

@@ -491,3 +501,24 @@ unset PKG_CONFIG_PATH
491501
PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP"
492502

493503
AC_OUTPUT
504+
505+
echo
506+
echo "Build Options:"
507+
echo " with endomorphism = $use_endomorphism"
508+
echo " with ecmult precomp = $set_precomp"
509+
echo " with jni = $use_jni"
510+
echo " with benchmarks = $use_benchmark"
511+
echo " with coverage = $enable_coverage"
512+
echo " module ecdh = $enable_module_ecdh"
513+
echo " module recovery = $enable_module_recovery"
514+
echo
515+
echo " asm = $set_asm"
516+
echo " bignum = $set_bignum"
517+
echo " field = $set_field"
518+
echo " scalar = $set_scalar"
519+
echo
520+
echo " CC = $CC"
521+
echo " CFLAGS = $CFLAGS"
522+
echo " CPPFLAGS = $CPPFLAGS"
523+
echo " LDFLAGS = $LDFLAGS"
524+
echo

0 commit comments

Comments
 (0)