Squashed 'src/secp256k1/' changes from 14e56970cb..57315a6985

57315a6985 Merge bitcoin-core/secp256k1#1813: Remove trailing spaces and introduce `-Wtrailing-whitespace=any` compiler flag
86cae58d2f build: Add `-Wleading-whitespace=spaces` compiler flag
fb229e7602 build: Add `-Wtrailing-whitespace=any` compiler flag
13e3bee504 refactor: Remove trailing whitespace
453949ab2a Merge bitcoin-core/secp256k1#1816: ci: Rotate Docker cache keys
cd49c57e44 Merge bitcoin-core/secp256k1#1814: release process: mention the `[Unreleased]` link clearly
2ccff6eb73 ci: Add weekly schedule
2f18567d24 ci: Rotate Docker cache keys every 4 weeks
0ffb1749a5 ci, docker: Fix LLVM repository signature failure
0267b65512 release process: mention the `[Unreleased]` link clearly
1605b02f75 Merge bitcoin-core/secp256k1#1775: Add CMake build directory patterns to `.gitignore`
748c0fdd67 Add CMake build directory patterns to `.gitignore`
7eb86bdb01 autotools: Rename `build-aux` to `autotools-aux`

git-subtree-dir: src/secp256k1
git-subtree-split: 57315a69853c9bd4765fccf20b541d47f1b45ca9
This commit is contained in:
fanquake
2026-02-02 15:21:14 +00:00
parent 2fccbea3c8
commit 9d4c9b0035
14 changed files with 40 additions and 28 deletions

View File

@@ -6,8 +6,7 @@ inputs:
required: true required: true
scope: scope:
description: 'A cached image scope' description: 'A cached image scope'
required: false required: true
default: ${{ runner.arch }}
command: command:
description: 'A command to run in a container' description: 'A command to run in a container'
required: true required: true

View File

@@ -6,6 +6,10 @@ on:
- '**' - '**'
tags-ignore: tags-ignore:
- '**' - '**'
schedule:
# Run on the default branch every Monday morning.
# This also warms the Docker caches after key rotation.
- cron: '22 2 * * 1'
concurrency: concurrency:
group: ${{ github.event_name != 'pull_request' && github.run_id || github.ref }} group: ${{ github.event_name != 'pull_request' && github.run_id || github.ref }}
@@ -48,6 +52,8 @@ jobs:
docker_cache: docker_cache:
name: "Build ${{ matrix.arch }} Docker image" name: "Build ${{ matrix.arch }} Docker image"
runs-on: ${{ matrix.runner }} runs-on: ${{ matrix.runner }}
outputs:
cache_scope: ${{ steps.cache_timestamp.outputs.period }}
strategy: strategy:
fail-fast: false fail-fast: false
@@ -59,6 +65,10 @@ jobs:
runner: ubuntu-24.04-arm runner: ubuntu-24.04-arm
steps: steps:
- name: Get cache validity period
id: cache_timestamp
run: echo "period=$(($(date +%V) / 4))" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
@@ -70,8 +80,8 @@ jobs:
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
file: ./ci/linux-debian.Dockerfile file: ./ci/linux-debian.Dockerfile
cache-from: type=gha,scope=${{ runner.arch }} cache-from: type=gha,scope=${{ runner.arch }}-${{ steps.cache_timestamp.outputs.period }}
cache-to: type=gha,scope=${{ runner.arch }},mode=min cache-to: type=gha,scope=${{ runner.arch }}-${{ steps.cache_timestamp.outputs.period }},mode=min
x86_64-debian: x86_64-debian:
name: "x86_64: Linux (Debian stable)" name: "x86_64: Linux (Debian stable)"
@@ -117,6 +127,7 @@ jobs:
uses: ./.github/actions/run-in-docker-action uses: ./.github/actions/run-in-docker-action
with: with:
dockerfile: ./ci/linux-debian.Dockerfile dockerfile: ./ci/linux-debian.Dockerfile
scope: ${{ runner.arch }}-${{ needs.docker_cache.outputs.cache_scope }}
command: ./ci/ci.sh command: ./ci/ci.sh
- &PRINT_LOGS - &PRINT_LOGS
@@ -636,6 +647,7 @@ jobs:
uses: ./.github/actions/run-in-docker-action uses: ./.github/actions/run-in-docker-action
with: with:
dockerfile: ./ci/linux-debian.Dockerfile dockerfile: ./ci/linux-debian.Dockerfile
scope: ${{ runner.arch }}-${{ needs.docker_cache.outputs.cache_scope }}
command: | command: |
g++ -Werror include/*.h g++ -Werror include/*.h
clang -Werror -x c++-header include/*.h clang -Werror -x c++-header include/*.h

21
.gitignore vendored
View File

@@ -45,26 +45,15 @@ coverage.*.html
*.gcno *.gcno
*.gcov *.gcov
build-aux/ar-lib /autotools-aux/
build-aux/config.guess !/autotools-aux/m4/bitcoin_secp.m4
build-aux/config.sub
build-aux/depcomp
build-aux/install-sh
build-aux/ltmain.sh
build-aux/m4/libtool.m4
build-aux/m4/lt~obsolete.m4
build-aux/m4/ltoptions.m4
build-aux/m4/ltsugar.m4
build-aux/m4/ltversion.m4
build-aux/missing
build-aux/compile
build-aux/test-driver
libsecp256k1.pc libsecp256k1.pc
### CMake ### CMake
/CMakeUserPresets.json /CMakeUserPresets.json
# Default CMake build directory. # CMake build directories.
/build /*build*
### Python ### Python
__pycache__/ __pycache__/

View File

@@ -217,6 +217,7 @@ else()
try_append_c_flags(-Wcast-align=strict) # GCC >= 8.0. try_append_c_flags(-Wcast-align=strict) # GCC >= 8.0.
try_append_c_flags(-Wconditional-uninitialized) # Clang >= 3.0 only. try_append_c_flags(-Wconditional-uninitialized) # Clang >= 3.0 only.
try_append_c_flags(-Wextra) # GCC >= 3.4, this is the newer name of -W, which we don't use because older GCCs will warn about unused functions. try_append_c_flags(-Wextra) # GCC >= 3.4, this is the newer name of -W, which we don't use because older GCCs will warn about unused functions.
try_append_c_flags(-Wleading-whitespace=spaces) # GCC >= 15.0
try_append_c_flags(-Wnested-externs) try_append_c_flags(-Wnested-externs)
try_append_c_flags(-Wno-long-long) # GCC >= 3.0, -Wlong-long is implied by -pedantic. try_append_c_flags(-Wno-long-long) # GCC >= 3.0, -Wlong-long is implied by -pedantic.
try_append_c_flags(-Wno-overlength-strings) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic. try_append_c_flags(-Wno-overlength-strings) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic.
@@ -224,6 +225,7 @@ else()
try_append_c_flags(-Wreserved-identifier) # Clang >= 13.0 only. try_append_c_flags(-Wreserved-identifier) # Clang >= 13.0 only.
try_append_c_flags(-Wshadow) try_append_c_flags(-Wshadow)
try_append_c_flags(-Wstrict-prototypes) try_append_c_flags(-Wstrict-prototypes)
try_append_c_flags(-Wtrailing-whitespace=any) # GCC >= 15.0
try_append_c_flags(-Wundef) try_append_c_flags(-Wundef)
endif() endif()

View File

@@ -1,4 +1,4 @@
ACLOCAL_AMFLAGS = -I build-aux/m4 ACLOCAL_AMFLAGS = -I autotools-aux/m4
# AM_CFLAGS will be automatically prepended to CFLAGS by Automake when compiling some foo # AM_CFLAGS will be automatically prepended to CFLAGS by Automake when compiling some foo
# which does not have an explicit foo_CFLAGS variable set. # which does not have an explicit foo_CFLAGS variable set.

View File

@@ -67,6 +67,9 @@ RUN \
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \ wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
# Add repository for this Debian release # Add repository for this Debian release
. /etc/os-release && echo "deb http://apt.llvm.org/${VERSION_CODENAME} llvm-toolchain-${VERSION_CODENAME} main" >> /etc/apt/sources.list && \ . /etc/os-release && echo "deb http://apt.llvm.org/${VERSION_CODENAME} llvm-toolchain-${VERSION_CODENAME} main" >> /etc/apt/sources.list && \
# Temporarily work around Sequoia PGP policy deadline for legacy repositories.
# See https://github.com/llvm/llvm-project/issues/153385.
sed -i 's/\(sha1\.second_preimage_resistance =\).*/\1 9999-01-01/' /usr/share/apt/default-sequoia.config && \
apt-get update && \ apt-get update && \
# Determine the version number of the LLVM development branch # Determine the version number of the LLVM development branch
LLVM_VERSION=$(apt-cache search --names-only '^clang-[0-9]+$' | sort -V | tail -1 | cut -f1 -d" " | cut -f2 -d"-" ) && \ LLVM_VERSION=$(apt-cache search --names-only '^clang-[0-9]+$' | sort -V | tail -1 | cut -f1 -d" " | cut -f2 -d"-" ) && \

View File

@@ -19,8 +19,8 @@ define(_LIB_VERSION_AGE, 0)
AC_INIT([libsecp256k1],m4_join([.], _PKG_VERSION_MAJOR, _PKG_VERSION_MINOR, _PKG_VERSION_PATCH)m4_if(_PKG_VERSION_IS_RELEASE, [true], [], [-dev]),[https://github.com/bitcoin-core/secp256k1/issues],[libsecp256k1],[https://github.com/bitcoin-core/secp256k1]) AC_INIT([libsecp256k1],m4_join([.], _PKG_VERSION_MAJOR, _PKG_VERSION_MINOR, _PKG_VERSION_PATCH)m4_if(_PKG_VERSION_IS_RELEASE, [true], [], [-dev]),[https://github.com/bitcoin-core/secp256k1/issues],[libsecp256k1],[https://github.com/bitcoin-core/secp256k1])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([autotools-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4]) AC_CONFIG_MACRO_DIR([autotools-aux/m4])
AC_CANONICAL_HOST AC_CANONICAL_HOST
# Require Automake 1.11.2 for AM_PROG_AR # Require Automake 1.11.2 for AM_PROG_AR
@@ -111,6 +111,8 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0 SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0
SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only
SECP_TRY_APPEND_CFLAGS([-Wreserved-identifier], $1) # Clang >= 13.0 only SECP_TRY_APPEND_CFLAGS([-Wreserved-identifier], $1) # Clang >= 13.0 only
SECP_TRY_APPEND_CFLAGS([-Wtrailing-whitespace=any], $1) # GCC >= 15.0
SECP_TRY_APPEND_CFLAGS([-Wleading-whitespace=spaces], $1) # GCC >= 15.0
CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS" CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"
fi fi

View File

@@ -61,7 +61,7 @@ Perform these checks when reviewing the release PR (see below):
4. Open a PR to the master branch with a commit (using message `"release cleanup: bump version after $MAJOR.$MINOR.$PATCH"`, for example) that 4. Open a PR to the master branch with a commit (using message `"release cleanup: bump version after $MAJOR.$MINOR.$PATCH"`, for example) that
* sets `_PKG_VERSION_IS_RELEASE` to `false` and increments `_PKG_VERSION_PATCH` and `_LIB_VERSION_REVISION` in `configure.ac`, * sets `_PKG_VERSION_IS_RELEASE` to `false` and increments `_PKG_VERSION_PATCH` and `_LIB_VERSION_REVISION` in `configure.ac`,
* increments the `$PATCH` component of `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_REVISION` in `CMakeLists.txt`, and * increments the `$PATCH` component of `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_REVISION` in `CMakeLists.txt`, and
* adds an `[Unreleased]` section header to the [CHANGELOG.md](../CHANGELOG.md). * adds an `[Unreleased]` section header and a corresponding `[Unreleased]` link at the bottom of [CHANGELOG.md](../CHANGELOG.md).
If other maintainers are not present to approve the PR, it can be merged without ACKs. If other maintainers are not present to approve the PR, it can be merged without ACKs.
5. Create a new GitHub release with a link to the corresponding entry in [CHANGELOG.md](../CHANGELOG.md). 5. Create a new GitHub release with a link to the corresponding entry in [CHANGELOG.md](../CHANGELOG.md).

View File

@@ -349,7 +349,7 @@ SECP256K1_API void secp256k1_context_destroy(
* writes the message to stderr and calls abort. This default callback can be * writes the message to stderr and calls abort. This default callback can be
* replaced at link time if the preprocessor macro * replaced at link time if the preprocessor macro
* USE_EXTERNAL_DEFAULT_CALLBACKS is defined, which is the case if the build * USE_EXTERNAL_DEFAULT_CALLBACKS is defined, which is the case if the build
* has been configured with --enable-external-default-callbacks (GNU Autotools) or * has been configured with --enable-external-default-callbacks (GNU Autotools) or
* -DSECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS=ON (CMake). Then the * -DSECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS=ON (CMake). Then the
* following two symbols must be provided to link against: * following two symbols must be provided to link against:
* - void secp256k1_default_illegal_callback_fn(const char *message, void *data); * - void secp256k1_default_illegal_callback_fn(const char *message, void *data);

View File

@@ -95,7 +95,7 @@ set_target_properties(secp256k1_objs PROPERTIES
) )
# This emulates Libtool to make sure Libtool and CMake agree on the ABI version, # This emulates Libtool to make sure Libtool and CMake agree on the ABI version,
# see below "Calculate the version variables" in build-aux/ltmain.sh. # see below "Calculate the version variables" in autotools-aux/ltmain.sh.
math(EXPR ${PROJECT_NAME}_soversion "${${PROJECT_NAME}_LIB_VERSION_CURRENT} - ${${PROJECT_NAME}_LIB_VERSION_AGE}") math(EXPR ${PROJECT_NAME}_soversion "${${PROJECT_NAME}_LIB_VERSION_CURRENT} - ${${PROJECT_NAME}_LIB_VERSION_AGE}")
set_target_properties(secp256k1 PROPERTIES set_target_properties(secp256k1 PROPERTIES
SOVERSION ${${PROJECT_NAME}_soversion} SOVERSION ${${PROJECT_NAME}_soversion}

View File

@@ -59,7 +59,7 @@ static void print_number(const int64_t x) {
y /= 10; y /= 10;
} }
} else if (c == 0) { /* fractional part is 0 */ } else if (c == 0) { /* fractional part is 0 */
buffer[--ptr] = '0'; buffer[--ptr] = '0';
} }
buffer[--ptr] = '.'; buffer[--ptr] = '.';
do { do {

View File

@@ -78,10 +78,15 @@
# if defined(__clang__) && defined(__APPLE__) # if defined(__clang__) && defined(__APPLE__)
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wreserved-identifier" # pragma clang diagnostic ignored "-Wreserved-identifier"
# elif defined(__GNUC__) && (__GNUC__ >= 15)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtrailing-whitespace"
# endif # endif
# include <valgrind/memcheck.h> # include <valgrind/memcheck.h>
# if defined(__clang__) && defined(__APPLE__) # if defined(__clang__) && defined(__APPLE__)
# pragma clang diagnostic pop # pragma clang diagnostic pop
# elif defined(__GNUC__) && (__GNUC__ >= 15)
# pragma GCC diagnostic pop
# endif # endif
# define SECP256K1_CHECKMEM_ENABLED 1 # define SECP256K1_CHECKMEM_ENABLED 1
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) VALGRIND_MAKE_MEM_UNDEFINED((p), (len)) # define SECP256K1_CHECKMEM_UNDEFINE(p, len) VALGRIND_MAKE_MEM_UNDEFINED((p), (len))

View File

@@ -233,7 +233,7 @@ static void secp256k1_fe_add_int(secp256k1_fe *r, int a);
#define secp256k1_fe_mul_int(r, a) ASSERT_INT_CONST_AND_DO(a, secp256k1_fe_mul_int_unchecked(r, a)) #define secp256k1_fe_mul_int(r, a) ASSERT_INT_CONST_AND_DO(a, secp256k1_fe_mul_int_unchecked(r, a))
/** Like secp256k1_fe_mul_int but a is not checked to be an integer constant expression. /** Like secp256k1_fe_mul_int but a is not checked to be an integer constant expression.
* *
* Should not be called directly outside of tests. * Should not be called directly outside of tests.
*/ */
static void secp256k1_fe_mul_int_unchecked(secp256k1_fe *r, int a); static void secp256k1_fe_mul_int_unchecked(secp256k1_fe *r, int a);