pkgsLLVM.grpc: fix build with clang < 11

Apparently there's an issue where compiling grpc with -std=c++17 fails
unless the clang version is at least 11. Hopefully our default clang
version will be increased to that soon, but until then we need to work
around this problem by setting an older C++ standard.

It's unclear if using C++11 causes further issues, but compiling is
better than not compiling, I suppose.

Contrary to the linked bug report, the darwin stdenv doesn't exhibit
this problem for some reason.
This commit is contained in:
sternenseemann 2021-10-07 21:06:56 +02:00
parent 34ca27bc95
commit 8e57c33ab6

View File

@ -57,7 +57,12 @@ stdenv.mkDerivation rec {
"-DgRPC_ABSL_PROVIDER=package"
"-DBUILD_SHARED_LIBS=ON"
"-DCMAKE_SKIP_BUILD_RPATH=OFF"
"-DCMAKE_CXX_STANDARD=17"
# Needs to be compiled with -std=c++11 for clang < 11. Interestingly this is
# only an issue with the useLLVM stdenv, not the darwin stdenv…
# https://github.com/grpc/grpc/issues/26473#issuecomment-860885484
(if (stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "11.0"
then "-DCMAKE_CXX_STANDARD=11"
else "-DCMAKE_CXX_STANDARD=17")
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc"
];