[libc] Distinguish compiler and run failures
authorPetr Hosek <phosek@google.com>
Thu, 21 Jan 2021 08:01:18 +0000 (00:01 -0800)
committerPetr Hosek <phosek@google.com>
Thu, 21 Jan 2021 23:27:34 +0000 (15:27 -0800)
This is useful for debugging issues, for example when cross-compiling.

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

libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake

index 86c3822..57dfbd9 100644 (file)
@@ -115,12 +115,14 @@ function(_check_defined_cpu_feature output_var)
     COMPILE_DEFINITIONS ${flags}
     COMPILE_OUTPUT_VARIABLE compile_output
     RUN_OUTPUT_VARIABLE run_output)
-  if(${compile_result} AND ("${run_result}" EQUAL 0))
+  if("${run_result}" EQUAL 0)
     set(${output_var}
         "${run_output}"
         PARENT_SCOPE)
+  elseif(NOT ${compile_result})
+    message(FATAL_ERROR "Failed to compile: ${compile_output}")
   else()
-    message(FATAL_ERROR "${compile_output}")
+    message(FATAL_ERROR "Failed to run: ${run_output}")
   endif()
 endfunction()