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

Build error when using g++ 9.3 and associated std lib #29984

Closed
RajivKurian opened this issue Jun 10, 2022 · 5 comments
Closed

Build error when using g++ 9.3 and associated std lib #29984

RajivKurian opened this issue Jun 10, 2022 · 5 comments

Comments

@RajivKurian
Copy link

What version of gRPC and what language are you using?

GRPC master, commit 0da56bc

What operating system (Linux, Windows,...) and version?

Ubuntu 20.04

What runtime / compiler are you using (e.g. python version or version of gcc)

g++ 9.30, libstdc++.so.6

What did you do?

Try to build a hello world server/client example in my project using bazel.
I import grpc in my bazel workspace as follows:
I use the absl version that I found used in grpc deps.

http_archive(
    name = "com_google_absl",
    sha256 = "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
    strip_prefix = "abseil-cpp-20211102.0",
    urls = [
        "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20211102.0.tar.gz",
        "https://github.com/abseil/abseil-cpp/archive/20211102.0.tar.gz",
    ],
)

http_archive(
    name = "com_github_grpc_grpc",
    strip_prefix = "grpc-0da56bcc0e42a9e288d7511ed8426b9831ffbfb5",
    urls = [
        "https://github.com/grpc/grpc/archive/0da56bcc0e42a9e288d7511ed8426b9831ffbfb5.tar.gz",
    ],
)

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()

I compile a copy of https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_server.cc by issuing
bazel build //grpc_example:greeter_server

What did you expect to see?

A successful compilation

What did you see instead?

A compile error like this:

In file included from external/com_github_grpc_grpc/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc:28:
In file included from external/com_github_grpc_grpc/src/core/ext/filters/client_channel/config_selector.h:30:
In file included from external/com_github_grpc_grpc/src/core/lib/channel/channel_stack.h:62:
In file included from external/com_github_grpc_grpc/src/core/lib/resource_quota/arena.h:42:
In file included from external/com_github_grpc_grpc/src/core/lib/resource_quota/memory_quota.h:33:
In file included from external/com_github_grpc_grpc/src/core/lib/promise/activity.h:33:
In file included from external/com_google_absl/absl/types/variant.h:50:
/my_conda_envs/conda/envs/d9695e4b93d2/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/variant:609:6: error: no matching conversion for functional-style cast from 'const std::basic_string<char>' to 'variant<std::basic_string<char>, std::vector<grpc_core::XdsRouteConfigResource::Route::RouteAction::ClusterWeight>, std::basic_string<char>>'
                        = variant<_Types...>(__rhs_mem);

I am using gcc 9.3 and libstdc++.so.6 from conda. I notice that this problem goes away if I update gcc and libstdc++ to higher versions but sadly that is not an option in my environment. Is there anything I can do to make this problem go away without updating gcc? I am already on one of the latest commits on grpc. Is there a downgrade I could perhaps do to make this problem go away?

Anything else we should know about your project / environment?

@RajivKurian
Copy link
Author

RajivKurian commented Jun 10, 2022

I also noticed that the problem goes away if I use downgrade to commit 1c159689ceda2c408f7f9d97d96a264c9521b806 which corresponds to v1.45.1(1c15968)

@markdroth
Copy link
Member

Looks like a possible portability issue. Esun, can you please take a look?

@veblush
Copy link
Contributor

veblush commented Jun 21, 2022

I briefly tried to reproduce this on Ubuntu 20 with gcc 9 but it worked as followings;

docker run -it --rm ubuntu:20.04
apt update
apt install build-essential git
# install bazel
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
apt update && apt install bazel
# get grpc
cd /tmp
git clone https://github.com/grpc/grpc
cd grpc
# build an example
export CC=gcc
export CXX=g++
bazel build examples/cpp/helloworld:greeter_server

If you can give us repro, it would be helpful to address it.

@RajivKurian
Copy link
Author

Hi @veblush, we are using conda to get our gcc toolchain including libstdc++. I can give it a shot in terms of reproducing it with that toolchain. I wonder if the conda libstdc++ is slightly different as surprising as that would be.

@veblush
Copy link
Contributor

veblush commented Oct 11, 2022

I guess #30118 fixed ths issue.

@veblush veblush closed this as completed Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants