Skip to content

Commit 275e03f

Browse files
committed
Merge commits '8b013fce 485f608 44c2452 cd47033 accadc9 43756da ' into temp-merge-1115
2 parents ff33018 + 43756da commit 275e03f

14 files changed

+278
-130
lines changed

.cirrus.yml

+56-9
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,57 @@ task:
231231
<< : *CAT_LOGS
232232

233233
task:
234-
name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
235234
<< : *LINUX_CONTAINER
236235
env:
237-
WRAPPER_CMD: wine64-stable
238-
SECP256K1_TEST_ITERS: 16
239-
HOST: x86_64-w64-mingw32
236+
WRAPPER_CMD: wine
240237
WITH_VALGRIND: no
241238
ECDH: yes
242239
RECOVERY: yes
243240
SCHNORRSIG: yes
244241
CTIMETEST: no
242+
matrix:
243+
- name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
244+
env:
245+
HOST: x86_64-w64-mingw32
246+
- name: "i686 (mingw32-w64): Windows (Debian stable, Wine)"
247+
env:
248+
HOST: i686-w64-mingw32
249+
<< : *MERGE_BASE
250+
test_script:
251+
- ./ci/cirrus.sh
252+
<< : *CAT_LOGS
253+
254+
task:
255+
<< : *LINUX_CONTAINER
256+
env:
257+
WRAPPER_CMD: wine
258+
WERROR_CFLAGS: -WX
259+
WITH_VALGRIND: no
260+
ECDH: yes
261+
RECOVERY: yes
262+
EXPERIMENTAL: yes
263+
SCHNORRSIG: yes
264+
CTIMETEST: no
265+
# Set non-essential options that affect the CLI messages here.
266+
# (They depend on the user's taste, so we don't want to set them automatically in configure.ac.)
267+
CFLAGS: -nologo -diagnostics:caret
268+
LDFLAGS: -XCClinker -nologo -XCClinker -diagnostics:caret
269+
# Use a MinGW-w64 host to tell ./configure we're building for Windows.
270+
# This will detect some MinGW-w64 tools but then make will need only
271+
# the MSVC tools CC, AR and NM as specified below.
272+
matrix:
273+
- name: "x86_64 (MSVC): Windows (Debian stable, Wine)"
274+
env:
275+
HOST: x86_64-w64-mingw32
276+
CC: /opt/msvc/bin/x64/cl
277+
AR: /opt/msvc/bin/x64/lib
278+
NM: /opt/msvc/bin/x64/dumpbin -symbols -headers
279+
- name: "i686 (MSVC): Windows (Debian stable, Wine)"
280+
env:
281+
HOST: i686-w64-mingw32
282+
CC: /opt/msvc/bin/x86/cl
283+
AR: /opt/msvc/bin/x86/lib
284+
NM: /opt/msvc/bin/x86/dumpbin -symbols -headers
245285
<< : *MERGE_BASE
246286
test_script:
247287
- ./ci/cirrus.sh
@@ -301,13 +341,12 @@ task:
301341
<< : *CAT_LOGS
302342

303343
task:
304-
name: "C++ -fpermissive"
344+
name: "C++ -fpermissive (entire project)"
305345
<< : *LINUX_CONTAINER
306346
env:
307-
# ./configure correctly errors out when given CC=g++.
308-
# We hack around this by passing CC=g++ only to make.
309-
CC: gcc
310-
MAKEFLAGS: -j4 CC=g++ CFLAGS=-fpermissive\ -g
347+
CC: g++
348+
CFLAGS: -fpermissive -g
349+
CPPFLAGS: -DSECP256K1_CPLUSPLUS_TEST_OVERRIDE
311350
WERROR_CFLAGS:
312351
ECDH: yes
313352
RECOVERY: yes
@@ -317,6 +356,14 @@ task:
317356
- ./ci/cirrus.sh
318357
<< : *CAT_LOGS
319358

359+
task:
360+
name: "C++ (public headers)"
361+
<< : *LINUX_CONTAINER
362+
test_script:
363+
- g++ -Werror include/*.h
364+
- clang -Werror -x c++-header include/*.h
365+
- /opt/msvc/bin/x64/cl.exe -c -WX -TP include/*.h
366+
320367
task:
321368
name: "sage prover"
322369
<< : *LINUX_CONTAINER

build-aux/m4/bitcoin_secp.m4

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell.
22
AC_DEFUN([SECP_64BIT_ASM_CHECK],[
33
AC_MSG_CHECKING(for x86_64 assembly availability)
4-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
55
#include <stdint.h>]],[[
66
uint64_t a = 11, tmp;
77
__asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
@@ -10,6 +10,7 @@ AC_MSG_RESULT([$has_64bit_asm])
1010
])
1111

1212
AC_DEFUN([SECP_VALGRIND_CHECK],[
13+
AC_MSG_CHECKING([for valgrind support])
1314
if test x"$has_valgrind" != x"yes"; then
1415
CPPFLAGS_TEMP="$CPPFLAGS"
1516
CPPFLAGS="$VALGRIND_CPPFLAGS $CPPFLAGS"
@@ -21,6 +22,7 @@ if test x"$has_valgrind" != x"yes"; then
2122
#endif
2223
]])], [has_valgrind=yes; AC_DEFINE(HAVE_VALGRIND,1,[Define this symbol if valgrind is installed, and it supports the host platform])])
2324
fi
25+
AC_MSG_RESULT($has_valgrind)
2426
])
2527

2628
dnl SECP_TRY_APPEND_CFLAGS(flags, VAR)

ci/cirrus.sh

+13
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ set -x
55

66
export LC_ALL=C
77

8+
# Start persistent wineserver if necessary.
9+
# This speeds up jobs with many invocations of wine (e.g., ./configure with MSVC) tremendously.
10+
case "$WRAPPER_CMD" in
11+
*wine*)
12+
# This is apparently only reliable when we run a dummy command such as "hh.exe" afterwards.
13+
wineserver -p && wine hh.exe
14+
;;
15+
esac
16+
817
env >> test_env.log
918

1019
$CC -v || true
1120
valgrind --version || true
21+
$WRAPPER_CMD --version || true
1222

1323
./autogen.sh
1424

@@ -71,6 +81,9 @@ then
7181
make precomp
7282
fi
7383

84+
# Shutdown wineserver again
85+
wineserver -k || true
86+
7487
# Check that no repo files have been modified by the build.
7588
# (This fails for example if the precomp files need to be updated in the repo.)
7689
git diff --exit-code

ci/linux-debian.Dockerfile

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
FROM debian:stable
22

3-
RUN dpkg --add-architecture i386
4-
RUN dpkg --add-architecture s390x
5-
RUN dpkg --add-architecture armhf
6-
RUN dpkg --add-architecture arm64
7-
RUN dpkg --add-architecture ppc64el
8-
RUN apt-get update
3+
RUN dpkg --add-architecture i386 && \
4+
dpkg --add-architecture s390x && \
5+
dpkg --add-architecture armhf && \
6+
dpkg --add-architecture arm64 && \
7+
dpkg --add-architecture ppc64el
98

109
# dkpg-dev: to make pkg-config work in cross-builds
1110
# llvm: for llvm-symbolizer, which is used by clang's UBSan for symbolized stack traces
12-
RUN apt-get install --no-install-recommends --no-upgrade -y \
11+
RUN apt-get update && apt-get install --no-install-recommends -y \
1312
git ca-certificates \
1413
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
1514
gcc clang llvm libc6-dbg \
@@ -19,8 +18,20 @@ RUN apt-get install --no-install-recommends --no-upgrade -y \
1918
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \
2019
gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6-dbg:arm64 \
2120
gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross libc6-dbg:ppc64el \
22-
wine gcc-mingw-w64-x86-64 \
21+
gcc-mingw-w64-x86-64-win32 wine64 wine \
22+
gcc-mingw-w64-i686-win32 wine32 \
2323
sagemath
2424

25-
# Run a dummy command in wine to make it set up configuration
26-
RUN wine64-stable xcopy || true
25+
WORKDIR /root
26+
# The "wine" package provides a convience wrapper that we need
27+
RUN apt-get update && apt-get install --no-install-recommends -y \
28+
git ca-certificates wine64 wine python3-simplejson python3-six msitools winbind procps && \
29+
git clone https://github.com/mstorsjo/msvc-wine && \
30+
mkdir /opt/msvc && \
31+
python3 msvc-wine/vsdownload.py --accept-license --dest /opt/msvc Microsoft.VisualStudio.Workload.VCTools && \
32+
msvc-wine/install.sh /opt/msvc
33+
34+
# Initialize the wine environment. Wait until the wineserver process has
35+
# exited before closing the session, to avoid corrupting the wine prefix.
36+
RUN wine64 wineboot --init && \
37+
while (ps -A | grep wineserver) > /dev/null; do sleep 1; done

configure.ac

+39-21
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ AM_INIT_AUTOMAKE([1.11.2 foreign subdir-objects])
3333
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
3434

3535
AC_PROG_CC
36-
if test x"$ac_cv_prog_cc_c89" = x"no"; then
37-
AC_MSG_ERROR([c89 compiler support required])
38-
fi
3936
AM_PROG_AS
4037
AM_PROG_AR
4138

39+
# Clear some cache variables as a workaround for a bug that appears due to a bad
40+
# interaction between AM_PROG_AR and LT_INIT when combining MSVC's archiver lib.exe.
41+
# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54421
42+
AS_UNSET(ac_cv_prog_AR)
43+
AS_UNSET(ac_cv_prog_ac_ct_AR)
4244
LT_INIT([win32-dll])
4345

46+
PKG_PROG_PKG_CONFIG
47+
4448
build_windows=no
4549

4650
case $host_os in
@@ -87,23 +91,35 @@ esac
8791
#
8892
# TODO We should analogously not touch CPPFLAGS and LDFLAGS but currently there are no issues.
8993
AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
90-
# Try to append -Werror=unknown-warning-option to CFLAGS temporarily. Otherwise clang will
91-
# not error out if it gets unknown warning flags and the checks here will always succeed
92-
# no matter if clang knows the flag or not.
93-
SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS="$CFLAGS"
94-
SECP_TRY_APPEND_CFLAGS([-Werror=unknown-warning-option], CFLAGS)
95-
96-
SECP_TRY_APPEND_CFLAGS([-std=c89 -pedantic -Wno-long-long -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef], $1) # GCC >= 3.0, -Wlong-long is implied by -pedantic.
97-
SECP_TRY_APPEND_CFLAGS([-Wno-overlength-strings], $1) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic.
98-
SECP_TRY_APPEND_CFLAGS([-Wall], $1) # GCC >= 2.95 and probably many other compilers
99-
SECP_TRY_APPEND_CFLAGS([-Wno-unused-function], $1) # GCC >= 3.0, -Wunused-function is implied by -Wall.
100-
SECP_TRY_APPEND_CFLAGS([-Wextra], $1) # GCC >= 3.4, this is the newer name of -W, which we don't use because older GCCs will warn about unused functions.
101-
SECP_TRY_APPEND_CFLAGS([-Wcast-align], $1) # GCC >= 2.95
102-
SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0
103-
SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only
104-
SECP_TRY_APPEND_CFLAGS([-fvisibility=hidden], $1) # GCC >= 4.0
105-
106-
CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"
94+
# GCC and compatible (incl. clang)
95+
if test "x$GCC" = "xyes"; then
96+
# Try to append -Werror=unknown-warning-option to CFLAGS temporarily. Otherwise clang will
97+
# not error out if it gets unknown warning flags and the checks here will always succeed
98+
# no matter if clang knows the flag or not.
99+
SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS="$CFLAGS"
100+
SECP_TRY_APPEND_CFLAGS([-Werror=unknown-warning-option], CFLAGS)
101+
102+
SECP_TRY_APPEND_CFLAGS([-std=c89 -pedantic -Wno-long-long -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef], $1) # GCC >= 3.0, -Wlong-long is implied by -pedantic.
103+
SECP_TRY_APPEND_CFLAGS([-Wno-overlength-strings], $1) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic.
104+
SECP_TRY_APPEND_CFLAGS([-Wall], $1) # GCC >= 2.95 and probably many other compilers
105+
SECP_TRY_APPEND_CFLAGS([-Wno-unused-function], $1) # GCC >= 3.0, -Wunused-function is implied by -Wall.
106+
SECP_TRY_APPEND_CFLAGS([-Wextra], $1) # GCC >= 3.4, this is the newer name of -W, which we don't use because older GCCs will warn about unused functions.
107+
SECP_TRY_APPEND_CFLAGS([-Wcast-align], $1) # GCC >= 2.95
108+
SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0
109+
SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only
110+
SECP_TRY_APPEND_CFLAGS([-fvisibility=hidden], $1) # GCC >= 4.0
111+
112+
CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"
113+
fi
114+
115+
# MSVC
116+
# Assume MSVC if we're building for Windows but not with GCC or compatible;
117+
# libtool makes the same assumption internally.
118+
# Note that "/opt" and "-opt" are equivalent for MSVC; we use "-opt" because "/opt" looks like a path.
119+
if test x"$GCC" != x"yes" && test x"$build_windows" = x"yes"; then
120+
SECP_TRY_APPEND_CFLAGS([-W2 -wd4146], $1) # Moderate warning level, disable warning C4146 "unary minus operator applied to unsigned type, result still unsigned"
121+
SECP_TRY_APPEND_CFLAGS([-external:anglebrackets -external:W0], $1) # Suppress warnings from #include <...> files
122+
fi
107123
])
108124
SECP_TRY_APPEND_DEFAULT_CFLAGS(SECP_CFLAGS)
109125

@@ -383,7 +399,9 @@ if test x"$enable_valgrind" = x"yes"; then
383399
SECP_INCLUDES="$SECP_INCLUDES $VALGRIND_CPPFLAGS"
384400
fi
385401

386-
# Add -Werror and similar flags passed from the outside (for testing, e.g., in CI)
402+
# Add -Werror and similar flags passed from the outside (for testing, e.g., in CI).
403+
# We don't want to set the user variable CFLAGS in CI because this would disable
404+
# autoconf's logic for setting default CFLAGS, which we would like to test in CI.
387405
SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
388406

389407
###

include/secp256k1.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@ typedef int (*secp256k1_nonce_function)(
141141
# define SECP256K1_NO_BUILD
142142
#endif
143143

144+
/** At secp256k1 build-time DLL_EXPORT is defined when building objects destined
145+
* for a shared library, but not for those intended for static libraries.
146+
*/
147+
144148
#ifndef SECP256K1_API
145149
# if defined(_WIN32)
146-
# ifdef SECP256K1_BUILD
150+
# if defined(SECP256K1_BUILD) && defined(DLL_EXPORT)
147151
# define SECP256K1_API __declspec(dllexport)
148152
# else
149153
# define SECP256K1_API

0 commit comments

Comments
 (0)