Merge pull request #140880 from sternenseemann/llvm-grpc

pkgsLLVM.grpc: fix build
This commit is contained in:
Mario Rodas 2021-10-08 20:37:53 -05:00 committed by GitHub
commit eb88cf6eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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"
];
@ -68,7 +73,12 @@ stdenv.mkDerivation rec {
rm -vf BUILD
'';
preBuild = ''
# When natively compiling, grpc_cpp_plugin is executed from the build directory,
# needing to load dynamic libraries from the build directory, so we set
# LD_LIBRARY_PATH to enable this. When cross compiling we need to avoid this,
# since it can cause the grpc_cpp_plugin executable from buildPackages to
# crash if build and host architecture are compatible (e. g. pkgsLLVM).
preBuild = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
export LD_LIBRARY_PATH=$(pwd)''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
'';