Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvmPackages_14: Fix build on aarch64-linux #201485

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/14/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

@ehmry ehmry Nov 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider if adding an argument above like { withLibgcc ? stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU, ... }: is better than putting these conditions inline in the body of derivations. This could make overriding LLVM easier and I think its self-documenting to have code in the form of effect ? cause rather than if ${cause} then ${action} else null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is just an ugly workaround, I would prefer to keep this as ugly as possible. 😬


cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-std=c++14"
"-DCLANGD_BUILD_XPC=OFF"
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/14/compiler-rt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/14/lld/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/14/lldb/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/14/llvm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

vcunat marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +14752 to +14753
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}));

llvmPackages_latest = llvmPackages_14;
Expand Down