[gn build] Add support for expensive checks
authorArthur Eubanks <aeubanks@google.com>
Sat, 15 Aug 2020 00:09:23 +0000 (17:09 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 18 Aug 2020 16:53:39 +0000 (09:53 -0700)
Reviewed By: hans, MaskRay

Differential Revision: https://reviews.llvm.org/D86007

llvm/utils/gn/build/BUILD.gn
llvm/utils/gn/build/buildflags.gni
llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn

index e29cdb6..3c0b905 100644 (file)
@@ -34,6 +34,10 @@ config("compiler_defaults") {
     defines += [ "NDEBUG" ]
   }
 
+  if (llvm_enable_expensive_checks) {
+    defines += [ "EXPENSIVE_CHECKS" ]
+  }
+
   asmflags = target_flags
   cflags = target_flags
   ldflags = target_flags + target_ldflags
index 4dcdc96..eb8ac55 100644 (file)
@@ -10,4 +10,7 @@ declare_args() {
 
   # Whether to enable assertions.
   llvm_enable_assertions = true
+
+  # Whether to enable expensive checks.
+  llvm_enable_expensive_checks = false
 }
index 5f80586..32480e5 100644 (file)
@@ -1,6 +1,7 @@
 import("//compiler-rt/target.gni")
 import("//compiler-rt/test/test.gni")
 import("//llvm/triples.gni")
+import("//llvm/utils/gn/build/buildflags.gni")
 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
 import("//llvm/utils/gn/build/toolchain/compiler.gni")
 import("//llvm/utils/gn/build/write_cmake_config.gni")
@@ -51,12 +52,17 @@ write_cmake_config("lit_common_configured") {
     "SANITIZER_CAN_USE_CXXABI_PYBOOL=True",
     "COMPILER_RT_HAS_LLD_PYBOOL=True",
     "COMPILER_RT_HAS_GWP_ASAN_PYBOOL=False",
-    "LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL=False",
     "HAVE_RPC_XDR_H=0",
     "ANDROID_NDK_VERSION=19",
     "ANDROID_SERIAL_FOR_TESTING=$android_serial_for_testing",
   ]
 
+  if (llvm_enable_expensive_checks) {
+    values += [ "LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL=True" ]
+  } else {
+    values += [ "LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL=False" ]
+  }
+
   if (host_cpu == "x64") {
     values += [ "HOST_ARCH=x86_64" ]
   } else {