-
Notifications
You must be signed in to change notification settings - Fork 5
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
cmake: Avoid overlinking #34
Conversation
If these exist in master, why do they need to be fixed here (at least, at this point)? Doesn't that just make the difference in behaviour between master, and the cmake branches larger, and potentially harder to review? I would expect changes to land in master first, and then incorporate them here? |
It can be done at any point. It can be postponed, of course.
The duplicated libraries, which are passed to a linker, do not affect the resulted binaries, don't they?
It could be not so easy as in here. |
618eec0
to
f4162d0
Compare
8b53050
to
79a3b38
Compare
Rebased. |
79a3b38
to
9477ad9
Compare
If I understand correctly, the duplicated libs don't happen in master because we don't use transitive linking for deps. So in master, libbitcoin_zmq (for example) has no dependencies, where in CMake it does. From what I can tell, this is simply cleaning up where those dependencies were over-specified for CMake? |
It happens in master. (at least on macOS with the recent Xcode) |
|
Could you please give an an example of exactly what is duplicated in master? I agree with @fanquake that if there's some broken behavior we don't want to carry forward, we should fix it upstream first. So it seems, then, that this is a mix of upsteram fixes and CMake fixups? Please help us to understand what's happening here :) |
I have to admit that my previous comments were not as precise as they should be. I'm sorry about that. I double checked the master branch on macOS Sonoma. There indeed are For example, the following code in the master branch: Lines 1430 to 1434 in 9477ad9
expands the
which ends with:
Another duplicated linked library is
This PR is CMake-specific and fixes my own mistakes such as over-specified libraries to link and link order. |
Having the link check in the header check loop means we get `-lminiupnpc -lminiupnpc -lminiupnpc` on the link line. This is unnecessary, and results in warnings, i.e: ```bash ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ``` These warnings have been occurring since the new linker released with Xcode 15, and also came up in hebasto#34.
Opened to bitcoin#28755 to remove some of the unrelated warnings. |
9477ad9
to
8ecc77d
Compare
Rebased. |
Having the link check in the header check loop means we get `-lminiupnpc -lminiupnpc -lminiupnpc` on the link line. This is unnecessary, and results in warnings, i.e: ```bash ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ``` These warnings have been occurring since the new linker released with Xcode 15, and also came up in hebasto#34.
Having the link check in the header check loop means we get `-lminiupnpc -lminiupnpc -lminiupnpc` on the link line. This is unnecessary, and results in warnings, i.e: ```bash ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ``` These warnings have been occurring since the new linker released with Xcode 15, and also came up in hebasto#34.
6e20a0f
to
d86340b
Compare
8ecc77d
to
16487e9
Compare
Rebased. |
…nking b74e449 build: remove potential for duplciate natpmp linking (fanquake) 4e95096 build: remove duplicate -lminiupnpc linking (fanquake) Pull request description: Having the link check in the header check loop means we get `-lminiupnpc -lminiupnpc -lminiupnpc` on the link line. This is unnecessary, and results in warnings, i.e: ```bash ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ``` These warnings have been occurring since the new macOS linker released with Xcode 15, and also came up in hebasto/bitcoin#34. There are other duplicate lib issues, i.e with `-levent` + `-levent_pthreads -levent`, but those are less straight forward to solve, and won't be included here. ACKs for top commit: jonatack: ACK b74e449 hebasto: ACK b74e449, it fixes one issue mentioned in hebasto/bitcoin#34 (comment). TheCharlatan: ACK b74e449 theuni: ACK b74e449 Tree-SHA512: 987a56ef17cbaf273cb672c41016f3f615b16889317325a9e88135d0c41f01af3840ad44a6f811a7df97f5873c9cd957e60aaa1b99bd408b17b4b1ffe2c68f36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, makes more sense after dropping the unrelated upstream stuff.
@@ -16,7 +16,6 @@ target_compile_definitions(bitcoin_zmq | |||
target_link_libraries(bitcoin_zmq | |||
PRIVATE | |||
core | |||
leveldb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally unrelated to CMake/this PR, but univalue is an unfortunate dependency for zmq. Seems to me it'd make sense to move zmq/rpc.cpp
to rpc/zmq.cpp
:)
1a00d05
to
7dc3874
Compare
16487e9
to
80c585c
Compare
Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than the comment about the added deps. I'm confused why this works without them.
src/bench/CMakeLists.txt
Outdated
leveldb | ||
bitcoin_node | ||
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet> | ||
bitcoin_common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the new deps (bitcoin_common, bitcoin_consensus, etc)? Were they necessary before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, the "duplicate libraries" warnings still being emitted. Besides, both test_bitcoin
and bench_bitcoin
targets do use symbols from the added libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand. libs are added here but none are removed. How does that eliminate any dupes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/test/CMakeLists.txt
Outdated
@@ -16,7 +16,6 @@ generate_header_from_raw(data/asmap.raw) | |||
|
|||
add_executable(test_bitcoin | |||
main.cpp | |||
$<TARGET_OBJECTS:bitcoin_consensus> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this change about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before CMake 3.12, the only way to consume the object library--which is a mere unarchived collection of object files, not a real library--was to add $<TARGET_OBJECTS:bitcoin_consensus>
to sources. Now we can use an idiomatic way: target_link_libraries(test_bitcoin bitcoin_consensus)
.
In short, it is a modernization after bumping the minimum required CMake version from 3.10 to 3.16.
80c585c
to
7d5af55
Compare
Reworked. PR title and description have been updated. |
I'm having trouble understanding several of the changes here. Deps are hopping around from libs to binaries. Could you please add some extra info in the commit messages about what's happening so we reviewers don't have to try to interpret your changes? |
Drop unneeded dependency.
Drop unneeded dependency.
7d5af55
to
b2610a4
Compare
Done. Sorry for the mess :) |
Ahhh. So much better :) Please consider this a request to do the same for future fixups. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested nor compared to the upstream deps, but changes make sense to me now that they have context.
Left one more question.
@@ -220,7 +220,6 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL | |||
) | |||
if(ENABLE_WALLET) | |||
target_sources(bitcoin_node PRIVATE wallet/init.cpp) | |||
target_link_libraries(bitcoin_node PRIVATE bitcoin_wallet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to go ahead and use TARGET_IF_NAME_EXISTS
for target_sources
here as well? Seems odd to leave only one behind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done.
Boost::headers | ||
PUBLIC | ||
univalue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to comment that I'd rather see this be PRIVATE
and have univalue included by the binaries as needed, but test_util pretty clearly exports univalue as part of its interface, so PUBLIC
univalue actually follows the code as-is quite well I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing univalue
into usage requirements, and removing it from build specifications for the bench_bitcoin
and test_bitcoin
targets, fixes actually, "ld: warning: ignoring duplicate libraries" on macOS.
Makes the `bitcoin_wallet` library a direct dependency of `bitcoind` rather `bitcoin_node`, that is outlined in bitcoin/bitcoin@master/doc/design/libraries.md.
1) Drop unneeded dependencies in `test_util`. 2) Adjust dependencies for `bench_bitcoin` (removed uneeded ones and add `bitcoin_node`, required after step (1).
Drop unneeded dependency.
b2610a4
to
8342981
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 8342981
Having the link check in the header check loop means we get `-lminiupnpc -lminiupnpc -lminiupnpc` on the link line. This is unnecessary, and results in warnings, i.e: ```bash ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ld: warning: ignoring duplicate libraries: '-levent', '-lminiupnpc' ``` These warnings have been occurring since the new linker released with Xcode 15, and also came up in hebasto/bitcoin#34.
Additionally, this PR fixes "ld: warning: ignoring duplicate libraries" on macOS:
The third commit makes the
bitcoin_wallet
library a direct dependency ofbitcoind
ratherbitcoin_node
, that is outlined in https://github.com/bitcoin/bitcoin/blob/master/doc/design/libraries.md.