Skip to content

Commit 901127b

Browse files
committed
simplicity-sys: add links= field to the Cargo.toml file
This field tells Cargo what library we're linking in, and helps it provide sane error messages (rather than linker spew) when somebody tries to compile multiple versions of the library that link the same thing. When we provide a links field we should also provide a build field. This is set to build.rs by default, but crate2nix seems to get confused when one is present but not the other.
1 parent ee46600 commit 901127b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

simplicity-sys/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ documentation = "https://docs.rs/simplicity-sys/"
88
description = "FFI bindings to libsimplicity"
99
edition = "2021"
1010
rust-version = "1.78.0"
11+
build = "build.rs"
12+
links = "rustsimplicity_0_4"
1113

1214
[build-dependencies]
1315
cc = "1.0.83"

simplicity-sys/vendor-simplicity.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,7 @@ sed -i -r "s/rustsimplicity_[0-9]+_[0-9]+_/rustsimplicity_${SIMPLICITY_ALLOC_VER
9797

9898
# d. ...also update the corresponding link_name= entries in the Rust source code
9999
find "./src/" -name "*.rs" -type f -print0 | xargs -0 \
100-
sed -i -r "s/rustsimplicity_[0-9]+_[0-9]+_(.*)([\"\(])/rustsimplicity_${SIMPLICITY_ALLOC_VERSION_CODE}_\1\2/g"
100+
sed -i -r "s/rustsimplicity_[0-9]+_[0-9]+_(.*)([\"\(])/rustsimplicity_${SIMPLICITY_ALLOC_VERSION_CODE}_\1\2/g"
101+
# e. ...and the links= field in the manifest file
102+
sed -i -r "s/^links = \".*\"$/links = \"rustsimplicity_${SIMPLICITY_ALLOC_VERSION_CODE}\"/" Cargo.toml
103+

0 commit comments

Comments
 (0)