forked from runtimeverification/llvm-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
92 lines (78 loc) · 2.54 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
let
sources = import ./nix/sources.nix;
pinned = import sources."nixpkgs" { config = {}; overlays = []; };
in
{ pkgs ? pinned
# Override `src` when this project is imported as a Git submodule:
#
# > ttuegel.cleanGitSubtree {
# > name = "llvm-backend";
# > src = ./parent/repo;
# > subDir = "path/to/submodule";
# > };
#
# Use `cleanGitSubtree` whenever possible to preserve the same source code
# layout as the kframework/llvm-backend repository (to enable cache re-use).
#
, src ? null
# Build an optimized release package.
# Currently requires dependents to use LTO. Use sparingly.
, release ? false
}:
let
ttuegel =
let
src = builtins.fetchGit {
url = "https://github.com/ttuegel/nix-lib";
rev = "66bb0ab890ff4d828a2dcfc7d5968465d0c7084f";
ref = "main";
};
in import src { inherit pkgs; };
in
let _src = src; in
let src = ttuegel.orElse _src (ttuegel.cleanGitSubtree { name = "llvm-backend"; src = ./.; }); in
let
inherit (pkgs) callPackage nix-gitignore;
llvmPackages = pkgs.llvmPackages_10;
# The backend requires clang/lld/libstdc++ at runtime.
# The closest configuration in Nixpkgs is clang/lld without any C++ standard
# library. We override that configuration to inherit libstdc++ from stdenv.
clang =
let
override = attrs: {
extraBuildCommands = ''
${attrs.extraBuildCommands}
sed -i $out/nix-support/cc-cflags -e '/^-nostdlib/ d'
'';
};
in
llvmPackages.lldClangNoLibcxx.override override;
llvm-backend = callPackage ./nix/llvm-backend.nix {
inherit llvmPackages src;
inherit (ttuegel) cleanSourceWith;
inherit release;
host.clang = clang;
};
mavenix = import sources."mavenix" { inherit pkgs; };
llvm-backend-matching = import ./nix/llvm-backend-matching.nix {
inherit mavenix src;
inherit (ttuegel) cleanSourceWith;
};
llvm-kompile-testing =
let inherit (pkgs) runCommandNoCC jre;
java = "${jre}/bin/java";
inherit (llvm-backend-matching) jar;
in runCommandNoCC "llvm-kompile-testing" { } ''
mkdir -p "$out/bin"
cp ${llvm-backend.src}/bin/llvm-kompile-testing "$out/bin"
sed -i "$out/bin/llvm-kompile-testing" \
-e '/@PROJECT_SOURCE_DIR@/ c ${java} -jar ${jar} $definition qbaL $dt_dir 1'
chmod +x "$out/bin/llvm-kompile-testing"
patchShebangs "$out/bin/llvm-kompile-testing"
'';
self = {
inherit llvm-backend llvm-backend-matching llvm-kompile-testing;
inherit clang; # for compatibility
inherit mavenix; # for CI
};
in self