summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2014-07-31 21:07:41 +0000
committerZachary Turner <zturner@google.com>2014-07-31 21:07:41 +0000
commit7c1bc2b8ae53b80593f2a0f3486d32d5f88e7851 (patch)
treec9f4f844d4d2663fe6f10956eb88e0d3fa96defa
parentea32c105a6959a503720e1c5a39e058cadfeef33 (diff)
downloadbcm5719-llvm-7c1bc2b8ae53b80593f2a0f3486d32d5f88e7851.tar.gz
bcm5719-llvm-7c1bc2b8ae53b80593f2a0f3486d32d5f88e7851.zip
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) llvm-svn: 214443
-rw-r--r--lldb/test/CMakeLists.txt42
-rwxr-xr-xlldb/test/dotest.py5
-rw-r--r--lldb/test/make/Makefile.rules15
3 files changed, 35 insertions, 27 deletions
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index f495eb26224..a5c9e383aca 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -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.)"
- )
-
-set(LLDB_COMMON_TEST_ARGS
+# 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_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.
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py
index 101fbfdf316..49cca982f57 100755
--- a/lldb/test/dotest.py
+++ b/lldb/test/dotest.py
@@ -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))
diff --git a/lldb/test/make/Makefile.rules b/lldb/test/make/Makefile.rules
index 787f4c51274..6852ac04e20 100644
--- a/lldb/test/make/Makefile.rules
+++ b/lldb/test/make/Makefile.rules
@@ -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"
OpenPOWER on IntegriCloud