@@ -67,68 +67,17 @@ include(GetToolchainDirs)
6767include (FlangCommon)
6868include (HandleCompilerRT)
6969include (ExtendPath)
70+ include (CheckFortranSourceCompiles)
71+ include (CMakePushCheckState)
7072
7173
7274############################
7375# Build Mode Introspection #
7476############################
7577
76- # Determine whether we are in the runtimes/runtimes-bins directory of a
77- # bootstrap build.
78- set (LLVM_TREE_AVAILABLE OFF )
79- if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION )
80- set (LLVM_TREE_AVAILABLE ON )
81- endif ()
82-
8378# Path to LLVM development tools (FileCheck, llvm-lit, not, ...)
8479set (LLVM_TOOLS_DIR "${LLVM_BINARY_DIR} /bin" )
8580
86- # Determine build and install paths.
87- # The build path is absolute, but the install dir is relative, CMake's install
88- # command has to apply CMAKE_INSTALL_PREFIX itself.
89- get_toolchain_library_subdir(toolchain_lib_subdir)
90- if (LLVM_TREE_AVAILABLE)
91- # In a bootstrap build emit the libraries into a default search path in the
92- # build directory of the just-built compiler. This allows using the
93- # just-built compiler without specifying paths to runtime libraries.
94- #
95- # Despite Clang in the name, get_clang_resource_dir does not depend on Clang
96- # being added to the build. Flang uses the same resource dir as clang.
97- include (GetClangResourceDir)
98- get_clang_resource_dir(FLANG_RT_OUTPUT_RESOURCE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR} /.." )
99- get_clang_resource_dir(FLANG_RT_INSTALL_RESOURCE_PATH_DEFAULT)
100-
101- extend_path(FLANG_RT_OUTPUT_RESOURCE_LIB_DIR "${FLANG_RT_OUTPUT_RESOURCE_DIR} " "${toolchain_lib_subdir} " )
102- else ()
103- # In a standalone runtimes build, do not write into LLVM_BINARY_DIR. It may be
104- # read-only and/or shared by multiple runtimes with different build
105- # configurations (e.g. Debug/Release). Use the runtime's own lib dir like any
106- # non-toolchain library.
107- # For the install prefix, still use the resource dir assuming that Flang will
108- # be installed there using the same prefix. This is to not have a difference
109- # between bootstrap and standalone runtimes builds.
110- set (FLANG_RT_OUTPUT_RESOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
111- set (FLANG_RT_INSTALL_RESOURCE_PATH_DEFAULT "lib${LLVM_LIBDIR_SUFFIX} /clang/${LLVM_VERSION_MAJOR} " )
112-
113- extend_path(FLANG_RT_OUTPUT_RESOURCE_LIB_DIR "${FLANG_RT_OUTPUT_RESOURCE_DIR} " "lib${LLVM_LIBDIR_SUFFIX} " )
114- endif ()
115- set (FLANG_RT_INSTALL_RESOURCE_PATH "${FLANG_RT_INSTALL_RESOURCE_PATH_DEFAULT} "
116- CACHE PATH "Path to install runtime libraries to (default: clang resource dir)" )
117- extend_path(FLANG_RT_INSTALL_RESOURCE_LIB_PATH "${FLANG_RT_INSTALL_RESOURCE_PATH} " "${toolchain_lib_subdir} " )
118- cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_DIR)
119- cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_PATH)
120- # FIXME: For the libflang_rt.so, the toolchain resource lib dir is not a good
121- # destination because it is not a ld.so default search path.
122- # The machine where the executable is eventually executed may not be the
123- # machine where the Flang compiler and its resource dir is installed, so
124- # setting RPath by the driver is not an solution. It should belong into
125- # /usr/lib/<triple>/libflang_rt.so, like e.g. libgcc_s.so.
126- # But the linker as invoked by the Flang driver also requires
127- # libflang_rt.so to be found when linking and the resource lib dir is
128- # the only reliable location.
129- cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_LIB_DIR)
130- cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH)
131-
13281
13382#################
13483# Build Options #
@@ -243,6 +192,22 @@ check_cxx_source_compiles(
243192 "
244193 HAVE_DECL_STRERROR_S)
245194
195+ include (CheckFortranSourceCompiles)
196+ include (CMakePushCheckState)
197+ cmake_push_check_state(RESET)
198+ set (CMAKE_REQUIRED_FLAGS "-ffree-form" )
199+ set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
200+ check_fortran_source_compiles([[
201+ subroutine test_quadmath
202+ real(16) :: var1
203+ end
204+ ]]
205+ FORTRAN_SUPPORTS_REAL16
206+ )
207+ cmake_pop_check_state()
208+
209+ flang_module_fortran_enable()
210+
246211# Search for clang_rt.builtins library. Need in addition to msvcrt.
247212if (WIN32 )
248213 find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY)
@@ -338,4 +303,4 @@ if (FLANG_RT_INCLUDE_TESTS)
338303 add_subdirectory (unittests)
339304else ()
340305 add_custom_target (check-flang-rt)
341- endif ()
306+ endif ()
0 commit comments