From d532f432786551e51da3a870d3d70400fca2c7f7 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 8 Nov 2021 15:11:05 +0800 Subject: [PATCH] conda: patch llvmlite --- artiq-fast/conda/llvmlite-patched.nix | 88 +++++++++++++++++++++++++++ artiq-fast/default.nix | 10 ++- 2 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 artiq-fast/conda/llvmlite-patched.nix diff --git a/artiq-fast/conda/llvmlite-patched.nix b/artiq-fast/conda/llvmlite-patched.nix new file mode 100644 index 0000000..4361708 --- /dev/null +++ b/artiq-fast/conda/llvmlite-patched.nix @@ -0,0 +1,88 @@ +{ pkgs, src }: + +let + condaBuilderEnv = import ./builder-env.nix { inherit pkgs; }; + fake-src = pkgs.runCommand "conda-fake-source-llvmlite" { } + '' + mkdir -p $out/fake-conda; + + mkdir conda-sucks + pushd conda-sucks + tar xvf ${src} --strip-components=1 + tar cf $out/src.tar . + patch -p1 < ${../pkgs/llvmlite-callsite.diff} + patch -p1 < ${../pkgs/llvmlite-abiname.diff} + popd + rm -rf conda-sucks + + cat << EOF > $out/fake-conda/meta.yaml + package: + name: llvmlite + version: 0.99 # high version number to entice the conda filth to choose it over others + + source: + url: ../src.tar + + # Again, we don't specify build dependencies since the conda garbage mistakenly thinks + # that they are not there if they have been installed from files. + requirements: + run: + - libllvm11 + - python<3.9 + - zlib + EOF + + cat << EOF > $out/fake-conda/build.sh + #!/bin/bash + set -e + + export LD_LIBRARY_PATH=/lib + python setup.py install \ + --prefix=\$PREFIX \ + --single-version-externally-managed \ + --record=record.txt \ + --no-compile + + EOF + chmod 755 $out/fake-conda/build.sh + ''; + conda-zlib = pkgs.fetchurl { + url = "https://anaconda.org/conda-forge/zlib/1.2.11/download/linux-64/zlib-1.2.11-h36c2ea0_1013.tar.bz2"; + sha256 = "sha256-zsSNs1p97wARv9qiuR5eBdKgrXiLiHGiE+uMrP63QYo="; + }; + conda-llvm = pkgs.fetchurl { + url = "https://anaconda.org/conda-forge/llvm/11.1.0/download/linux-64/llvm-11.1.0-h32600fe_2.tar.bz2"; + sha256 = "sha256-E+jnVeGHad3LH+dKqFKH0/lBuQqZKtybXF44uArmNz8="; + }; + conda-llvm-tools = pkgs.fetchurl { + url = "https://anaconda.org/conda-forge/llvm-tools/11.1.0/download/linux-64/llvm-tools-11.1.0-hf817b99_2.tar.bz2"; + sha256 = "sha256-Y87krT+d9vdVIPliJVc/szIVBRA3NNcUDdY9Gc9KpXg="; + }; + conda-llvmdev = pkgs.fetchurl { + url = "https://anaconda.org/conda-forge/llvmdev/11.1.0/download/linux-64/llvmdev-11.1.0-hf817b99_2.tar.bz2"; + sha256 = "sha256-vN87BWggPfpFp51Qm60R3D5krQ4AQwiEJaqPfVb6x40="; + }; +in + pkgs.stdenv.mkDerivation { + name = "conda-llvmlite"; + src = fake-src; + buildCommand = + '' + HOME=`pwd` + mkdir $out + cat << EOF > conda-commands.sh + set -e + + conda create --prefix ./conda_tmp ${conda-zlib} ${conda-llvm} ${conda-llvm-tools} ${conda-llvmdev} + conda init + source .bashrc + conda activate ./conda_tmp + + conda build --no-anaconda-upload --no-test --output-folder $out $src/fake-conda + EOF + ${condaBuilderEnv}/bin/conda-builder-env conda-commands.sh + + mkdir -p $out/nix-support + echo file conda $out/*/*.tar.bz2 >> $out/nix-support/hydra-build-products + ''; + } diff --git a/artiq-fast/default.nix b/artiq-fast/default.nix index dba8327..4ef4ca6 100644 --- a/artiq-fast/default.nix +++ b/artiq-fast/default.nix @@ -93,9 +93,13 @@ let }; }; - # ARTIQ-7 uses upstream conda-forge packages - - condaLinux = lib.optionalAttrs (!artiq7) (rec { + condaLinux = if artiq7 then ({ + # ARTIQ-7 uses upstream conda-forge packages except llvmlite + conda-llvmlite = import ./conda/llvmlite-patched.nix { + inherit pkgs; + inherit (mainPackages.llvmlite-llvm11) src; + }; + }) else (rec { conda-binutils-or1k = import ./conda/binutils.nix { inherit pkgs; inherit (mainPackages.binutils-or1k) version src;