Skip to content

Commit 9973673

Browse files
committed
Fix support for user mode emulation when using cmake/lit.
When using user mode emulation, i.e. cross-compiling programs for a different target and running them on a host under qemu user mode emulation, timeit and fpcmp should have host versions, not target versions. Running under user mode emulation had been broken for a while, presumably since https://reviews.llvm.org/rT341257 I first tried an alternative approach where fpcmp would be run under qemu user mode emulation too. That in itself worked, but if going for that approach, for orthogonality reasons, we probably should also run the other helper programs as if they were running on the target, i.e. also under qemu user mode emulation. I ran into issues with running timeit under qemu user mode emulation and also running RunSafely.sh under user mode emulation doesn't seem trivial. In the end, it seemed better to me to explicitly add a cmake option to mark that we're running under qemu user mode emulation, and in that mode, only aim to run the test/benchmark under qemu user mode emulation, rather than also all the helper programs (such as fpcmp, timeit, RunSafely.sh) under it (which is what would be needed if we just kept on using only the RUN_UNDER option for qemu user mode emulation. Differential Revision: https://reviews.llvm.org/D61597 llvm-svn: 365783
1 parent 00bd6ed commit 9973673

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ endif()
7777
# Run Under configuration for RunSafely.sh (will be set in lit.site.cfg)
7878
set(TEST_SUITE_RUN_UNDER "" CACHE STRING "RunSafely.sh run-under (-u) parameter")
7979

80+
# User mode emulation configuration (e.g. running under qemu)
81+
# (will be set in lit.site.cfg)
82+
set(TEST_SUITE_USER_MODE_EMULATION NO CACHE BOOL
83+
"RUN_UNDER is used to run tests under emulation.")
84+
# Set value to python style True/False
85+
if (TEST_SUITE_USER_MODE_EMULATION)
86+
set(TEST_SUITE_USER_MODE_EMULATION "True")
87+
else()
88+
set(TEST_SUITE_USER_MODE_EMULATION "False")
89+
endif()
90+
91+
8092
# run type/benchmark size configuration (mostly for SPEC at the moment)
8193
set(TEST_SUITE_RUN_TYPE "train" CACHE STRING
8294
"Type of benchmark inputs (may be test,train or ref)")
@@ -220,7 +232,10 @@ mark_as_advanced(TEST_SUITE_LIT)
220232

221233
add_subdirectory(tools)
222234
# Shortcut for the path to the fpcmp executable
223-
set(FPCMP ${CMAKE_BINARY_DIR}/tools/fpcmp)
235+
set(FPCMP ${CMAKE_BINARY_DIR}/tools/fpcmp-target)
236+
if (TEST_SUITE_USER_MODE_EMULATION)
237+
set(FPCMP ${CMAKE_BINARY_DIR}/tools/fpcmp)
238+
endif()
224239

225240
option(TEST_SUITE_COLLECT_COMPILE_TIME
226241
"Measure compile time by wrapping compiler invocations in timeit" ON)

cmake/modules/TestSuite.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ function(test_suite_add_build_dependencies target)
9999
build-HashProgramOutput.sh
100100
build-timeit
101101
build-timeit-target
102-
fpcmp
102+
build-fpcmp
103+
build-fpcmp-target
103104
)
104105
endfunction()
105106

lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ config.test_exec_root = "@CMAKE_BINARY_DIR@"
55
config.remote_client = "@TEST_SUITE_REMOTE_CLIENT@"
66
config.remote_host = "@TEST_SUITE_REMOTE_HOST@"
77
config.run_under = "@TEST_SUITE_RUN_UNDER@"
8+
config.user_mode_emulation = @TEST_SUITE_USER_MODE_EMULATION@
89
config.strip_tool = "@CMAKE_STRIP@"
910
config.profile_generate = @TEST_SUITE_PROFILE_GENERATE@
1011
config.llvm_profdata = "@TEST_SUITE_LLVM_PROFDATA@"

litsupport/modules/timeit.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ def _mutateCommandLine(context, commandline):
99
config = context.config
1010
cmd = shellcommand.parse(commandline)
1111

12-
timeit = "%s/tools/timeit-target" % config.test_source_root
12+
if config.user_mode_emulation:
13+
# user_mode_emulation should be true if tests are being run via
14+
# user-mode emulation (e.g. Qemu) and thus the host version of timeit
15+
# should be used.
16+
timeit_name = "timeit"
17+
else:
18+
timeit_name = "timeit-target"
19+
timeit = "%s/tools/%s" % (config.test_source_root, timeit_name)
1320
args = ["--limit-core", "0"]
1421
args += ["--limit-cpu", "7200"]
1522
args += ["--timeout", "7200"]

tools/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
include(Host)
99

10-
add_executable(fpcmp fpcmp.c)
10+
add_executable(fpcmp-target ${CMAKE_CURRENT_SOURCE_DIR}/fpcmp.c)
11+
add_executable(build-fpcmp-target ALIAS fpcmp-target)
12+
llvm_add_host_executable(build-fpcmp fpcmp fpcmp.c)
1113

1214
add_custom_command(
1315
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/HashProgramOutput.sh

0 commit comments

Comments
 (0)