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

[boost] libraries built with dependency on boost::system, which is not included in the manifest #7435

Closed
planetmarshall opened this issue Sep 27, 2021 · 4 comments · Fixed by #7482
Labels
bug Something isn't working

Comments

@planetmarshall
Copy link
Contributor

planetmarshall commented Sep 27, 2021

#7290 removed boost_system from the dependency manifest, however some boost libraries are still linked to it. Notably:

  • boost_contract
  • boost_locale
  • boost_random
  • boost_type_erasure

Steps to reproduce

Build the Boost package with shared libraries

conan create . boost/1.70.0@ -o boost:shared=True

Run

$ ldd test_package/build/<id>/bin/random_exe

An unresolved runtime dependency on libboost_system is visible in the output:

libboost_random.so.1.70.0 => ${CONAN_USER_HOME}/data/boost/1.70.0/_/_/package/<id>/lib/libboost_random.so.1.70.0 (0x00007f8071ec9000)
libboost_atomic.so.1.70.0 => ${CONAN_USER_HOME}/data/boost/1.70.0/_/_/package/<id>/lib/libboost_atomic.so.1.70.0 (0x00007f8071ec4000)
libboost_system.so.1.70.0 => not found

Expected Results

No runtime dependencies should be added by conan that cannot subsequently be resolved. In addition, the JSON manifest (generated with --generator json) should contain all the dependencies necessary to run the package.

Actual Results

Linking to one of the above libraries generates an additional dependency on boost_system, which is not included in the JSON manifest.

Notes

We use a tool to generate deployable packages (eg deb or zip packages) using the JSON manifest to resolve dependencies. As boost_system does not appear in the manifest, we get runtime linking errors at deployment time.

Workaround

Add an explicit link using CMake

target_link_directories(<target> PRIVATE ${Boost_system_LIB_DIRS})
target_link_libraries(<target> PRIVATE boost_system)

This resolves the runtime linking issue, but not the absence in the manifest.

@planetmarshall planetmarshall added the bug Something isn't working label Sep 27, 2021
@madebr
Copy link
Contributor

madebr commented Sep 27, 2021

Is this problem also present with boost/1.77?
If not, perhaps a fix can be backported.

@planetmarshall
Copy link
Contributor Author

It looks to have been resolved as of boost/1.75:

$ ldd boost/1.74.0/_/_/package/<id>/lib/libboost_random.so | grep -c boost_system
1
$ ldd boost/1.74.0/_/_/package/<id>/lib/libboost_random.so
...
libboost_system.so.1.74.0 => not found
...
$ ldd boost/1.75.0/_/_/package/<id>/lib/libboost_random.so | grep -c boost_system
0

@planetmarshall
Copy link
Contributor Author

planetmarshall commented Oct 1, 2021

In boost 1.77 boost_locale and boost_type_erasure still contain references to boost_system.

The only reason this package builds currently is because the test package is run under the virtual environment, which adds boost_system to the LD_LIBRARY_PATH.

If the package is built with shared libraries, and the test package is run on Linux using only rpaths to find shared libraries, the test package will fail.

Eg, modify the test package as follows:

if not self.options["boost"].without_locale:
  self.run(os.path.join("bin", "locale_exe"), run_environment=False)

And run the test package:

conan test test_package boost/1.77.0@ -o boost:shared=True

The test will fail with

bin/locale_exe: error while loading shared libraries: libboost_system.so.1.77.0: cannot open shared object file: No such file or directory

Normally this would work as any shared libraries can be located using the RPATH provided at link time.

@madebr
Copy link
Contributor

madebr commented Oct 1, 2021

I ran the following command in the lib folder of a shared boost/1.77.0 package:

for i in *.so; do
  echo "boost dependencies of $i";
  objdump -p "$i" | grep NEEDED | awk '{print $2}' | grep boost;
done
Output
boost dependencies of libboost_atomic.so
boost dependencies of libboost_chrono.so
boost dependencies of libboost_container.so
boost dependencies of libboost_context.so
boost dependencies of libboost_contract.so
boost dependencies of libboost_coroutine.so
libboost_chrono.so.1.77.0
libboost_context.so.1.77.0
libboost_thread.so.1.77.0
boost dependencies of libboost_date_time.so
boost dependencies of libboost_fiber_numa.so
libboost_fiber.so.1.77.0
libboost_filesystem.so.1.77.0
libboost_context.so.1.77.0
boost dependencies of libboost_fiber.so
libboost_filesystem.so.1.77.0
libboost_context.so.1.77.0
boost dependencies of libboost_filesystem.so
libboost_atomic.so.1.77.0
boost dependencies of libboost_graph.so
libboost_regex.so.1.77.0
boost dependencies of libboost_iostreams.so
boost dependencies of libboost_json.so
libboost_container.so.1.77.0
boost dependencies of libboost_locale.so
libboost_system.so.1.77.0
boost dependencies of libboost_log_setup.so
libboost_log.so.1.77.0
libboost_regex.so.1.77.0
libboost_filesystem.so.1.77.0
libboost_chrono.so.1.77.0
libboost_atomic.so.1.77.0
libboost_thread.so.1.77.0
boost dependencies of libboost_log.so
libboost_filesystem.so.1.77.0
libboost_regex.so.1.77.0
libboost_chrono.so.1.77.0
libboost_atomic.so.1.77.0
libboost_thread.so.1.77.0
boost dependencies of libboost_math_c99f.so
boost dependencies of libboost_math_c99l.so
boost dependencies of libboost_math_c99.so
boost dependencies of libboost_math_tr1f.so
boost dependencies of libboost_math_tr1l.so
boost dependencies of libboost_math_tr1.so
boost dependencies of libboost_nowide.so
boost dependencies of libboost_prg_exec_monitor.so
boost dependencies of libboost_program_options.so
boost dependencies of libboost_random.so
boost dependencies of libboost_regex.so
boost dependencies of libboost_serialization.so
boost dependencies of libboost_stacktrace_addr2line.so
boost dependencies of libboost_stacktrace_backtrace.so
boost dependencies of libboost_stacktrace_basic.so
boost dependencies of libboost_stacktrace_noop.so
boost dependencies of libboost_system.so
boost dependencies of libboost_thread.so
boost dependencies of libboost_timer.so
libboost_chrono.so.1.77.0
boost dependencies of libboost_type_erasure.so
libboost_thread.so.1.77.0
libboost_system.so.1.77.0
libboost_chrono.so.1.77.0
boost dependencies of libboost_unit_test_framework.so
boost dependencies of libboost_wave.so
libboost_filesystem.so.1.77.0
libboost_thread.so.1.77.0
libboost_chrono.so.1.77.0
boost dependencies of libboost_wserialization.so
libboost_serialization.so.1.77.0

So it looks like libboost_type_erasure and libboost_locale still link to boost_system.

And sure enough,
libs/locale/build/Jamfile.v2 contains: result += <library>../../system/build//boost_system ;
libs/type_erasue/Jamfile.v2 contains: lib boost_type_erasure : dynamic_binding.cpp /boost//thread /boost//system ;

I think the boost sources need to be patched to remove boost_system of the link libraries.
This should probably be back ported..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants