1 import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
2 import("//llvm/triples.gni")
3 import("//llvm/utils/gn/build/libs/xml/enable.gni")
4 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
5 import("//llvm/utils/gn/build/libs/zstd/enable.gni")
6 import("//llvm/utils/gn/build/write_cmake_config.gni")
7 import("//llvm/utils/llvm-lit/lit_path_function.gni")
8 import("lld_lit_site_cfg_files.gni")
10 # The bits common to writing lit.site.cfg.py.in and Unit/lit.site.cfg.py.in.
11 template("write_lit_cfg") {
12 write_cmake_config(target_name) {
14 output = invoker.output
15 dir = get_path_info(output, "dir")
17 "LIT_SITE_CFG_IN_HEADER=" +
18 "## Autogenerated from $input, do not edit\n\n" + lit_path_function,
20 rebase_path(get_label_info("//lld", "target_out_dir"), dir),
21 "LLD_SOURCE_DIR=" + rebase_path("//lld", dir),
23 if (host_os == "win") {
24 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
25 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
27 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
29 values += invoker.extra_values
33 write_lit_cfg("lit_site_cfg") {
34 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
35 input = "//lld/test/lit.site.cfg.py.in"
36 output = lld_lit_site_cfg_file
37 dir = get_path_info(output, "dir")
40 "CURRENT_LIBS_DIR=", # FIXME: for shared builds only (?)
41 "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
42 "ENABLE_BACKTRACES=1",
44 rebase_path(get_label_info("//llvm", "target_out_dir"), dir),
45 "LLVM_HOST_TRIPLE=$llvm_current_triple",
46 "LLVM_LIBS_DIR=", # needed only for shared builds
47 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
48 "LLVM_SOURCE_DIR=" + rebase_path("//llvm", dir),
49 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
50 "Python3_EXECUTABLE=$python_path",
51 "LLVM_TARGET_TRIPLE=$llvm_target_triple",
53 "LLD_DEFAULT_LD_LLD_IS_MINGW=0",
54 "LLVM_BUILD_EXAMPLES=0",
55 "LLVM_BYE_LINK_INTO_TOOLS=0",
58 if (host_os == "win") {
60 "LLVM_LIT_ERRC_MESSAGES=no such file or directory;is a directory;" +
61 "invalid argument;permission denied",
62 "LLVM_ENABLE_PLUGINS=0",
66 "LLVM_LIT_ERRC_MESSAGES=",
67 "LLVM_ENABLE_PLUGINS=1",
71 if (host_os == "mac") {
72 extra_values += [ "SHLIBEXT=.dylib" ]
73 } else if (host_os == "win") {
74 extra_values += [ "SHLIBEXT=.dll" ]
76 extra_values += [ "SHLIBEXT=.so" ]
79 if (llvm_enable_dia_sdk) {
80 extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]
82 extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0.
85 if (llvm_enable_libxml2) {
86 extra_values += [ "LLVM_ENABLE_LIBXML2=1" ]
88 extra_values += [ "LLVM_ENABLE_LIBXML2=0" ] # Must be 0.
91 if (llvm_enable_zlib) {
92 extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
94 extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.
97 if (llvm_enable_zstd) {
98 extra_values += [ "LLVM_ENABLE_ZSTD=1" ]
100 extra_values += [ "LLVM_ENABLE_ZSTD=0" ] # Must be 0.
103 if (current_cpu == "x64" || current_cpu == "arm64" ||
104 current_cpu == "ppc64") {
105 extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ]
107 extra_values += [ "CMAKE_SIZEOF_VOID_P=4" ]
111 write_lit_cfg("lit_unit_site_cfg") {
112 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
113 input = "//lld/test/Unit/lit.site.cfg.py.in"
114 output = lld_lit_unit_site_cfg_file
115 extra_values = [ "LLVM_BUILD_MODE=." ]
118 # This target should contain all dependencies of check-lld.
119 # //:default depends on it, so that ninja's default target builds all
120 # prerequisites for check-lld but doesn't run check-lld itself.
124 ":lit_unit_site_cfg",
125 "//lld/tools/lld:symlinks",
127 "//llvm/tools/dsymutil",
129 "//llvm/tools/llvm-ar:symlinks",
130 "//llvm/tools/llvm-as",
131 "//llvm/tools/llvm-bcanalyzer",
132 "//llvm/tools/llvm-cgdata",
133 "//llvm/tools/llvm-cvtres",
134 "//llvm/tools/llvm-dis",
135 "//llvm/tools/llvm-dwarfdump",
136 "//llvm/tools/llvm-lipo:symlinks",
137 "//llvm/tools/llvm-mc",
138 "//llvm/tools/llvm-nm:symlinks",
139 "//llvm/tools/llvm-objcopy:symlinks",
140 "//llvm/tools/llvm-objdump:symlinks",
141 "//llvm/tools/llvm-pdbutil",
142 "//llvm/tools/llvm-profdata",
143 "//llvm/tools/llvm-readobj:symlinks",
144 "//llvm/tools/llvm-strings:symlinks",
145 "//llvm/tools/llvm-symbolizer:symlinks",
146 "//llvm/tools/obj2yaml",
148 "//llvm/tools/yaml2obj",
149 "//llvm/utils/FileCheck",
150 "//llvm/utils/count",
151 "//llvm/utils/llvm-lit",
153 "//llvm/utils/split-file",
158 # This is the action that runs all of lld's tests, check-lld.
159 action("check-lld") {
160 script = "$root_out_dir/bin/llvm-lit"
161 if (host_os == "win") {
166 rebase_path(".", root_out_dir),
168 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
171 # Since check-lld is always dirty, //:default doesn't depend on it so that
172 # it's not part of the default ninja target. Hence, check-lld shouldn't
173 # have any deps except :test, so that the default target is sure to build