Commit Graph

1835 Commits

Author SHA1 Message Date
roconnor-blockstream
d1e7ca192d Typo 2023-03-22 22:01:01 -04:00
Tim Ruffing
9c8c4f443c Merge bitcoin-core/secp256k1#1238: build: bump CMake minimum requirement to 3.13
96dd062511 build: bump CMake minimum requirement to 3.13 (Cory Fields)

Pull request description:

  As requested here: https://github.com/bitcoin-core/secp256k1/pull/1230#issuecomment-1464730218 . Ping @hebasto

  Among other things this allows us to link against object libraries.

  3.13 has been mentioned several times as a good overlap between newish features and widespread Linux availability.

ACKs for top commit:
  hebasto:
    ACK 96dd062511
  real-or-random:
    utACK 96dd062511

Tree-SHA512: 6c744809aa393b48ef10b3d46c6630370c388a8d375116bfad65c6c907e69c36ed71c1579b9d5c3aa976f70b1cd70e837c1a0226910a43539435125115b32568
2023-03-22 00:14:55 +09:00
Tim Ruffing
0cf2fb91ef Merge bitcoin-core/secp256k1#1243: build: Ensure no optimization when building for coverage analysis
8e79c7ed11 build: Ensure no optimization when building for coverage analysis (Hennadii Stepanov)

Pull request description:

  #944 introduced a regression when building for coverage analysis. The `-O2` flag from the default Autoconf's `CFLAGS` overrides the coverage-specific `-O0` one, which makes coverage analysis results [less reliable](https://gcc.gnu.org/onlinedocs/gcc/Gcov-and-Optimization.html).

  This PR restores the pre-#944 behaviour.

  In contrast to an alternative smaller diff:
  ```diff
  --- a/configure.ac
  +++ b/configure.ac
  @@ -240,7 +240,7 @@ fi

   if test x"$enable_coverage" = x"yes"; then
       SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DCOVERAGE=1"
  -    SECP_CFLAGS="-O0 --coverage $SECP_CFLAGS"
  +    CFLAGS="$CFLAGS -O0 --coverage "
       LDFLAGS="--coverage $LDFLAGS"
   else
       # Most likely the CFLAGS already contain -O2 because that is autoconf's default.
  ```

  this PR ensures that the user always has the last word.

  FWIW, Bitcoin Core uses a similar [approach](460e394625/configure.ac (L879-L884)).

ACKs for top commit:
  jonasnick:
    tested ACK 8e79c7ed11
  real-or-random:
    utACK 8e79c7ed11

Tree-SHA512: f04b55921d397bd7c003ec0283101d3908f3fb507789c855e1b6d5abd150e7d6281d5eeb8fefbb7d6a55b3c6f29a19324f570eee009794f8fa9bca956229e7ce
2023-03-21 21:05:09 +09:00
Hennadii Stepanov
8e79c7ed11 build: Ensure no optimization when building for coverage analysis 2023-03-14 18:56:24 +00:00
Cory Fields
96dd062511 build: bump CMake minimum requirement to 3.13
Among other things this allows us to link against object libraries.
2023-03-12 19:03:39 +00:00
Pieter Wuille
427bc3cdcf Merge bitcoin-core/secp256k1#1236: Update comment for secp256k1_modinv32_inv256
647f0a5cb1 Update comment for secp256k1_modinv32_inv256 (roconnor-blockstream)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 647f0a5cb1
  real-or-random:
    utACK 647f0a5cb1

Tree-SHA512: 7c2ec02acf985bb6edfc619ce31bd63511ff634d847a25888927b48b5164353a912d470421b0b969a868fbc5b865cbea188e14357557f44be42d5702af7c5a6b
2023-03-11 18:14:01 -05:00
roconnor-blockstream
647f0a5cb1 Update comment for secp256k1_modinv32_inv256 2023-03-10 08:53:33 -05:00
Tim Ruffing
5658209459 Merge bitcoin-core/secp256k1#1228: release cleanup: bump version after 0.3.0
28e63f7ea7 release cleanup: bump version after 0.3.0 (Jonas Nick)

Pull request description:

  Based on #1223. Should be merged only after tagging the release.

ACKs for top commit:
  sipa:
    ACK 28e63f7ea7
  real-or-random:
    ACK 28e63f7ea7

Tree-SHA512: d219f836c9258af52389f62c167adb79a0f83f520ede514e286e84f0540d35234322e67d582409c332662db17114da1681419d5d400ed88ad2be66a0f6a06089
2023-03-08 23:59:29 +01:00
Jonas Nick
bdf39000b9 Merge bitcoin-core/secp256k1#1223: release: prepare for 0.3.0
b40adf2360 release: prepare for 0.3.0 (Jonas Nick)

Pull request description:

ACKs for top commit:
  sipa:
    ACK b40adf2360
  real-or-random:
    ACK b40adf2360
  hebasto:
    ACK b40adf2360

Tree-SHA512: 221ba2d846804cefa139bee28b985414e293106cf63ef71ce4b34f815a62e5efd58d4ca6a03d6bcd5d843010d18f5be8d1cf43721a92e5196d732f5325499377
v0.3.0
2023-03-08 22:14:06 +00:00
Jonas Nick
28e63f7ea7 release cleanup: bump version after 0.3.0 2023-03-08 22:07:11 +00:00
Jonas Nick
b40adf2360 release: prepare for 0.3.0 2023-03-08 22:00:43 +00:00
Pieter Wuille
90b513aada Merge bitcoin-core/secp256k1#1229: cmake: Rename project to "libsecp256k1"
8be82d4362 cmake: Rename project to "libsecp256k1" (Hennadii Stepanov)

Pull request description:

  Was discussed today on IRC.

ACKs for top commit:
  sipa:
    ACK 8be82d4362
  real-or-random:
    ACK 8be82d4362

Tree-SHA512: 4ea0fe6722c34acc50ebfba9f3c0503c773e268f8c3df6368e20c829ea800e3cb96758eec2813ed9f56ae4aae1f3919d8ae2755d55582e8c1811a08386f1b925
2023-03-08 16:58:47 -05:00
Hennadii Stepanov
8be82d4362 cmake: Rename project to "libsecp256k1" 2023-03-08 21:22:24 +00:00
Tim Ruffing
ef4f8bd025 Merge bitcoin-core/secp256k1#1227: readme: Use correct build type in CMake/Windows build instructions
756b61d451 readme: Use correct build type in CMake/Windows build instructions (Tim Ruffing)

Pull request description:

ACKs for top commit:
  hebasto:
    ACK 756b61d451, it is correct to provide the "RelWithDebInfo" configuration in multi-config setup, as the same build type is the default in single-config setups.

Tree-SHA512: e98a1519fdae4a29c7e06ecd0e68083acaf0f4fc14dfcd12282b89468052bb7c6c2fc7517c8526c9f7555a822a64b2f7c3f1ecc70d17e37a11d831d213f1daef
2023-03-08 19:39:59 +01:00
Tim Ruffing
756b61d451 readme: Use correct build type in CMake/Windows build instructions 2023-03-08 19:21:13 +01:00
Tim Ruffing
3295aa149b Merge bitcoin-core/secp256k1#1225: changelog: Add entry for CMake
92098d84cf changelog: Add entry for CMake (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 92098d84cf
  jonasnick:
    ACK 92098d84cf
  hebasto:
    ACK 92098d84cf

Tree-SHA512: d81ee4f7e1cd31c85a738fb7caaa96fe02add936732b5cdfd74a77191206709fa18157e949b84c04b1932fbcba8f082106acd303924be8312b4ea2f012ecae53
2023-03-08 18:28:04 +01:00
Tim Ruffing
92098d84cf changelog: Add entry for CMake 2023-03-08 17:49:01 +01:00
Pieter Wuille
df323b5c14 Merge bitcoin-core/secp256k1#1113: build: Add CMake-based build system
e1eb33724c ci: Add "x86_64: Windows (VS 2022)" task (Hennadii Stepanov)
10602b0030 cmake: Export config files (Hennadii Stepanov)
5468d70964 build: Add CMake-based build system (Hennadii Stepanov)

Pull request description:

  This PR adds a [CMake](https://cmake.org/)-based build system.

  Added build instructions and examples to the [`README.md`](https://github.com/hebasto/secp256k1/blob/220628-cmake/README.md#building-with-cmake-experimental) file.

  Ways to integrate with downstream CMake-based projects:
  - if `secp256k1` is a subtree (including Bitcoin Core project) -- `add_subdirectory(secp256k1)`
  - if `secp256k1` has been installed -- `find_package(secp256k1 0.2.1 CONFIG)`, see https://github.com/hebasto/secp256k1-CMake-example

  Added a few toolchain files for easy cross compiling.

  Discussions on IRC:
  - https://gnusha.org/secp256k1/2022-06-23.log
  - https://gnusha.org/secp256k1/2022-06-24.log
  - https://gnusha.org/secp256k1/2022-06-27.log
  - https://gnusha.org/secp256k1/2023-01-30.log

  ---

  Related PRs:
  - #315
  - #549
  - #761

  ---

  **Implementation notes**

  Minimum required CMake version is 3.1. This was required to provide [`C_STANDARD`](https://cmake.org/cmake/help/latest/prop_tgt/C_STANDARD.html) property.

  In turn, this choice of CMake version implies it is not possible to build with default CMake on Debian 8, which has CMake v3.0.2 only.

  Also see:
  - [CMake Versions on Linux Distros](https://gitlab.kitware.com/cmake/community/-/wikis/CMake-Versions-on-Linux-Distros)
  - https://repology.org/project/cmake/versions

  ---

  # Autotools -- CMake Feature Parity Tables

  ## 1. Configuration options

  Autotool-based build system features being listed according to the `./configure --help` output.

  | Autotools | CMake |
  |---|---|
  | `--prefix` | `-DCMAKE_INSTALL_PREFIX`
  | `--enable-shared` | `-DSECP256K1_BUILD_SHARED` |
  | `--enable-static` | `-DSECP256K1_BUILD_STATIC` |
  | `--enable-dev-mode` _hidden_ | N/A, see https://github.com/bitcoin-core/secp256k1/pull/1113#discussion_r916979117 |
  | `--enable-benchmark` | `-DSECP256K1_BUILD_BENCHMARK` |
  | `--enable-coverage` | `-DCMAKE_BUILD_TYPE=Coverage` |
  | `--enable-tests` | `-DSECP256K1_BUILD_TESTS` |
  | `--enable-ctime-tests` | `-DSECP256K1_BUILD_CTIME_TESTS` |
  | `--enable-experimental` | `-DSECP256K1_EXPERIMENTAL` |
  | `--enable-exhaustive-tests` | `-DSECP256K1_BUILD_EXHAUSTIVE_TESTS` |
  | `--enable-examples` | `-DSECP256K1_BUILD_EXAMPLES` |
  | `--enable-module-ecdh` | `-DSECP256K1_ENABLE_MODULE_ECDH` |
  | `--enable-module-recovery` | `-DSECP256K1_ENABLE_MODULE_RECOVERY` |
  | `--enable-module-extrakeys` | `-DSECP256K1_ENABLE_MODULE_EXTRAKEYS` |
  | `--enable-module-schnorrsig` | `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG` |
  | `--enable-external-default-callbacks` | `-DSECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS` |
  | `--with-test-override-wide-multiply` _hidden_ | `-DSECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY` |
  | `--with-asm` | `-DSECP256K1_ASM` |
  | `--with-ecmult-window` | `-DSECP256K1_ECMULT_WINDOW_SIZE` |
  | `--with-ecmult-gen-precision` | `-DSECP256K1_ECMULT_GEN_PREC_BITS` |
  | `--with-valgrind` | `-DSECP256K1_VALGRING` |

  A screenshot of grouped options from `cmake-gui`:
  ![image](https://user-images.githubusercontent.com/32963518/214821305-fc3ffe82-4d05-4dd7-b2c2-7ca2d5d12e86.png)

  ## 2. `make` targets

  | Autotools | CMake |
  |---|---|
  | `make` | `make` |
  | `make check` | `make check` |
  | `make install` | `make install` * |

  * Installation of `lib/pkgconfig/libsecp256k1.pc` not implemented.

ACKs for top commit:
  theuni:
    ACK e1eb33724c.
  sipa:
    ACK e1eb33724c
  real-or-random:
    ACK e1eb33724c

Tree-SHA512: ebe2772eeb1a430a0a7ae767fb1a9a82d52d5e9bf2306956cd08f7b442c862be2539774dd10d5555817353d37d1c6add78b8fe5a85bb71239304fb42c98ff337
2023-03-08 10:33:09 -05:00
Hennadii Stepanov
e1eb33724c ci: Add "x86_64: Windows (VS 2022)" task 2023-03-08 13:33:58 +00:00
Hennadii Stepanov
10602b0030 cmake: Export config files 2023-03-08 13:33:52 +00:00
Hennadii Stepanov
5468d70964 build: Add CMake-based build system
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2023-03-08 13:33:16 +00:00
Tim Ruffing
6048e6c03e Merge bitcoin-core/secp256k1#1222: Remove redundant checks.
5d8f53e312 Remove redudent checks. (Russell O'Connor)

Pull request description:

  These abs checks are implied by the subsequent line, and with the subsequent line written as it is, no underflow is possible with signed integers.

  Follows up on https://github.com/bitcoin-core/secp256k1/pull/1218.

ACKs for top commit:
  sipa:
    utACK 5d8f53e312
  real-or-random:
    ACK 5d8f53e312

Tree-SHA512: ddd6758638fe634866fdaf900224372e2e51cb81ef4d024f169fbc39fff38ef1b29e90e0732877e8910158b82bc428ee9c3a4031882c2850b22ad87cc63ee305
2023-03-08 14:18:44 +01:00
Tim Ruffing
eb8749fcd0 Merge bitcoin-core/secp256k1#1221: Update Changelog
d232112fa7 Update Changelog (Tim Ruffing)

Pull request description:

  Fixes #1220.

ACKs for top commit:
  sipa:
    ACK d232112fa7
  jonasnick:
    ACK d232112fa7

Tree-SHA512: 86c0b9ec54480b87772bb3458ba3016676f747ea76148326b1c9c7fa3f0d8f3cee26bb68c1f2cb736f69a00811691b4d8c02e27c2de799552c547e824fbbb7ec
2023-03-08 12:08:56 +01:00
Russell O'Connor
5d8f53e312 Remove redudent checks.
These abs checks are implied by the subsequent line, and with the subsequent line written as it is, no underflow is possible with signed integers.
2023-03-07 09:10:36 -05:00
Jonas Nick
9d1b458d5f Merge bitcoin-core/secp256k1#1217: Add secp256k1_fe_add_int function
b081f7e4cb Add secp256k1_fe_add_int function (Pieter Wuille)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK b081f7e4cb
  real-or-random:
    utACK b081f7e4cb

Tree-SHA512: daf9956c81a328505faee7fb59d29ec0c5a326bce7c48159a8e0ed7590505b430785d750d0c34f152b9119ad130030063be999da0c2035747a27fe501e77560a
2023-03-07 14:08:05 +00:00
Tim Ruffing
d232112fa7 Update Changelog
Fixes #1220.
2023-03-07 12:01:23 +01:00
Tim Ruffing
8962fc95bb Merge bitcoin-core/secp256k1#1218: Update overflow check
2ef1c9b387 Update overflow check (Russell O'Connor)

Pull request description:

  One does not simply check for integer overlow.

ACKs for top commit:
  sipa:
    ACK 2ef1c9b387
  real-or-random:
    ACK 2ef1c9b387

Tree-SHA512: 61238b7b59b3840aa04c4c3ff768789eba95d8d9cbd16507b86bae585fe8d077ac1ac234f9d8aea7fa342c7278a30d2d888df3a93d7ab24730e73b682b11a7fe
2023-03-07 09:50:03 +01:00
Russell O'Connor
2ef1c9b387 Update overflow check
One does not simply check for integer overlow.
2023-03-06 18:13:47 -05:00
Tim Ruffing
5757318782 Merge bitcoin-core/secp256k1#1212: Prevent dead-store elimination when clearing secrets in examples
5660c13755 prevent optimization in algorithms (Harshil Jani)

Pull request description:

  Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>

ACKs for top commit:
  sipa:
    utACK 5660c13755
  real-or-random:
    utACK 5660c13755

Tree-SHA512: 90024b7445c04e18a88af4099fc1ac6d1b9b2309b88dd22ae2b1f50aed7bac28b2c180cc28e1a95d5e9ec94b4c4adc44b9ada1477e6abe8efae7884c2382645c
2023-03-02 23:30:20 +01:00
Pieter Wuille
b081f7e4cb Add secp256k1_fe_add_int function 2023-03-02 17:09:25 -05:00
Harshil Jani
5660c13755 prevent optimization in algorithms
Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>

Add secure_erase function to clear secrets

Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>

Update the function with good practices

Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>

Renaming random.h to examples_util.h

Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
2023-03-02 15:36:41 +05:30
Tim Ruffing
09b1d466db Merge bitcoin-core/secp256k1#979: Native jacobi symbol algorithm
ce3cfc78a6 doc: Describe Jacobi calculation in safegcd_implementation.md (Elliott Jin)
6be01036c8 Add secp256k1_fe_is_square_var function (Pieter Wuille)
1de2a01c2b Native jacobi symbol algorithm (Pieter Wuille)
04c6c1b181 Make secp256k1_modinv64_det_check_pow2 support abs val (Pieter Wuille)
5fffb2c7af Make secp256k1_i128_check_pow2 support -(2^n) (Pieter Wuille)

Pull request description:

  This introduces variants of the vartime divsteps-based GCD algorithm used for modular inverses to compute Jacobi symbols. Changes compared to the normal vartime divsteps:
  * Only positive matrices are used, guaranteeing that f and g remain positive.
  * An additional jac variable is updated to track sign changes during matrix computation.
  * There is (so far) no proof that this algorithm terminates within reasonable amount of time for every input, but experimentally it appears to almost always need less than 900 iterations. To account for that, only a bounded number of iterations is performed (1500), after which failure is returned. The field logic then falls back to using square roots to determining the result.
  * The algorithm converges to f=g=gcd(f0,g0) rather than g=0. To keep this test simple, the end condition is f=1, which won't be reached if started with g=0. That case is dealt with specially.

  This code is currently unused, except for tests. I don't aim for it to be merged until there is a need for it, but this demonstrates its feasibility.

  In terms of performance:
  ```
  field_inverse: min 1.76us / avg 1.76us / max 1.78us
  field_inverse_var: min 0.991us / avg 0.993us / max 0.996us
  field_jacobi_var: min 1.31us / avg 1.31us / max 1.31us
  field_sqrt: min 4.36us / avg 4.37us / max 4.40us
  ```

  while with the older (f24e122d13) libgmp based Jacobi code on the same system:
  ```
  num_jacobi: min 1.53us / avg 1.54us / max 1.55us
  ```

ACKs for top commit:
  jonasnick:
    ACK ce3cfc78a6
  real-or-random:
    reACK ce3cfc78a6 diff and writeup is good and I tested every commit

Tree-SHA512: 8a6204a7a108d8802d942a54faca39917f90ea5923130683bbd870f9025f4ec8ef256ffa1d939a793f0b32d4cdfcdcd1d3f8ae5ed74a0193be7ad98362ce027e
2023-03-01 15:44:00 +01:00
Elliott Jin
ce3cfc78a6 doc: Describe Jacobi calculation in safegcd_implementation.md 2023-02-28 15:57:32 -05:00
Pieter Wuille
6be01036c8 Add secp256k1_fe_is_square_var function
The implementation calls the secp256k1_modinvNN_jacobi_var code, falling back
to computing a square root in the (extremely rare) case it failed converge.
2023-02-28 15:57:32 -05:00
Pieter Wuille
1de2a01c2b Native jacobi symbol algorithm
This introduces variants of the divsteps-based GCD algorithm used for
modular inverses to compute Jacobi symbols. Changes compared to
the normal vartime divsteps:
* Only positive matrices are used, guaranteeing that f and g remain
  positive.
* An additional jac variable is updated to track sign changes during
  matrix computation.
* There is (so far) no proof that this algorithm terminates within
  reasonable amount of time for every input, but experimentally it
  appears to almost always need less than 900 iterations. To account
  for that, only a bounded number of iterations is performed (1500),
  after which failure is returned. In VERIFY mode a lower iteration
  count is used to make sure that callers exercise their fallback.
* The algorithm converges to f=g=gcd(f0,g0) rather than g=0. To keep
  this test simple, the end condition is f=1, which won't be reached
  if started with non-coprime or g=0 inputs. Because of that we only
  support coprime non-zero inputs.
2023-02-28 15:54:00 -05:00
Pieter Wuille
04c6c1b181 Make secp256k1_modinv64_det_check_pow2 support abs val 2023-02-27 15:38:05 -05:00
Pieter Wuille
5fffb2c7af Make secp256k1_i128_check_pow2 support -(2^n) 2023-02-27 15:38:05 -05:00
Tim Ruffing
cbd2555934 Merge bitcoin-core/secp256k1#1209: build: Add SECP256K1_API_VAR to fix importing variables from DLLs
e4330341bd ci: Shutdown wineserver whenever CI script exits (Tim Ruffing)
9a5a611a21 build: Suppress stupid MSVC linker warning (Tim Ruffing)
739c53b19a examples: Extend sig examples by call that uses static context (Tim Ruffing)
914276e4d2 build: Add SECP256K1_API_VAR to fix importing variables from DLLs (Tim Ruffing)

Pull request description:

  ... and more Windows fixes, please see the individual commits.

  The fixed issues were discovered in https://github.com/bitcoin-core/secp256k1/pull/1198.

ACKs for top commit:
  sipa:
    utACK e4330341bd
  hebasto:
    ACK e4330341bd, tested on Windows using [CMake](https://github.com/bitcoin-core/secp256k1/pull/1113) (which means that the 3rd commit is reviewed only, but not tested). FWIW, `LNK4217` warnings have been indeed observed.

Tree-SHA512: ce7845b106190cdc517988c30aaf2cc9f1d6da22904dfc5cb6bf4ee05f063929dc8b3038479e703b6cebac79d1c21d0c84560344d2478cb1c1740087383f40e3
2023-02-22 00:41:04 +01:00
Pieter Wuille
1b21aa5175 Merge bitcoin-core/secp256k1#1078: group: Save a normalize_to_zero in gej_add_ge
e089eecc1e group: Further simply gej_add_ge (Tim Ruffing)
ac71020ebe group: Save a normalize_to_zero in gej_add_ge (Tim Ruffing)

Pull request description:

  As discovered  by sipa in #1033.

  See commit message for reasoning but note that the infinity handling will be replaced in the second commit again.

ACKs for top commit:
  sipa:
    ACK e089eecc1e
  apoelstra:
    ACK e089eecc1e

Tree-SHA512: fb1b5742e73dd8b2172b4d3e2852490cfd626e8673b72274d281fa34b04e9368a186895fb9cd232429c22b14011df136f4c09bdc7332beef2b3657f7f2798d66
2023-02-14 14:55:46 -05:00
Tim Ruffing
e4330341bd ci: Shutdown wineserver whenever CI script exits
Before: CI times out when a wine task fails.
After:  Wine tasks exit properly when they fail.
2023-02-06 21:44:56 +01:00
Tim Ruffing
9a5a611a21 build: Suppress stupid MSVC linker warning
... and use correct format to pass linker flags
2023-02-06 21:44:56 +01:00
Tim Ruffing
739c53b19a examples: Extend sig examples by call that uses static context
Besides improving the examples, this makes sure that the examples
import a variable (instead of a function), namely the static context,
from the library. This is helpful when testing MSVC builds, because
the MSVC linker tends to be awkward when importing variables.
2023-02-06 21:44:56 +01:00
Tim Ruffing
914276e4d2 build: Add SECP256K1_API_VAR to fix importing variables from DLLs
This fixes a build issue with MSVC. While MSVC imports *functions*
from DLLs automatically when building a consumer of the DLL, it does
not import *variables* automatically. In these cases, we need an
explicit __declspec(dllimport).

This commit simply changes our logic to what the libtool manual
suggests, which has a very comprehensive writeup on the topic. Note
that in particular, this solution is carefully designed not to break
static linking. However, as described in the libtool manual,
statically linking the library with MSVC will output warning LNK4217.
This is still the best solution overall, because the warning is
merely a cosmetic issue.
2023-02-06 21:44:56 +01:00
Tim Ruffing
1cca7c1744 Merge bitcoin-core/secp256k1#1206: build: Add -Wreserved-identifier supported by clang
8c7e0fc1de build: Add -Wreserved-identifier supported by clang (Tim Ruffing)

Pull request description:

  This warns on certain identifiers reserved by the C standard, namely
   * identifiers that begin with an underscore followed by an uppercase letter, and
   * identifiers in the global namespace that begin with an underscore.

  We had used such identifiers in the past for macros in include guards, and we should make sure that we don't reintroduce such identifiers going forward.

  Note that C reserves more identifiers for "future library directions", e.g., identifiers that begin with "str" followed by a lowercase letter. But even the C standards committee has decided that this is somewhat silly and adopted a proposal [1] for C23 that removes the restriction that programs using these identifiers have UB. Instead, these identifiers are now "potentially reserved", which is not a normative restriction but simply an informative warning that the identifiers may become fully reserved in the future.

  [1] https://www.open-std.org/jtc1/sc22/WG14/www/docs/n2625.pdf

ACKs for top commit:
  sipa:
    utACK 8c7e0fc1de
  jonasnick:
    tested ACK 8c7e0fc1de

Tree-SHA512: da0c5f1e36cffad2ab2f0b8055c8b3cb56e904d8bfea5a9eed9d6fa984359217b3ef3b9232bfb455cf4071c04a6c2a077e26d2a15b20d1eabc99b1fc61d2025c
2023-02-03 11:39:03 +01:00
Tim Ruffing
8c7e0fc1de build: Add -Wreserved-identifier supported by clang
This warns on certain identifiers reserved by the C standard, namely
 * identifiers that begin with an underscore followed by an uppercase
   letter, and
 * identifiers in the global namespace that begin with an underscore.

We had used such identifiers in the past for macros in include guards,
and we should make sure that we don't reintroduce such identifiers
going forward.

Note that C reserves more identifiers for "future library directions",
e.g., identifiers that begin with "str" followed by a lowercase letter.
But even the C standards committee has decided that this is somewhat
silly and adopted a proposal [1] for C23 that removes the restriction
that programs using these identifiers have UB. Instead, these
identifiers are now "potentially reserved", which is not a normative
restriction but simply an informative warning that the identifiers
may become fully reserved in the future.

[1] https://www.open-std.org/jtc1/sc22/WG14/www/docs/n2625.pdf
2023-02-02 14:56:58 +01:00
Tim Ruffing
8ebe5c5205 Merge bitcoin-core/secp256k1#1201: ci: Do not set git's user.{email,name} config options
9b60e3148d ci: Do not set git's `user.{email,name}` config options (Hennadii Stepanov)

Pull request description:

  A cleanup after https://github.com/bitcoin-core/secp256k1/pull/1199.

  git's `user.{email,name}` config options have been no longer required since 0ecf318851.

ACKs for top commit:
  real-or-random:
    utACK 9b60e3148d

Tree-SHA512: 04f737b0549a91ca992cd1410420e041549a07869eeef068e08971781ea8a4c88a2486e789df36a5ad370ccbbf5d9f7e49ab5f7c1d01faef358ffc4863aaf8e4
2023-01-31 09:15:48 +01:00
Tim Ruffing
5596ec5c2c Merge bitcoin-core/secp256k1#1203: Do not link bench and ctime_tests to COMMON_LIB
ef39721ccc Do not link `bench` and `ctime_tests` to `COMMON_LIB` (Hennadii Stepanov)

Pull request description:

  The `bench` and `ctime_tests` binaries are users of the library, they should only be linked to the library, not the objects it was built from.

ACKs for top commit:
  sipa:
    utACK ef39721ccc
  real-or-random:
    utACK ef39721ccc

Tree-SHA512: 8bf8330adcce9bf6b21aceacf86e6aff7594762ab68b09257cfe2904fa0ce827377d5a13c0bed5acde74a2b420bb49460657c66d0068ecbe36dc162140876be4
2023-01-31 09:08:46 +01:00
Hennadii Stepanov
ef39721ccc Do not link bench and ctime_tests to COMMON_LIB
The `bench` and `ctime_tests` are users of the library, they should only
be linked to the library, not the objects it was built from.
2023-01-30 22:42:39 +00:00
Hennadii Stepanov
9b60e3148d ci: Do not set git's user.{email,name} config options
git's `user.{email,name}` config options have been no longer required
since 0ecf318851.
2023-01-30 16:29:46 +00:00
Tim Ruffing
e1817a6f54 Merge bitcoin-core/secp256k1#1199: ci: Minor improvements inspired by Bitcoin Core
c2415866c7 ci: Don't fetch git history (Tim Ruffing)
0ecf318851 ci: Use remote pull/merge ref instead of local git merge (Tim Ruffing)

Pull request description:

  This steals two recent CI improvements from bitcoin/bitcoin.  See individual commit messages.

ACKs for top commit:
  sipa:
    utACK c2415866c7

Tree-SHA512: 966130f45767c6bee8bc041d7e90a3166591a54c7cfccdcf4dff99aa4f6ccc2d02544fa7dca9fd020241349775da3cbd9bdbb041fcdd32de7426efd9dcc9c7f8
2023-01-30 11:06:19 +01:00