Merge pull request #224257 from paveloom/codon

This commit is contained in:
Sandro 2023-04-14 00:56:33 +02:00 committed by GitHub
commit ea6869e610
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 164 additions and 0 deletions

View file

@ -0,0 +1,23 @@
From 5c158213fc3afe39ee96be84e255c12d5886ca18 Mon Sep 17 00:00:00 2001
From: Pavel Sobolev <paveloom@riseup.net>
Date: Sat, 1 Apr 2023 17:38:37 +0300
Subject: [PATCH] Add a hash to the `googletest` binary.
---
CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a06e6f..a614025 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -434,6 +434,7 @@ include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
+ URL_HASH SHA256=5cf189eb6847b4f8fc603a3ffff3b0771c08eec7dd4bd961bfd45477dd13eb73
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
--
2.39.2

View file

@ -0,0 +1,137 @@
{ cacert
, cmake
, fetchFromGitHub
, git
, lib
, lld
, ninja
, nix-update-script
, perl
, python3
, stdenv
}:
let
version = "0.15.5";
src = fetchFromGitHub {
owner = "exaloop";
repo = "codon";
rev = "v${version}";
sha256 = "sha256-/IUGX5iSRvZzwyRdkGe0IVHp44D+GXZtbkdtswekwSU=";
};
depsDir = "deps";
codon-llvm = stdenv.mkDerivation {
pname = "codon-llvm";
version = "unstable-2022-09-23";
src = fetchFromGitHub {
owner = "exaloop";
repo = "llvm-project";
rev = "55b0b8fa1c9f9082b535628fc9fa6313280c0b9a";
sha256 = "sha256-03SPQgNdrpR6/JZ5aR/ntoh/FnZvCjT/6bTAcZaFafw=";
};
nativeBuildInputs = [
cmake
git
lld
ninja
python3
];
cmakeFlags = [
"-DCMAKE_CXX_COMPILER=clang++"
"-DCMAKE_C_COMPILER=clang"
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_ENABLE_TERMINFO=OFF"
"-DLLVM_ENABLE_ZLIB=OFF"
"-DLLVM_INCLUDE_TESTS=OFF"
"-DLLVM_TARGETS_TO_BUILD=all"
"-DLLVM_USE_LINKER=lld"
"-S ../llvm"
];
};
codon-deps = stdenv.mkDerivation {
name = "codon-deps-${version}.tar.gz";
inherit src;
nativeBuildInputs = [
cacert
cmake
git
perl
python3
];
dontBuild = true;
cmakeFlags = [
"-DCPM_DOWNLOAD_ALL=ON"
"-DCPM_SOURCE_CACHE=${depsDir}"
"-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm"
];
installPhase = ''
# Prune the `.git` directories
find ${depsDir} -name .git -type d -prune -exec rm -rf {} \;;
# Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/
tar --owner=0 --group=0 --numeric-owner --format=gnu \
--sort=name --mtime="@$SOURCE_DATE_EPOCH" \
-czf $out \
${depsDir} \
cmake \
_deps/googletest-subbuild/googletest-populate-prefix/src/*.zip
'';
outputHash = "sha256-a1zGSpbMjfQBrcgW/aiIdKX8+uI3p/S9pgZjHe2HtWs=";
outputHashAlgo = "sha256";
};
in
stdenv.mkDerivation {
pname = "codon";
inherit src version;
patches = [
# Without the hash, CMake will try to replace the `.zip` file
./Add-a-hash-to-the-googletest-binary.patch
];
nativeBuildInputs = [
cmake
git
lld
ninja
perl
python3
];
postUnpack = ''
mkdir -p $sourceRoot/build
tar -xf ${codon-deps} -C $sourceRoot/build
'';
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_CXX_COMPILER=clang++"
"-DCMAKE_C_COMPILER=clang"
"-DCPM_SOURCE_CACHE=${depsDir}"
"-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm"
"-DLLVM_USE_LINKER=lld"
];
passthru.updateScript = nix-update-script { };
meta = {
description = "A high-performance, zero-overhead, extensible Python compiler using LLVM";
homepage = "https://docs.exaloop.io/codon";
maintainers = [ lib.maintainers.paveloom ];
license = lib.licenses.bsl11;
platforms = lib.platforms.all;
};
}

View file

@ -14364,6 +14364,10 @@ with pkgs;
ciao = callPackage ../development/compilers/ciao { };
codon = callPackage ../development/compilers/codon {
inherit (llvmPackages_latest) lld stdenv;
};
colm = callPackage ../development/compilers/colm { };
colmap = libsForQt5.callPackage ../applications/science/misc/colmap { cudaSupport = config.cudaSupport or false; };