From 20c2871896a43a009d102bd1c2eb543658ee9e00 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 9 Jun 2020 18:21:54 +0800 Subject: [PATCH] conda: build llvm-or1k --- artiq-fast/conda/builder-env.nix | 7 ++++- artiq-fast/conda/llvm-or1k.nix | 52 ++++++++++++++++++++++++++++++++ artiq-fast/default.nix | 5 +++ artiq-fast/pkgs/llvm-or1k.nix | 4 ++- 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 artiq-fast/conda/llvm-or1k.nix diff --git a/artiq-fast/conda/builder-env.nix b/artiq-fast/conda/builder-env.nix index edd0b09..e1f3b8a 100644 --- a/artiq-fast/conda/builder-env.nix +++ b/artiq-fast/conda/builder-env.nix @@ -16,6 +16,7 @@ let targetPkgs = pkgs: ([ condaSrcChmod ] ++ condaDeps); }; + # for binutils libiconv-filename = "libiconv-1.15-h516909a_1006.tar.bz2"; libiconv = pkgs.fetchurl { url = "https://anaconda.org/conda-forge/libiconv/1.15/download/linux-64/${libiconv-filename}"; @@ -38,5 +39,9 @@ let in buildFHSUserEnv { name = "conda-builder-env"; - targetPkgs = pkgs: [ condaInstalled ] ++ condaDeps; + targetPkgs = pkgs: ([ condaInstalled ] ++ condaDeps ++ [ + # for llvm-or1k + cmake + ] + ); } diff --git a/artiq-fast/conda/llvm-or1k.nix b/artiq-fast/conda/llvm-or1k.nix new file mode 100644 index 0000000..80db2d2 --- /dev/null +++ b/artiq-fast/conda/llvm-or1k.nix @@ -0,0 +1,52 @@ +{ pkgs, version, src }: + +let + fake-src = pkgs.runCommand "conda-fake-source-llvm-or1k" { } + '' + mkdir -p $out/fake-conda; + + # work around yet more idiotic conda behavior - build breaks if write permissions aren't set on source files. + cp --no-preserve=mode,ownership -R ${src} workaround-conda + pushd workaround-conda + tar cf $out/src.tar . + popd + rm -rf workaround-conda + + cat << EOF > $out/fake-conda/meta.yaml + package: + name: llvm-or1k + version: ${version} + + # Use the nixpkgs cmake to build, so we are less bothered by conda idiocy. + + source: + url: ../src.tar + + EOF + + cat << EOF > $out/fake-conda/build.sh + mkdir build + cd build + cmake .. \$COMPILER32 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=\$PREFIX \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON \ + -DLLVM_TARGETS_TO_BUILD=X86 \ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=OR1K \ + -DLLVM_ENABLE_ASSERTIONS=OFF \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_INCLUDE_TESTS=OFF \ + -DLLVM_INCLUDE_DOCS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF + make -j2 + make install + + EOF + chmod 755 $out/fake-conda/build.sh + ''; +in + import ./build.nix { inherit pkgs; } { + name = "conda-llvm-or1k"; + src = fake-src; + } diff --git a/artiq-fast/default.nix b/artiq-fast/default.nix index 1a44933..1e28cb7 100644 --- a/artiq-fast/default.nix +++ b/artiq-fast/default.nix @@ -54,6 +54,11 @@ let inherit (binutils-arm) version src; target = "armv7-unknown-linux-gnueabihf"; }; + conda-llvm-or1k = import ./conda/llvm-or1k.nix { + inherit pkgs; + inherit (llvm-or1k) version; + src = llvm-or1k.llvm-src; + }; conda-sipyco = import ./conda/build.nix { inherit pkgs; } { name = "conda-sipyco"; src = import ./conda/fake-source.nix { inherit pkgs; } { diff --git a/artiq-fast/pkgs/llvm-or1k.nix b/artiq-fast/pkgs/llvm-or1k.nix index 8340375..92f923e 100644 --- a/artiq-fast/pkgs/llvm-or1k.nix +++ b/artiq-fast/pkgs/llvm-or1k.nix @@ -26,9 +26,11 @@ let in stdenv.mkDerivation rec { name = "llvm-or1k"; + passthru.llvm-src = llvm-src; src = llvm-clang-src; + version = "6.0.0"; - buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind; + buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind; preBuild = '' NIX_BUILD_CORES=4