xref: /llvm-project/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn (revision 9118d3a564f271006b0d8aed0983f7ba025e77a0)
1import("//compiler-rt/target.gni")
2import("//compiler-rt/test/test.gni")
3import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
4import("//llvm/triples.gni")
5import("//llvm/utils/gn/build/buildflags.gni")
6import("//llvm/utils/gn/build/libs/zlib/enable.gni")
7import("//llvm/utils/gn/build/toolchain/compiler.gni")
8import("//llvm/utils/gn/build/write_cmake_config.gni")
9import("//llvm/version.gni")
10
11ext = ""
12if (host_os == "win") {
13  ext = ".exe"
14}
15
16write_cmake_config("lit_common_configured") {
17  input = "lit.common.configured.in"
18  output = "$target_gen_dir/lit.common.configured"
19
20  values = [
21    "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
22
23    "COMPILER_RT_DEFAULT_TARGET_TRIPLE=$llvm_current_triple",
24    "COMPILER_RT_DEFAULT_TARGET_ARCH=$crt_current_target_arch",
25
26    "COMPILER_RT_TEST_COMPILER_CFLAGS=$target_flags_string",
27    "LLVM_BUILD_MODE=.",
28    "LLVM_MAIN_SRC_DIR=" + rebase_path("//llvm"),
29    "LLVM_BINARY_DIR=" + rebase_path(root_build_dir),
30    "COMPILER_RT_SOURCE_DIR=" + rebase_path("//compiler-rt"),
31
32    # This is only used by tsan to find the path to an instrumented libc++.
33    # Since we don't currently support running the tsan tests, leave it empty
34    # for now. Eventually it should probably be replaced with some mechanism
35    # where the libraries are found in a toolchain dir.
36    "COMPILER_RT_BINARY_DIR=",
37
38    # We don't currently support the multiarch runtime layout.
39    "LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_PYBOOL=False",
40
41    "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
42    "LLVM_TOOLS_DIR=" + rebase_path("$root_build_dir/bin"),
43    "LLVM_LIBRARY_OUTPUT_INTDIR=" + rebase_path("$root_build_dir/lib"),
44
45    "LLVM_LIBCXX_USED=0",
46
47    "GOLD_EXECUTABLE=ld",
48    "GNU_LD_EXECUTABLE=ld",
49    "COMPILER_RT_RESOLVED_TEST_COMPILER=" +
50        rebase_path("$root_build_dir/bin/clang") + ext,
51    "COMPILER_RT_TEST_COMPILER_ID=Clang",
52    "Python3_EXECUTABLE=$python_path",
53    "COMPILER_RT_BUILD_STANDALONE_LIBATOMIC_PYBOOL=False",
54    "COMPILER_RT_DEBUG_PYBOOL=False",
55    "COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER_PYBOOL=False",
56    "COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG_PYBOOL=True",
57    "COMPILER_RT_INTERCEPT_LIBDISPATCH_PYBOOL=False",
58    "COMPILER_RT_RESOLVED_EXEC_OUTPUT_DIR=" +
59        rebase_path("$root_build_dir/bin"),
60    "COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR=" +
61        rebase_path(crt_current_out_dir),
62    "COMPILER_RT_RESOLVED_OUTPUT_DIR=" + rebase_path(crt_current_out_dir),
63    "COMPILER_RT_EMULATOR=",
64    "COMPILER_RT_ASAN_SHADOW_SCALE=",
65    "COMPILER_RT_MEMPROF_SHADOW_SCALE=",
66    "COMPILER_RT_TEST_STANDALONE_BUILD_LIBS_PYBOOL=False",
67    "COMPILER_RT_TEST_USE_LLD_PYBOOL=False",  # FIXME: base off use_lld?
68    "SANITIZER_CAN_USE_CXXABI_PYBOOL=True",
69    "SANITIZER_USE_STATIC_CXX_ABI_PYBOOL=False",
70    "SANITIZER_USE_STATIC_LLVM_UNWINDER_PYBOOL=False",
71    "COMPILER_RT_HAS_AARCH64_SME_PYBOOL=False",
72    "COMPILER_RT_DARWIN_LINKER_VERSION=",
73    "COMPILER_RT_HAS_LLD_PYBOOL=True",
74    "COMPILER_RT_HAS_GWP_ASAN_PYBOOL=False",
75    "HAVE_RPC_XDR_H=0",
76    "ANDROID_API_LEVEL=$android_api_level",
77    "ANDROID_SERIAL_FOR_TESTING=$android_serial_for_testing",
78  ]
79
80  if (llvm_enable_expensive_checks) {
81    values += [ "LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL=True" ]
82  } else {
83    values += [ "LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL=False" ]
84  }
85
86  if (host_cpu == "x64") {
87    values += [ "HOST_ARCH=x86_64" ]
88  } else if (host_cpu == "arm64") {
89    values += [ "HOST_ARCH=aarch64" ]
90  } else {
91    assert(false, "unimplemented host_cpu " + host_cpu)
92  }
93
94  if (host_os == "mac") {
95    values += [ "HOST_OS=Darwin" ]
96  } else if (host_os == "linux") {
97    values += [ "HOST_OS=Linux" ]
98  } else if (host_os == "win") {
99    values += [ "HOST_OS=Windows" ]
100  } else {
101    assert(false, "unsupported host_os " + host_os)
102  }
103
104  if (current_os != "win" || llvm_enable_dia_sdk) {
105    values += [ "CAN_SYMBOLIZE=1" ]
106  } else {
107    values += [ "CAN_SYMBOLIZE=0" ]
108  }
109
110  if (current_os == "android") {
111    values += [ "ANDROID_PYBOOL=True" ]
112  } else {
113    values += [ "ANDROID_PYBOOL=False" ]
114  }
115
116  if (llvm_enable_zlib) {
117    # FIXME: Include dir and library are wrong on Windows; look at zlib_path.
118    values += [
119      "ZLIB_FOUND_PYBOOL=1",
120      "ZLIB_INCLUDE_DIR=-I=",
121      "ZLIB_LIBRARY=-lz",
122    ]
123  } else {
124    values += [
125      "ZLIB_FOUND_PYBOOL=0",
126      "ZLIB_INCLUDE_DIR=",
127      "ZLIB_LIBRARY=",
128    ]
129  }
130}
131