From c33c7c3d5fa99fb13d39fd9af265b38a161abaf1 Mon Sep 17 00:00:00 2001 From: Tom Repetti Date: Sun, 29 Aug 2021 19:31:30 -0400 Subject: [PATCH] clang_11: Fix RISC-V builds for compiler-rt. (#135718) Closes: #135628 --- pkgs/development/compilers/llvm/11/compiler-rt/default.nix | 3 +++ pkgs/development/compilers/llvm/11/default.nix | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/llvm/11/compiler-rt/default.nix b/pkgs/development/compilers/llvm/11/compiler-rt/default.nix index 89b47df405fe..e5b79692ae24 100644 --- a/pkgs/development/compilers/llvm/11/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/11/compiler-rt/default.nix @@ -112,5 +112,8 @@ stdenv.mkDerivation { # "All of the code in the compiler-rt project is dual licensed under the MIT # license and the UIUC License (a BSD-like license)": license = with lib.licenses; [ mit ncsa ]; + # compiler-rt requires a Clang stdenv on 32-bit RISC-V: + # https://reviews.llvm.org/D43106#1019077 + broken = stdenv.hostPlatform.isRiscV && stdenv.hostPlatform.is32bit && !stdenv.cc.isClang; }; } diff --git a/pkgs/development/compilers/llvm/11/default.nix b/pkgs/development/compilers/llvm/11/default.nix index 661e60e24b18..9834ce30cdd2 100644 --- a/pkgs/development/compilers/llvm/11/default.nix +++ b/pkgs/development/compilers/llvm/11/default.nix @@ -227,7 +227,7 @@ let compiler-rt-libc = callPackage ./compiler-rt { inherit llvm_meta; - stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) + stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) || (stdenv.hostPlatform.isRiscV && stdenv.hostPlatform.is32bit) then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc else stdenv; }; @@ -240,7 +240,7 @@ let }; # N.B. condition is safe because without useLLVM both are the same. - compiler-rt = if stdenv.hostPlatform.isAndroid || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) + compiler-rt = if stdenv.hostPlatform.isAndroid || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) || (stdenv.hostPlatform.libc == "newlib") then libraries.compiler-rt-libc else libraries.compiler-rt-no-libc;