···57 "-DgRPC_ABSL_PROVIDER=package"
58 "-DBUILD_SHARED_LIBS=ON"
59 "-DCMAKE_SKIP_BUILD_RPATH=OFF"
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")
66 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
67 "-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc"
68 ];
···73 rm -vf BUILD
74 '';
7576+ # 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) ''
82 export LD_LIBRARY_PATH=$(pwd)''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
83 '';
84