[llvm-branch-commits] [compiler-rt] 550c750 - Add support for building compiler-rt for bare metal.

Konstantin Schwarz via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 9 08:37:41 PDT 2021


Author: Konstantin Schwarz
Date: 2019-01-17T12:15:24+01:00
New Revision: 550c750e922efcd0960498f876b28de71eb1657b

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

LOG: Add support for building compiler-rt for bare metal.

Added: 
    

Modified: 
    compiler-rt/cmake/builtin-config-ix.cmake
    compiler-rt/lib/builtins/CMakeLists.txt
    compiler-rt/lib/builtins/int_util.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake
index a5704e5fed537..17311bcd8661a 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -23,8 +23,8 @@ int foo(int x, int y) {
 ")
 
 
-set(ARM64 aarch64)
-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k)
+set(ARM64 aarch64 aarch64v8a)
+set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv8r armv8a)
 set(HEXAGON hexagon)
 set(X86 i386)
 set(X86_64 x86_64)

diff  --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 82332967b1047..7a1b74d0c7e0e 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -207,11 +207,11 @@ if (HAVE_UNWIND_H)
       gcc_personality_v0.c)
 endif ()
 
-if (NOT FUCHSIA)
-  set(GENERIC_SOURCES
-    ${GENERIC_SOURCES}
-    clear_cache.c)
-endif()
+#if (NOT FUCHSIA)
+#  set(GENERIC_SOURCES
+#    ${GENERIC_SOURCES}
+#    clear_cache.c)
+#endif()
 
 # These sources work on all x86 variants, but only x86 variants.
 set(x86_ARCH_SOURCES
@@ -394,11 +394,18 @@ set(arm_Thumb1_VFPv2_SOURCES
   arm/unordsf2vfp.S)
 set(arm_Thumb1_icache_SOURCES
   arm/sync_synchronize.S)
-set(arm_Thumb1_SOURCES
-  ${arm_Thumb1_JT_SOURCES}
-  ${arm_Thumb1_SjLj_EH_SOURCES}
-  ${arm_Thumb1_VFPv2_SOURCES}
-  ${arm_Thumb1_icache_SOURCES})
+
+if(APPLE)
+  set(arm_Thumb1_SOURCES
+    ${arm_Thumb1_JT_SOURCES}
+    ${arm_Thumb1_SjLj_EH_SOURCES}
+    ${arm_Thumb1_VFPv2_SOURCES}
+    ${arm_Thumb1_icache_SOURCES})
+else()
+  set(arm_Thumb1_SOURCES
+    ${arm_Thumb1_JT_SOURCES}
+    ${arm_Thumb1_icache_SOURCES})
+endif()
 
 if(MINGW)
   set(arm_SOURCES
@@ -453,6 +460,12 @@ set(armhf_SOURCES ${arm_SOURCES})
 set(armv7_SOURCES ${arm_SOURCES})
 set(armv7s_SOURCES ${arm_SOURCES})
 set(armv7k_SOURCES ${arm_SOURCES})
+
+set(armv8a_SOURCES ${arm_SOURCES})
+set(armv8r_SOURCES ${arm_SOURCES})
+
+set(aarch64v8a_SOURCES ${aarch64_SOURCES})
+
 set(arm64_SOURCES ${aarch64_SOURCES})
 
 # macho_embedded archs
@@ -565,8 +578,13 @@ else ()
         set(_arch "arm|armv6m")
       elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
         set(_arch "arm")
+      elseif("${arch}" MATCHES "^(armv8a|armv8r)$")
+        set(_arch "arm")
+      elseif("${arch}" MATCHES "^(aarch64v8a)$")
+        set(_arch "aarch64")
       endif()
 
+      message(WARNING "supposed to work for target: " ${arch})
       # For ARM archs, exclude any VFP builtins if VFP is not supported
       if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
         string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")
@@ -589,8 +607,9 @@ else ()
 
       # Needed for clear_cache on debug mode, due to r7's usage in inline asm.
       # Release mode already sets it via -O2/3, Debug mode doesn't.
+      set(BUILTIN_HF_CFLAGS "")
       if (${arch} STREQUAL "armhf")
-        list(APPEND BUILTIN_CFLAGS -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
+        list(APPEND BUILTIN_HF_CFLAGS -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
       endif()
 
       # For RISCV32, we must force enable int128 for compiling long
@@ -604,7 +623,7 @@ else ()
                               ARCHS ${arch}
                               SOURCES ${${arch}_SOURCES}
                               DEFS ${BUILTIN_DEFS}
-                              CFLAGS ${BUILTIN_CFLAGS}
+                              CFLAGS ${BUILTIN_CFLAGS} ${BUILTIN_HF_CFLAGS}
                               PARENT_TARGET builtins)
     endif ()
   endforeach ()

diff  --git a/compiler-rt/lib/builtins/int_util.c b/compiler-rt/lib/builtins/int_util.c
index de87410dbca28..b7e6a1c90741f 100644
--- a/compiler-rt/lib/builtins/int_util.c
+++ b/compiler-rt/lib/builtins/int_util.c
@@ -45,7 +45,7 @@ void compilerrt_abort_impl(const char *file, int line, const char *function) {
   __assert_rtn(function, file, line, "libcompiler_rt abort");
 }
 
-#elif __Fuchsia__
+#elif 1
 
 #ifndef _WIN32
 __attribute__((weak))


        


More information about the llvm-branch-commits mailing list