| 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") |
| 9 |
|
| 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) { |
| 13 |
input = invoker.input |
| 14 |
output = invoker.output |
| 15 |
dir = get_path_info(output, "dir") |
| 16 |
values = [ |
| 17 |
"LIT_SITE_CFG_IN_HEADER=" + |
| 18 |
"## Autogenerated from $input, do not edit\n\n" + lit_path_function, |
| 19 |
"LLD_BINARY_DIR=" + |
| 20 |
rebase_path(get_label_info("//lld", "target_out_dir"), dir), |
| 21 |
"LLD_SOURCE_DIR=" + rebase_path("//lld", dir), |
| 22 |
] |
| 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) ] |
| 26 |
} else { |
| 27 |
values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ] |
| 28 |
} |
| 29 |
values += invoker.extra_values |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 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") |
| 38 |
|
| 39 |
extra_values = [ |
| 40 |
"CURRENT_LIBS_DIR=", # FIXME: for shared builds only (?) |
| 41 |
"CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir), |
| 42 |
"ENABLE_BACKTRACES=1", |
| 43 |
"LLVM_BINARY_DIR=" + |
| 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", |
| 52 |
|
| 53 |
"LLD_DEFAULT_LD_LLD_IS_MINGW=0", |
| 54 |
"LLVM_BUILD_EXAMPLES=0", |
| 55 |
"LLVM_BYE_LINK_INTO_TOOLS=0", |
| 56 |
] |
| 57 |
|
| 58 |
if (host_os == "win") { |
| 59 |
extra_values += [ |
| 60 |
"LLVM_LIT_ERRC_MESSAGES=no such file or directory;is a directory;" + |
| 61 |
"invalid argument;permission denied", |
| 62 |
"LLVM_ENABLE_PLUGINS=0", |
| 63 |
] |
| 64 |
} else { |
| 65 |
extra_values += [ |
| 66 |
"LLVM_LIT_ERRC_MESSAGES=", |
| 67 |
"LLVM_ENABLE_PLUGINS=1", |
| 68 |
] |
| 69 |
} |
| 70 |
|
| 71 |
if (host_os == "mac") { |
| 72 |
extra_values += [ "SHLIBEXT=.dylib" ] |
| 73 |
} else if (host_os == "win") { |
| 74 |
extra_values += [ "SHLIBEXT=.dll" ] |
| 75 |
} else { |
| 76 |
extra_values += [ "SHLIBEXT=.so" ] |
| 77 |
} |
| 78 |
|
| 79 |
if (llvm_enable_dia_sdk) { |
| 80 |
extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ] |
| 81 |
} else { |
| 82 |
extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0. |
| 83 |
} |
| 84 |
|
| 85 |
if (llvm_enable_libxml2) { |
| 86 |
extra_values += [ "LLVM_ENABLE_LIBXML2=1" ] |
| 87 |
} else { |
| 88 |
extra_values += [ "LLVM_ENABLE_LIBXML2=0" ] # Must be 0. |
| 89 |
} |
| 90 |
|
| 91 |
if (llvm_enable_zlib) { |
| 92 |
extra_values += [ "LLVM_ENABLE_ZLIB=1" ] |
| 93 |
} else { |
| 94 |
extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0. |
| 95 |
} |
| 96 |
|
| 97 |
if (llvm_enable_zstd) { |
| 98 |
extra_values += [ "LLVM_ENABLE_ZSTD=1" ] |
| 99 |
} else { |
| 100 |
extra_values += [ "LLVM_ENABLE_ZSTD=0" ] # Must be 0. |
| 101 |
} |
| 102 |
|
| 103 |
if (current_cpu == "x64" || current_cpu == "arm64" || |
| 104 |
current_cpu == "ppc64") { |
| 105 |
extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ] |
| 106 |
} else { |
| 107 |
extra_values += [ "CMAKE_SIZEOF_VOID_P=4" ] |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 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=." ] |
| 116 |
} |
| 117 |
|
| 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. |
| 121 |
group("test") { |
| 122 |
deps = [ |
| 123 |
":lit_site_cfg", |
| 124 |
":lit_unit_site_cfg", |
| 125 |
"//lld/tools/lld:symlinks", |
| 126 |
"//lld/unittests", |
| 127 |
"//llvm/tools/dsymutil", |
| 128 |
"//llvm/tools/llc", |
| 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", |
| 147 |
"//llvm/tools/opt", |
| 148 |
"//llvm/tools/yaml2obj", |
| 149 |
"//llvm/utils/FileCheck", |
| 150 |
"//llvm/utils/count", |
| 151 |
"//llvm/utils/llvm-lit", |
| 152 |
"//llvm/utils/not", |
| 153 |
"//llvm/utils/split-file", |
| 154 |
] |
| 155 |
testonly = true |
| 156 |
} |
| 157 |
|
| 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") { |
| 162 |
script += ".py" |
| 163 |
} |
| 164 |
args = [ |
| 165 |
"-sv", |
| 166 |
rebase_path(".", root_out_dir), |
| 167 |
] |
| 168 |
outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it |
| 169 |
# each time. |
| 170 |
|
| 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 |
| 174 |
# all the deps. |
| 175 |
deps = [ ":test" ] |
| 176 |
testonly = true |
| 177 |
|
| 178 |
pool = "//:console" |
| 179 |
} |