Skip to content

Commit cf4cbcb

Browse files
committed
Big Cleanup
1 parent fae4276 commit cf4cbcb

File tree

16 files changed

+155
-309
lines changed

16 files changed

+155
-309
lines changed

flang-rt/CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ include(GetToolchainDirs)
6767
include(FlangCommon)
6868
include(HandleCompilerRT)
6969
include(ExtendPath)
70+
include(CheckFortranSourceCompiles)
71+
include(CMakePushCheckState)
7072

7173

7274
############################
@@ -76,8 +78,6 @@ include(ExtendPath)
7678
# Path to LLVM development tools (FileCheck, llvm-lit, not, ...)
7779
set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin")
7880

79-
flang_module_fortran_enable()
80-
8181

8282
#################
8383
# Build Options #
@@ -192,6 +192,22 @@ check_cxx_source_compiles(
192192
"
193193
HAVE_DECL_STRERROR_S)
194194

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+
195211
# Search for clang_rt.builtins library. Need in addition to msvcrt.
196212
if (WIN32)
197213
find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY)
@@ -287,4 +303,4 @@ if (FLANG_RT_INCLUDE_TESTS)
287303
add_subdirectory(unittests)
288304
else ()
289305
add_custom_target(check-flang-rt)
290-
endif()
306+
endif()

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,14 @@
3030
# May specify header files for IDE generators.
3131
# INCLUDE_DIRECTORIES
3232
# Additional target_include_directories for all added targets
33-
# COMPILE_OPTIONS
34-
# Set target compile options of all added targets
3533
# LINK_LIBRARIES
3634
# Additional target_link_libraries for all added targets
3735
# TARGET_PROPERTIES
3836
# Set target properties of all added targets
3937
# )
4038
function (add_flangrt_library name)
4139
set(options STATIC SHARED OBJECT INSTALL_WITH_TOOLCHAIN EXCLUDE_FROM_ALL LINK_TO_LLVM)
42-
set(multiValueArgs ADDITIONAL_HEADERS INCLUDE_DIRECTORIES COMPILE_OPTIONS LINK_LIBRARIES TARGET_PROPERTIES)
40+
set(multiValueArgs ADDITIONAL_HEADERS INCLUDE_DIRECTORIES LINK_LIBRARIES TARGET_PROPERTIES)
4341
cmake_parse_arguments(ARG
4442
"${options}"
4543
""
@@ -290,8 +288,8 @@ function (add_flangrt_library name)
290288
# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
291289
# build, to avoid an unwanted dependency on libstdc++/libc++.so.
292290
if (FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
293-
target_compile_options(${tgtname} PUBLIC "$<$<COMPILE_LANGUAGE:C,CXX>:-U_GLIBCXX_ASSERTIONS>")
294-
target_compile_options(${tgtname} PUBLIC "$<$<COMPILE_LANGUAGE:C,CXX>:-U_LIBCPP_ENABLE_ASSERTIONS>")
291+
target_compile_options(${tgtname} PUBLIC -U_GLIBCXX_ASSERTIONS)
292+
target_compile_options(${tgtname} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
295293
endif ()
296294

297295
# Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
@@ -301,12 +299,12 @@ function (add_flangrt_library name)
301299
# dependency to Compiler-RT's builtin library where these are implemented.
302300
if (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
303301
if (FLANG_RT_BUILTINS_LIBRARY)
304-
#target_compile_options(${tgtname} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>" "$<$<COMPILE_LANGUAGE:CXX,C>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
302+
target_compile_options(${tgtname} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>" "$<$<COMPILE_LANGUAGE:CXX,C>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
305303
endif ()
306304
endif ()
307305
if (MSVC AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
308306
if (FLANG_RT_BUILTINS_LIBRARY)
309-
#target_compile_options(${tgtname} PRIVATE "$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "$<$<COMPILE_LANGUAGE:Fortran>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
307+
target_compile_options(${tgtname} PRIVATE "$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "$<$<COMPILE_LANGUAGE:Fortran>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
310308
else ()
311309
message(WARNING "Did not find libclang_rt.builtins.lib.
312310
LLVM may emit builtins that are not implemented in msvcrt/ucrt and
@@ -335,18 +333,6 @@ function (add_flangrt_library name)
335333
endif ()
336334
endforeach ()
337335

338-
message("${name} RUNTIMES_OUTPUT_RESOURCE_MOD_DIR: ${RUNTIMES_OUTPUT_RESOURCE_MOD_DIR}")
339-
foreach (tgtname IN LISTS srctargets)
340-
set_target_properties(${tgtname}
341-
PROPERTIES
342-
Fortran_MODULE_DIRECTORY "${RUNTIMES_OUTPUT_RESOURCE_MOD_DIR}"
343-
)
344-
345-
target_compile_options(${tgtname} PRIVATE ${ARG_COMPILE_OPTIONS})
346-
endforeach ()
347-
348-
349-
350336
foreach (tgtname IN LISTS libtargets)
351337
# If this is part of the toolchain, put it into the compiler's resource
352338
# directory. Otherwise it is part of testing and is not installed at all.

0 commit comments

Comments
 (0)