[Lldb-commits] [lldb] r214443 - Make CMake choose the target architecture according to the build.

Zachary Turner zturner at google.com
Thu Jul 31 14:07:41 PDT 2014


Author: zturner
Date: Thu Jul 31 16:07:41 2014
New Revision: 214443

URL: http://llvm.org/viewvc/llvm-project?rev=214443&view=rev
Log:
Make CMake choose the target architecture according to the build.

Previously, CMake was invoking the test runner and not specifying
what architecture to use when building test executables.  The
Makefiles for the test executables then had logic to choose x64
by default.  This doesn't work on Windows because the test compiler
would then try to link against the 64-bit MSVCRT and not find them
since only the 32-bit MSVCRT was in the path.

This patch addresses this by figuring out, at CMake time, whether
or not you are building LLDB with a 64 or 32-bit toolchain.  Then,
it explicitly passes this value to the test runner, causing the
test runner to build tests whose architecture matches that of LLDB
itself.  This can still be overridden by setting the CMake variable
LLDB_TEST_EXECUTABLE_ARCH=(x64|x86)

Modified:
    lldb/trunk/test/CMakeLists.txt
    lldb/trunk/test/dotest.py
    lldb/trunk/test/make/Makefile.rules

Modified: lldb/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=214443&r1=214442&r2=214443&view=diff
==============================================================================
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Thu Jul 31 16:07:41 2014
@@ -15,36 +15,40 @@ if ("${LLDB_TEST_COMPILER}" STREQUAL "")
     string(REGEX REPLACE ".*ccache\ +" "" LLDB_TEST_COMPILER ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
 endif()
 
-# Users can override LLDB_TEST_ARGS to modify the way LLDB tests are run. See help below.
-set(LLDB_TEST_ARGS
-  -C
-  ${LLDB_TEST_COMPILER}
-  CACHE STRING "Specify compiler(s) and architecture(s) with which run LLDB tests. For example: '-C gcc -C clang -A i386 -A x86_64'"
-  )
-string(REPLACE " " ";" LLDB_TEST_ARGS ${LLDB_TEST_ARGS})
-
-set(LLDB_TRACE_DIR "${CMAKE_BINARY_DIR}/lldb-test-traces"
-  CACHE STRING "Set directory to output LLDB test traces (for tests that do not pass.)"
-  )
+# The default architecture with which to compile test executables is the default LLVM target
+# architecture, which itself defaults to the host architecture.
+string(TOLOWER "${LLVM_TARGET_ARCH}" LLDB_DEFAULT_TEST_ARCH)
+if( LLDB_DEFAULT_TEST_ARCH STREQUAL "host" )
+  string(REGEX MATCH "^[^-]*" LLDB_DEFAULT_TEST_ARCH ${LLVM_HOST_TRIPLE})
+endif ()
+
+# Allow the user to override the default by setting LLDB_TEST_ARCH
+set(LLDB_TEST_ARCH
+	${LLDB_DEFAULT_TEST_ARCH}
+	CACHED STRING "Specify the architecture to run LLDB tests as (x86|x64).  Determines whether tests are compiled with -m32 or -m64")
+
+# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script
+set(LLDB_TEST_USER_ARGS
+  -C ${LLDB_TEST_COMPILER}
+  CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'")
 
-set(LLDB_COMMON_TEST_ARGS
+set(LLDB_TEST_COMMON_ARGS
+  --arch=${LLDB_TEST_ARCH}
   --executable
   ${CMAKE_BINARY_DIR}/bin/lldb${CMAKE_EXECUTABLE_SUFFIX}
   -s
-  ${LLDB_TRACE_DIR}
+  ${CMAKE_BINARY_DIR}/lldb-test-traces
   -u CXXFLAGS
   -u CFLAGS
   )
 
 add_python_test_target(check-lldb-single
   ${LLDB_SOURCE_DIR}/test/dotest.py
-  "${LLDB_COMMON_TEST_ARGS};${LLDB_TEST_ARGS}"
-  "Testing LLDB with args: ${LLDB_COMMON_TEST_ARGS};${LLDB_TEST_ARGS}"
+  "${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
+  "Testing LLDB with args: ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
   )
 
-set(LLDB_DOSEP_ARGS
-  -o;\"-q;${LLDB_COMMON_TEST_ARGS};${LLDB_TEST_ARGS}\"
-  )
+set(LLDB_DOSEP_ARGS -o;\"-q;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}\")
 
 # If tests crash cause LLDB to crash, or things are otherwise unstable, or if machine-parsable
 # output is desired (i.e. in continuous integration contexts) check-lldb-sep is a better target.

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=214443&r1=214442&r2=214443&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Thu Jul 31 16:07:41 2014
@@ -578,10 +578,7 @@ def parseOptionsAndInitTestdirs():
             if arch.startswith('arm') and platform_system == 'Darwin':
                 os.environ['SDKROOT'] = commands.getoutput('xcodebuild -version -sdk iphoneos.internal Path')
     else:
-        if (platform_system == 'Darwin' or (platform_system == 'Linux' and compilers == ['clang'])) and platform_machine == 'x86_64':
-            archs = ['x86_64', 'i386']
-        else:
-            archs = [platform_machine]
+        archs = [platform_machine]
 
     if args.categoriesList:
         categoriesList = set(validate_categories(args.categoriesList))

Modified: lldb/trunk/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=214443&r1=214442&r2=214443&view=diff
==============================================================================
--- lldb/trunk/test/make/Makefile.rules (original)
+++ lldb/trunk/test/make/Makefile.rules Thu Jul 31 16:07:41 2014
@@ -73,15 +73,22 @@ else
 	# On non-Apple platforms, -arch becomes -m
 	ARCHFLAG := -m
 
-	# i386 becomes 32, and amd64 or x86_64 becomes 64
+	# i386,i686 -> 32
+	# amd64, x86_64, x64 -> 64
 	ifeq "$(ARCH)" "amd64"
-	    override ARCH := $(subst amd64,64,$(ARCH))
+		override ARCH := $(subst amd64,64,$(ARCH))
 	endif
 	ifeq "$(ARCH)" "x86_64"
-	    override ARCH := $(subst x86_64,64,$(ARCH))
+		override ARCH := $(subst x86_64,64,$(ARCH))
+	endif
+	ifeq "$(ARCH)" "x64"
+		override ARCH := $(subst x64,64,$(ARCH))
 	endif
 	ifeq "$(ARCH)" "i386"
-	    override ARCH := $(subst i386,32,$(ARCH))
+		override ARCH := $(subst i386,32,$(ARCH))
+	endif
+	ifeq "$(ARCH)" "i686"
+		override ARCH := $(subst i686,32,$(ARCH))
 	endif
 
 	ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"





More information about the lldb-commits mailing list