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 has 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.
Currently this patch only copes with using 1 to denote True, which is less than CMake normally accepts ("On" is a good, explicit value that CMake allows, in addition to "True").
However, there is a hack that this CMake configuration uses for TEST_SUITE_PROFILE_GENERATE which we can replicate inside this if: set the value to an explicitly python-like string "True" (in this branch) and "False" (in an else branch). Then you can just directly set config.user_mode_emulation = @TEST_SUITE_USER_MODE_EMULATION@ in lit.site.cfg.in, and the configuration should be less brittle to exactly which boolean value that someone chooses at the command line for CMake.
In the future, it would probably make sense to have a python function for lit.site.cfg.in which can parse any cmake-valid boolean from a string into the correct python boolean, which feels like a nicer solution, but can come along later.