Switch to static linking of secp256k1

Pieter moved some stuff I need into the contrib/ directory which does
not expose anything through the shared lib, so I need to statically
link.

I might also use this to do evil things to expose the SHA256 code
in libsecp, but not for now ;).
This commit is contained in:
Andrew Poelstra 2015-10-26 10:21:01 -05:00
parent 98295a285b
commit e7ca836c2b
4 changed files with 48 additions and 6 deletions

View File

@ -7,11 +7,6 @@ matrix:
- rust: nightly - rust: nightly
install: install:
- git clone https://github.com/bitcoin/secp256k1.git
- cd secp256k1
- ./autogen.sh && ./configure --enable-module-ecdh --enable-module-recovery && make && sudo make install
- sudo ldconfig /usr/local/lib
- cd ..
- | - |
pip install 'travis-cargo<0.2' --user && pip install 'travis-cargo<0.2' --user &&
export PATH=$HOME/.local/bin:$PATH export PATH=$HOME/.local/bin:$PATH

View File

@ -12,6 +12,10 @@ description = "Rust bindings for Pieter Wuille's `libsecp256k1` library. Impleme
keywords = [ "crypto", "ECDSA", "secp256k1", "libsecp256k1", "bitcoin" ] keywords = [ "crypto", "ECDSA", "secp256k1", "libsecp256k1", "bitcoin" ]
readme = "README.md" readme = "README.md"
build = "build.rs"
[build-dependencies]
gcc = "0.3"
[lib] [lib]
name = "secp256k1" name = "secp256k1"
path = "src/lib.rs" path = "src/lib.rs"

44
build.rs Normal file
View File

@ -0,0 +1,44 @@
// Bitcoin secp256k1 bindings
// Written in 2015 by
// Andrew Poelstra
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
//
//! # Build script
// Coding conventions
#![deny(non_upper_case_globals)]
#![deny(non_camel_case_types)]
#![deny(non_snake_case)]
#![deny(unused_mut)]
#![warn(missing_docs)]
extern crate gcc;
fn main() {
gcc::Config::new()
.file("depend/secp256k1/src/secp256k1.c")
.include("depend/secp256k1/")
.include("depend/secp256k1/src")
// TODO these three should be changed to use libgmp, at least until secp PR 290 is merged
.define("USE_NUM_NONE", Some("1"))
.define("USE_FIELD_INV_BUILTIN", Some("1"))
.define("USE_SCALAR_INV_BUILTIN", Some("1"))
// TODO these should use 64-bit variants on 64-bit systems
.define("USE_FIELD_10X26", Some("1"))
.define("USE_SCALAR_8X32", Some("1"))
.define("USE_ENDOMORPHISM", Some("1"))
// These all are OK.
.define("ENABLE_MODULE_ECDH", Some("1"))
.define("ENABLE_MODULE_RECOVERY", Some("1"))
.compile("libsecp256k1.a");
}

View File

@ -116,7 +116,6 @@ impl SharedSecret {
unsafe impl Send for Context {} unsafe impl Send for Context {}
unsafe impl Sync for Context {} unsafe impl Sync for Context {}
#[link(name = "secp256k1")]
extern "C" { extern "C" {
pub static secp256k1_nonce_function_rfc6979: NonceFn; pub static secp256k1_nonce_function_rfc6979: NonceFn;