Fil-C on Nix

Filnix wiki

mbrock/filnix

shells/filc-llvm.nix

Shell for hacking on the Fil-C LLVM/Clang (FilPizlonator, clang CodeGen) outside Nix with incremental ninja builds. See docs/llvm-dev.md.

λpkgs, sources?
pkgs
sourcesdefault import../lib/sources.nix inherit pkgs;
let
9lib=
import../lib inherit pkgs;
used by cmakeArgs
10filc0=
import../compiler/filc0.nix inherit pkgs sources;
used by cmakeArgs
11filcc-dev=
12inherit
pkgs sources
13devLlvm=
true
16cmakeArgs=
pkgs.lib.escapeShellArgs
lib.cmakeFlags
filc0.cmakeOptions
//

Faster relinks than gold for the edit/build loop.

21LLVM_USE_LINKER=
"lld"
22LLVM_USE_SPLIT_DWARF=
true
23CMAKE_C_COMPILER_LAUNCHER=
"ccache"
24CMAKE_CXX_COMPILER_LAUNCHER=
"ccache"
uses filc0 lib used by configure
29configure=
pkgs.writeShellScriptBin"filc-llvm-configure"
set -eu
exec cmake -S "$FILC_SRC/llvm" -B "$FILC_DEV_LLVM" -G Ninja ${cmakeArgs} "$@"
uses cmakeArgs
34build=
pkgs.writeShellScriptBin"filc-llvm-build"
set -eu
[ -f "$FILC_DEV_LLVM/build.ninja" ] || filc-llvm-configure
if [ $# -eq 0 ]; then set -- clang; fi
exec ninja -C "$FILC_DEV_LLVM" "$@"
41worktree=
pkgs.writeShellScriptBin"filc-llvm-worktree"
# usage: filc-llvm-worktree <existing fil-c clone> <new worktree dir> <branch>
# Creates a sparse worktree at the revision filnix pins (${sources.coreRev}).
set -eu
git -C "$1" fetch ${pkgs.lib.escapeShellArgsources.filc0-src.url} ${sources.coreRev}
git -C "$1" worktree add --no-checkout -b "$3" "$2" ${sources.coreRev}
git -C "$2" sparse-checkout set --no-cone \
/LLVM-LICENSE.txt /llvm/ /clang/ /cmake/ /third-party/ \
/libcxx/ /libcxxabi/ /libc/ /runtimes/ /filc/ /libpas/
git -C "$2" checkout "$3"
in
pkgs.mkShell
54name=
"filc-llvm"
55packages=
pkgs.cmake pkgs.ninja pkgs.python3 pkgs.ccache pkgs.lld pkgs.git configure build worktree filcc-dev
68shellHook=
export FILC_SRC="''${FILC_SRC:-$HOME/fil-c-dev}"
export FILC_DEV_LLVM="''${FILC_DEV_LLVM:-$FILC_SRC/build-filnix}"
echo "Fil-C LLVM dev shell"
echo " FILC_SRC=$FILC_SRC"
echo " FILC_DEV_LLVM=$FILC_DEV_LLVM"
echo " filc-llvm-build [targets] (default: clang)"
echo " clang / clang++ run the dev clang with the pinned Fil-C runtime"