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

asio-grpc: Fix grpc++ linkage #19070

Closed
wants to merge 1 commit into from

Conversation

Tradias
Copy link
Contributor

@Tradias Tradias commented Aug 6, 2023

Specify library name and version: asio-grpc/*

Fixes #18102 in the following ways:

  • It seems that no other recipe handles the difference between gRPC secure and unsecure correctly. See for example google-cloud-cpp or opentelemetry-cpp. I think this is a problem with the gRPC recipe itself where grpc++ should alias grpc++_unsecure when grpc:secure=False and it should not be addressed in dependent recipes. Linking with both grpc++ and grpc++_unsecure leads to the issues described in this issue: ServerBuilder::BuildAndStart hangs on Ubuntu 19.10 grpc/grpc#21213 (comment).

  • It fixes another problem given the following conanfile.txt:

[requires]
asio-grpc/2.4.0

[generators]
CMakeDeps
CMakeToolchain

[layout]
cmake_layout

[options]
grpc:secure=True

fails with

> conan install --build=missing ..

======== Finalizing install (deploy, generators) ========
conanfile.txt: Writing generators to C:\3YOURMIND\test-conan\build\generators
conanfile.txt: Generator 'CMakeDeps' calling 'generate()'
conanfile.txt: ERROR: Traceback (most recent call last):
  File "conan\tools\cmake\cmakedeps\templates\__init__.py", line 35, in render
  File "conan\tools\cmake\cmakedeps\templates\target_configuration.py", line 24, in context
  File "conan\tools\cmake\cmakedeps\templates\target_configuration.py", line 251, in get_deps_targets_names
  File "conan\tools\cmake\cmakedeps\templates\__init__.py", line 90, in get_component_alias
conans.errors.ConanException: Component 'grpc::grpc++_unsecure' not found in 'grpc' package requirement

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "conans\client\generators\__init__.py", line 92, in write_generators
  File "conan\tools\cmake\cmakedeps\cmakedeps.py", line 43, in generate
  File "conan\tools\cmake\cmakedeps\cmakedeps.py", line 85, in content
  File "conan\tools\cmake\cmakedeps\cmakedeps.py", line 103, in _generate_files
  File "conan\tools\cmake\cmakedeps\templates\__init__.py", line 37, in render
conans.errors.ConanException: error generating context for 'asio-grpc/2.5.1': Component 'grpc::grpc++_unsecure' not found in 'grpc' package requirement

ERROR: Error in generator 'CMakeDeps': error generating context for 'asio-grpc/2.5.1': Component 'grpc::grpc++_unsecure' not found in 'grpc' package requirement
  • It is a breaking change of this recipe but I do not know what the policy is regarding that in conan and I think it is ok. After all, it is also a bug fix. If people use, for example, asio-grpc and opentelemetry-cpp today then they would link with grpc++ and grpc++_unsecure. In other words, asio-grpc is currently broken when other dependencies (from conan-center) that themselves depend on gRPC are used.

PS D:\Programming\conan-center-index\recipes\asio-grpc> conan config set hooks.conan-center
usage: conan config [-h] [-v [V]] {home,install,list,show} ...
conan config: error: argument subcommand: invalid choice: 'set' (choose from 'home', 'install', 'list', 'show')
ERROR: Exiting with code: 2

@CLAassistant
Copy link

CLAassistant commented Aug 6, 2023

CLA assistant check
All committers have signed the CLA.

@Tradias
Copy link
Contributor Author

Tradias commented Aug 6, 2023

This pull request is independent from #19069

and supersedes #18529 (tbd).

@ghost
Copy link

ghost commented Aug 6, 2023

I detected other pull requests that are modifying asio-grpc/all recipe:

This message is automatically generated by https://github.com/ericLemanissier/conan-center-conflicting-prs so don't hesitate to report issues/improvements there.

@weatherhead99
Copy link
Contributor

I don't think this addresses the exact problem I mentioned in #18102 - my CMakeLists.txt file uses ASIO_GRPC_DISABLE_AUTOLINK because it has to build without using conan in some instances. Choosing to link either grpc++ or grpc++_unsecure in asio-grpc therefore inevitably has some library linked twice unless I manually remove it (as shown in that bug report)

@weatherhead99
Copy link
Contributor

to be clear, this is because in my own CMakeLists.txt (having used DISABLE_AUTOLINK) I then explicitly link in grpc++ to the target. If conan does that as well I think we end up linking it twice... this actually isn't a problem in my particular build as I'm using it as a shared library, but if you used it as static you end up with duplicated code...

THen again, using it as static I'm not sure triggers the original issue anyway...

@weatherhead99
Copy link
Contributor

a second issue (that I also brought up in another thread somewhere) is that grpc build with "secure=False" does not mean you always want to link against grpc++_unsecure does it? Both libraries are built in that case as far as I can see...

@Tradias
Copy link
Contributor Author

Tradias commented Aug 6, 2023

I think we end up linking it twice...

I don't see how that can happen when you use CMake, it will automatically deduplicate.

grpc build with "secure=False" does not mean you always want to link against grpc++_unsecure does it?

As is, the option isn't really applicable, if you link with grpc++_unsecure in your application while dependencies are linking with grpc++. This option has to be reworked in the grpc recipe, it should force you and every dependency to link with _unsecure.

@ghost ghost mentioned this pull request Aug 19, 2023
3 tasks
@Tradias
Copy link
Contributor Author

Tradias commented Sep 18, 2023

@ conan-team, this pull request is now ready for review. The conflicting pull request has been closed, see #18529 (comment)

@ghost ghost mentioned this pull request Oct 30, 2023
3 tasks
@Tradias Tradias mentioned this pull request Dec 26, 2023
3 tasks
@conan-center-bot conan-center-bot added Failed Missing dependencies Build failed due missing dependencies in Conan Center labels Dec 26, 2023
@conan-center-bot
Copy link
Collaborator

Conan v1 pipeline ✔️

All green in build 1 (d88910f0c51d60c27fc94db679160e229eadccec):

  • asio-grpc/2.4.0:
    All packages built successfully! (All logs)

  • asio-grpc/2.6.0:
    All packages built successfully! (All logs)

  • asio-grpc/2.5.1:
    All packages built successfully! (All logs)

  • asio-grpc/2.3.0:
    All packages built successfully! (All logs)

  • asio-grpc/2.1.0:
    All packages built successfully! (All logs)

  • asio-grpc/2.2.0:
    All packages built successfully! (All logs)

  • asio-grpc/2.0.0:
    All packages built successfully! (All logs)

  • asio-grpc/1.7.0:
    All packages built successfully! (All logs)

  • asio-grpc/2.7.0:
    All packages built successfully! (All logs)


Conan v2 pipeline ❌

Note: Conan v2 builds are now mandatory. Please read our discussion about it.

The v2 pipeline failed. Please, review the errors and note this is required for pull requests to be merged. In case this recipe is still not ported to Conan 2.x, please, ping @conan-io/barbarians on the PR and we will help you.

See details:

Failure in build 1 (d88910f0c51d60c27fc94db679160e229eadccec):

  • asio-grpc/2.6.0:
    Didn't run or was cancelled before finishing

  • asio-grpc/2.2.0:
    Didn't run or was cancelled before finishing

  • asio-grpc/2.4.0:
    CI failed to create some packages (All logs)

    Logs for packageID faa49d02adbb24e16e4a2bc5c7554bd5e6cc6af2:
    [settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.cppstd=17
    compiler.libcxx=libstdc++11
    compiler.version=11
    os=Linux
    
    [...]
        boost/1.83.0#7825569cd0622461dec7bc87dfdf47ae:bd134fe1c1cdd81f5e2cd74f387c541ed18d0bdf#a228da56c25627e5267ca356db20542f - Download (conan-center)
        bzip2/1.0.8#457c272f7da34cb9c67456dd217d36c4:763ddd53d7a4775fe84a285f56005a096d9786fd#53f22895547ac66130effcf590404b46 - Download (conan-center)
        c-ares/1.19.1#420a0b77e370f4b96bee88ef91837ccc:e3c52a2f5bd5dc2a32df2d25f9f70a04cfd7bea3#6e93e72b59f5e63a049e9ccd3ed10dc3 - Download (conan-center)
        grpc/1.50.1#0ea683e6b90eb00ac2cdd937700a9e7e:f907664fa3de2578b82af2ad5f031b1feea0c86b - Missing
        libbacktrace/cci.20210118#ec1aa63bbc10145c6a299e68e711670c:b647c43bfefae3f830561ca202b6cfd935b56205#af5aa1daf14bcf7e7254f15d75e8ab44 - Download (conan-center)
        openssl/3.2.0#d81e0a8c08372368fe7cb757280e2196:5246365bd0fb8fe4176d7e3004664503a288770f#36cc26ad7646e948d80fa8f0ffd2c6bb - Download (conan-center)
        protobuf/3.21.12#ff413e7c6d81724e872661875af83e68:10670e90b03eb1607902ed190ae2fecdc52d69bb#cf81c3658abf202d94bfa9ad0798a2af - Download (conan-center)
        re2/20230301#4482314b6488e5d71e9944f5bedb730d:81d35562505eb9186290237bea6e2684b0ba3cc8#684bce1ba6e0f89a6fd6e6ed9262f99d - Download (conan-center)
        zlib/1.3#06023034579559bb64357db3a53f88a4:b647c43bfefae3f830561ca202b6cfd935b56205#9f51ace6f715101c7daf0f943c803d69 - Download (conan-center)
    Build requirements
    Skipped binaries
        b2/4.10.1
    
    ======== Installing packages ========
    ERROR: Missing binary: grpc/1.50.1:f907664fa3de2578b82af2ad5f031b1feea0c86b
    
    grpc/1.50.1: WARN: Can't find a 'grpc/1.50.1' package binary 'f907664fa3de2578b82af2ad5f031b1feea0c86b' for the configuration:
    [settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.cppstd=17
    compiler.libcxx=libstdc++11
    compiler.version=11
    os=Linux
    [options]
    codegen=True
    cpp_plugin=True
    csharp_ext=False
    csharp_plugin=True
    fPIC=True
    node_plugin=True
    objective_c_plugin=True
    php_plugin=True
    python_plugin=True
    ruby_plugin=True
    shared=False
    [requires]
    abseil/20230125.3.Z
    c-ares/1.19.Z
    openssl/3.2.Z
    protobuf/3.21.Z
    re2/20230301.0.Z
    zlib/1.3.Z
    
    ERROR: Missing prebuilt package for 'grpc/1.50.1'
    Check the available packages using 'conan list grpc/1.50.1:* -r=remote'
    or try to build locally from sources using the '--build=grpc/1.50.1' argument
    
    More Info at 'https://docs.conan.io/2/knowledge/faq.html#error-missing-prebuilt-package'
    
  • asio-grpc/2.1.0:
    Didn't run or was cancelled before finishing

  • asio-grpc/2.7.0:
    Didn't run or was cancelled before finishing

  • asio-grpc/2.5.1:
    Didn't run or was cancelled before finishing

  • asio-grpc/2.3.0:
    Didn't run or was cancelled before finishing

  • asio-grpc/1.7.0:
    Didn't run or was cancelled before finishing

  • asio-grpc/2.0.0:
    Didn't run or was cancelled before finishing


Note: To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability.

@Tradias
Copy link
Contributor Author

Tradias commented Feb 27, 2024

Contained in #22910

@Tradias Tradias closed this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Failed Missing dependencies Build failed due missing dependencies in Conan Center
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[package] asio-grpc: ability to not link any library
4 participants