at 23.05-pre 54 lines 2.3 kB view raw
1{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }: 2 3let 4 version = "5.3.1"; 5 src = fetchFromGitHub { 6 owner = "RadeonOpenCompute"; 7 repo = "llvm-project"; 8 rev = "rocm-${version}"; 9 hash = "sha256-IKo7N8wWvh5PBrZ2mh1Vu5s3uUXhanqYtC4qLV/+JBs="; 10 }; 11in rec { 12 clang = wrapCCWith rec { 13 cc = llvm; 14 extraBuildCommands = '' 15 clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` 16 rsrc="$out/resource-root" 17 mkdir "$rsrc" 18 ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc" 19 ln -s "${cc}/lib/clang/$clang_version/lib" "$rsrc/lib" 20 echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags 21 echo "--gcc-toolchain=${stdenv.cc.cc}" >> $out/nix-support/cc-cflags 22 rm $out/nix-support/add-hardening.sh 23 touch $out/nix-support/add-hardening.sh 24 # GPU compilation uses builtin lld 25 substituteInPlace $out/bin/clang \ 26 --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' 27 substituteInPlace $out/bin/clang++ \ 28 --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' 29 ''; 30 }; 31 32 clangNoCompilerRt = wrapCCWith rec { 33 cc = llvm; 34 extraBuildCommands = '' 35 clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` 36 rsrc="$out/resource-root" 37 mkdir "$rsrc" 38 ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc" 39 echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags 40 echo "--gcc-toolchain=${stdenv.cc.cc}" >> $out/nix-support/cc-cflags 41 rm $out/nix-support/add-hardening.sh 42 touch $out/nix-support/add-hardening.sh 43 # GPU compilation uses builtin lld 44 substituteInPlace $out/bin/clang \ 45 --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' 46 substituteInPlace $out/bin/clang++ \ 47 --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' 48 ''; 49 }; 50 51 llvm = callPackage ./llvm.nix { 52 inherit src version; 53 }; 54}