diff --git a/pkgs/development/compilers/llvm/10/libcxxabi/default.nix b/pkgs/development/compilers/llvm/10/libcxxabi/default.nix index 482ced8e0c3fc..c61f48485580f 100644 --- a/pkgs/development/compilers/llvm/10/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/10/libcxxabi/default.nix @@ -42,11 +42,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/11/libcxxabi/default.nix b/pkgs/development/compilers/llvm/11/libcxxabi/default.nix index 6c4ca925ab116..2359820dddecd 100644 --- a/pkgs/development/compilers/llvm/11/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/11/libcxxabi/default.nix @@ -46,11 +46,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/12/libcxxabi/default.nix b/pkgs/development/compilers/llvm/12/libcxxabi/default.nix index 89b56ad230d85..c130a6c1c3115 100644 --- a/pkgs/development/compilers/llvm/12/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/12/libcxxabi/default.nix @@ -44,11 +44,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/13/libcxxabi/default.nix b/pkgs/development/compilers/llvm/13/libcxxabi/default.nix index 16ea0b113c754..5da86b96d5a72 100644 --- a/pkgs/development/compilers/llvm/13/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/13/libcxxabi/default.nix @@ -41,11 +41,21 @@ stdenv.mkDerivation rec { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix index d64708ab040ae..0487f1d0de83c 100644 --- a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix @@ -52,12 +52,23 @@ stdenv.mkDerivation rec { installPhase = if stdenv.isDarwin then '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done + make install install -d 755 $out/include install -m 644 ../include/*.h $out/include diff --git a/pkgs/development/compilers/llvm/5/libcxxabi/default.nix b/pkgs/development/compilers/llvm/5/libcxxabi/default.nix index 60a41ab2d8303..f2f707ec445d0 100644 --- a/pkgs/development/compilers/llvm/5/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/5/libcxxabi/default.nix @@ -27,11 +27,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/6/libcxxabi/default.nix b/pkgs/development/compilers/llvm/6/libcxxabi/default.nix index d7de130fbaaf6..63e6eee6f596c 100644 --- a/pkgs/development/compilers/llvm/6/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/6/libcxxabi/default.nix @@ -27,11 +27,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/7/libcxxabi/default.nix b/pkgs/development/compilers/llvm/7/libcxxabi/default.nix index 1bc9444feda11..721200136a57b 100644 --- a/pkgs/development/compilers/llvm/7/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/7/libcxxabi/default.nix @@ -46,11 +46,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/8/libcxxabi/default.nix b/pkgs/development/compilers/llvm/8/libcxxabi/default.nix index 50a5eabc17039..5ade8a5ae66f9 100644 --- a/pkgs/development/compilers/llvm/8/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/8/libcxxabi/default.nix @@ -42,11 +42,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/9/libcxxabi/default.nix b/pkgs/development/compilers/llvm/9/libcxxabi/default.nix index ee6834affbcd3..4a235f5c2ef70 100644 --- a/pkgs/development/compilers/llvm/9/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/9/libcxxabi/default.nix @@ -42,11 +42,21 @@ stdenv.mkDerivation { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done ''; diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix index 2d4fe974c016b..b478668ebded9 100644 --- a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix @@ -70,11 +70,21 @@ stdenv.mkDerivation rec { preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do + # Fix up the install name. Preserve the basename, just replace the path. + installName="$out/lib/$(basename $(otool -D $file | tail -n 1))" + # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - install_name_tool -id $out/$file $file + ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file + + # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes + # libcxxabi to sometimes link against a different version of itself. + # Here we simply make that second reference point to ourselves. + for other in $(otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do + ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file + done done '';