[llvm-branch-commits] [compiler-rt] bd6783b - [compiler-rt] Fix invalid triple on ARM build

Leandro Lupori via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Apr 27 05:02:36 PDT 2023


Author: Leandro Lupori
Date: 2023-04-27T11:10:43Z
New Revision: bd6783b380768bd35f37e0034dccf6c5736dd031

URL: https://github.com/llvm/llvm-project/commit/bd6783b380768bd35f37e0034dccf6c5736dd031
DIFF: https://github.com/llvm/llvm-project/commit/bd6783b380768bd35f37e0034dccf6c5736dd031.diff

LOG: [compiler-rt] Fix invalid triple on ARM build

The fuzzer build was failing on armv7l, with an invalid triple
error. This happened because CMake's get_compiler_rt_target
function was missing some code to correctly handle arm archs,
such as armhf.

This was originaly part of https://reviews.llvm.org/D140011, that
landed on main with commit cd173cbd7cca69c29df42cd4b42e60433435c29b.

Fixes #60115

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

Added: 
    

Modified: 
    compiler-rt/cmake/Modules/CompilerRTUtils.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index 4c85551d77662..eefc466a46103 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -433,6 +433,25 @@ function(get_compiler_rt_target arch variable)
     string(REGEX REPLACE "mipsisa64" "mipsisa32" triple_cpu_mips "${triple_cpu}")
     string(REGEX REPLACE "mips64" "mips" triple_cpu_mips "${triple_cpu_mips}")
     set(target "${triple_cpu_mips}${triple_suffix_gnu}")
+  elseif("${arch}" MATCHES "^arm")
+    # Arch is arm, armhf, armv6m (anything else would come from using
+    # COMPILER_RT_DEFAULT_TARGET_ONLY, which is checked above).
+    if (${arch} STREQUAL "armhf")
+      # If we are building for hard float but our ABI is soft float.
+      if ("${triple_suffix}" MATCHES ".*eabi$")
+        # Change "eabi" -> "eabihf"
+        set(triple_suffix "${triple_suffix}hf")
+      endif()
+      # ABI is already set in the triple, don't repeat it in the architecture.
+      set(arch "arm")
+    else ()
+      # If we are building for soft float, but the triple's ABI is hard float.
+      if ("${triple_suffix}" MATCHES ".*eabihf$")
+        # Change "eabihf" -> "eabi"
+        string(REGEX REPLACE "hf$" "" triple_suffix "${triple_suffix}")
+      endif()
+    endif()
+    set(target "${arch}${triple_suffix}")
   else()
     set(target "${arch}${triple_suffix}")
   endif()


        


More information about the llvm-branch-commits mailing list