-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ninja
More file actions
176 lines (154 loc) · 8.73 KB
/
Copy pathbuild.ninja
File metadata and controls
176 lines (154 loc) · 8.73 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# This is a Ninja build file.
# See https://ninja-build.org/manual.html for syntax.
# Variables
# Build directory for Ninja's own files
builddir = build
# Installation directories
install_dir = install
prefix = /usr/local
atoll_llvm_dir = /usr/local/atoll-llvm
# Rules
# Rule for running CMake to configure a project
rule cmake
command = cmake -S $in -B $out -G Ninja $args > /dev/null 2>&1
description = Configuring $out with CMake
# Rule for running Ninja to build a configured project
rule ninja_build
command = ninja -C $in > /dev/null 2>&1
description = Building $in with Ninja
# Rule for running a shell command
rule command
command = $cmd
description = $desc
# Rule for installing artifacts to project install directory
rule install_artifacts
command = bash -c '$cmd'
description = $desc
# Build Targets
# 1. LLVM/Clang
# This target configures and builds LLVM and Clang from the source
# in external/iree/third_party/llvm-project. The binaries will be in external/iree/third_party/llvm-project/build/bin.
build external/iree/third_party/llvm-project/build: cmake external/iree/third_party/llvm-project/llvm
args = -DLLVM_ENABLE_PROJECTS="clang;lld;mlir" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_TARGETS_TO_BUILD="host;NVPTX"
build llvm: ninja_build external/iree/third_party/llvm-project/build
# 2. AToLL pass/JIT libraries (libAtollPasses.so and libAtollVcJit.so)
# This target builds the shared libraries from the passes/ directory. It depends
# on the LLVM target, as it uses the LLVM libraries.
# Configure the AtollPasses build.
build passes/build: cmake passes | llvm
args = -DLT_LLVM_INSTALL_DIR=external/iree/third_party/llvm-project/build
# Build the AtollPasses plugin and VC JIT shim.
# Outputs: passes/build/lib/libAtollPasses.so and passes/build/lib/libAtollVcJit.so.
build atoll_passes: ninja_build passes/build
# Pass test proxy targets.
# These delegate to the CMake-generated Ninja build under passes/build so they
# can be invoked from the repository root:
# ninja check-atoll-passes
# LIT_TEST=passes/test/AtollMem/Global/kernel-arg-load-store.ll ninja check-atoll-passes-debug-kernel
# LIT_TEST=passes/test/AtollMem/VC/global-arg-store-basic.ll ninja check-atoll-passes-debug-vc
build check-atoll-passes: command atoll_passes
cmd = ninja -C passes/build check-atoll-passes
desc = Running AtollPasses lit tests
build check-atoll-passes-debug-kernel: command atoll_passes
cmd = ninja -C passes/build check-atoll-passes-debug-kernel
desc = Running one AtollPasses lit test with kernel instrumentation debug output
build check-atoll-passes-debug-vc: command atoll_passes
cmd = ninja -C passes/build check-atoll-passes-debug-vc
desc = Running one AtollPasses lit test with VC debug output
# 3. AToLL Crates
# This target builds all AToLL crates in the workspace.
rule cargo
command = cargo build --release > /dev/null 2>&1
description = Building Rust crates
build atoll_crates: cargo
# 4. Install to Project Directory (Default)
# This target installs all artifacts to <project_dir>/install.
build install: install_artifacts llvm atoll_passes atoll_crates
cmd = mkdir -p ${install_dir}/bin && $
mkdir -p ${install_dir}/tools/gpu-atoll && $
mkdir -p ${install_dir}/lib/gpu-atoll && $
mkdir -p ${install_dir}/atoll-llvm/bin && $
mkdir -p ${install_dir}/atoll-llvm/lib && $
mkdir -p ${install_dir}/atoll-llvm/lib/clang/23/include && $
cp passes/build/lib/libAtollPasses.so ${install_dir}/lib/gpu-atoll/libAtollPasses.so && $
cp passes/build/lib/libAtollVcJit.so ${install_dir}/lib/gpu-atoll/libAtollVcJit.so && $
cp scripts/summarize-analytics ${install_dir}/tools/gpu-atoll/summarize-analytics && $
cp target/release/atoll-server ${install_dir}/bin/atoll-server && $
cp target/release/atoll-admin ${install_dir}/bin/atoll-admin && $
cp scripts/atoll-harden ${install_dir}/bin/atoll-harden && $
cp external/iree/third_party/llvm-project/build/bin/clang++ ${install_dir}/atoll-llvm/bin/clang++ && $
cp external/iree/third_party/llvm-project/build/bin/opt ${install_dir}/atoll-llvm/bin/opt && $
cp external/iree/third_party/llvm-project/build/bin/llc ${install_dir}/atoll-llvm/bin/llc && $
cp -P external/iree/third_party/llvm-project/build/lib/libLLVM.so* ${install_dir}/atoll-llvm/lib/ && $
cp -r external/iree/third_party/llvm-project/build/lib/clang/23/include/. ${install_dir}/atoll-llvm/lib/clang/23/include/ && $
echo "Artifacts installed to ${install_dir}/"
desc = Installing artifacts to ${install_dir}
# 5. Local Install
# This target installs to the user's home directory (~/.local).
# It checks that all artifacts exist in install/ first.
build local-install: install_artifacts
cmd = if [ ! -f "${install_dir}/tools/gpu-atoll/summarize-analytics" ] || $
[ ! -f "${install_dir}/lib/gpu-atoll/libAtollPasses.so" ] || $
[ ! -f "${install_dir}/lib/gpu-atoll/libAtollVcJit.so" ] || $
[ ! -f "${install_dir}/atoll-llvm/bin/clang++" ] || $
[ ! -f "${install_dir}/bin/atoll-server" ] || $
[ ! -f "${install_dir}/bin/atoll-admin" ] || $
[ ! -f "${install_dir}/bin/atoll-harden" ]; then $
echo "Error: Not all artifacts are present in ${install_dir}/"; $
echo "Please build the project first by running: ninja install"; $
exit 1; $
fi && $
mkdir -p ~/.local/bin && $
mkdir -p ~/.local/tools/gpu-atoll && $
mkdir -p ~/.local/lib/gpu-atoll && $
mkdir -p ~/.local/atoll-llvm/bin && $
mkdir -p ~/.local/atoll-llvm/lib && $
mkdir -p ~/.local/atoll-llvm/lib/clang/23/include && $
cp ${install_dir}/lib/gpu-atoll/libAtollPasses.so ~/.local/lib/gpu-atoll/libAtollPasses.so && $
cp ${install_dir}/lib/gpu-atoll/libAtollVcJit.so ~/.local/lib/gpu-atoll/libAtollVcJit.so && $
cp ${install_dir}/tools/gpu-atoll/summarize-analytics ~/.local/tools/gpu-atoll/summarize-analytics && $
cp ${install_dir}/bin/atoll-server ~/.local/bin/atoll-server && $
cp ${install_dir}/bin/atoll-admin ~/.local/bin/atoll-admin && $
cp ${install_dir}/bin/atoll-harden ~/.local/bin/atoll-harden && $
cp -r ${install_dir}/atoll-llvm/bin/. ~/.local/atoll-llvm/bin/ && $
cp -P ${install_dir}/atoll-llvm/lib/libLLVM.so* ~/.local/atoll-llvm/lib/ && $
cp -r ${install_dir}/atoll-llvm/lib/clang/23/include/. ~/.local/atoll-llvm/lib/clang/23/include/ && $
ln -sf ~/.local/atoll-llvm/bin/clang++ ~/.local/bin/atoll-clang++ && $
echo "Artifacts installed to ~/.local/"
desc = Installing artifacts from ${install_dir} to ~/.local
# 6. System Install
# This target installs all artifacts to the system (using $prefix).
# It checks that all artifacts exist in install/ first.
build system-install: install_artifacts
cmd = if [ ! -f "${install_dir}/tools/gpu-atoll/summarize-analytics" ] || $
[ ! -f "${install_dir}/lib/gpu-atoll/libAtollPasses.so" ] || $
[ ! -f "${install_dir}/lib/gpu-atoll/libAtollVcJit.so" ] || $
[ ! -f "${install_dir}/atoll-llvm/bin/clang++" ] || $
[ ! -f "${install_dir}/bin/atoll-server" ] || $
[ ! -f "${install_dir}/bin/atoll-admin" ] || $
[ ! -f "${install_dir}/bin/atoll-harden" ]; then $
echo "Error: Not all artifacts are present in ${install_dir}/"; $
echo "Please build the project first by running: ninja install"; $
exit 1; $
fi && $
sudo mkdir -p ${prefix}/bin && $
sudo mkdir -p ${prefix}/tools/gpu-atoll && $
sudo mkdir -p ${prefix}/lib/gpu-atoll && $
sudo mkdir -p ${atoll_llvm_dir}/bin && $
sudo mkdir -p ${atoll_llvm_dir}/lib && $
sudo mkdir -p ${atoll_llvm_dir}/lib/clang/23/include && $
sudo cp ${install_dir}/lib/gpu-atoll/libAtollPasses.so ${prefix}/lib/gpu-atoll/libAtollPasses.so && $
sudo cp ${install_dir}/lib/gpu-atoll/libAtollVcJit.so ${prefix}/lib/gpu-atoll/libAtollVcJit.so && $
sudo cp ${install_dir}/tools/gpu-atoll/summarize-analytics ${prefix}/tools/gpu-atoll/summarize-analytics && $
sudo cp ${install_dir}/bin/atoll-server ${prefix}/bin/atoll-server && $
sudo cp ${install_dir}/bin/atoll-admin ${prefix}/bin/atoll-admin && $
sudo cp ${install_dir}/bin/atoll-harden ${prefix}/bin/atoll-harden && $
sudo cp -r ${install_dir}/atoll-llvm/bin/. ${atoll_llvm_dir}/bin/ && $
sudo cp -P ${install_dir}/atoll-llvm/lib/libLLVM.so* ${atoll_llvm_dir}/lib/ && $
sudo cp -r ${install_dir}/atoll-llvm/lib/clang/23/include/. ${atoll_llvm_dir}/lib/clang/23/include/ && $
sudo ln -sf ${atoll_llvm_dir}/bin/clang++ ${prefix}/bin/atoll-clang++ && $
echo "Artifacts installed to ${prefix}/ and ${atoll_llvm_dir}/"
desc = Installing artifacts from ${install_dir} to ${prefix} and ${atoll_llvm_dir}
# Default target
# Builds all components and installs to project install/ directory.
default install