[Lldb-commits] [PATCH] D66429: [CMake] Remove LLDB_TEST_USE_CUSTOM_C(XX)_COMPILER

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 19 10:36:47 PDT 2019


JDevlieghere created this revision.
JDevlieghere added a reviewer: LLDB.
Herald added subscribers: teemperor, mgorny.
Herald added a project: LLDB.

Given that `LLDB_TEST_USE_CUSTOM_C_COMPILER` and `LLDB_TEST_C_COMPILER` are both set at configuration time, I don't really see the point of having them both. This patch simplifies things and uses the custom C/C++ compiler when the variable is set, and uses the default one when it's not set, or explicitly set to the empty string (so that you can choose to switch back to using the default compiler).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D66429

Files:
  lldb/CMakeLists.txt
  lldb/docs/resources/build.rst
  lldb/docs/resources/test.rst


Index: lldb/docs/resources/test.rst
===================================================================
--- lldb/docs/resources/test.rst
+++ lldb/docs/resources/test.rst
@@ -30,9 +30,7 @@
 By default, the ``check-lldb`` target builds the test programs with the same
 compiler that was used to build LLDB. To build the tests with a different
 compiler, you can set the ``LLDB_TEST_C_COMPILER`` or the
-``LLDB_TEST_CXX_COMPILER`` CMake variables. These variables are ignored unless
-the respective ``LLDB_TEST_USE_CUSTOM_C_COMPILER`` and
-``LLDB_TEST_USE_CUSTOM_CXX_COMPILER`` are set to ``ON``.
+``LLDB_TEST_CXX_COMPILER`` CMake variables.
 
 It is possible to customize the architecture of the test binaries and compiler
 used by appending ``-A`` and ``-C`` options respectively to the CMake variable
Index: lldb/docs/resources/build.rst
===================================================================
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -185,8 +185,6 @@
 ::
 
   > cmake -G Ninja \
-      -DLLDB_TEST_USE_CUSTOM_C_COMPILER=On \
-      -DLLDB_TEST_USE_CUSTOM_CXX_COMPILER=On \
       -DLLDB_TEST_C_COMPILER=<path to C compiler> \
       -DLLDB_TEST_CXX_COMPILER=<path to C++ compiler> \
       <path to root of llvm source tree>
@@ -228,7 +226,6 @@
   > cmake -G Ninja^
       -DLLDB_TEST_DEBUG_TEST_CRASHES=1^
       -DPYTHON_HOME=C:\Python35^
-      -DLLDB_TEST_USE_CUSTOM_C_COMPILER=ON^
       -DLLDB_TEST_C_COMPILER=d:\src\llvmbuild\ninja_release\bin\clang.exe^
       <path to root of llvm source tree>
 
Index: lldb/CMakeLists.txt
===================================================================
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -70,8 +70,6 @@
 add_subdirectory(docs)
 
 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
-option(LLDB_TEST_USE_CUSTOM_C_COMPILER "Use the C compiler provided via LLDB_TEST_C_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF)
-option(LLDB_TEST_USE_CUSTOM_CXX_COMPILER "Use the C++ compiler provided via LLDB_TEST_CXX_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF)
 if(LLDB_INCLUDE_TESTS)
 
   # Set the path to the default lldb test executable.
@@ -81,27 +79,33 @@
   set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
   set(LLDB_DEFAULT_TEST_FILECHECK "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/FileCheck${CMAKE_EXECUTABLE_SUFFIX}")
 
-  if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER AND TARGET clang)
+  if (TARGET clang)
     set(LLDB_DEFAULT_TEST_C_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
+    set(LLDB_DEFAULT_TEST_CXX_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}")
   else()
     set(LLDB_DEFAULT_TEST_C_COMPILER "")
+    set(LLDB_DEFAULT_TEST_CXX_COMPILER "")
   endif()
 
-  if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER AND TARGET clang)
-    set(LLDB_DEFAULT_TEST_CXX_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}")
-  else()
-    set(LLDB_DEFAULT_TEST_CXX_COMPILER "")
+  # Use the default C compiler if LLDB_TEST_C_COMPILER is explicitly unset.
+  if (LLDB_TEST_C_COMPILER STREQUAL "")
+    set(LLDB_TEST_C_COMPILER_force FORCE)
+  endif()
+
+  # Use the default C++ compiler if LLDB_TEST_CXX_COMPILER is explicitly unset.
+  if (LLDB_TEST_CXX_COMPILER STREQUAL "")
+    set(LLDB_TEST_CXX_COMPILER_force FORCE)
   endif()
 
   set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb executable used for testing")
-  set(LLDB_TEST_C_COMPILER "${LLDB_DEFAULT_TEST_C_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors")
-  set(LLDB_TEST_CXX_COMPILER "${LLDB_DEFAULT_TEST_CXX_COMPILER}" CACHE PATH "C++ Compiler to use for building LLDB test inferiors")
+  set(LLDB_TEST_C_COMPILER "${LLDB_DEFAULT_TEST_C_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors" ${LLDB_TEST_C_COMPILER_force})
+  set(LLDB_TEST_CXX_COMPILER "${LLDB_DEFAULT_TEST_CXX_COMPILER}" CACHE PATH "C++ Compiler to use for building LLDB test inferiors" ${LLDB_TEST_CXX_COMPILER_force})
   set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles")
   set(LLDB_TEST_FILECHECK "${LLDB_DEFAULT_TEST_FILECHECK}" CACHE PATH "FileCheck used for testing purposes")
 
   if (("${LLDB_TEST_C_COMPILER}" STREQUAL "") OR
       ("${LLDB_TEST_CXX_COMPILER}" STREQUAL ""))
-    message(FATAL_ERROR "LLDB test compilers not specified.  Tests will not run")
+    message(FATAL_ERROR "LLDB test compilers not specified. Tests will not run.")
   endif()
 
   set(LLDB_TEST_DEPS lldb)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66429.215944.patch
Type: text/x-patch
Size: 4787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190819/4e859492/attachment-0001.bin>


More information about the lldb-commits mailing list