Skip to content

Commit

Permalink
Update Bitcoin Core dependency to 0.21.2
Browse files Browse the repository at this point in the history
Currently we are vendoring the source code from Bitcoin Core `v0.20.1`.

Update the subtree to use branch `0.21.2` using:

git subtree pull --prefix='depend/bitcoin' \
                 git@github.com:bitcoin/bitcoin.git v0.21.2 \
                 --squash

Includes changes to the build script by Jake and update to the C++
toolchain suggested by Richard.

Uses the new version format, increasing the Bitocoin Core version as is
applicable and also bumping the minor version of this lib.

Co-developed-by: Jake Rawsthorne <jake@jakerawsthorne.co.uk>
Co-developed-by: Richard Ulrich <richard.ulrich@seba.swiss>
  • Loading branch information
tcharding committed Jul 22, 2022
1 parent 22d001c commit 53f991c
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ fn main() {
let is_big_endian = env::var("CARGO_CFG_TARGET_ENDIAN").expect("No endian is set") == "big";
let mut base_config = cc::Build::new();
base_config
.cpp(true)
.include("depend/bitcoin/src")
.include("depend/bitcoin/src/secp256k1/include")
.define("__STDC_FORMAT_MACROS", None);

if target.contains("windows") {
base_config.define("WIN32", "1");
}

let mut secp_config = base_config.clone();
let mut consensus_config = base_config;

// **Secp256k1**
if !cfg!(feature = "external-secp") {
base_config
secp_config
.include("depend/bitcoin/src/secp256k1")
.include("depend/bitcoin/src/secp256k1/src")
.flag_if_supported("-Wno-unused-function") // some ecmult stuff is defined but not used upstream
.define("SECP256K1_BUILD", "1")
// Bitcoin core defines libsecp to *not* use libgmp.
Expand All @@ -38,34 +44,39 @@ fn main() {
.define("USE_SCALAR_INV_BUILTIN", "1")
// Technically libconsensus doesn't require the recovery feautre, but `pubkey.cpp` does.
.define("ENABLE_MODULE_RECOVERY", "1")
.define("ECMULT_WINDOW_SIZE", "15")
.define("ECMULT_GEN_PREC_BITS", "4")
.define("ENABLE_MODULE_SCHNORRSIG", "1")
.define("ENABLE_MODULE_EXTRAKEYS", "1")
// The actual libsecp256k1 C code.
.file("depend/bitcoin/src/secp256k1/src/secp256k1.c");

if is_big_endian {
base_config.define("WORDS_BIGENDIAN", "1");
secp_config.define("WORDS_BIGENDIAN", "1");
}

if use_64bit_compilation {
base_config
secp_config
.define("USE_FIELD_5X52", "1")
.define("USE_SCALAR_4X64", "1")
.define("HAVE___INT128", "1");
} else {
base_config.define("USE_FIELD_10X26", "1").define("USE_SCALAR_8X32", "1");
secp_config.define("USE_FIELD_10X26", "1").define("USE_SCALAR_8X32", "1");
}
}

let tool = base_config.get_compiler();
secp_config.compile("libsecp256k1.a");

let tool = consensus_config.get_compiler();
if tool.is_like_msvc() {
base_config.flag("/std:c++14").flag("/wd4100");
consensus_config.flag("/std:c++17").flag("/wd4100");
} else if tool.is_like_clang() || tool.is_like_gnu() {
base_config.flag("-std=c++11").flag("-Wno-unused-parameter");
consensus_config.flag("-std=c++17").flag("-Wno-unused-parameter");
}

if target.contains("windows") {
base_config.define("WIN32", "1");
}
base_config
consensus_config.cpp(true)
.include("depend/bitcoin/src")
.include("depend/bitcoin/src/secp256k1/include")
.file("depend/bitcoin/src/util/strencodings.cpp")
.file("depend/bitcoin/src/uint256.cpp")
.file("depend/bitcoin/src/pubkey.cpp")
Expand Down

0 comments on commit 53f991c

Please sign in to comment.