forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
403 lines (374 loc) · 9.56 KB
/
CMakeLists.txt
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# Copyright 2019 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Special case package namespace for tools/ -> "" (empty string)
# For example, tools/iree-compile -> iree-compile (no namespace)
set(IREE_PACKAGE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
# Tools IREE provides for compiling, executing, and benchmarking programs, as
# well as other utilities.
#
# Only binary targets and their associated main files should go in this
# directory. Library targets and header files should be placed in the
# appropriate subtree, e.g. `compiler/src/iree/compiler/Tools/`.
#
# Compiler tools are designed to run on host platforms (Linux, macOS, Windows),
# so they are only built when IREE_BUILD_COMPILER is set and are tagged
# "hostonly". When cross-compiling (or generally wanting to use already-built
# compiler tools), set the IREE_HOST_BIN_DIR CMake option.
#
# This file does not use bazel_to_cmake because of special logic throughout.
# Write some important CMake options to a file for convenient use from scripts.
configure_file(build_config_template.txt.in build_config.txt)
# For sub-directories, we want targets fully qualified relative to the
# root. But after, we want those in *this* directory to be unqualified
# (i.e. 'iree-compile').
set(IREE_PACKAGE_ROOT_PREFIX "iree/tools")
iree_add_all_subdirs()
set(IREE_PACKAGE_ROOT_PREFIX "")
# TODO(scotttodd): Should this be checking IREE_BUILD_COMPILER?
# Maybe we should disallow setting both at the same time, since it's
# ambigious which should be used
if(IREE_HOST_BIN_DIR AND NOT IREE_BUILD_COMPILER)
iree_import_binary(NAME iree-tblgen)
iree_import_binary(NAME iree-compile)
iree_import_binary(NAME iree-opt)
iree_import_binary(NAME iree-run-mlir)
iree_import_binary(NAME clang)
iree_import_binary(NAME llvm-link)
endif()
# TODO(#6353): Tools has thread dependencies in gtest, benchmark, yaml, etc.
# This should be split between runtime/compiler with optional threading support.
if(NOT IREE_ENABLE_THREADING)
return()
endif()
iree_cc_binary(
NAME
iree-benchmark-module
SRCS
"iree-benchmark-module-main.cc"
DEPS
benchmark
iree::base
iree::base::internal::flags
iree::hal
iree::modules::hal::types
iree::tooling::context_util
iree::tooling::device_util
iree::tooling::vm_util
iree::vm
)
iree_cc_binary(
NAME
iree-benchmark-trace
SRCS
"iree-benchmark-trace-main.c"
DEPS
iree::base
iree::base::internal::atomic_slist
iree::base::internal::file_io
iree::base::internal::flags
iree::base::internal::path
iree::hal
iree::modules::hal
iree::testing::benchmark
iree::tooling::device_util
iree::tooling::trace_replay
iree::tooling::vm_util
iree::tooling::yaml_util
iree::vm
yaml
)
iree_cc_binary(
NAME
iree-check-module
SRCS
"iree-check-module-main.cc"
DEPS
iree::base
iree::base::internal::file_io
iree::base::internal::flags
iree::hal
iree::modules::check
iree::testing::gtest
iree::tooling::context_util
iree::tooling::device_util
iree::tooling::vm_util
iree::vm
iree::vm::bytecode::module
TESTONLY
)
iree_cc_binary(
NAME
iree-convert-parameters
SRCS
"iree-convert-parameters-main.c"
DEPS
iree::base
iree::base::internal::file_io
iree::base::internal::flags
iree::hal
iree::io::formats::irpa
iree::io::parameter_index
iree::io::scope_map
iree::tooling::parameter_util
)
iree_cc_binary(
NAME
iree-cpuinfo
SRCS
"iree-cpuinfo.c"
DEPS
iree::base
iree::base::internal::cpu
iree::schemas::cpu_data
)
iree_cc_binary(
NAME
iree-create-parameters
SRCS
"iree-create-parameters-main.c"
DEPS
iree::base
iree::base::internal::file_io
iree::base::internal::flags
iree::hal
iree::io::formats::irpa
iree::io::parameter_index
iree::io::scope_map
iree::io::stream
)
iree_cc_binary(
NAME
iree-dump-instruments
SRCS
"iree-dump-instruments-main.c"
DEPS
flatcc::runtime
iree::base
iree::base::internal::file_io
iree::base::internal::flatcc::parsing
iree::schemas::instruments
iree::schemas::instruments::dispatch_def_c_fbs
)
iree_cc_binary(
NAME
iree-dump-module
SRCS
"iree-dump-module-main.c"
DEPS
flatcc::runtime
iree::base
iree::base::internal::file_io
iree::base::internal::flags
iree::base::internal::flatcc::debugging
iree::base::internal::flatcc::parsing
iree::schemas::bytecode_module_def_c_fbs
iree::vm::bytecode::module
)
iree_cc_binary(
NAME
iree-dump-parameters
SRCS
"iree-dump-parameters-main.c"
DEPS
iree::base
iree::base::internal::file_io
iree::base::internal::flags
iree::io::parameter_index
iree::io::scope_map
iree::tooling::parameter_util
)
# Only enable fatelf tool when we're compiling it in.
# Currently it requires that the host and target both support embedded ELFs as
# the ELF implementation is only compiled when the target supports it.
if(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF OR
IREE_HAL_EXECUTABLE_PLUGIN_EMBEDDED_ELF)
iree_cc_binary(
NAME
iree-fatelf
SRCS
"iree-fatelf.c"
DEPS
iree::base
iree::base::internal::file_io
iree::base::internal::path
iree::hal::local::elf::elf_module
)
endif() # IREE_HAL_EXECUTABLE_*_EMBEDDED_ELF
iree_cc_binary(
NAME
iree-run-module
SRCS
"iree-run-module-main.c"
DEPS
iree::base
iree::base::internal::flags
iree::hal
iree::tooling::context_util
iree::tooling::run_module
iree::vm
)
iree_cc_binary(
NAME
iree-run-trace
SRCS
"iree-run-trace-main.c"
DEPS
iree::base
iree::base::internal::flags
iree::base::internal::path
iree::hal
iree::modules::hal
iree::tooling::device_util
iree::tooling::trace_replay
iree::tooling::vm_util
iree::tooling::yaml_util
iree::vm
yaml
)
iree_cc_binary(
NAME
iree-e2e-matmul-test
SRCS
"iree-e2e-matmul-test.c"
DEPS
iree::base
iree::base::internal::cpu
iree::base::internal::flags
iree::base::internal::path
iree::hal
iree::modules::hal
iree::tooling::device_util
iree::tooling::trace_replay
iree::tooling::vm_util
iree::tooling::yaml_util
iree::vm
yaml
)
if(IREE_BUILD_COMPILER)
# If a target backend that requires LLD to link codegen executables is
# enabled, install the target.
if(IREE_LLD_TARGET)
install(
TARGETS lld
COMPONENT Compiler
RUNTIME DESTINATION bin
)
endif()
if(IREE_LLVM_LINK_TARGET)
install(
TARGETS llvm-link
COMPONENT Compiler
RUNTIME DESTINATION bin
)
endif()
if(IREE_CLANG_TARGET)
install(
TARGETS clang
COMPONENT Compiler
RUNTIME DESTINATION bin
)
endif()
# Tablegen binaries are special snowflakes among special snowflakes.
# They must be statically linked against internal LLVM libraries, and they
# therefore must not depend on anything outside of the upstream tablegen
# libraries. These targets are specially set up to link in the correct
# way. This is a necessary diversion from how Bazel deals with it (which
# must deep-link to everything to satisfy its checks).
iree_cc_binary(
NAME
iree-tblgen
SRCS
"iree-tblgen.cpp"
"${IREE_SOURCE_DIR}/compiler/src/iree/compiler/Dialect/VM/Tools/VMOpEncoderGen.cpp"
"${IREE_SOURCE_DIR}/compiler/src/iree/compiler/Dialect/VM/Tools/VMOpTableGen.cpp"
DEPS
LLVMSupport
MLIRTblgenLib
HOSTONLY
DISABLE_LLVM_LINK_LLVM_DYLIB
)
iree_cc_binary(
NAME
iree-compile
SRCS
"iree-compile-main.cc"
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
DATA
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
)
iree_cc_binary(
NAME
iree-reduce
SRCS
"iree-reduce.cc"
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
DATA
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
)
iree_cc_binary(
NAME
iree-opt
SRCS
"iree-opt-main.cc"
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
DATA
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
)
iree_cc_binary(
NAME
iree-mlir-lsp-server
SRCS
"iree-mlir-lsp-server.cc"
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
SETUP_INSTALL_RPATH
)
iree_cc_binary(
NAME
iree-run-mlir
SRCS
"iree-run-mlir-main.cc"
DEPS
iree::base
iree::base::internal::flags
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
iree::hal
iree::tooling::context_util
iree::tooling::device_util
iree::tooling::run_module
iree::vm
DATA
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
)
# Ensure FileCheck and associated binaries get built. Tests don't have
# dependencies in CMake because they aren't targets. So until we fix that, we
# just force this to get built.
# Limiting this to when IREE_BUILD_TESTS is set prevents the installation
# below, which we use for cross-platform testing.
set_target_properties(FileCheck PROPERTIES EXCLUDE_FROM_ALL OFF)
set_target_properties(not PROPERTIES EXCLUDE_FROM_ALL OFF)
elseif(NOT IREE_HOST_BIN_DIR)
message(STATUS
"*Not* building or importing IREE's compiler tools.\n "
"Set IREE_BUILD_COMPILER to build them or IREE_HOST_BIN_DIR to "
"import them.")
endif()