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_latest: 14 -> 15 #213202

Closed
wants to merge 9 commits into from
4 changes: 4 additions & 0 deletions pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ in let

libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;

libclc = callPackage ./libclc {
inherit llvm_meta targetLlvm;
};

libcxxabi = let
# CMake will "require" a compiler capable of compiling C++ programs
# cxx-header's build does not actually use one so it doesn't really matter
Expand Down
62 changes: 62 additions & 0 deletions pkgs/development/compilers/llvm/15/libclc/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{ lib
, stdenv
, llvm_meta
, monorepoSrc
, runCommand
, cmake
, ninja
, python3
, llvm
, targetLlvm
, clang-unwrapped
, spirv-llvm-translator
, version
} @ args:

let
llvm = if stdenv.buildPlatform == stdenv.hostPlatform then args.llvm else targetLlvm;
spirv = spirv-llvm-translator.override {
llvm = args.llvm; # use LLVM for the build platform here, not targetLlvm
};
in

stdenv.mkDerivation rec {
pname = "libclc";
inherit version;

src = runCommand "${pname}-src-${version}" {} ''
cp -r ${monorepoSrc}/${pname} "$out"
'';

# cmake expects all required binaries to be in the same place, so it will not be able to find clang without the patch
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_BINDIR} NO_DEFAULT_PATH )' \
'find_program( LLVM_CLANG clang PATHS "${clang-unwrapped}/bin" NO_DEFAULT_PATH )' \
--replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_BINDIR} NO_DEFAULT_PATH )' \
'find_program( LLVM_SPIRV llvm-spirv PATHS "${spirv}/bin" NO_DEFAULT_PATH )'
'';

nativeBuildInputs = [ cmake ninja python3 spirv ];
buildInputs = [ llvm clang-unwrapped ];
strictDeps = true;
cmakeFlags = [
"-DCMAKE_INSTALL_INCLUDEDIR=include"
# the libclc build uses the `clang` we pass in to build OpenCL C files but
# we don't want it to use this `clang` for building C/C++ files
#
# usually the `cmake` setup hook passes in `-DCMAKE_CXX_COMPILER=$CXX` where
# `$CXX` is the name of the compiler (i.e. `g++`, `clang++`, etc); in cases
# where the stdenv is `clang` based this causes `cmake` to search `$PATH`
# for `clang++` and to find our unwrapped `clang` instead of the stdenv's
#
# so, we explicitly tell CMake to use the C/C++ compiler from the stdenv:
"-DCMAKE_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"-DCMAKE_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
];

meta = llvm_meta // {
homepage = "http://libclc.llvm.org/";
description = "Implementation of the library requirements of the OpenCL C programming language";
};
}
7 changes: 6 additions & 1 deletion pkgs/development/compilers/llvm/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# This is the default binutils, but with *this* version of LLD rather
# than the default LLVM verion's, if LLD is the choice. We use these for
# the `useLLVM` bootstrapping below.
, targetLlvm
, bootBintoolsNoLibc ?
if stdenv.targetPlatform.linker == "lld"
then null
Expand Down Expand Up @@ -257,6 +258,10 @@ let

libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;

libclc = callPackage ./libclc {
inherit llvm_meta targetLlvm;
};

libcxxabi = let
# CMake will "require" a compiler capable of compiling C++ programs
# cxx-header's build does not actually use one so it doesn't really matter
Expand Down Expand Up @@ -296,7 +301,7 @@ let
};

openmp = callPackage ./openmp {
inherit llvm_meta;
inherit llvm_meta targetLlvm;
};
});

Expand Down
62 changes: 62 additions & 0 deletions pkgs/development/compilers/llvm/git/libclc/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{ lib
, stdenv
, llvm_meta
, monorepoSrc
, runCommand
, cmake
, ninja
, python3
, llvm
, targetLlvm
, clang-unwrapped
, spirv-llvm-translator
, version
} @ args:

let
llvm = if stdenv.buildPlatform == stdenv.hostPlatform then args.llvm else targetLlvm;
spirv = spirv-llvm-translator.override {
llvm = args.llvm; # use LLVM for the build platform here, not targetLlvm
};
in

stdenv.mkDerivation rec {
pname = "libclc";
inherit version;

src = runCommand "${pname}-src-${version}" {} ''
cp -r ${monorepoSrc}/${pname} "$out"
'';

# cmake expects all required binaries to be in the same place, so it will not be able to find clang without the patch
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_BINDIR} NO_DEFAULT_PATH )' \
'find_program( LLVM_CLANG clang PATHS "${clang-unwrapped}/bin" NO_DEFAULT_PATH )' \
--replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_BINDIR} NO_DEFAULT_PATH )' \
'find_program( LLVM_SPIRV llvm-spirv PATHS "${spirv}/bin" NO_DEFAULT_PATH )'
'';

nativeBuildInputs = [ cmake ninja python3 spirv ];
buildInputs = [ llvm clang-unwrapped ];
strictDeps = true;
cmakeFlags = [
"-DCMAKE_INSTALL_INCLUDEDIR=include"
# the libclc build uses the `clang` we pass in to build OpenCL C files but
# we don't want it to use this `clang` for building C/C++ files
#
# usually the `cmake` setup hook passes in `-DCMAKE_CXX_COMPILER=$CXX` where
# `$CXX` is the name of the compiler (i.e. `g++`, `clang++`, etc); in cases
# where the stdenv is `clang` based this causes `cmake` to search `$PATH`
# for `clang++` and to find our unwrapped `clang` instead of the stdenv's
#
# so, we explicitly tell CMake to use the C/C++ compiler from the stdenv:
"-DCMAKE_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"-DCMAKE_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
];

meta = llvm_meta // {
homepage = "http://libclc.llvm.org/";
description = "Implementation of the library requirements of the OpenCL C programming language";
};
}
5 changes: 4 additions & 1 deletion pkgs/development/compilers/llvm/git/openmp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
, cmake
, ninja
, llvm
, targetLlvm
, lit
, clang-unwrapped
, perl
Expand Down Expand Up @@ -34,7 +35,9 @@ stdenv.mkDerivation rec {
outputs = [ "out" "dev" ];

nativeBuildInputs = [ cmake ninja perl pkg-config lit ];
buildInputs = [ llvm ];
buildInputs = [
(if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
];

# Unsup:Pass:XFail:Fail
# 26:267:16:8
Expand Down
22 changes: 20 additions & 2 deletions pkgs/development/compilers/spirv-llvm-translator/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
, llvm
, spirv-headers
, spirv-tools
, testers
}:

let
# TODO(rrbutani): use release-version instead of version to support
# `llvmPackages_git`.
llvmMajor = lib.versions.major llvm.version;
isROCm = lib.hasPrefix "rocm" llvm.pname;

Expand All @@ -28,7 +31,7 @@ let
hash = "sha256-NoIoa20+2sH41rEnr8lsMhtfesrtdPINiXtUnxYVm8s=";
} else throw "Incompatible LLVM version.";
in
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "SPIRV-LLVM-Translator";
inherit (branch) version;

Expand Down Expand Up @@ -64,11 +67,26 @@ stdenv.mkDerivation {
install -D tools/llvm-spirv/llvm-spirv $out/bin/llvm-spirv
'';

# On macOS the produced binaries' rpath references the build dir and is *not*
# rewritten to the install dir by cmake during installation (when
# `CMAKE_SKIP_BUILD_RPATH` is set to `Off`). So, we set rpath ourselves.
preFixup = lib.optional stdenv.hostPlatform.isDarwin ''
for exe in "$out/bin/"* ; do
${stdenv.cc.targetPrefix}install_name_tool -add_rpath "$out/lib" "$exe"
done
'';

passthru.tests.version = with finalAttrs; testers.testVersion {
package = finalPackage;
version = llvm.version;
};

meta = with lib; {
homepage = "https://github.com/KhronosGroup/SPIRV-LLVM-Translator";
description = "A tool and a library for bi-directional translation between SPIR-V and LLVM IR";
license = licenses.ncsa;
platforms = platforms.unix;
maintainers = with maintainers; [ gloaming ];
mainProgram = "llvm-spirv";
};
}
})
11 changes: 11 additions & 0 deletions pkgs/development/compilers/swift/compiler/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ in stdenv.mkDerivation {
sha256 = "1rma1al0rbm3s3ql6bnvbcighp74lri1lcrwbyacgdqp80fgw1b6";
}}

${lib.optionalString (!stdenv.isDarwin) ''
# Needed to build with clang 15+ without disabling warnings; can drop this
# once we update to 5.8.x.
patch -p1 -d swift-corelibs-libdispatch -i ${fetchpatch {
name = "swift-corelibs-libdispatch-fix-unused-but-set-warning";
url = "https://github.com/apple/swift-corelibs-libdispatch/commit/915f25141a7c57b6a2a3bc8697572644af181ec5.patch";
sha256 = "sha256-gxhMwSlE/y4LkOvmCaDMPjd7EcoX6xaacK4MLa3mOUM=";
includes = ["src/shims/yield.c"];
}}
''}

${lib.optionalString stdenv.isLinux ''
substituteInPlace llvm-project/clang/lib/Driver/ToolChains/Linux.cpp \
--replace 'SysRoot + "/lib' '"${glibc}/lib" "' \
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/swift/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
, pkgs
, newScope
, darwin
, llvmPackages_latest
# See: https://github.com/NixOS/nixpkgs/pull/213202#issuecomment-1483644798
, llvmPackages_14
, overrideCC
}:

Expand All @@ -23,12 +24,12 @@ let
# currently closest to the official Swift builds.
clang = if pkgs.stdenv.isDarwin
then
llvmPackages_latest.clang.override rec {
llvmPackages_14.clang.override rec {
libc = apple_sdk.Libsystem;
bintools = pkgs.bintools.override { inherit libc; };
}
else
llvmPackages_latest.clang;
llvmPackages_14.clang;

# Overrides that create a useful environment for swift packages, allowing
# packaging with `swiftPackages.callPackage`. These are similar to
Expand Down
14 changes: 13 additions & 1 deletion pkgs/development/compilers/swift/libdispatch/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, stdenv
, callPackage
, fetchpatch
, cmake
, ninja
, useSwift ? true, swift
Expand All @@ -19,7 +20,18 @@ in stdenv.mkDerivation {
nativeBuildInputs = [ cmake ]
++ lib.optionals useSwift [ ninja swift ];

patches = [ ./disable-swift-overlay.patch ];
patches = [
./disable-swift-overlay.patch

# Needed to build with clang 15+ without disabling warnings; can drop this
# once we update to 5.8.x.
(fetchpatch {
name = "swift-corelibs-libdispatch-fix-unused-but-set-warning";
url = "https://github.com/apple/swift-corelibs-libdispatch/commit/915f25141a7c57b6a2a3bc8697572644af181ec5.patch";
sha256 = "sha256-gxhMwSlE/y4LkOvmCaDMPjd7EcoX6xaacK4MLa3mOUM=";
includes = ["src/shims/yield.c"];
})
];

cmakeFlags = lib.optional useSwift "-DENABLE_SWIFT=ON";

Expand Down
43 changes: 0 additions & 43 deletions pkgs/development/libraries/libclc/default.nix

This file was deleted.

1 change: 1 addition & 0 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,7 @@ mapAliases ({
inherit (stdenvAdapters) overrideCC;
buildLlvmTools = buildPackages.llvmPackages_git.tools;
targetLlvmLibraries = targetPackages.llvmPackages_git.libraries or llvmPackages_git.libraries;
targetLlvm = targetPackages.llvmPackages_git.llvm or llvmPackages_git.llvm;
});

# Added 2022-01-28
Expand Down
6 changes: 2 additions & 4 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15554,7 +15554,7 @@ with pkgs;
targetLlvm = targetPackages.llvmPackages_15.llvm or llvmPackages_15.llvm;
}));

llvmPackages_latest = llvmPackages_14;
llvmPackages_latest = llvmPackages_15;

llvmPackages_rocm = recurseIntoAttrs (callPackage ../development/compilers/llvm/rocm { });

Expand Down Expand Up @@ -21192,9 +21192,7 @@ with pkgs;

libcint = callPackage ../development/libraries/libcint { };

libclc = callPackage ../development/libraries/libclc {
llvmPackages = llvmPackages_latest;
};
libclc = llvmPackages_latest.libclc;

libcli = callPackage ../development/libraries/libcli { };

Expand Down