Merge bitcoin-core/secp256k1#988: Make signing table fully static
7dfceceea6build: Remove #undef hack for ASM in the precomputation programs (Tim Ruffing)bb36fe9be0ci: Test `make precomp` (Tim Ruffing)d94a37a20cbuild: Remove CC_FOR_BUILD stuff (Tim Ruffing)ad63bb4c29build: Prebuild and distribute ecmult_gen table (Tim Ruffing)ac49361ed0prealloc: Get rid of manual memory management for prealloc contexts (Tim Ruffing)6573c08f65ecmult_gen: Tidy precomputed file and save space (Tim Ruffing)5eba83f17cecmult_gen: Precompute tables for all values of ECMULT_GEN_PREC_BITS (Tim Ruffing)fdb33dd122refactor: Make PREC_BITS a parameter of ecmult_gen_build_prec_table (Tim Ruffing)a4875e30a6refactor: Move default callbacks to util.h (Tim Ruffing)4c94c55bcedoc: Remove obsolete hint for valgrind stack size (Tim Ruffing)5106226991exhaustive_tests: Fix with ecmult_gen table with custom generator (Tim Ruffing)e1a76530dbrefactor: Make generator a parameter of ecmult_gen_create_prec_table (Tim Ruffing)9ad09f6911refactor: Rename program that generates static ecmult_gen table (Tim Ruffing)8ae18f1ab3refactor: Rename file that contains static ecmult_gen table (Tim Ruffing)00d2fa116eecmult_gen: Make code consistent with comment (Tim Ruffing)3b0c2185eaecmult_gen: Simplify ecmult_gen context after making table static (Tim Ruffing)e43ba02cfcrefactor: Decouple table generation and ecmult_gen context (Tim Ruffing)22dc2c0a0decmult_gen: Move table creation to new file and force static prec (Tim Ruffing) Pull request description: This resolves #893, resolves #692 (and also resolves bitcoin/bitcoin#22854). - [x] Extract table generation to separate function in separate file (to be used by generation script and exhaustive tests) - [x] Tidy up - [x] Remove code that deals with non-static tables - [x] Make functions that need ecmult_gen not depend on signing context - [x] Rename stuff to make it fit the new structure and consistent with how we hande verification tables (#956) - [x] Fix exhaustive tests - [x] Make table generation function take generator as input - [x] Overwrite the static tables with a table with custom generator in exhaustive tests - [x] Overhaul script that generates table files - [x] Make table generation function take PREC_BITS as input (I have some code already, just not yet in this branch) - [x] Change generation script to generate three tables (for all three values of ECMULT_GEN_PREC_BITS) - [x] Ship pre-built tables - [x] Add pregenerated table file to repo - [x] Remove generation of table file from build process (like in #956) - [x] Remove left-over stuff (e.g., detecting a compiler running on the build machine) from build system - [x] Final cleanups (copyright headers, commit, messages, etc.) - [ ] (separate PR:) Make sure link-time optimization remove corresponding static tables (and code) when no signing/verifcation function is called - [ ] (separate PR:) Compile precomputation as a separate object file and link it (https://github.com/bitcoin-core/secp256k1/pull/988#issuecomment-977813538) - [ ] (separate PR:) Document the backwards-compatible API changes made in this PR and in #956. - [ ] Maybe deprecate the static context ACKs for top commit: sipa: ACK7dfceceea6robot-dreams: ACK7dfceceea6(based on range-diff between 56284c7d44c0ed46e636588bfbf6c403b7dfa6c1 and7dfceceea6) Tree-SHA512: 6efb3f36f05efe3b79bbd877881fe1409f71fd6488d24c811b2e77d9f053bed78670dd1dcbb42ad780458a51c4ffa36de9cd6567271b22041dc7a122ceb677c5
This commit is contained in:
96
configure.ac
96
configure.ac
@@ -19,16 +19,7 @@ AC_PATH_TOOL(AR, ar)
|
||||
AC_PATH_TOOL(RANLIB, ranlib)
|
||||
AC_PATH_TOOL(STRIP, strip)
|
||||
|
||||
# Save definition of AC_PROG_CC because AM_PROG_CC_C_O in automake<=1.13 will
|
||||
# redefine AC_PROG_CC to exit with an error, which avoids the user calling it
|
||||
# accidentally and screwing up the effect of AM_PROG_CC_C_O. However, we'll need
|
||||
# AC_PROG_CC later on in AX_PROG_CC_FOR_BUILD, where its usage is fine, and
|
||||
# we'll carefully make sure not to call AC_PROG_CC anywhere else.
|
||||
m4_copy([AC_PROG_CC], [saved_AC_PROG_CC])
|
||||
AM_PROG_CC_C_O
|
||||
# Restore AC_PROG_CC
|
||||
m4_rename_force([saved_AC_PROG_CC], [AC_PROG_CC])
|
||||
|
||||
AC_PROG_CC_C89
|
||||
if test x"$ac_cv_prog_cc_c89" = x"no"; then
|
||||
AC_MSG_ERROR([c89 compiler support required])
|
||||
@@ -125,11 +116,6 @@ AC_ARG_ENABLE(exhaustive_tests,
|
||||
[use_exhaustive_tests=$enableval],
|
||||
[use_exhaustive_tests=yes])
|
||||
|
||||
AC_ARG_ENABLE(ecmult_static_precomputation,
|
||||
AS_HELP_STRING([--enable-ecmult-static-precomputation],[enable precomputed ecmult table for signing [default=auto]]),
|
||||
[use_ecmult_static_precomputation=$enableval],
|
||||
[use_ecmult_static_precomputation=auto])
|
||||
|
||||
AC_ARG_ENABLE(module_ecdh,
|
||||
AS_HELP_STRING([--enable-module-ecdh],[enable ECDH shared secret computation]),
|
||||
[enable_module_ecdh=$enableval],
|
||||
@@ -213,7 +199,6 @@ else
|
||||
# We still add it here because passing it twice is not an issue, and handling
|
||||
# this case would just add unnecessary complexity (see #896).
|
||||
SECP_CFLAGS="-O2 $SECP_CFLAGS"
|
||||
SECP_CFLAGS_FOR_BUILD="-O2 $SECP_CFLAGS_FOR_BUILD"
|
||||
fi
|
||||
|
||||
if test x"$req_asm" = x"auto"; then
|
||||
@@ -325,77 +310,6 @@ fi
|
||||
# Add -Werror and similar flags passed from the outside (for testing, e.g., in CI)
|
||||
SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
|
||||
|
||||
# Handle static precomputation (after everything which modifies CFLAGS and friends)
|
||||
if test x"$use_ecmult_static_precomputation" != x"no"; then
|
||||
if test x"$cross_compiling" = x"no"; then
|
||||
set_precomp=yes
|
||||
if test x"${CC_FOR_BUILD+x}${CFLAGS_FOR_BUILD+x}${CPPFLAGS_FOR_BUILD+x}${LDFLAGS_FOR_BUILD+x}" != x; then
|
||||
AC_MSG_WARN([CC_FOR_BUILD, CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD, and/or LDFLAGS_FOR_BUILD is set but ignored because we are not cross-compiling.])
|
||||
fi
|
||||
# If we're not cross-compiling, simply use the same compiler for building the static precompation code.
|
||||
CC_FOR_BUILD="$CC"
|
||||
CPPFLAGS_FOR_BUILD="$CPPFLAGS"
|
||||
SECP_CFLAGS_FOR_BUILD="$SECP_CFLAGS"
|
||||
CFLAGS_FOR_BUILD="$CFLAGS"
|
||||
LDFLAGS_FOR_BUILD="$LDFLAGS"
|
||||
else
|
||||
AX_PROG_CC_FOR_BUILD
|
||||
|
||||
# Temporarily switch to an environment for the native compiler
|
||||
save_cross_compiling=$cross_compiling
|
||||
cross_compiling=no
|
||||
SAVE_CC="$CC"
|
||||
CC="$CC_FOR_BUILD"
|
||||
SAVE_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS_FOR_BUILD"
|
||||
SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS_FOR_BUILD"
|
||||
SAVE_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS_FOR_BUILD"
|
||||
|
||||
SECP_TRY_APPEND_DEFAULT_CFLAGS(SECP_CFLAGS_FOR_BUILD)
|
||||
|
||||
AC_MSG_CHECKING([for working native compiler: ${CC_FOR_BUILD}])
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([], [])],
|
||||
[working_native_cc=yes],
|
||||
[working_native_cc=no],[:])
|
||||
|
||||
# Restore the environment
|
||||
cross_compiling=$save_cross_compiling
|
||||
CC="$SAVE_CC"
|
||||
CPPFLAGS="$SAVE_CPPFLAGS"
|
||||
CFLAGS="$SAVE_CFLAGS"
|
||||
LDFLAGS="$SAVE_LDFLAGS"
|
||||
|
||||
if test x"$working_native_cc" = x"no"; then
|
||||
AC_MSG_RESULT([no])
|
||||
set_precomp=no
|
||||
m4_define([please_set_for_build], [Please set CC_FOR_BUILD, CPPFLAGS_FOR_BUILD, CFLAGS_FOR_BUILD, and/or LDFLAGS_FOR_BUILD.])
|
||||
if test x"$use_ecmult_static_precomputation" = x"yes"; then
|
||||
AC_MSG_ERROR([native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build])
|
||||
else
|
||||
AC_MSG_WARN([Disabling statically generated ecmult table because the native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build])
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
set_precomp=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(CC_FOR_BUILD)
|
||||
AC_SUBST(CPPFLAGS_FOR_BUILD)
|
||||
AC_SUBST(SECP_CFLAGS_FOR_BUILD)
|
||||
AC_SUBST(CFLAGS_FOR_BUILD)
|
||||
AC_SUBST(LDFLAGS_FOR_BUILD)
|
||||
else
|
||||
set_precomp=no
|
||||
fi
|
||||
|
||||
if test x"$set_precomp" = x"yes"; then
|
||||
AC_DEFINE(USE_ECMULT_STATIC_PRECOMPUTATION, 1, [Define this symbol to use a statically generated ecmult table])
|
||||
fi
|
||||
|
||||
###
|
||||
### Handle module options
|
||||
###
|
||||
@@ -461,7 +375,6 @@ AM_CONDITIONAL([ENABLE_COVERAGE], [test x"$enable_coverage" = x"yes"])
|
||||
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
|
||||
AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
|
||||
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
|
||||
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
|
||||
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
|
||||
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
|
||||
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
|
||||
@@ -478,7 +391,6 @@ AC_OUTPUT
|
||||
|
||||
echo
|
||||
echo "Build Options:"
|
||||
echo " with ecmult precomp = $set_precomp"
|
||||
echo " with external callbacks = $use_external_default_callbacks"
|
||||
echo " with benchmarks = $use_benchmark"
|
||||
echo " with tests = $use_tests"
|
||||
@@ -502,11 +414,3 @@ echo " CPPFLAGS = $CPPFLAGS"
|
||||
echo " SECP_CFLAGS = $SECP_CFLAGS"
|
||||
echo " CFLAGS = $CFLAGS"
|
||||
echo " LDFLAGS = $LDFLAGS"
|
||||
echo
|
||||
if test x"$set_precomp" = x"yes"; then
|
||||
echo " CC_FOR_BUILD = $CC_FOR_BUILD"
|
||||
echo " CPPFLAGS_FOR_BUILD = $CPPFLAGS_FOR_BUILD"
|
||||
echo " SECP_CFLAGS_FOR_BUILD = $SECP_CFLAGS_FOR_BUILD"
|
||||
echo " CFLAGS_FOR_BUILD = $CFLAGS_FOR_BUILD"
|
||||
echo " LDFLAGS_FOR_BUILD = $LDFLAGS_FOR_BUILD"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user