Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy implementation of semver trick for 0.15 #209

Closed
Kixunil opened this issue Apr 18, 2020 · 31 comments
Closed

Lazy implementation of semver trick for 0.15 #209

Kixunil opened this issue Apr 18, 2020 · 31 comments

Comments

@Kixunil
Copy link
Collaborator

Kixunil commented Apr 18, 2020

Hello, I'm unable to create a PR against non-existing branch, so I'm opening this as an issue.

I managed to implement version 0.15.6 in terms of using secp256k1-sys. This is very useful because it avoids linking the C library twice, creating link errors. Such errors prevented me from building lnp-node. It compiles fine when my change is used (tested via patch in Cargo.toml). CC @dr-orlovsky, you probably want to know about this. :)

All tests (except fuzztarget) for secp256k1 are passing of course. I guess fuzztarget is something special used for fuzzing only, so it doesn't matter that it's not passing, right?

It'd be nice if you created a new branch (maybe without the -lazy-semver-trick suffix) in your repo with my changes and published the 0.15.6 crate to crates.io. I created two commits expecting that it'll make code review easier, but feel free to squash it, if you want. (I wrote the commit message to be easy to modify. :))

See the description in Kixunil@10a33cc to understand what I mean by "lazy" :)

I hope you will find this helpful!

@elichai
Copy link
Member

elichai commented Apr 18, 2020

Hmm That's cool,
But sadly it is still a breaking change, but not in a rust way. this removes the libsecp symbols from 0.15.* meaning that if someone used the library for C linkage it will break linking.

An example is rust-bitcoinconsensus at version 0.17.1: https://github.com/rust-bitcoin/rust-bitcoinconsensus/blob/6fa2f9e9d0df0e311432c3b81ee5afae3b82ab81/Cargo.toml

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

Ah, good catch! Didn't notice there are essentially hidden public items. So I guess we would have to reimplement them? Or is there any workaround for it?

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

Ah, I see now where's the problem, it's just that prefixes changed. Forwarding those symbols somehow should work, I think.

@elichai
Copy link
Member

elichai commented Apr 18, 2020

You can't fix it without causing the same linking issues you're trying to avoid(multiple definitions of the same symbol)
Although maybe through exposing the functions as weak symbols? hmm

EDIT: It seems like it isn't possible to define weak symbols in stable rust rust-lang/rust#29603

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

Shouldn't be an issue because the library will be included only once. Or is there any other instance of a different library defining those same symbols?

@elichai
Copy link
Member

elichai commented Apr 18, 2020

I managed to implement version 0.15.6 in terms of using secp256k1-sys. This is very useful because it avoids linking the C library twice, creating link errors.

I think I might've misunderstood your original problem, are you trying to avoid linking twice to the C library because of binary sizes, or are there actual linking errors? (and rust style errors or C linking errors?)

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

lnp-node depends on two crates, each of them depending on a different version of secp25k1, each of them attempting to link to a C library with the same symbols. By implementing 0.15.6in terms ofsecp256k1-sys`, there will be only one C library to link to, so this error goes away. I already tested that this works.

Kixunil added a commit to Kixunil/rust-secp256k1 that referenced this issue Apr 18, 2020
The previous version of the crate also contained exported symbols as a
part of invisible, but used public API. At least bitcoinconsensus was
using these symbols. This change reexports them under the old names, so
they can still be used.

See rust-bitcoin#209
@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

I managed to fix it! 🎉

The latest commit fixes bitcoinconsensus and does not break lnp-node.

Would be nice if someone looked at it to see if the change is sound (no UB), but at least the tests passed.

@apoelstra
Copy link
Member

I really like this in principle but am having trouble deciding whether this would constitute a breaking change (and if it did, whether it's one so edge-casey or work-around-able that it's worth improving ergonomics for old versions of the library).

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

Worst case we could just revert all the changes, release a new version and tell all projects that have double-linking problems to search for another solution, right?

@apoelstra
Copy link
Member

Heh, yes, in principle we can always "revert if somebody complains" but if we break things for downstream users, that still causes them pain for a day or two, and if they don't think/don't want to complain, maybe we won't ever fix it.

@TheBlueMatt
Copy link
Member

TheBlueMatt commented Apr 18, 2020 via email

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

Yeah, would be better to find out who exactly uses it and how, to know if the trick works reliably enough. Wouldn't want to recklessly break stuff. Just if we do everything we can to avoid breakage without stagnating and it breaks anyway, we have a way out.

Rust lightning is the stale dependency that causes lnp-node to break, so upgrading it there would resolve the linking issue too. There's no other stale dependency, because if it was stale too, it wouldn't have duplicate symbols.

There's also the grin version, but looks like it doesn't conflict for some reason. IDK how it's possible.

If the decision ends up "don't release semver trick version", then maybe mentioning that it exists and is usable via [patch....] somewhere in the docs might still be helpful.

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

Hmm, went to read the docs to see if they promise anything about C symbols being available for other libraries. There's no such thing, so I'd say that the users shouldn't depend on them just because it works. Feels like bypassing the usual stability conventions.

Of course, if symbols are something that is supposed to be available and stable, then it should be documented. Documenting that bitcoinconsensus is a special blessed library would be fine too IMO.

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

FYI, noticed that I broke MSRV, but I fixed it easily.

@TheBlueMatt
Copy link
Member

Rust lightning is the stale dependency that causes lnp-node to break, so upgrading it there would resolve the linking issue too. There's no other stale dependency, because if it was stale too, it wouldn't have duplicate symbols.

I'm a little confused by this. It seems like the only way to hit this issue would be to have two versions of rust-secp in the dependency tree that both predate the switch to versioned symbols. Or is the other such dependency libbitcoinconsensus?

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 18, 2020

Ah, yes, the symbols were renamed, I forgot. This is the error with unpatched version:

/home/user/sources/lnp-node/target/debug/deps/libsecp256k1-9640e677cf524655.rlib(secp256k1-9640e677cf524655.secp256k1.tmtcjvkp-cgu.2.rcgu.o): In function `secp256k1_context_create':
          /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/secp256k1-0.15.5/src/ffi.rs:269: multiple definition of `secp256k1_context_create'
          /home/user/sources/lnp-node/target/debug/deps/libsecp256k1zkp-777673333de8267f.rlib(secp256k1.o):/home/user/.cargo/git/checkouts/rust-secp256k1-zkp-69577f4990b9398e/bf8d0aa/depend/secp256k1-zkp/src/secp256k1.c:79: first defined here

So apparently the symbols from the old version conflict with zkp (grin) version.

It seems like the only way to hit this issue would be to have two versions of rust-secp in the dependency tree that both predate the switch to versioned symbols.

Pretty much what's happening here, it's just that one of them is essentially renamed.

What's really strange is how come that my other commit to fix bitcoinconsensus didn't break it again?? I went to double check it and made sure to run cargo update, still works. 🤔

Cargo tree before semver trick
lnp_node v0.1.0 (/home/user/sources/lnp-node)
├── async-trait v0.1.30
│   ├── proc-macro2 v1.0.10
│   │   └── unicode-xid v0.2.0
│   ├── quote v1.0.3
│   │   └── proc-macro2 v1.0.10 (*)
│   └── syn v1.0.17
│       ├── proc-macro2 v1.0.10 (*)
│       ├── quote v1.0.3 (*)
│       └── unicode-xid v0.2.0 (*)
├── chrono v0.4.11
│   ├── num-integer v0.1.42
│   │   └── num-traits v0.2.11
│   │       [build-dependencies]
│   │       └── autocfg v1.0.0
│   │   [build-dependencies]
│   │   └── autocfg v1.0.0 (*)
│   ├── num-traits v0.2.11 (*)
│   └── time v0.1.42
│       └── libc v0.2.69
├── clap v3.0.0-beta.1 (git+https://github.com/clap-rs/clap.git#aae96236b27d43ede24bd7e58668786cd1073c21)
│   ├── atty v0.2.14
│   │   └── libc v0.2.69 (*)
│   ├── bitflags v1.2.1
│   ├── clap_derive v3.0.0-beta.1 (git+https://github.com/clap-rs/clap.git#aae96236b27d43ede24bd7e58668786cd1073c21)
│   │   ├── heck v0.3.1
│   │   │   └── unicode-segmentation v1.6.0
│   │   ├── proc-macro-error v0.4.12
│   │   │   ├── proc-macro-error-attr v0.4.12
│   │   │   │   ├── proc-macro2 v1.0.10 (*)
│   │   │   │   ├── quote v1.0.3 (*)
│   │   │   │   ├── syn v1.0.17 (*)
│   │   │   │   └── syn-mid v0.5.0
│   │   │   │       ├── proc-macro2 v1.0.10 (*)
│   │   │   │       ├── quote v1.0.3 (*)
│   │   │   │       └── syn v1.0.17 (*)
│   │   │   │   [build-dependencies]
│   │   │   │   └── version_check v0.9.1
│   │   │   ├── proc-macro2 v1.0.10 (*)
│   │   │   ├── quote v1.0.3 (*)
│   │   │   └── syn v1.0.17 (*)
│   │   │   [build-dependencies]
│   │   │   └── version_check v0.9.1 (*)
│   │   ├── proc-macro2 v1.0.10 (*)
│   │   ├── quote v1.0.3 (*)
│   │   └── syn v1.0.17 (*)
│   ├── indexmap v1.3.2
│   │   [build-dependencies]
│   │   └── autocfg v1.0.0 (*)
│   ├── lazy_static v1.4.0
│   ├── strsim v0.9.3
│   ├── termcolor v1.1.0
│   ├── textwrap v0.11.0
│   │   └── unicode-width v0.1.7
│   ├── unicode-width v0.1.7 (*)
│   └── vec_map v0.8.1
├── configure_me v0.3.3
│   ├── parse_arg v0.1.4
│   ├── serde v1.0.106
│   │   └── serde_derive v1.0.106
│   │       ├── proc-macro2 v1.0.10 (*)
│   │       ├── quote v1.0.3 (*)
│   │       └── syn v1.0.17 (*)
│   ├── serde_derive v1.0.106 (*)
│   └── toml v0.4.10
│       └── serde v1.0.106 (*)
├── derive_wrapper v0.1.4
│   ├── quote v0.6.13
│   │   └── proc-macro2 v0.4.30
│   │       └── unicode-xid v0.1.0
│   └── syn v0.15.44
│       ├── proc-macro2 v0.4.30 (*)
│       ├── quote v0.6.13 (*)
│       └── unicode-xid v0.1.0 (*)
├── diesel v1.4.4
│   ├── bigdecimal v0.1.0
│   │   ├── num-bigint v0.2.6
│   │   │   ├── num-integer v0.1.42 (*)
│   │   │   └── num-traits v0.2.11 (*)
│   │   │   [build-dependencies]
│   │   │   └── autocfg v1.0.0 (*)
│   │   ├── num-integer v0.1.42 (*)
│   │   └── num-traits v0.2.11 (*)
│   ├── byteorder v1.3.4
│   ├── chrono v0.4.11 (*)
│   ├── diesel_derives v1.4.1
│   │   ├── proc-macro2 v1.0.10 (*)
│   │   ├── quote v1.0.3 (*)
│   │   └── syn v1.0.17 (*)
│   ├── libsqlite3-sys v0.17.3
│   │   [build-dependencies]
│   │   └── pkg-config v0.3.17
│   ├── num-bigint v0.2.6 (*)
│   ├── num-integer v0.1.42 (*)
│   └── num-traits v0.2.11 (*)
├── dotenv v0.15.0
├── env_logger v0.7.1
│   ├── atty v0.2.14 (*)
│   ├── humantime v1.3.0
│   │   └── quick-error v1.2.3
│   ├── log v0.4.8
│   │   └── cfg-if v0.1.10
│   ├── regex v1.3.7
│   │   ├── aho-corasick v0.7.10
│   │   │   └── memchr v2.3.3
│   │   ├── memchr v2.3.3 (*)
│   │   ├── regex-syntax v0.6.17
│   │   └── thread_local v1.0.1
│   │       └── lazy_static v1.4.0 (*)
│   └── termcolor v1.1.0 (*)
├── futures v0.3.4
│   ├── futures-channel v0.3.4
│   │   ├── futures-core v0.3.4
│   │   └── futures-sink v0.3.4
│   ├── futures-core v0.3.4 (*)
│   ├── futures-executor v0.3.4
│   │   ├── futures-core v0.3.4 (*)
│   │   ├── futures-task v0.3.4
│   │   └── futures-util v0.3.4
│   │       ├── futures-channel v0.3.4 (*)
│   │       ├── futures-core v0.3.4 (*)
│   │       ├── futures-io v0.3.4
│   │       ├── futures-macro v0.3.4
│   │       │   ├── proc-macro-hack v0.5.15
│   │       │   ├── proc-macro2 v1.0.10 (*)
│   │       │   ├── quote v1.0.3 (*)
│   │       │   └── syn v1.0.17 (*)
│   │       ├── futures-sink v0.3.4 (*)
│   │       ├── futures-task v0.3.4 (*)
│   │       ├── memchr v2.3.3 (*)
│   │       ├── pin-utils v0.1.0-alpha.4
│   │       ├── proc-macro-hack v0.5.15 (*)
│   │       ├── proc-macro-nested v0.1.4
│   │       └── slab v0.4.2
│   ├── futures-io v0.3.4 (*)
│   ├── futures-sink v0.3.4 (*)
│   ├── futures-task v0.3.4 (*)
│   └── futures-util v0.3.4 (*)
├── lnpbp v0.1.0-alpha.1 (git+https://github.com/lnp-bp/rust-lnpbp#2e144027dc7047ad10fdf1257983647d7d0d17ba)
│   ├── async-trait v0.1.30 (*)
│   ├── bitcoin v0.23.0 (git+https://github.com/lnp-bp/rust-bitcoin?branch=staging#ef3d0f843023e9d508d47871e402adbbc02ff773)
│   │   ├── bech32 v0.7.2
│   │   ├── bitcoin_hashes v0.7.4 (git+https://github.com/lnp-bp/bitcoin_hashes.git?branch=staging#8f6df3c2c85e3dd5d214a797a7026ebcf5e92346)
│   │   │   └── serde v1.0.106 (*)
│   │   ├── secp256k1 v0.17.2
│   │   │   ├── secp256k1-sys v0.1.2
│   │   │   │   [build-dependencies]
│   │   │   │   └── cc v1.0.41
│   │   │   └── serde v1.0.106 (*)
│   │   └── serde v1.0.106 (*)
│   ├── derive_wrapper v0.1.4 (*)
│   ├── futures v0.3.4 (*)
│   ├── grin_secp256k1zkp v0.7.7 (git+https://github.com/lnp-bp/rust-secp256k1-zkp?branch=stable#bf8d0aa5a8dc442dcf78f45aa749305c1f9e6b0c)
│   │   ├── arrayvec v0.3.25
│   │   │   ├── nodrop v0.1.14
│   │   │   └── odds v0.2.26
│   │   ├── libc v0.2.69 (*)
│   │   ├── rand v0.5.6
│   │   │   ├── libc v0.2.69 (*)
│   │   │   └── rand_core v0.3.1
│   │   │       └── rand_core v0.4.2
│   │   ├── rustc-serialize v0.3.24
│   │   ├── serde v1.0.106 (*)
│   │   ├── serde_json v1.0.51
│   │   │   ├── itoa v0.4.5
│   │   │   ├── ryu v1.0.3
│   │   │   └── serde v1.0.106 (*)
│   │   └── zeroize v0.9.3
│   │       └── zeroize_derive v0.9.3
│   │           ├── proc-macro2 v0.4.30 (*)
│   │           ├── quote v0.6.13 (*)
│   │           ├── syn v0.15.44 (*)
│   │           └── synstructure v0.10.2
│   │               ├── proc-macro2 v0.4.30 (*)
│   │               ├── quote v0.6.13 (*)
│   │               ├── syn v0.15.44 (*)
│   │               └── unicode-xid v0.1.0 (*)
│   │   [build-dependencies]
│   │   └── cc v1.0.41 (*)
│   ├── lightning v0.0.10 (git+https://github.com/lnp-bp/rust-lightning?branch=staging#66c0b68b2d8759a3cd5eac011ae0de3d04113059)
│   │   ├── bitcoin v0.21.0
│   │   │   ├── bech32 v0.7.2 (*)
│   │   │   ├── bitcoin_hashes v0.7.6
│   │   │   ├── byteorder v1.3.4 (*)
│   │   │   ├── hex v0.3.2
│   │   │   └── secp256k1 v0.15.5
│   │   │       └── rand v0.6.5
│   │   │           ├── libc v0.2.69 (*)
│   │   │           ├── rand_chacha v0.1.1
│   │   │           │   └── rand_core v0.3.1 (*)
│   │   │           │   [build-dependencies]
│   │   │           │   └── autocfg v0.1.7
│   │   │           ├── rand_core v0.4.2 (*)
│   │   │           ├── rand_hc v0.1.0
│   │   │           │   └── rand_core v0.3.1 (*)
│   │   │           ├── rand_isaac v0.1.1
│   │   │           │   └── rand_core v0.3.1 (*)
│   │   │           ├── rand_jitter v0.1.4
│   │   │           │   └── rand_core v0.4.2 (*)
│   │   │           ├── rand_os v0.1.3
│   │   │           │   ├── libc v0.2.69 (*)
│   │   │           │   └── rand_core v0.4.2 (*)
│   │   │           ├── rand_pcg v0.1.2
│   │   │           │   └── rand_core v0.4.2 (*)
│   │   │           │   [build-dependencies]
│   │   │           │   └── autocfg v0.1.7 (*)
│   │   │           └── rand_xorshift v0.1.1
│   │   │               └── rand_core v0.3.1 (*)
│   │   │           [build-dependencies]
│   │   │           └── autocfg v0.1.7 (*)
│   │   │       [build-dependencies]
│   │   │       └── cc v1.0.41 (*)
│   │   ├── bitcoin_hashes v0.7.6 (*)
│   │   └── secp256k1 v0.15.5 (*)
│   ├── lightning-net-tokio v0.0.3 (git+https://github.com/lnp-bp/rust-lightning?branch=staging#66c0b68b2d8759a3cd5eac011ae0de3d04113059)
│   │   ├── bitcoin v0.21.0 (*)
│   │   ├── bitcoin_hashes v0.7.6 (*)
│   │   ├── lightning v0.0.10 (git+https://github.com/lnp-bp/rust-lightning?branch=staging#66c0b68b2d8759a3cd5eac011ae0de3d04113059) (*)
│   │   ├── secp256k1 v0.15.5 (*)
│   │   └── tokio v0.2.18
│   │       ├── bytes v0.5.4
│   │       ├── fnv v1.0.6
│   │       ├── futures-core v0.3.4 (*)
│   │       ├── iovec v0.1.4
│   │       │   └── libc v0.2.69 (*)
│   │       ├── lazy_static v1.4.0 (*)
│   │       ├── libc v0.2.69 (*)
│   │       ├── memchr v2.3.3 (*)
│   │       ├── mio v0.6.21
│   │       │   ├── cfg-if v0.1.10 (*)
│   │       │   ├── iovec v0.1.4 (*)
│   │       │   ├── libc v0.2.69 (*)
│   │       │   ├── log v0.4.8 (*)
│   │       │   ├── net2 v0.2.33
│   │       │   │   ├── cfg-if v0.1.10 (*)
│   │       │   │   └── libc v0.2.69 (*)
│   │       │   └── slab v0.4.2 (*)
│   │       ├── mio-uds v0.6.7
│   │       │   ├── iovec v0.1.4 (*)
│   │       │   ├── libc v0.2.69 (*)
│   │       │   └── mio v0.6.21 (*)
│   │       ├── num_cpus v1.13.0
│   │       │   └── libc v0.2.69 (*)
│   │       ├── pin-project-lite v0.1.4
│   │       ├── signal-hook-registry v1.2.0
│   │       │   ├── arc-swap v0.4.5
│   │       │   └── libc v0.2.69 (*)
│   │       ├── slab v0.4.2 (*)
│   │       └── tokio-macros v0.2.5
│   │           ├── proc-macro2 v1.0.10 (*)
│   │           ├── quote v1.0.3 (*)
│   │           └── syn v1.0.17 (*)
│   ├── log v0.4.8 (*)
│   ├── miniscript v0.12.0 (git+https://github.com/lnp-bp/rust-miniscript?branch=staging#a5ba1219feb8b5a289c8f12176d632635eb8a959)
│   │   └── bitcoin v0.23.0 (git+https://github.com/lnp-bp/rust-bitcoin?branch=staging#ef3d0f843023e9d508d47871e402adbbc02ff773) (*)
│   ├── num-derive v0.3.0
│   │   ├── proc-macro2 v1.0.10 (*)
│   │   ├── quote v1.0.3 (*)
│   │   └── syn v1.0.17 (*)
│   ├── num-integer v0.1.42 (*)
│   ├── num-traits v0.2.11 (*)
│   ├── parse_arg v0.1.4 (*)
│   ├── rand v0.5.6 (*)
│   ├── serde v1.0.106 (*)
│   ├── tokio v0.2.18 (*)
│   └── torut v0.1.2
│       ├── base32 v0.4.0
│       ├── base64 v0.10.1
│       │   └── byteorder v1.3.4 (*)
│       ├── derive_more v0.15.0
│       │   ├── lazy_static v1.4.0 (*)
│       │   ├── proc-macro2 v0.4.30 (*)
│       │   ├── quote v0.6.13 (*)
│       │   ├── regex v1.3.7 (*)
│       │   └── syn v0.15.44 (*)
│       │   [build-dependencies]
│       │   └── rustc_version v0.2.3
│       │       └── semver v0.9.0
│       │           └── semver-parser v0.7.0
│       ├── ed25519-dalek v1.0.0-pre.3
│       │   ├── clear_on_drop v0.2.3
│       │   │   [build-dependencies]
│       │   │   └── cc v1.0.41 (*)
│       │   ├── curve25519-dalek v2.0.0
│       │   │   ├── byteorder v1.3.4 (*)
│       │   │   ├── digest v0.8.1
│       │   │   │   └── generic-array v0.12.3
│       │   │   │       └── typenum v1.12.0
│       │   │   ├── rand_core v0.5.1
│       │   │   │   └── getrandom v0.1.14
│       │   │   │       ├── cfg-if v0.1.10 (*)
│       │   │   │       └── libc v0.2.69 (*)
│       │   │   ├── subtle v2.2.2
│       │   │   └── zeroize v1.1.0
│       │   ├── rand v0.7.3
│       │   │   ├── getrandom v0.1.14 (*)
│       │   │   ├── libc v0.2.69 (*)
│       │   │   ├── rand_chacha v0.2.2
│       │   │   │   ├── ppv-lite86 v0.2.6
│       │   │   │   └── rand_core v0.5.1 (*)
│       │   │   └── rand_core v0.5.1 (*)
│       │   └── sha2 v0.8.1
│       │       ├── block-buffer v0.7.3
│       │       │   ├── block-padding v0.1.5
│       │       │   │   └── byte-tools v0.3.1
│       │       │   ├── byte-tools v0.3.1 (*)
│       │       │   ├── byteorder v1.3.4 (*)
│       │       │   └── generic-array v0.12.3 (*)
│       │       ├── digest v0.8.1 (*)
│       │       ├── fake-simd v0.1.2
│       │       └── opaque-debug v0.2.3
│       ├── hex v0.4.2
│       ├── hmac v0.7.1
│       │   ├── crypto-mac v0.7.0
│       │   │   ├── generic-array v0.12.3 (*)
│       │   │   └── subtle v1.0.0
│       │   └── digest v0.8.1 (*)
│       ├── openssl v0.10.29
│       │   ├── bitflags v1.2.1 (*)
│       │   ├── cfg-if v0.1.10 (*)
│       │   ├── foreign-types v0.3.2
│       │   │   └── foreign-types-shared v0.1.1
│       │   ├── lazy_static v1.4.0 (*)
│       │   ├── libc v0.2.69 (*)
│       │   └── openssl-sys v0.9.55
│       │       └── libc v0.2.69 (*)
│       │       [build-dependencies]
│       │       ├── autocfg v1.0.0 (*)
│       │       ├── cc v1.0.41 (*)
│       │       └── pkg-config v0.3.17 (*)
│       ├── rand v0.7.3 (*)
│       ├── serde v1.0.106 (*)
│       ├── serde_derive v1.0.106 (*)
│       ├── sha1 v0.6.0
│       ├── sha2 v0.8.1 (*)
│       ├── sha3 v0.8.2
│       │   ├── block-buffer v0.7.3 (*)
│       │   ├── byte-tools v0.3.1 (*)
│       │   ├── digest v0.8.1 (*)
│       │   ├── keccak v0.1.0
│       │   └── opaque-debug v0.2.3 (*)
│       └── tokio v0.2.18 (*)
├── log v0.4.8 (*)
├── prometheus v0.8.0
│   ├── cfg-if v0.1.10 (*)
│   ├── fnv v1.0.6 (*)
│   ├── lazy_static v1.4.0 (*)
│   ├── protobuf v2.14.0
│   ├── spin v0.5.2
│   └── thiserror v1.0.15
│       └── thiserror-impl v1.0.15
│           ├── proc-macro2 v1.0.10 (*)
│           ├── quote v1.0.3 (*)
│           └── syn v1.0.17 (*)
├── serde v1.0.106 (*)
├── serde_derive v1.0.106 (*)
├── tiny_http v0.6.2
│   ├── ascii v0.8.7
│   ├── chrono v0.4.11 (*)
│   ├── chunked_transfer v0.3.1
│   ├── log v0.4.8 (*)
│   └── url v1.7.2
│       ├── idna v0.1.5
│       │   ├── matches v0.1.8
│       │   ├── unicode-bidi v0.3.4
│       │   │   └── matches v0.1.8 (*)
│       │   └── unicode-normalization v0.1.12
│       │       └── smallvec v1.3.0
│       ├── matches v0.1.8 (*)
│       └── percent-encoding v1.0.1
├── tokio v0.2.18 (*)
└── zmq v0.9.2
    ├── bitflags v1.2.1 (*)
    ├── libc v0.2.69 (*)
    ├── log v0.4.8 (*)
    └── zmq-sys v0.11.0
        └── libc v0.2.69 (*)
        [build-dependencies]
        └── metadeps v1.1.2
            ├── error-chain v0.10.0
            ├── pkg-config v0.3.17 (*)
            └── toml v0.2.1
[build-dependencies]
└── configure_me_codegen v0.3.12
    ├── cargo_toml v0.8.0
    │   ├── serde v1.0.106 (*)
    │   ├── serde_derive v1.0.106 (*)
    │   └── toml v0.5.6
    │       └── serde v1.0.106 (*)
    ├── fmt2io v0.1.0
    ├── man v0.1.1
    │   └── roff v0.1.0
    ├── serde v1.0.106 (*)
    ├── serde_derive v1.0.106 (*)
    ├── toml v0.4.10 (*)
    ├── unicode-segmentation v1.6.0 (*)
    └── void v1.0.2

@elichai
Copy link
Member

elichai commented Apr 19, 2020

/home/user/sources/lnp-node/target/debug/deps/libsecp256k1-9640e677cf524655.rlib(secp256k1-9640e677cf524655.secp256k1.tmtcjvkp-cgu.2.rcgu.o): In function `secp256k1_context_create':
          /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/secp256k1-0.15.5/src/ffi.rs:269: multiple definition of `secp256k1_context_create'
          /home/user/sources/lnp-node/target/debug/deps/libsecp256k1zkp-777673333de8267f.rlib(secp256k1.o):/home/user/.cargo/git/checkouts/rust-secp256k1-zkp-69577f4990b9398e/bf8d0aa/depend/secp256k1-zkp/src/secp256k1.c:79: first defined here

That's what I was talking about.
If you have another libsecp impl in the tree, the C symbols will collide as long as you export the official unmodified symbols, they were exported in 0.15 and your rexport! macro exports them again.
but they will collide with any other library containing the same symbols (like libsecp256k1-zkp).

@dr-orlovsky
Copy link
Contributor

dr-orlovsky commented Apr 19, 2020

@Kixunil thanks for doing this. FYI, I'm working on updating rust-lightning to match the latest rust-bitcoin version: lightningdevkit/rust-lightning#578.

The problem is that adoption of new hash type system rust-bitcoin/rust-bitcoin#349 has introduced a lot of breaking changes in the code; it takes a lot of time to hunt all of them down. After this change updates must be easier and rust-lightning probably will always match the latest rust-bitcoin release.

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 19, 2020

@elichai yes, I understand now what you were talking about, however, that macro does not break lnp-node! I have no idea how it's possible. I have a feeling that I've read something about all Rust symbols being weak but can't find it.

@dr-orlovsky yeah, I noticed. Bumping the version was the first thing I attempted to see if it's trivial enough. When I saw the errors, doing the semver trick seemed easier. 😆

@dr-orlovsky
Copy link
Contributor

Just did version bump for electrs project BTW; have taken about 3 hrs to complete: romanz/electrs#238

Lightning looks more complex though...

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 23, 2020

@dr-orlovsky I've listened to the devcall and while the newer versions have versioned symbols, the issue is that not everything is updated to the newer version yet. Of course, upgrading is a cleaner solution, lazy semver trick is just a workaround to get something working quickly.

@dr-orlovsky
Copy link
Contributor

Yes, seems like the only way is to fork and update to the newer version manually... I will try it in the next few days

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 24, 2020

Might be worth asking people from grin to use the same trick with renaming symbols.

@elichai
Copy link
Member

elichai commented Apr 24, 2020

Might be worth asking people from grin to use the same trick with renaming symbols.

Feel free, they're best on a very old version of this repo, I hope this PR will nudge them into a rebase/merge, and maybe they'll even adapt this renaming symbols trick
mimblewimble/rust-secp256k1-zkp#71

FYI, if you're linking both you can enable the feature external-symbols here, which will use their symbols instead of compiling the lib here

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 24, 2020

I tried external symbols and it didn't work for me.

@elichai
Copy link
Member

elichai commented Apr 24, 2020

I tried external symbols and it didn't work for me.

Can you please expand on that?

@Kixunil
Copy link
Collaborator Author

Kixunil commented Apr 24, 2020

Sorry, I don't remember what the error was exactly. I tried to set that feature and compile, but got some other errors. I might give it another try in a few days, if it's still relevant.

@elichai
Copy link
Member

elichai commented Apr 24, 2020

Hmm sorry I forgot we were talking about 0.15.
We could backport this feature bf3fba7

@TheBlueMatt
Copy link
Member

As for rust-lightning. Given we merged the version bump this morning, does that resolve the issue here, at least for the immediate needs of those in this thread (when using rust-lightning master)?

@Kixunil
Copy link
Collaborator Author

Kixunil commented Jan 6, 2022

lnp-node now builds fine, closing.

@Kixunil Kixunil closed this as completed Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants