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/write_cmake_config.gni")
6 import("//llvm/utils/llvm-lit/lit_path_function.gni")
7 import("lld_lit_site_cfg_files.gni")
9 # The bits common to writing lit.site.cfg.py.in and Unit/lit.site.cfg.py.in.
10 template("write_lit_cfg") {
11 write_cmake_config(target_name) {
13 output = invoker.output
14 dir = get_path_info(output, "dir")
16 "LIT_SITE_CFG_IN_HEADER=" +
17 "## Autogenerated from $input, do not edit\n\n" + lit_path_function,
19 rebase_path(get_label_info("//lld", "target_out_dir"), dir),
20 "LLD_SOURCE_DIR=" + rebase_path("//lld", dir),
22 if (host_os == "win") {
23 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
24 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
26 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
28 values += invoker.extra_values
32 write_lit_cfg("lit_site_cfg") {
33 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
34 input = "//lld/test/lit.site.cfg.py.in"
35 output = lld_lit_site_cfg_file
36 dir = get_path_info(output, "dir")
39 "CURRENT_LIBS_DIR=", # FIXME: for shared builds only (?)
40 "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
41 "ENABLE_BACKTRACES=1",
43 rebase_path(get_label_info("//llvm", "target_out_dir"), dir),
44 "LLVM_HOST_TRIPLE=$llvm_current_triple",
45 "LLVM_LIBS_DIR=", # needed only for shared builds
46 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
47 "LLVM_SOURCE_DIR=" + rebase_path("//llvm", dir),
48 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
49 "Python3_EXECUTABLE=$python_path",
50 "LLVM_TARGET_TRIPLE=$llvm_target_triple",
52 "LLD_DEFAULT_LD_LLD_IS_MINGW=0",
53 "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 (current_cpu == "x64" || current_cpu == "arm64" ||
98 current_cpu == "ppc64") {
99 extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ]
101 extra_values += [ "CMAKE_SIZEOF_VOID_P=4" ]
105 write_lit_cfg("lit_unit_site_cfg") {
106 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
107 input = "//lld/test/Unit/lit.site.cfg.py.in"
108 output = lld_lit_unit_site_cfg_file
109 extra_values = [ "LLVM_BUILD_MODE=." ]
112 # This target should contain all dependencies of check-lld.
113 # //:default depends on it, so that ninja's default target builds all
114 # prerequisites for check-lld but doesn't run check-lld itself.
118 ":lit_unit_site_cfg",
119 "//lld/tools/lld:symlinks",
121 "//llvm/tools/dsymutil",
123 "//llvm/tools/llvm-ar:symlinks",
124 "//llvm/tools/llvm-as",
125 "//llvm/tools/llvm-bcanalyzer",
126 "//llvm/tools/llvm-cvtres",
127 "//llvm/tools/llvm-dis",
128 "//llvm/tools/llvm-dwarfdump",
129 "//llvm/tools/llvm-lipo:symlinks",
130 "//llvm/tools/llvm-mc",
131 "//llvm/tools/llvm-nm:symlinks",
132 "//llvm/tools/llvm-objcopy:symlinks",
133 "//llvm/tools/llvm-objdump:symlinks",
134 "//llvm/tools/llvm-pdbutil",
135 "//llvm/tools/llvm-profdata",
136 "//llvm/tools/llvm-readobj:symlinks",
137 "//llvm/tools/llvm-symbolizer:symlinks",
138 "//llvm/tools/obj2yaml",
140 "//llvm/tools/yaml2obj",
141 "//llvm/utils/FileCheck",
142 "//llvm/utils/count",
143 "//llvm/utils/llvm-lit",
145 "//llvm/utils/split-file",
150 # This is the action that runs all of lld's tests, check-lld.
151 action("check-lld") {
152 script = "$root_out_dir/bin/llvm-lit"
153 if (host_os == "win") {
158 rebase_path(".", root_out_dir),
160 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
163 # Since check-lld is always dirty, //:default doesn't depend on it so that
164 # it's not part of the default ninja target. Hence, check-lld shouldn't
165 # have any deps except :test, so that the default target is sure to build