Skip to content

Commit

Permalink
Float128Math support
Browse files Browse the repository at this point in the history
  • Loading branch information
Meinersbur committed Oct 3, 2024
1 parent 871c690 commit c42127f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
7 changes: 7 additions & 0 deletions FortranRuntime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ check_cxx_source_compiles(
"
HAVE_DECL_STRERROR_S)


# Search for clang_rt.builtins
execute_process(
COMMAND "${CMAKE_CXX_COMPILER}" "-print-libgcc-file-name" "-rtlib=compiler-rt"
RESULT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE
OUTPUT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT
ERROR_QUIET
)
if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FORTRANRUNTIME_LIBCALL)
Expand All @@ -111,6 +113,11 @@ endif ()
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)

# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
# to avoid an unwanted dependency on libstdc++/libc++.so.
add_definitions(-U_GLIBCXX_ASSERTIONS)
add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)

configure_file(cmake/config.h.cmake.in config.h)


Expand Down
5 changes: 0 additions & 5 deletions FortranRuntime/cmake/modules/AddFortranRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ function (add_fortranruntime_library name)
# For configured config.h for be found
target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}")

# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
# to avoid an unwanted dependency on libstdc++/libc++.so.
target_compile_definitions(${name} PRIVATE -U_GLIBCXX_ASSERTIONS)
target_compile_definitions(${name} PRIVATE -U_LIBCPP_ENABLE_ASSERTIONS)

# Clang/Flang, targeting the MSVC ABI, including clang-cl, should only depends on msv(u)crt. LLVM still emits libgcc/compiler-rt functions for 128-bit integer math (__udivti3, __modti3, __fixsfti, __floattidf, ...) that msvc does not support.
# We are injecting a dependency to Compiler-RT where these are implemented.
if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FORTRANRUNTIME_LIBCALL)
Expand Down
5 changes: 5 additions & 0 deletions FortranRuntime/lib/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ file(GLOB_RECURSE private_headers
"${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
)




get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
)
Expand All @@ -106,6 +109,8 @@ if (f128_sources)
list(APPEND sources ${f128_sources})
endif()



if (NOT DEFINED WIN32)
add_fortranruntime_library(FortranRuntime STATIC
${sources}
Expand Down
29 changes: 11 additions & 18 deletions FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===-- lib/Runtime/Float128Math/CMakeLists.txt -----------------------------===#
#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
Expand All @@ -15,6 +15,7 @@
# used for building this FortranFloat128Math library.

include(CheckLibraryExists)
include(CheckIncludeFile)

set(sources
acos.cpp
Expand Down Expand Up @@ -87,23 +88,15 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
"${FLANG_RUNTIME_F128_MATH_LIB}"
)
endif()

add_flang_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
${sources})

if (DEFINED MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_flang_library(FortranFloat128Math.static STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
add_flang_library(FortranFloat128Math.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
add_dependencies(FortranFloat128Math FortranFloat128Math.static
FortranFloat128Math.static_dbg
)
endif()

if (WIN32)
# Do not create a FortranFloat128Math library under Windows, the Flang driver never links it. Instead, add the sources to the main FortranRuntime.lib.
target_sources(FortranFloat128MathILib INTERFACE ${sources})
target_compile_definitions(FortranFloat128MathILib INTERFACE HAS_QUADMATHLIB)
else ()
add_fortranruntime_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
${sources})
endif ()
elseif (HAVE_LDBL_MANT_DIG_113)
# We can use 'long double' versions from libc.
check_library_exists(m sinl "" FOUND_LIBM)
Expand Down

0 comments on commit c42127f

Please sign in to comment.