[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / utils / gn / secondary / clang / test / BUILD.gn
blob7c0d33002dacaa5a0f89253e5151100b0dbbfe40
1 import("//clang/lib/ARCMigrate/enable.gni")
2 import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
3 import("//llvm/lib/Target/targets.gni")
4 import("//llvm/triples.gni")
5 import("//llvm/utils/gn/build/libs/pthread/enable.gni")
6 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
7 import("//llvm/utils/gn/build/write_cmake_config.gni")
8 import("clang_lit_site_cfg_files.gni")
10 template("write_lit_config") {
11   write_cmake_config(target_name) {
12     input = invoker.input
13     output = invoker.output
14     values = [
15       "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
16       "CLANG_BINARY_DIR=" +
17           rebase_path(get_label_info("//clang", "target_out_dir")),
18       "CLANG_SOURCE_DIR=" + rebase_path("//clang"),
19       "ENABLE_SHARED=0",
20       "LLVM_BINARY_DIR=" +
21           rebase_path(get_label_info("//llvm", "target_out_dir")),
22       "LLVM_LIBS_DIR=",  # needed only for shared builds
23       "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
24       "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
25       "TARGET_TRIPLE=$llvm_target_triple",
26     ]
27     if (host_os == "win") {
28       # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
29       values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
30     } else {
31       values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
32     }
33     values += invoker.extra_values
34   }
37 write_lit_config("lit_site_cfg") {
38   # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
39   input = "//clang/test/lit.site.cfg.py.in"
40   output = clang_lit_site_cfg_file
42   extra_values = [
43     "LLVM_WITH_Z3=",  # Must be empty, not 0.
44     "CLANG_BUILD_EXAMPLES=0",
45     "CLANG_DEFAULT_CXX_STDLIB=",  # Empty string means "default value" here.
46     "CLANG_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
48     # This is only used if LLVM_USE_SANITIZER includes lsan and the host
49     # OS is macOS. Since the GN build currently never uses LLVM_USE_SANITIZER,
50     # this is never read.  If it's ever needed,
51     # utils/gn/build/toolchain/BUILD.gn should get the compiler from a variable
52     # that's also read here -- but that should happen after multi-toolchain
53     # builds exist, to make sure it's a toolchain var.
54     "CMAKE_CXX_COMPILER=c++",
55     "ENABLE_BACKTRACES=1",
56     "ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=0",
57     "LLVM_HOST_TRIPLE=$llvm_current_triple",
58     "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
59     "LLVM_USE_SANITIZER=",
60     "PYTHON_EXECUTABLE=$python_path",
61     "USE_Z3_SOLVER=",
62   ]
64   if (clang_enable_arcmt) {
65     extra_values += [ "CLANG_ENABLE_ARCMT=1" ]
66   } else {
67     extra_values += [ "CLANG_ENABLE_ARCMT=0" ]
68   }
70   if (clang_enable_static_analyzer) {
71     extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
72   } else {
73     extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=0" ]
74   }
76   if (llvm_enable_zlib) {
77     extra_values += [ "HAVE_LIBZ=1" ]
78   } else {
79     extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
80   }
82   if (host_cpu == "x64") {
83     extra_values += [ "HOST_ARCH=x86_64" ]
84   } else if (host_cpu == "ppc64") {
85     extra_values += [ "HOST_ARCH=powerpc64le" ]
86   } else {
87     assert(false, "unimplemented host_cpu " + host_cpu)
88   }
90   if (host_os == "mac") {
91     extra_values += [ "LLVM_PLUGIN_EXT=.dylib" ]
92   } else if (host_os == "win") {
93     extra_values += [ "LLVM_PLUGIN_EXT=.dll" ]
94   } else {
95     extra_values += [ "LLVM_PLUGIN_EXT=.so" ]
96   }
98   if (host_os == "win") {
99     extra_values += [ "LLVM_ENABLE_PLUGINS=0" ]
100   } else {
101     # FIXME: Analysis/plugins need global -fPIC
102     extra_values += [ "LLVM_ENABLE_PLUGINS=0" ]
103   }
105   if (llvm_enable_threads) {
106     extra_values += [ "LLVM_ENABLE_THREADS=1" ]
107   } else {
108     extra_values += [ "LLVM_ENABLE_THREADS=0" ]  # Must be 0.
109   }
112 write_lit_config("lit_unit_site_cfg") {
113   # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
114   input = "//clang/test/Unit/lit.site.cfg.py.in"
115   output = clang_lit_unit_site_cfg_file
116   extra_values = [ "LLVM_BUILD_MODE=." ]
119 # This target should contain all dependencies of check-clang.
120 # //:default depends on it, so that ninja's default target builds all
121 # prerequisites for check-clang but doesn't run check-clang itself.
122 group("test") {
123   deps = [
124     ":lit_site_cfg",
125     ":lit_unit_site_cfg",
126     "//clang/lib/Headers",
127     "//clang/tools/c-index-test",
128     "//clang/tools/clang-diff",
129     "//clang/tools/clang-format",
130     "//clang/tools/clang-import-test",
131     "//clang/tools/clang-offload-bundler",
132     "//clang/tools/clang-refactor",
133     "//clang/tools/clang-rename",
134     "//clang/tools/clang-scan-deps",
135     "//clang/tools/diagtool",
136     "//clang/tools/driver:symlinks",
137     "//clang/unittests",
138     "//clang/utils/TableGen:clang-tblgen",
139     "//clang/utils/hmaptool",
140     "//llvm/tools/llc",
141     "//llvm/tools/llvm-as",
142     "//llvm/tools/llvm-bcanalyzer",
143     "//llvm/tools/llvm-cat",
144     "//llvm/tools/llvm-config",
145     "//llvm/tools/llvm-dis",
146     "//llvm/tools/llvm-dwarfdump",
147     "//llvm/tools/llvm-ifs",
148     "//llvm/tools/llvm-lto",
149     "//llvm/tools/llvm-lto2",
150     "//llvm/tools/llvm-modextract",
151     "//llvm/tools/llvm-nm:symlinks",
152     "//llvm/tools/llvm-objdump:symlinks",
153     "//llvm/tools/llvm-profdata",
154     "//llvm/tools/llvm-readobj:symlinks",
155     "//llvm/tools/llvm-symbolizer:symlinks",
156     "//llvm/tools/opt",
157     "//llvm/utils/FileCheck",
158     "//llvm/utils/count",
159     "//llvm/utils/llvm-lit",
160     "//llvm/utils/not",
161   ]
162   if (clang_enable_arcmt) {
163     deps += [
164       "//clang/tools/arcmt-test",
165       "//clang/tools/c-arcmt-test",
166     ]
167   }
168   if (clang_enable_static_analyzer) {
169     deps += [
170       "//clang/tools/clang-check",
171       "//clang/tools/clang-extdef-mapping",
172     ]
173   }
175   # FIXME: clang_build_examples
176   testonly = true
179 action("check-clang") {
180   script = "$root_out_dir/bin/llvm-lit"
181   if (host_os == "win") {
182     script += ".py"
183   }
184   args = [
185     "-sv",
186     "--param",
187     "clang_site_config=" + rebase_path(clang_lit_site_cfg_file, root_out_dir),
188     "--param",
189     "clang_unit_site_config=" +
190         rebase_path(clang_lit_unit_site_cfg_file, root_out_dir),
191     rebase_path(".", root_out_dir),
192   ]
193   outputs = [
194     "$target_gen_dir/run-lit",  # Non-existing, so that ninja runs it each time.
195   ]
197   # Since check-clang is always dirty, //:default doesn't depend on it so that
198   # it's not part of the default ninja target.  Hence, check-clang shouldn't
199   # have any deps except :test. so that the default target is sure to build
200   # all the deps.
201   deps = [
202     ":test",
203   ]
204   testonly = true
206   pool = "//:console"