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 (I had been using a different workaround for that issue).
@pzheng had suggested an alternative fix in [1]:
- if(ANDROID OR ${arch} MATCHES "arm|aarch64") + if(ANDROID OR ${arch} MATCHES "arm|aarch64" OR + COMPILER_RT_TEST_COMPILER_CFLAGS)
I'm not sure that's correct and safe in all scenarios. If it is, couldn't the COMPILER_RT_TEST_COMPILER_CFLAGS condition subsume the other ones anyway? If the answer to this isn't clear I suggest we just add the RISC-V matches for now, as done in this patch.