From 9ed661d3574fcb10d833604b69f82f24420d9db9 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Mon, 28 Nov 2022 08:51:36 +0100 Subject: [PATCH 1/2] llvmPackages_14: Use GCC 11 on aarch64-linux The libcxx library needs a C++20 capable compiler toolchain since version 14, but aarch64-linux uses GCC 9 by default. However, building libcxxabi fails when using GCC 10, see [llvm/llvm-project#56828]. So let's use GCC 11 instead. [llvm/llvm-project#56828]: https://github.com/llvm/llvm-project/issues/56828 --- pkgs/top-level/all-packages.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 206ccc82b2fac2a..7da3206818279ea 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14749,6 +14749,8 @@ with pkgs; buildLlvmTools = buildPackages.llvmPackages_14.tools; targetLlvmLibraries = targetPackages.llvmPackages_14.libraries or llvmPackages_14.libraries; targetLlvm = targetPackages.llvmPackages_14.llvm or llvmPackages_14.llvm; + } // lib.optionalAttrs (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux && buildPackages.stdenv.cc.isGNU) { + stdenv = gcc11Stdenv; })); llvmPackages_latest = llvmPackages_14; From 176a7a31607704b9b2b5da80e60d5b9b5699b307 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Mon, 28 Nov 2022 08:56:11 +0100 Subject: [PATCH 2/2] llvmPackages_14: Add -lgcc to NIX_LDFLAGS to lld, lldb, llvm, compiler-rt and clang This is required to workaround #201254. --- pkgs/development/compilers/llvm/14/clang/default.nix | 3 +++ pkgs/development/compilers/llvm/14/compiler-rt/default.nix | 3 +++ pkgs/development/compilers/llvm/14/lld/default.nix | 3 +++ pkgs/development/compilers/llvm/14/lldb/default.nix | 3 +++ pkgs/development/compilers/llvm/14/llvm/default.nix | 3 +++ 5 files changed, 15 insertions(+) diff --git a/pkgs/development/compilers/llvm/14/clang/default.nix b/pkgs/development/compilers/llvm/14/clang/default.nix index 6b775efcc039dc2..bf349eec1499ce9 100644 --- a/pkgs/development/compilers/llvm/14/clang/default.nix +++ b/pkgs/development/compilers/llvm/14/clang/default.nix @@ -26,6 +26,9 @@ let buildInputs = [ libxml2 libllvm ]; + # workaround https://github.com/NixOS/nixpkgs/issues/201254 + NIX_LDFLAGS = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then "-lgcc" else null; + cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++14" "-DCLANGD_BUILD_XPC=OFF" diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/default.nix b/pkgs/development/compilers/llvm/14/compiler-rt/default.nix index 4351c56ef530bc7..994d6eaaad6a14f 100644 --- a/pkgs/development/compilers/llvm/14/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/14/compiler-rt/default.nix @@ -35,6 +35,9 @@ stdenv.mkDerivation { "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" ]; + # workaround https://github.com/NixOS/nixpkgs/issues/201254 + NIX_LDFLAGS = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then "-lgcc" else null; + cmakeFlags = [ "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" diff --git a/pkgs/development/compilers/llvm/14/lld/default.nix b/pkgs/development/compilers/llvm/14/lld/default.nix index 2e0d893c7febe4d..8938c5de93f59df 100644 --- a/pkgs/development/compilers/llvm/14/lld/default.nix +++ b/pkgs/development/compilers/llvm/14/lld/default.nix @@ -34,6 +34,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; buildInputs = [ libllvm libxml2 ]; + # workaround https://github.com/NixOS/nixpkgs/issues/201254 + NIX_LDFLAGS = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then "-lgcc" else null; + cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" ]; diff --git a/pkgs/development/compilers/llvm/14/lldb/default.nix b/pkgs/development/compilers/llvm/14/lldb/default.nix index 2493dcde0c84534..28d3a2bd3ff4f46 100644 --- a/pkgs/development/compilers/llvm/14/lldb/default.nix +++ b/pkgs/development/compilers/llvm/14/lldb/default.nix @@ -86,6 +86,9 @@ stdenv.mkDerivation (rec { hardeningDisable = [ "format" ]; + # workaround https://github.com/NixOS/nixpkgs/issues/201254 + NIX_LDFLAGS = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then "-lgcc" else null; + cmakeFlags = [ "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" "-DLLVM_ENABLE_RTTI=OFF" diff --git a/pkgs/development/compilers/llvm/14/llvm/default.nix b/pkgs/development/compilers/llvm/14/llvm/default.nix index 673cd31460e834f..4cc6c80dd4aa9bd 100644 --- a/pkgs/development/compilers/llvm/14/llvm/default.nix +++ b/pkgs/development/compilers/llvm/14/llvm/default.nix @@ -129,6 +129,9 @@ in stdenv.mkDerivation (rec { # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + # workaround https://github.com/NixOS/nixpkgs/issues/201254 + NIX_LDFLAGS = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then "-lgcc" else null; + cmakeFlags = with stdenv; let # These flags influence llvm-config's BuildVariables.inc in addition to the # general build. We need to make sure these are also passed via