about summary refs log tree commit diff
path: root/pkgs/development/compilers/llvm/common/compiler-rt/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/llvm/common/compiler-rt/default.nix')
-rw-r--r--pkgs/development/compilers/llvm/common/compiler-rt/default.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix
index 4f44d6396d301..7d47436b714ff 100644
--- a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix
@@ -14,7 +14,18 @@
 , libllvm
 , linuxHeaders
 , libxcrypt
+
+# Some platforms have switched to using compiler-rt, but still want a
+# libgcc.a for ABI compat purposes. The use case would be old code that
+# expects to link `-lgcc` but doesn't care exactly what its contents
+# are, so long as it provides some builtins.
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
+
+# In recent releases, the compiler-rt build seems to produce
+# many `libclang_rt*` libraries, but not a single unified
+# `libcompiler_rt` library, at least under certain configurations. Some
+# platforms stil expect this, however, so we symlink one into place.
+, forceLinkCompilerRt ? stdenv.hostPlatform.isOpenBSD
 }:
 
 let
@@ -149,7 +160,9 @@ stdenv.mkDerivation ({
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
     ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
   '' + lib.optionalString doFakeLibgcc ''
-     ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a
+     ln -s $out/lib/*/libclang_rt.builtins-*.a $out/lib/libgcc.a
+  '' + lib.optionalString forceLinkCompilerRt ''
+     ln -s $out/lib/*/libclang_rt.builtins-*.a $out/lib/libcompiler_rt.a
   '';
 
   meta = llvm_meta // {