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

Leandro Lupori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 09:00:06 PST 2023


luporl created this revision.
luporl added reviewers: DavidSpickett, phosek, MaskRay.
luporl added a project: Sanitizers.
Herald added subscribers: Enna1, kristof.beyls, dberris.
Herald added a reviewer: bollu.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
luporl requested review of this revision.

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.

The cmake command that caused the build failure was:

  cmake --fresh -S "$PWD/llvm/" -B "$PWD/build/" -G Ninja \
    -DCMAKE_INSTALL_PREFIX="$PWD/install" \
    -DCMAKE_BUILD_TYPE=Release \
    -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;clang-tools-extra;polly" \
    -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
    -DLLVM_TOOLCHAIN_TOOLS="llvm-ar;llvm-ranlib;llvm-objdump;\
  llvm-rc;llvm-cvtres;llvm-nm;llvm-strings;llvm-readobj;\
  llvm-dlltool;llvm-pdbutil;llvm-objcopy;llvm-strip;llvm-cov;\
  llvm-profdata;llvm-addr2line;llvm-symbolizer;llvm-windres;llvm-ml;\
  llvm-readelf;llvm-size" \
    -DLLVM_INSTALL_BINUTILS_SYMLINKS=OFF -DLLVM_PARALLEL_LINK_JOBS=1

The fix was extracted from D140011 <https://reviews.llvm.org/D140011>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142906

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


Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -433,6 +433,25 @@
     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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142906.493327.patch
Type: text/x-patch
Size: 1388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230130/3613b2f6/attachment.bin>


More information about the llvm-commits mailing list