1 import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
2 import("//llvm/lib/Target/targets_string.gni")
3 import("//llvm/triples.gni")
4 import("//llvm/utils/gn/build/buildflags.gni")
5 import("//llvm/utils/gn/build/libs/pthread/enable.gni")
6 import("//llvm/utils/gn/build/libs/xar/enable.gni")
7 import("//llvm/utils/gn/build/libs/xml/enable.gni")
8 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
9 import("//llvm/utils/gn/build/write_cmake_config.gni")
10 import("llvm_lit_site_cfg_files.gni")
12 template("write_lit_config") {
13 write_cmake_config(target_name) {
15 output = invoker.output
17 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
20 rebase_path(get_label_info("//llvm", "target_out_dir")),
21 "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
22 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
24 if (host_os == "win") {
25 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
26 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
28 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
30 values += invoker.extra_values
34 write_lit_config("lit_site_cfg") {
35 input = "//llvm/test/lit.site.cfg.py.in"
36 output = llvm_lit_site_cfg_file
38 "BUILD_SHARED_LIBS=0",
40 # Only used by the Go bindings tests, or if LLVM_USE_SANITIZER includes
41 # asan and the host OS is macOS. The GN build currently never uses
42 # LLVM_USE_SANITIZER. (See also CMAKE_CXX_COMPILER in clang/test/BUILD.gn.)
45 # Only used by the Go bindings tests, or if LLVM_USE_SANITIZER includes
46 # lsan and the host OS is macOS. The GN build currently never uses
47 # LLVM_USE_SANITIZER. (See also CMAKE_CXX_COMPILER in clang/test/BUILD.gn.)
50 # Only used by the Go bindings tests, and for detecting a 32-bit build
51 # and in a belt-and-suspenders check for detecting 32-bit host builds.
52 # (That check also checks LLVM_HOST_TRIPLE.)
56 "LLVM_HAVE_OPT_VIEWER_MODULES=0",
57 "LLVM_HOST_TRIPLE=$llvm_current_triple",
58 "LLVM_LIBRARY_DIR=" + rebase_path("$root_out_dir/lib"),
59 "LLVM_LINK_LLVM_DYLIB=0",
60 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
61 "LLVM_NATIVE_ARCH=$native_target",
62 "LLVM_USE_INTEL_JITEVENTS=0",
63 "LLVM_USE_SANITIZER=",
64 "PYTHON_EXECUTABLE=$python_path",
65 "TARGETS_TO_BUILD=$llvm_targets_to_build_string",
66 "TARGET_TRIPLE=$llvm_target_triple",
70 # No bindings are implemented in the GN build.
74 "LLVM_INCLUDE_GO_TESTS=0",
78 "OCAMLFIND=OCAMLFIND-NOTFOUND",
80 "LLVM_BUILD_EXAMPLES=0",
83 if (host_cpu == "x64") {
84 extra_values += [ "HOST_ARCH=x86_64" ]
85 } else if (host_cpu == "ppc64") {
86 extra_values += [ "HOST_ARCH=powerpc64le" ]
88 assert(false, "unimplemented host_cpu " + host_cpu)
91 if (host_os == "win") {
92 extra_values += [ "EXEEXT=.exe" ]
94 extra_values += [ "EXEEXT=" ]
97 if (host_os == "win") {
98 extra_values += [ "LLVM_ENABLE_PLUGINS=0" ]
100 extra_values += [ "LLVM_ENABLE_PLUGINS=1" ]
103 if (host_os == "mac") {
104 extra_values += [ "SHLIBEXT=.dylib" ]
105 } else if (host_os == "win") {
106 extra_values += [ "SHLIBEXT=.dll" ]
108 extra_values += [ "SHLIBEXT=.so" ]
111 if (host_os == "freebsd") {
112 extra_values += [ "HOST_OS=FreeBSD" ]
113 } else if (host_os == "mac") {
114 extra_values += [ "HOST_OS=Darwin" ]
115 } else if (host_os == "linux") {
116 extra_values += [ "HOST_OS=Linux" ]
117 } else if (host_os == "win") {
118 extra_values += [ "HOST_OS=Windows" ]
120 assert(false, "unsupported host_os " + host_os)
122 if (host_os == "linux") {
123 # lit.cfg.py's have_ld_plugin_support() checks for "gold" in --version,
124 # so just claim that ld is gold on Linux. The function also checks if
125 # LLVMgold.so exists, but since that target isn't hooked up yet in the GN
126 # build the LLVMgold.so tests currently don't run anywhere in the GN build.
127 extra_values += [ "GOLD_EXECUTABLE=ld" ]
129 extra_values += [ "GOLD_EXECUTABLE=" ]
131 if (host_os == "mac") {
132 extra_values += [ "LD64_EXECUTABLE=ld" ]
134 extra_values += [ "LD64_EXECUTABLE=" ]
137 if (llvm_enable_assertions) {
138 extra_values += [ "ENABLE_ASSERTIONS=1" ]
140 extra_values += [ "ENABLE_ASSERTIONS=0" ] # Must be 0.
143 if (llvm_enable_libxar) {
144 extra_values += [ "HAVE_LIBXAR=1" ]
146 extra_values += [ "HAVE_LIBXAR=0" ] # Must be 0.
149 if (llvm_enable_dia_sdk) {
150 extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]
152 extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0.
155 if (llvm_enable_libxml2) {
156 extra_values += [ "LLVM_LIBXML2_ENABLED=1" ]
158 extra_values += [ "LLVM_LIBXML2_ENABLED=0" ] # Must be 0.
161 if (llvm_enable_threads) {
162 extra_values += [ "LLVM_ENABLE_THREADS=1" ]
164 extra_values += [ "LLVM_ENABLE_THREADS=0" ] # Must be 0.
167 if (llvm_enable_zlib) {
168 extra_values += [ "HAVE_LIBZ=1" ]
170 extra_values += [ "HAVE_LIBZ=0" ] # Must be 0.
174 write_lit_config("lit_unit_site_cfg") {
175 input = "//llvm/test/Unit/lit.site.cfg.py.in"
176 output = llvm_lit_unit_site_cfg_file
177 extra_values = [ "LLVM_BUILD_MODE=." ]
180 # This target should contain all dependencies of check-llvm.
181 # //:default depends on it, so that ninja's default target builds all
182 # prerequisites for check-llvm but doesn't run check-llvm itself.
186 ":lit_unit_site_cfg",
188 # Because llvm/tools/llvm-config/BUILD.gn calls llvm-build to generate
189 # LibraryDependencies.inc, llvm-config expects these libraries to exist
190 # even though nothing but unittests depends on them. Add explicit
191 # dependencies to make sure the libaries exist on disk when llvm-config's
193 "//llvm/lib/LineEditor",
194 "//llvm/lib/Testing/Support",
195 "//llvm/tools/bugpoint",
196 "//llvm/tools/dsymutil",
199 "//llvm/tools/lli/ChildTarget:lli-child-target",
200 "//llvm/tools/llvm-ar:symlinks",
201 "//llvm/tools/llvm-as",
202 "//llvm/tools/llvm-bcanalyzer",
203 "//llvm/tools/llvm-c-test",
204 "//llvm/tools/llvm-cat",
205 "//llvm/tools/llvm-cfi-verify",
206 "//llvm/tools/llvm-cov",
207 "//llvm/tools/llvm-cvtres",
208 "//llvm/tools/llvm-cxxdump",
209 "//llvm/tools/llvm-cxxfilt",
210 "//llvm/tools/llvm-cxxmap",
211 "//llvm/tools/llvm-diff",
212 "//llvm/tools/llvm-dis",
213 "//llvm/tools/llvm-dwarfdump",
214 "//llvm/tools/llvm-dwp",
215 "//llvm/tools/llvm-elfabi",
216 "//llvm/tools/llvm-exegesis",
217 "//llvm/tools/llvm-extract",
218 "//llvm/tools/llvm-ifs",
219 "//llvm/tools/llvm-isel-fuzzer",
220 "//llvm/tools/llvm-jitlink",
221 "//llvm/tools/llvm-link",
222 "//llvm/tools/llvm-lipo",
223 "//llvm/tools/llvm-lto",
224 "//llvm/tools/llvm-lto2",
225 "//llvm/tools/llvm-mc",
226 "//llvm/tools/llvm-mca",
227 "//llvm/tools/llvm-modextract",
228 "//llvm/tools/llvm-mt",
229 "//llvm/tools/llvm-nm",
230 "//llvm/tools/llvm-objcopy:symlinks",
231 "//llvm/tools/llvm-objdump",
232 "//llvm/tools/llvm-opt-fuzzer",
233 "//llvm/tools/llvm-opt-report",
234 "//llvm/tools/llvm-pdbutil",
235 "//llvm/tools/llvm-profdata",
236 "//llvm/tools/llvm-rc",
237 "//llvm/tools/llvm-readobj:symlinks",
238 "//llvm/tools/llvm-reduce",
239 "//llvm/tools/llvm-rtdyld",
240 "//llvm/tools/llvm-size",
241 "//llvm/tools/llvm-split",
242 "//llvm/tools/llvm-strings",
243 "//llvm/tools/llvm-symbolizer:symlinks",
244 "//llvm/tools/llvm-undname",
245 "//llvm/tools/llvm-xray",
247 "//llvm/tools/obj2yaml",
249 "//llvm/tools/sancov",
250 "//llvm/tools/sanstats",
251 "//llvm/tools/verify-uselistorder",
252 "//llvm/tools/yaml2obj",
254 "//llvm/utils/FileCheck",
255 "//llvm/utils/TableGen:llvm-tblgen",
256 "//llvm/utils/count",
257 "//llvm/utils/llvm-lit",
260 # llvm-config wants libgtest_main.a to exist at runtime when run as in
261 # its tests, but nothing in the tree depends on them.
262 "//llvm/utils/unittest/UnitTestMain:gtest_main",
263 "//llvm/utils/yaml-bench",
265 if (host_os != "win") {
266 # loadable_modules don't work on Windows.
267 # FIXME: In the CMake build, ENABLE_SHARED makes them work somehow
268 # (but they're off by default there too).
270 "//llvm/lib/Transforms/Hello",
271 "//llvm/tools/bugpoint-passes",
275 # FIXME: llvm_build_examples
279 action("check-llvm") {
280 script = "$root_out_dir/bin/llvm-lit"
281 if (host_os == "win") {
287 "llvm_site_config=" + rebase_path(llvm_lit_site_cfg_file, root_out_dir),
289 "llvm_unit_site_config=" +
290 rebase_path(llvm_lit_unit_site_cfg_file, root_out_dir),
291 rebase_path(".", root_out_dir),
294 "$target_gen_dir/run-lit", # Non-existing, so that ninja runs it each time.
297 # Since check-llvm is always dirty, //:default doesn't depend on it so that
298 # it's not part of the default ninja target. Hence, check-llvm shouldn't
299 # have any deps except :test. so that the default target is sure to build