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

[package] grpc/1.65.0: downstream builds break if absel is used as shared #24806

Closed
weatherhead99 opened this issue Aug 3, 2024 · 4 comments · Fixed by #25087
Closed

[package] grpc/1.65.0: downstream builds break if absel is used as shared #24806

weatherhead99 opened this issue Aug 3, 2024 · 4 comments · Fixed by #25087
Assignees
Labels
bug Something isn't working

Comments

@weatherhead99
Copy link
Contributor

Description

When building a package which depends on gRPC, and using abseil as a shared library, downstream builds can break with an error like (on gcc):

undefined reference to symbol '_ZN4absl12lts_2024011612log_internal17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_T0_PKc'
/usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: /home/danw/.conan2/p/b/absei344124e3560e9/p/lib/libabsl_log_internal_check_op.so.2401.0.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

or similar. In the recipe for gRPC, the self.requires statement for abseil correctly adds the "transitive_headers=True" trait. It should also add the "transitive_libs=True", because downstream consumers need to link to the abseil shared library.

This is not true for static library usage, but unfortunately I don't see a way to detect whether abseil is a shared library at this point in the build. Using self.options['abseil'].shared doesn't seem to work, and of course `self.dependencies' doesn't exist at the time of the 'requirements()' method being called.

Package and Environment Details

  • Package Name/Version: grpc/1.65.0
  • Operating System+version: Linux openSUSE Tumbleweed
  • Compiler+version: GCC 13.3.0
  • Conan version: conan 2.6.0
  • Python version: Python 3.11.9

Conan profile

[settings]
arch=x86_64
build_type=RelWithDebInfo
compiler=gcc
compiler.cppstd=gnu20
compiler.libcxx=libstdc++11
compiler.version=13
os=Linux
[buildenv]
[conf]
[options]
grpc/*:with_libsystemd=False
/:shared=True

Steps to reproduce

create package which uses grpc/1.65.0 as a dependency
conan build . -oabseil/*:shared=True --build=missing

package build fails with missing DSO from command line related to absl

Logs

Click to expand log
[ 16%] Linking CXX executable asio_server_dev
[ 18%] Linking CXX shared library libfoxtrot_server.so
/usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/asio_server_dev.dir/asio_server_dev.cpp.o: undefined reference to symbol '_ZN4absl12lts_2024011612log_internal17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_T0_PKc'
/usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: /home/danw/.conan2/p/b/absei344124e3560e9/p/lib/libabsl_log_internal_check_op.so.2401.0.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
gmake[2]: *** [devprogs/CMakeFiles/asio_server_dev.dir/build.make:123: devprogs/asio_server_dev] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:350: devprogs/CMakeFiles/asio_server_dev.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[ 27%] Built target foxtrot_server
gmake: *** [Makefile:136: all] Error 2

ERROR: conanfile.py (foxtrot_server/0.5.1-b2+dev-5-g90d8ee8-dirty): Error in build() method, line 110
        cmake.build()
        ConanException: Error 2 while executing

@weatherhead99 weatherhead99 added the bug Something isn't working label Aug 3, 2024
@jcar87 jcar87 self-assigned this Aug 5, 2024
@jcar87
Copy link
Contributor

jcar87 commented Aug 5, 2024

hi @weatherhead99 - thank you for reporting this.

Would you be able to provide a minimal example of a consumer project that results in that linker error?

transitive_libs=True is hardly ever needed, as Conan handles that automatically depending on the package_type of the affected recipes - both abseil and grpc are of type library so Conan should handle this dynamically.

On the other hand, the grpc recipe already expresses that some components depend on abseil libraries - its a bit hard to see, but:

self.cpp_info.components[component].requires = values.get("requires", [])
self.cpp_info.components[component].system_libs = values.get("system_libs", [])

should be already "linking" the abseil targets:

- abseil::absl_algorithm_container
- abseil::absl_config
- abseil::absl_no_destructor
- abseil::absl_cleanup
- abseil::absl_flat_hash_map
- abseil::absl_flat_hash_set
- abseil::absl_inlined_vector
- abseil::absl_bind_front
- abseil::absl_function_ref
- abseil::absl_hash
- abseil::absl_type_traits
- abseil::absl_random_bit_gen_ref
- abseil::absl_random_distributions
- abseil::absl_statusor
- abseil::absl_span
- abseil::absl_utility
- c-ares::cares
-

I would have expected this to work already - but need to double check.

It would be useful if we had a way to repro this. transitive_libs=True can have the undersired effect of always linking all transitive libraries - which on some platforms/configurations can result in overlinking (linked binaries will require more libraries than they actually need at runtime)

@memsharded
Copy link
Member

I am trying to reproduce this in Ubuntu 22.04, gcc11

My first attempt has been trying to use the grpc test_package in conan-center-index with:

conan create . --version=1.65.0 --build=missing -o abseil*:shared=True -o grpc/*:with_libsystemd=False

But this works fine.
We would need a minimal full reproducible case to investigate this, can someone please provide one?

@memsharded
Copy link
Member

All shared still works fine:

conan create . --version=1.65.0 --build=missing -o *:shared=True -o grpc/*:with_libsystemd=False

@jcar87
Copy link
Contributor

jcar87 commented Sep 3, 2024

Thanks @weatherhead99 - we have fixed this now in the recipe, thanks for reporting this!

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.

3 participants