Skip to content

Enable building 16 bit floating point builtins in apple platforms if supported by the compiler #84192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function(darwin_get_toolchain_supported_archs output_var)
message(WARNING "Detecting supported architectures from 'ld -v' failed. Returning default set.")
set(ARCHES "i386;x86_64;armv7;armv7s;arm64")
endif()

set(${output_var} ${ARCHES} PARENT_SCOPE)
endfunction()

Expand Down Expand Up @@ -135,7 +134,7 @@ function(darwin_test_archs os valid_archs)
endif()
endif()

# The simple program will build for x86_64h on the simulator because it is
# The simple program will build for x86_64h on the simulator because it is
# compatible with x86_64 libraries (mostly), but since x86_64h isn't actually
# a valid or useful architecture for the iOS simulator we should drop it.
if(${os} MATCHES "^(iossim|tvossim|watchossim)$")
Expand All @@ -154,7 +153,7 @@ function(darwin_test_archs os valid_archs)

set(working_archs)
foreach(arch ${archs})

set(arch_linker_flags "-arch ${arch} ${os_linker_flags}")
if(TEST_COMPILE_ONLY)
# `-w` is used to surpress compiler warnings which `try_compile_only()` treats as an error.
Expand Down Expand Up @@ -269,7 +268,7 @@ function(darwin_find_excluded_builtins_list output_var)
${DARWIN_EXCLUDE_DIR}/${LIB_OS}${smallest_version}-${LIB_ARCH}.txt)
endif()
endif()

set(${output_var}
${${LIB_ARCH}_${LIB_OS}_BUILTINS}
${${LIB_OS}_${LIB_ARCH}_BASE_BUILTINS}
Expand Down Expand Up @@ -447,7 +446,15 @@ macro(darwin_add_builtin_libraries)
OS ${os}
ARCH ${arch}
MIN_VERSION ${DARWIN_${os}_BUILTIN_MIN_VER})

check_c_source_compiles("_Float16 foo(_Float16 x) { return x; }"
COMPILER_RT_HAS_${arch}_FLOAT16)
append_list_if(COMPILER_RT_HAS_${arch}_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 BUILTIN_CFLAGS_${arch})
check_c_source_compiles("__bf16 foo(__bf16 x) { return x; }"
COMPILER_RT_HAS_${arch}_BFLOAT16)
# Build BF16 files only when "__bf16" is available.
if(COMPILER_RT_HAS_${arch}_BFLOAT16)
list(APPEND ${arch}_SOURCES ${BF16_SOURCES})
endif()
darwin_filter_builtin_sources(filtered_sources
${os}_${arch}
EXCLUDE ${arch}_${os}_EXCLUDED_BUILTINS
Expand Down Expand Up @@ -548,7 +555,7 @@ macro(darwin_add_embedded_builtin_libraries)
${COMPILER_RT_OUTPUT_LIBRARY_DIR}/macho_embedded)
set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
${COMPILER_RT_INSTALL_LIBRARY_DIR}/macho_embedded)

set(CFLAGS_armv7 -target thumbv7-apple-darwin-eabi)
set(CFLAGS_i386 -march=pentium)

Expand Down