-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Description
Since the secp256k1 subtree update in #19228 (8c97780), it hasn't been possible to compile on OpenBSD.
Building fails with (cc is Clang 8.0.1):
./autogen.sh
./configure --disable-wallet --with-gui=no CC=cc CXX=c++ MAKE=gmake
gmake -j6 V=1
...
gmake[3]: Entering directory '/home/vagrant/bitcoin/src/secp256k1'
gcc -I. -I./src -Wall -Wextra -Wno-unused-function -g -O2 -c src/gen_context.c -o gen_context.o
In file included from src/gen_context.c:16:
src/util.h:179: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'uint128_t'
gmake[3]: *** [Makefile:1689: gen_context.o] Error 1
gmake[3]: Leaving directory '/home/vagrant/bitcoin/src/secp256k1'
The issue is that libsecp does some native compiler detection in configure, and then uses that compiler specifically for the ecmult precomputation. See here, (the call settings CC_FOR_BUILD
is earlier):
bitcoin/src/secp256k1/configure.ac
Lines 186 to 188 in 476436b
if test x"$use_ecmult_static_precomputation" != x"no"; then | |
# Temporarily switch to an environment for the native compiler | |
save_cross_compiling=$cross_compiling |
and then here where it's used:
bitcoin/src/secp256k1/Makefile.am
Lines 129 to 130 in 476436b
gen_%.o: src/gen_%.c src/libsecp256k1-config.h | |
$(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@ |
The problem is that this ends up picking up and using OpenBSDs ancient GCC 4.2.1, which barfs when it gets to util.h:
bitcoin/src/secp256k1/src/util.h
Line 179 in 476436b
SECP256K1_GNUC_EXT typedef unsigned __int128 uint128_t; |
If anyone does happen to run into this issue, the immediate workaround is to just pass CC_FOR_BUILD
to configure, i.e: ./configure --disable-wallet --with-gui=no CC=cc CXX=c++ MAKE=gmake CC_FOR_BUILD=cc
.
However before we update any docs etc, I'm going to take the issue upstream.