[CMake][compiler-rt][RISCV] Support RISC-V cross-compilation
authorLuís Marques <luismarques@lowrisc.org>
Sun, 31 Jan 2021 23:51:38 +0000 (23:51 +0000)
committerLuís Marques <luismarques@lowrisc.org>
Sun, 31 Jan 2021 23:52:57 +0000 (23:52 +0000)
This seems to be a safe way to ensure that the Compiler-RT test compiler
flags are properly set in all cross-compilation scenarios. Without this
when `BUILTINS_TEST_TARGET_CFLAGS` is set in
`compiler-rt/test/builtins/CMakeLists.txt` the other flags are cleared.

Differential Revision: https://reviews.llvm.org/D92124

compiler-rt/cmake/config-ix.cmake

index 8135738..47039a3 100644 (file)
@@ -219,7 +219,7 @@ endfunction()
 # specific architecture.  When cross-compiling, this is controled via
 # COMPILER_RT_TEST_COMPILER and COMPILER_RT_TEST_COMPILER_CFLAGS.
 macro(get_test_cc_for_arch arch cc_out cflags_out)
-  if(ANDROID OR ${arch} MATCHES "arm|aarch64")
+  if(ANDROID OR ${arch} MATCHES "arm|aarch64|riscv32|riscv64")
     # This is only true if we are cross-compiling.
     # Build all tests with host compiler and use host tools.
     set(${cc_out} ${COMPILER_RT_TEST_COMPILER})