diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b7bf99bdb..11156350e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -101,8 +101,10 @@ test_amalgamation: - touch config.h - gcc -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c - gcc -DBUILD_ELEMENTS -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c + - gcc -DBUILD_ELEMENTS -DBUILD_MINIMAL -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c - clang -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c - clang -DBUILD_ELEMENTS -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c + - clang -DBUILD_ELEMENTS -DBUILD_MINIMAL -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c test_mingw_static_build: stage: test diff --git a/configure.ac b/configure.ac index 039a8243f..d1c154c34 100644 --- a/configure.ac +++ b/configure.ac @@ -149,6 +149,9 @@ if test "x$standard_secp" = "xyes"; then fi if test "x$minimal" = "xyes"; then + if test "x$elements" = "xno"; then + AC_MSG_FAILURE([ERROR: Minimal mode requires Elements support to be enabled]) + fi AX_CHECK_COMPILE_FLAG([-DBUILD_MINIMAL=1], [AM_CFLAGS="$AM_CFLAGS -DBUILD_MINIMAL=1"]) fi @@ -271,6 +274,9 @@ AC_ARG_WITH([system-secp256k1], AM_CONDITIONAL([LINK_SYSTEM_SECP256K1], [test "x$with_system_secp256k1" != xno]) AM_COND_IF([LINK_SYSTEM_SECP256K1], [ dnl Use the secp installed system-wide (after checking it for suitability) + if test "x$minimal" = "xyes"; then + AC_MSG_ERROR([Minimal mode cannot be used with --with-system-secp256k1]) + fi saved_LIBS=$LIBS m4_ifdef([PKG_CHECK_MODULES], [PKG_CHECK_MODULES([libsecp256k1], [$with_system_secp256k1])], diff --git a/src/amalgamation/combined.c b/src/amalgamation/combined.c index 3f1f7659d..7952e1652 100644 --- a/src/amalgamation/combined.c +++ b/src/amalgamation/combined.c @@ -1,3 +1,4 @@ +#ifndef WALLY_NO_AMALGAMATION /* * secp2556k1-zkp configuration */ @@ -38,6 +39,7 @@ * config.h (which must be provided by the amalgamation user) * is included. */ +#define BUILD_AMALGAMATION 1 #include "src/internal.h" /* The amalgamation user can provide their own defines and skip @@ -121,3 +123,12 @@ void wally_silence_unused_warnings(void) assert_bip38_assumptions(); assert_tx_assumptions(); } + +/* Undefine our internal macros */ +#undef BYTES_VALID +#undef BYTES_INVALID +#undef BYTES_INVALID_N +#undef OUTPUT_CHECK +#undef OUTPUT_ALLOC + +#endif /* WALLY_NO_AMALGAMATION */ diff --git a/src/internal.h b/src/internal.h index 1b17f7def..bc07f5163 100644 --- a/src/internal.h +++ b/src/internal.h @@ -73,6 +73,7 @@ bool mem_is_zero(const void *mem, size_t len); /* Fetch our internal operations function pointers */ const struct wally_operations *wally_ops(void); +#ifndef BUILD_AMALGAMATION #define malloc(size) __use_wally_malloc_internally__ #define calloc(size) __use_wally_calloc_internally__ #define free(ptr) __use_wally_free_internally__ @@ -80,6 +81,7 @@ const struct wally_operations *wally_ops(void); #undef strdup #endif #define strdup(ptr) __use_wally_strdup_internally__ +#endif #define NUM_ELEMS(a) (sizeof(a) / sizeof(a[0]))