about summary refs log tree commit diff
path: root/pkgs/development/libraries/grpc
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2021-10-07 21:04:39 +0200
committersternenseemann <sternenseemann@systemli.org>2021-10-07 21:04:39 +0200
commit34ca27bc95261256846ee8d0ebcdf4aeafef907a (patch)
tree8dc5f37ae17ad5b2ab51c656d7d7af2570d33140 /pkgs/development/libraries/grpc
parent9a76986ee0d46ea8074c9a8992df531dd90ac261 (diff)
grpc: don't set LD_LIBRARY_PATH when cross compiling
LD_LIBRARY_PATH is only necessary in the native compilation case when we
need to execute grpc_cpp_plugin from the build directory. Disabling this
for cross is not only cleaner, but eliminates linker failures when cross
compiling to a compatible configuration, since LD_LIBRARY_PATH takes
precedence over the rpath set in buildPackages.grpc's grpc_cpp_plugin.
Diffstat (limited to 'pkgs/development/libraries/grpc')
-rw-r--r--pkgs/development/libraries/grpc/default.nix7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkgs/development/libraries/grpc/default.nix b/pkgs/development/libraries/grpc/default.nix
index 2000bdccb0087..0787ffea41faa 100644
--- a/pkgs/development/libraries/grpc/default.nix
+++ b/pkgs/development/libraries/grpc/default.nix
@@ -68,7 +68,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
   '';