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

abseil/20180223 - Wrong linkage order #176

Closed
r-darwish opened this issue Mar 13, 2018 · 9 comments
Closed

abseil/20180223 - Wrong linkage order #176

r-darwish opened this issue Mar 13, 2018 · 9 comments
Assignees
Labels
bug feedback Waiting for feedback from the original issue author. Gets closed after several weeks if no feedback

Comments

@r-darwish
Copy link

r-darwish commented Mar 13, 2018

Description of Problem, Request, or Question

Trying to build this app caused the following linkage command:

/usr/bin/c++ -std=c++11 -rdynamic CMakeFiles/atest.dir/main.cpp.o -o bin/atest -L/home/roeyd/.conan/data/abseil/20180223/bincrafters/stable/package/d2b9b1e5dc4f75ac827291c9bda9970b49137f53/lib -L/home/roeyd/.conan/data/cctz/2.2/bincrafters/stable/package/b60023f9fa06321277cb53d223d0048027c27904/lib -Wl,-rpath,/home/roeyd/.conan/data/abseil/20180223/bincrafters/stable/package/d2b9b1e5dc4f75ac827291c9bda9970b49137f53/lib:/home/roeyd/.conan/data/cctz/2.2/bincrafters/stable/package/b60023f9fa06321277cb53d223d0048027c27904/lib -labsl_algorithm -labsl_container -labsl_memory -labsl_dynamic_annotations -labsl_spinlock_wait -labsl_meta -labsl_utility -labsl_stack_consumption -labsl_throw_delegate -labsl_span -labsl_bad_optional_access -labsl_any -ltest_instance_tracker_lib -labsl_int128 -labsl_numeric -labsl_stacktrace -labsl_malloc_internal -labsl_base -labsl_leak_check -labsl_bad_any_cast -labsl_optional -labsl_malloc_extension -labsl_debugging -labsl_time -labsl_strings -labsl_synchronization -lpthread -lcctz 

Which caused the following error:

sysinfo.cc:(.text+0x452): undefined reference to `AbslInternalSpinLockWake'

This is due to the fact that -labsl_spinlock_wait, which contains AbslInternalSpinLockWake, comes before -labsl_base, which depends on it. As stated here, the order should be reversed. Running the same command when moving -labsl_spinlock_wait to end of the command seems to work.

The current implementation of package_info calls tools.collect_libs, which in turn calls os.listdir, which does not guarantee any order, so the problem reproduces randomly.

Package Details (Include if Applicable)

  • Package Name/Version: abseil/20180223
  • Operating System: Arch Linux
  • Compiler+version: gcc-7.3

Steps to reproduce (Include if Applicable)

Compile the program above.

@solvingj
Copy link
Member

@r-darwish Are we able to fix the link order manually now that we know of the issue?

@SSE4 SSE4 self-assigned this Mar 15, 2018
@bschindler
Copy link

bschindler commented Mar 26, 2018

@solvingj I got notified of this issue as I ran into a similar issue. In my case, it was a package which attempted to install some system libraries and then link against them. But since the library was only added as if it was part of the package, conan did not know that there was a dependency between the two. As soon another package (or some other command) added a link dependency to that system library, cmake sometimes reordered the link order which made compilation break.

So essentially, this is an issue for every package doing something like:

installer.install("%s%s" % ("somelib", arch_suffix))
... 
self.cpp_info.libs = ['package_lib' 'somelib']

All it takes that this potentially breaks is:

target_link_library(mytarget PUBLIC CONAN_PKG::package_lib)
target_link_library(mytarget somelib)

cmake (or any other build system) has no knowledge that package_lib depends on somelib which gives potential for link failures

@drrlvn
Copy link

drrlvn commented Mar 26, 2018

Unless I'm missing something, it looks like abseil's CMakeLists.txt correctly specifies that absl_base depends on absl_spinlock_wait here. If so then this bug should not happen regardless of the order returned by tools.collect_libs.

@solvingj
Copy link
Member

solvingj commented Apr 5, 2018

Did anyone involved make any headway with this? @drrlvn or @bschindler ?

@drrlvn
Copy link

drrlvn commented Apr 5, 2018

Both @r-darwish and I had babies very recently so we're not doing much work, it'll take us a bit to get back. Sorry.

@uilianries uilianries added the bug label Apr 5, 2018
@SSE4
Copy link
Member

SSE4 commented Apr 20, 2018

@r-darwish changes are in testing/20180223 branch, please give a try

@uilianries uilianries added the feedback Waiting for feedback from the original issue author. Gets closed after several weeks if no feedback label Apr 20, 2018
@drrlvn
Copy link

drrlvn commented May 2, 2018

The testing branch works for me, thanks!

@SSE4
Copy link
Member

SSE4 commented May 2, 2018

confirmed as fixed, closing

@SSE4 SSE4 closed this as completed May 2, 2018
@SimonEbner
Copy link

@bschindler sorry for hijacking the topic but I do have exactly this situation that you mention

installer.install("%s%s" % ("somelib", arch_suffix))
... 
self.cpp_info.libs = ['package_lib' 'somelib']

Is there any solution in conan how to handle this situation? In my specific case I am talking about openssl with libcryto that has a dependency on libdl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug feedback Waiting for feedback from the original issue author. Gets closed after several weeks if no feedback
Projects
None yet
Development

No branches or pull requests

7 participants