summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Gorny <mgorny@gentoo.org>2017-01-06 21:33:48 +0000
committerMichal Gorny <mgorny@gentoo.org>2017-01-06 21:33:48 +0000
commit9283f5b200585dfe9265bd23ad24234bcb5ed8d4 (patch)
tree0f0b75be6c1da02f85a92d83363a8777188bc5aa
parent82eb45a6f8825eda6e1106501495f5b2694b0e49 (diff)
downloadbcm5719-llvm-9283f5b200585dfe9265bd23ad24234bcb5ed8d4.tar.gz
bcm5719-llvm-9283f5b200585dfe9265bd23ad24234bcb5ed8d4.zip
[cmake] Canonicalize CMake booleans to 0/1 for lit interop
Canonicalize all CMake booleans to 0/1 before passing them to lit, to ensure that the Python side handles all of them consistently and correctly. 0/1 is a safe choice of values that trigger the same boolean interpretation in CMake, Python and C++. Furthermore, using them without quotes improves the chance Python will explicitly fail when an incorrect value (such as ON/OFF, TRUE/FALSE, YES/NO) is accidentally passed, rather than silently misinterpreting the value. This replaces a lot of different logics spread around lit site files, attempting to partially reproduce the boolean logic used in CMake and usually silently failing when an uncommon value was used instead. In fact, some of them were never working correctly since different values were assigned in CMake and checked in Python. The alternative solution could be to create a common parser for CMake booleans in lit and use it consistently throughout the site files. However, it does not seem like the best idea to create redundant implementation of the same logic and have to follow upstream if it ever is extended to handle more values. Differential Revision: https://reviews.llvm.org/D28294 llvm-svn: 291284
-rwxr-xr-xllvm/cmake/config-ix.cmake7
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake13
-rw-r--r--llvm/test/Bindings/Go/lit.local.cfg2
-rw-r--r--llvm/test/Bindings/OCaml/lit.local.cfg2
-rw-r--r--llvm/test/CMakeLists.txt11
-rw-r--r--llvm/test/ExecutionEngine/Interpreter/lit.local.cfg2
-rw-r--r--llvm/test/JitListener/lit.local.cfg2
-rw-r--r--llvm/test/lit.cfg6
-rw-r--r--llvm/test/lit.site.cfg.in16
9 files changed, 39 insertions, 22 deletions
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index d76f1293d02..0f1fc34ed28 100755
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -462,13 +462,6 @@ if( MSVC )
if(LLVM_ENABLE_DIA_SDK AND NOT HAVE_DIA_SDK)
message(FATAL_ERROR "DIA SDK not found. If you have both VS 2012 and 2013 installed, you may need to uninstall the former and re-install the latter afterwards.")
endif()
-
- # Normalize to 0/1 for lit.site.cfg
- if(LLVM_ENABLE_DIA_SDK)
- set(LLVM_ENABLE_DIA_SDK 1)
- else()
- set(LLVM_ENABLE_DIA_SDK 0)
- endif()
else()
set(LLVM_ENABLE_DIA_SDK 0)
endif( MSVC )
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index fbef1d04eac..0eb16974517 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1067,6 +1067,19 @@ function(llvm_add_go_executable binary pkgpath)
endif()
endfunction()
+# This function canonicalize the CMake variables passed by names
+# from CMake boolean to 0/1 suitable for passing into Python or C++,
+# in place.
+function(llvm_canonicalize_cmake_booleans)
+ foreach(var ${ARGN})
+ if(${var})
+ set(${var} 1 PARENT_SCOPE)
+ else()
+ set(${var} 0 PARENT_SCOPE)
+ endif()
+ endforeach()
+endfunction(llvm_canonicalize_cmake_booleans)
+
# This function provides an automatic way to 'configure'-like generate a file
# based on a set of common and custom variables, specifically targeting the
# variables needed for the 'lit.site.cfg' files. This function bundles the
diff --git a/llvm/test/Bindings/Go/lit.local.cfg b/llvm/test/Bindings/Go/lit.local.cfg
index d68d867fb30..a587f88f54a 100644
--- a/llvm/test/Bindings/Go/lit.local.cfg
+++ b/llvm/test/Bindings/Go/lit.local.cfg
@@ -6,7 +6,7 @@ import sys
if not 'go' in config.root.llvm_bindings:
config.unsupported = True
-if config.root.include_go_tests != 'ON':
+if not config.root.include_go_tests:
config.unsupported = True
def find_executable(executable, path=None):
diff --git a/llvm/test/Bindings/OCaml/lit.local.cfg b/llvm/test/Bindings/OCaml/lit.local.cfg
index 7a83ca14280..fd9e1c50e99 100644
--- a/llvm/test/Bindings/OCaml/lit.local.cfg
+++ b/llvm/test/Bindings/OCaml/lit.local.cfg
@@ -3,5 +3,5 @@ config.suffixes = ['.ml']
if not 'ocaml' in config.root.llvm_bindings:
config.unsupported = True
-if config.root.have_ocaml_ounit not in ('1', 'TRUE'):
+if not config.root.have_ocaml_ounit:
config.unsupported = True
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index 06cf5be267a..3bef0209620 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -1,3 +1,14 @@
+llvm_canonicalize_cmake_booleans(
+ LLVM_TOOL_LTO_BUILD
+ HAVE_OCAMLOPT
+ HAVE_OCAML_OUNIT
+ LLVM_INCLUDE_GO_TESTS
+ LLVM_USE_INTEL_JITEVENTS
+ HAVE_LIBZ
+ HAVE_LIBXAR
+ LLVM_ENABLE_DIA_SDK
+ LLVM_ENABLE_FFI)
+
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
diff --git a/llvm/test/ExecutionEngine/Interpreter/lit.local.cfg b/llvm/test/ExecutionEngine/Interpreter/lit.local.cfg
index 8cbaf03217d..231d8e22cc6 100644
--- a/llvm/test/ExecutionEngine/Interpreter/lit.local.cfg
+++ b/llvm/test/ExecutionEngine/Interpreter/lit.local.cfg
@@ -1,3 +1,3 @@
# These tests require foreign function calls
-if config.enable_ffi != "ON":
+if not config.enable_ffi:
config.unsupported = True
diff --git a/llvm/test/JitListener/lit.local.cfg b/llvm/test/JitListener/lit.local.cfg
index 05f34a744ad..f485229b01c 100644
--- a/llvm/test/JitListener/lit.local.cfg
+++ b/llvm/test/JitListener/lit.local.cfg
@@ -1,3 +1,3 @@
-if not config.root.llvm_use_intel_jitevents == "true":
+if not config.root.llvm_use_intel_jitevents:
config.unsupported = True
diff --git a/llvm/test/lit.cfg b/llvm/test/lit.cfg
index e0881ef2162..f3b1d1c1ed2 100644
--- a/llvm/test/lit.cfg
+++ b/llvm/test/lit.cfg
@@ -231,7 +231,7 @@ config.substitutions.append( ('%ld64', ld64_cmd) )
config.substitutions.append( ('%ocamlc',
"%s ocamlc -cclib -L%s %s" %
(config.ocamlfind_executable, llvm_lib_dir, config.ocaml_flags)) )
-if config.have_ocamlopt in ('1', 'TRUE'):
+if config.have_ocamlopt:
config.substitutions.append( ('%ocamlopt',
"%s ocamlopt -cclib -L%s -cclib -Wl,-rpath,%s %s" %
(config.ocamlfind_executable, llvm_lib_dir, llvm_lib_dir, config.ocaml_flags)) )
@@ -399,7 +399,7 @@ if lit_config.params.get("run_long_tests", None) == "true":
if not 'hexagon' in config.target_triple:
config.available_features.add("object-emission")
-if config.have_zlib == "1":
+if config.have_zlib:
config.available_features.add("zlib")
else:
config.available_features.add("nozlib")
@@ -455,7 +455,7 @@ if have_ld_plugin_support():
config.available_features.add('ld_plugin')
def have_ld64_plugin_support():
- if (config.llvm_tool_lto_build == 'OFF' or config.ld64_executable == ''):
+ if not config.llvm_tool_lto_build or config.ld64_executable == '':
return False
ld_cmd = subprocess.Popen([config.ld64_executable, '-v'], stderr = subprocess.PIPE)
diff --git a/llvm/test/lit.site.cfg.in b/llvm/test/lit.site.cfg.in
index a24d0db3655..4bf1211eeff 100644
--- a/llvm/test/lit.site.cfg.in
+++ b/llvm/test/lit.site.cfg.in
@@ -15,12 +15,12 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.gold_executable = "@GOLD_EXECUTABLE@"
config.ld64_executable = "@LD64_EXECUTABLE@"
-config.llvm_tool_lto_build = "@LLVM_TOOL_LTO_BUILD@"
+config.llvm_tool_lto_build = @LLVM_TOOL_LTO_BUILD@
config.ocamlfind_executable = "@OCAMLFIND@"
-config.have_ocamlopt = "@HAVE_OCAMLOPT@"
-config.have_ocaml_ounit = "@HAVE_OCAML_OUNIT@"
+config.have_ocamlopt = @HAVE_OCAMLOPT@
+config.have_ocaml_ounit = @HAVE_OCAML_OUNIT@
config.ocaml_flags = "@OCAMLFLAGS@"
-config.include_go_tests = "@LLVM_INCLUDE_GO_TESTS@"
+config.include_go_tests = @LLVM_INCLUDE_GO_TESTS@
config.go_executable = "@GO_EXECUTABLE@"
config.enable_shared = @ENABLE_SHARED@
config.enable_assertions = @ENABLE_ASSERTIONS@
@@ -32,12 +32,12 @@ config.host_arch = "@HOST_ARCH@"
config.host_cc = "@HOST_CC@"
config.host_cxx = "@HOST_CXX@"
config.host_ldflags = "@HOST_LDFLAGS@"
-config.llvm_use_intel_jitevents = "@LLVM_USE_INTEL_JITEVENTS@"
+config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = "@HAVE_LIBZ@"
-config.have_libxar = "@HAVE_LIBXAR@"
+config.have_zlib = @HAVE_LIBZ@
+config.have_libxar = @HAVE_LIBXAR@
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
-config.enable_ffi = "@LLVM_ENABLE_FFI@"
+config.enable_ffi = @LLVM_ENABLE_FFI@
# Support substitution of the tools_dir with user parameters. This is
# used when we can't determine the tool dir at configuration time.
OpenPOWER on IntegriCloud