Improve CC_FOR_BUILD detection
This commits simply uses CC as CC_FOR_BUILD and the same for corresponding flags if we're not cross-compiling. This has a number of benefits in this common case: - It avoids strange cases where very old compilers are used (#768). - Flags are consistently set for CC and CC_FOR_BUILD. - ./configure is faster. - You get compiler x consistently if you set CC=x; we got this wrong in CI in the past. ./configure warns if a _FOR_BUILD variable is set but ignored because we're not cross-compiling. The change exposed that //-style comments are used in gen_context.c, which is also fixed by this commit. This commit also reorganizes code in configure.ac to have a cleaner separation of sections.
This commit is contained in:
parent
47802a4762
commit
3c15130709
26
configure.ac
26
configure.ac
|
@ -22,7 +22,6 @@ PKG_PROG_PKG_CONFIG
|
||||||
AC_PATH_TOOL(AR, ar)
|
AC_PATH_TOOL(AR, ar)
|
||||||
AC_PATH_TOOL(RANLIB, ranlib)
|
AC_PATH_TOOL(RANLIB, ranlib)
|
||||||
AC_PATH_TOOL(STRIP, strip)
|
AC_PATH_TOOL(STRIP, strip)
|
||||||
AX_PROG_CC_FOR_BUILD
|
|
||||||
|
|
||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
|
|
||||||
|
@ -394,6 +393,19 @@ fi
|
||||||
|
|
||||||
# Handle static precomputation (after everything which modifies CFLAGS and friends)
|
# Handle static precomputation (after everything which modifies CFLAGS and friends)
|
||||||
if test x"$use_ecmult_static_precomputation" != x"no"; then
|
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"
|
||||||
|
CFLAGS_FOR_BUILD="$CFLAGS"
|
||||||
|
CPPFLAGS_FOR_BUILD="$CPPFLAGS"
|
||||||
|
LDFLAGS_FOR_BUILD="$LDFLAGS"
|
||||||
|
else
|
||||||
|
AX_PROG_CC_FOR_BUILD
|
||||||
|
|
||||||
# Temporarily switch to an environment for the native compiler
|
# Temporarily switch to an environment for the native compiler
|
||||||
save_cross_compiling=$cross_compiling
|
save_cross_compiling=$cross_compiling
|
||||||
cross_compiling=no
|
cross_compiling=no
|
||||||
|
@ -444,6 +456,12 @@ if test x"$use_ecmult_static_precomputation" != x"no"; then
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
set_precomp=yes
|
set_precomp=yes
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST(CC_FOR_BUILD)
|
||||||
|
AC_SUBST(CFLAGS_FOR_BUILD)
|
||||||
|
AC_SUBST(CPPFLAGS_FOR_BUILD)
|
||||||
|
AC_SUBST(LDFLAGS_FOR_BUILD)
|
||||||
else
|
else
|
||||||
set_precomp=no
|
set_precomp=no
|
||||||
fi
|
fi
|
||||||
|
@ -559,3 +577,9 @@ echo " CFLAGS = $CFLAGS"
|
||||||
echo " CPPFLAGS = $CPPFLAGS"
|
echo " CPPFLAGS = $CPPFLAGS"
|
||||||
echo " LDFLAGS = $LDFLAGS"
|
echo " LDFLAGS = $LDFLAGS"
|
||||||
echo
|
echo
|
||||||
|
if test x"$set_precomp" = x"yes"; then
|
||||||
|
echo " CC_FOR_BUILD = $CC_FOR_BUILD"
|
||||||
|
echo " CFLAGS_FOR_BUILD = $CFLAGS_FOR_BUILD"
|
||||||
|
echo " CPPFLAGS_FOR_BUILD = $CPPFLAGS_FOR_BUILD"
|
||||||
|
echo " LDFLAGS_FOR_BUILD = $LDFLAGS_FOR_BUILD"
|
||||||
|
fi
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
// Autotools creates libsecp256k1-config.h, of which ECMULT_GEN_PREC_BITS is needed.
|
/* Autotools creates libsecp256k1-config.h, of which ECMULT_GEN_PREC_BITS is needed.
|
||||||
// ifndef guard so downstream users can define their own if they do not use autotools.
|
ifndef guard so downstream users can define their own if they do not use autotools. */
|
||||||
#if !defined(ECMULT_GEN_PREC_BITS)
|
#if !defined(ECMULT_GEN_PREC_BITS)
|
||||||
#include "libsecp256k1-config.h"
|
#include "libsecp256k1-config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue