Merge pull request #140880 from sternenseemann/llvm-grpc

pkgsLLVM.grpc: fix build

authored by Mario Rodas and committed by GitHub eb88cf6e 91bb6da2

+12 -2
+12 -2
pkgs/development/libraries/grpc/default.nix
··· 57 57 "-DgRPC_ABSL_PROVIDER=package" 58 58 "-DBUILD_SHARED_LIBS=ON" 59 59 "-DCMAKE_SKIP_BUILD_RPATH=OFF" 60 - "-DCMAKE_CXX_STANDARD=17" 60 + # Needs to be compiled with -std=c++11 for clang < 11. Interestingly this is 61 + # only an issue with the useLLVM stdenv, not the darwin stdenv… 62 + # https://github.com/grpc/grpc/issues/26473#issuecomment-860885484 63 + (if (stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "11.0" 64 + then "-DCMAKE_CXX_STANDARD=11" 65 + else "-DCMAKE_CXX_STANDARD=17") 61 66 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 62 67 "-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc" 63 68 ]; ··· 68 73 rm -vf BUILD 69 74 ''; 70 75 71 - preBuild = '' 76 + # When natively compiling, grpc_cpp_plugin is executed from the build directory, 77 + # needing to load dynamic libraries from the build directory, so we set 78 + # LD_LIBRARY_PATH to enable this. When cross compiling we need to avoid this, 79 + # since it can cause the grpc_cpp_plugin executable from buildPackages to 80 + # crash if build and host architecture are compatible (e. g. pkgsLLVM). 81 + preBuild = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' 72 82 export LD_LIBRARY_PATH=$(pwd)''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH 73 83 ''; 74 84