This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
fix boost unit test linkage; fixes build on Fedora 34 #10305
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change Description
Even with #10270 building still fails on Fedora 34 due to duplicate symbol errors.
I'm not really sure why Fedora 34 is the first environment encountering this problem. Compiler version? Boost version? Some combination of those? Are they using a different linker? Hidden compiler flags? Regardless, after digging it seems fairly clear we've messed up with linking boost unit test.
First off, there are several ways of using boost test:
https://www.boost.org/doc/libs/1_76_0/libs/test/doc/html/boost_test/usage_variants.html
Most important to us is the header-only variant and the static library variant.
In the current develop code you'll find that
eosio_testing
will static link to boost unit testeos/libraries/testing/CMakeLists.txt
Line 10 in 049b601
But then in, say, in
plugin_test
we link toeosio_testing
eos/tests/CMakeLists.txt
Line 8 in 049b601
and then use... the header-only variant of boost_test in
plugin_test
!eos/tests/main.cpp
Line 3 in 049b601
This hasn't caused us any problems in the past (AFAIK), but it's causing problems on Fedora 34 and seems flat out wrong to mix them up.
Fixing this is complicated by
txn_test_gen_plugin
which links toeosio_testing
. (yes this means the testing library gets linked in to nodeos 😞) Just simply removing the static library linkage of boost test fromeosio_testing
causes problems when building nodeos because of missing symbols -- symbols that can't easily be added back because we can't use the header-only version of boost test in nodeos due to it taking overmain()
etc etc etctxn_test_gen_plugin
actually only needs a very tiny sliver ofeosio_testing
-- it needs theeosio::testing::contracts
incontracts.hpp
, generated fromcontracts.hpp.in
. This is quite self-contained.. it just reads some files at some paths figured out during the build. What I've elected to do is move thiscontracts.hpp
generation out to its own cmake target:eosio_testing_contracts
. This now allowstxn_test_gen_plugin
(and thus nodeos) to only link to that small helper instead of the entireeosio_testing
which needs some boost test pieces.Now honestly, what is going on here is still a little icky since
eosio_testing_contracts
is creating a header file that references contract file paths fromunittests/
. This doesn't seem any more or less icky that what already existed though --eosio_testing
having a dependency on a header file that doesn't exist untilunittests/CMakeLists.txt
creates it way aftereosio_testing
target has been defined. It may be possible to clean some of this up further in the future... maybe all contracts ofunittests/
should get pulled up tolibraries/testing
or something. Such a change would make this PR hard to follow though.Anyways, now this means we can remove the static library linkage of boost test from
eosio_testing
allowing the header-only variant to be properly used from something likeplugin_test
. Best I could tell, nearly all of our existing tests already were eitherSo a small number of tests were using
eosio_testing
but expected the static library variant. These were simply changed from<boost/test/unit_test.hpp>
to<boost/test/included/unit_test.hpp>
to fix them up.After these changes, build completes correctly on Fedora 34.
Change Type
Select ONE:
Testing Changes
Select ANY that apply:
Consensus Changes
API Changes
Documentation Additions