[compiler-rt] 45368c7 - [compiler-rt][builtins] Skip building (b)float16 support on i386-freebsd

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 22 13:17:09 PST 2023


Author: Dimitry Andric
Date: 2023-01-22T22:16:51+01:00
New Revision: 45368c75582f0bded1f06d5c82c1f2ee023fb186

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

LOG: [compiler-rt][builtins] Skip building (b)float16 support on i386-freebsd

Since bfloat16 and float16 support is not available for i386-freebsd,
the `truncdfbf2.c` and `truncsfbf2.c` builtin sources should be skipped
when targeting that platform, and `COMPILER_RT_HAS_FLOAT16` should not
be defined.

However, the CMake configuration stage runs its tests with the default
target, which normally is amd64-freebsd, so it will detect both bfloat16
and float16 support.

Move adding of the `COMPILER_RT_HAS_FLOAT16` define to the `foreach()`
loop where all the supported architectures are handled, and do not
enable it when targeting i386-freebsd.

Also remove the bfloat16 sources from the `i386_SOURCES` list, when
targeting i386-freebsd.

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

Added: 
    

Modified: 
    compiler-rt/lib/builtins/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 5e2274d522560..d18b82fc6299c 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -192,11 +192,14 @@ set(GENERIC_SOURCES
 
 # Build BF16 files only when "__bf16" is available.
 if(COMPILER_RT_HAS_BFLOAT16 AND NOT APPLE)
-  set(GENERIC_SOURCES
-    ${GENERIC_SOURCES}
+  set(GENERIC_BF_SOURCES
     truncdfbf2.c
     truncsfbf2.c
   )
+  set(GENERIC_SOURCES
+    ${GENERIC_SOURCES}
+    ${GENERIC_BF_SOURCES}
+  )
 endif()
 
 # TODO: Several "tf" files (and divtc3.c, but not multc3.c) are in
@@ -369,6 +372,11 @@ if (NOT MSVC)
       i386/chkstk2.S
     )
   endif()
+
+  if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+    # Do not build bfloat16 sources i386-freebsd, as it is not supported.
+    list(REMOVE_ITEM i386_SOURCES ${GENERIC_BF_SOURCES})
+  endif()
 else () # MSVC
   # Use C versions of functions when building on MSVC
   # MSVC's assembler takes Intel syntax, not AT&T syntax.
@@ -747,8 +755,6 @@ else ()
     append_list_if(COMPILER_RT_ENABLE_CET -fcf-protection=full BUILTIN_CFLAGS)
   endif()
 
-  append_list_if(COMPILER_RT_HAS_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 BUILTIN_CFLAGS)
-
   append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
 
   # These flags would normally be added to CMAKE_C_FLAGS by the llvm
@@ -825,6 +831,11 @@ else ()
         set(deps_aarch64 lse_builtin_symlinks)
       endif()
 
+      # Do not enable float16 on i386-freebsd, as it is not supported.
+      if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" AND ${arch} STREQUAL "i386"))
+        append_list_if(COMPILER_RT_HAS_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 BUILTIN_CFLAGS)
+      endif()
+
       add_compiler_rt_runtime(clang_rt.builtins
                               STATIC
                               ARCHS ${arch}


        


More information about the llvm-commits mailing list