From fea424fea33b7b71dfc43b3297ad2d1d2da36f5a Mon Sep 17 00:00:00 2001
From: Joe Hermaszewski <git@monoid.al>
Date: Tue, 25 Apr 2017 22:23:58 +0000
Subject: [PATCH] LLVM-3.9: Fix RPATH in cross compile builds

This error was cause by multiple-outputs.sh not setting
NIX_CROSS_LDFLAGS
---
 pkgs/development/compilers/llvm/3.9/llvm.nix | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix
index 0408b9413c8..6c86ac0c294 100644
--- a/pkgs/development/compilers/llvm/3.9/llvm.nix
+++ b/pkgs/development/compilers/llvm/3.9/llvm.nix
@@ -81,6 +81,12 @@ in stdenv.mkDerivation rec {
   preBuild = ''
     mkdir -p $out/
     ln -sv $PWD/lib $out
+  ''
+  + # This is a good candidate for using the `placeholder` primitive when it's released
+    # This should hopefully be unnecessary once
+    # https://github.com/NixOS/nixpkgs/pull/25047 is merged
+    stdenv.lib.optionalString (buildPlatform != hostPlatform && enableSharedLibraries) ''
+    export NIX_CROSS_LDFLAGS="-rpath $lib/lib -rpath $lib/lib64 $NIX_CROSS_LDFLAGS"
   '';
 
   cmakeFlags = with stdenv; [