Skip to content

Commit bc47e8a

Browse files
committed
Working on keeping FortranRuntime
1 parent ae7cc78 commit bc47e8a

File tree

9 files changed

+87
-90
lines changed

9 files changed

+87
-90
lines changed

flang-rt/unittests/Evaluate/CMakeLists.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

flang-rt/unittests/Runtime/CMakeLists.txt

Lines changed: 0 additions & 49 deletions
This file was deleted.

flang/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if (LLVM_ENABLE_EH)
2323
endif()
2424

2525
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
26+
set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang-rt")
2627

2728
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
2829
message(FATAL_ERROR "In-source builds are not allowed. \
@@ -473,7 +474,7 @@ if (FLANG_CUF_RUNTIME)
473474
find_package(CUDAToolkit REQUIRED)
474475
endif()
475476

476-
add_subdirectory(../flang-rt/lib/flang_rt runtime)
477+
add_subdirectory(runtime)
477478

478479
if (LLVM_INCLUDE_EXAMPLES)
479480
add_subdirectory(examples)

flang-rt/lib/flang_rt/CMakeLists.txt renamed to flang/runtime/CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#===-- lib/flang_rt/CMakeLists.txt -----------------------------------------===#
1+
#===-- runtime/CMakeLists.txt ----------------------------------------------===#
22
#
33
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
# See https://llvm.org/LICENSE.txt for license information.
@@ -15,7 +15,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1515
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
1616
set(CMAKE_CXX_EXTENSIONS OFF)
1717

18-
set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../flang")
18+
set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
1919

2020
set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
2121
set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
@@ -59,8 +59,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
5959
)
6060
endif()
6161

62-
include_directories(BEFORE ../../include)
63-
6462
# function checks
6563
find_package(Backtrace)
6664
set(HAVE_BACKTRACE ${Backtrace_FOUND})
@@ -96,11 +94,12 @@ else()
9694
set(NO_LTO_FLAGS "")
9795
endif()
9896

99-
configure_file(../../cmake/config.h.cmake.in config.h)
97+
configure_file("${FLANG_RT_SOURCE_DIR}/cmake/config.h.cmake.in" config.h)
10098
# include_directories is used here instead of target_include_directories
10199
# because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
102100
# with different names
103101
include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
102+
include_directories("${FLANG_RT_SOURCE_DIR}/include")
104103

105104
append(${NO_LTO_FLAGS} CMAKE_C_FLAGS)
106105
append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
@@ -110,7 +109,7 @@ append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
110109
add_definitions(-U_GLIBCXX_ASSERTIONS)
111110
add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
112111

113-
add_subdirectory(../FortranFloat128Math Float128Math)
112+
add_subdirectory(Float128Math)
114113

115114
set(sources
116115
ISO_Fortran_binding.cpp
@@ -269,6 +268,15 @@ if (NOT TARGET FortranFloat128Math)
269268
endif()
270269
endif()
271270

271+
# Relative paths are relative to Flang-RT's source dir.
272+
set(new_sources "")
273+
foreach (source IN LISTS sources)
274+
set(new_source "${FLANG_RT_SOURCE_DIR}/lib/flang_rt")
275+
cmake_path(APPEND new_source "${source}")
276+
list(APPEND new_sources "${new_source}")
277+
endforeach ()
278+
set(sources ${new_sources})
279+
272280
if (NOT DEFINED MSVC)
273281
add_flang_library(FortranRuntime
274282
${sources}

flang-rt/lib/flang_rt/CUDA/CMakeLists.txt renamed to flang/runtime/CUDA/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#===-- lib/flang_rt/CUDA/CMakeLists.txt ------------------------------------===#
1+
#===-- runtime/CUDA/CMakeLists.txt -----------------------------------------===#
22
#
33
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
# See https://llvm.org/LICENSE.txt for license information.
@@ -14,13 +14,13 @@ include_directories(${CUDAToolkit_INCLUDE_DIRS})
1414
set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
1515

1616
add_flang_library(${CUFRT_LIBNAME}
17-
allocator.cpp
18-
allocatable.cpp
19-
descriptor.cpp
20-
kernel.cpp
21-
memmove-function.cpp
22-
memory.cpp
23-
registration.cpp
17+
${FLANG_RT_SOURCE_DIR}/lib/flang_rt/CUDA/allocator.cpp
18+
${FLANG_RT_SOURCE_DIR}/lib/flang_rt/CUDA/allocatable.cpp
19+
${FLANG_RT_SOURCE_DIR}/lib/flang_rt/CUDA/descriptor.cpp
20+
${FLANG_RT_SOURCE_DIR}/lib/flang_rt/CUDA/kernel.cpp
21+
${FLANG_RT_SOURCE_DIR}/lib/flang_rt/CUDA/memmove-function.cpp
22+
${FLANG_RT_SOURCE_DIR}/lib/flang_rt/CUDA/memory.cpp
23+
${FLANG_RT_SOURCE_DIR}/lib/flang_rt/CUDA/registration.cpp
2424
)
2525

2626
if (BUILD_SHARED_LIBS)

flang-rt/lib/FortranFloat128Math/CMakeLists.txt renamed to flang/runtime/Float128Math/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#===-- lib/FortranFloat128Math/CMakeLists.txt ------------------------------===#
1+
#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===#
22
#
33
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
# See https://llvm.org/LICENSE.txt for license information.

flang/unittests/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ function(add_flang_nongtest_unittest test_name)
5656
set(suffix .test)
5757
endif()
5858

59-
add_executable(${test_name}${suffix} ${test_name}.cpp)
59+
set(test_filepath "${FLANG_RT_SOURCE_DIR}/unittests/Evaluate/${test_name}.cpp")
60+
if (NOT EXISTS "${test_filepath}")
61+
set(test_filepath "${test_name}.cpp")
62+
endif ()
63+
64+
add_executable(${test_name}${suffix} "${test_filepath}")
6065
set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang/Tests/Unit")
6166

6267
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
@@ -77,5 +82,5 @@ add_subdirectory(Optimizer)
7782
add_subdirectory(Common)
7883
add_subdirectory(Decimal)
7984
add_subdirectory(Evaluate)
80-
add_subdirectory(../../flang-rt/unittests/Runtime Runtime)
85+
add_subdirectory(Runtime)
8186
add_subdirectory(Frontend)

flang/unittests/Evaluate/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,23 @@ add_flang_nongtest_unittest(real
6969
)
7070
llvm_update_compile_flags(real.test)
7171

72+
add_flang_nongtest_unittest(reshape
73+
FortranEvaluateTesting
74+
FortranSemantics
75+
FortranEvaluate
76+
FortranRuntime
77+
)
78+
79+
add_flang_nongtest_unittest(ISO-Fortran-binding
80+
FortranEvaluateTesting
81+
FortranEvaluate
82+
FortranSemantics
83+
FortranRuntime
84+
)
85+
7286
add_flang_nongtest_unittest(folding
7387
FortranCommon
7488
FortranEvaluateTesting
7589
FortranEvaluate
7690
FortranSemantics
7791
)
78-
79-
add_subdirectory(../../../flang-rt/unittests/Evaluate runtime)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
add_flang_unittest(FlangRuntimeTests
2+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/AccessTest.cpp
3+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Allocatable.cpp
4+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/ArrayConstructor.cpp
5+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/BufferTest.cpp
6+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CharacterTest.cpp
7+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CommandTest.cpp
8+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Complex.cpp
9+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CrashHandlerFixture.cpp
10+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Derived.cpp
11+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/ExternalIOTest.cpp
12+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Format.cpp
13+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Inquiry.cpp
14+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/ListInputTest.cpp
15+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/LogicalFormatTest.cpp
16+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Matmul.cpp
17+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/MatmulTranspose.cpp
18+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/MiscIntrinsic.cpp
19+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Namelist.cpp
20+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Numeric.cpp
21+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/NumericalFormatTest.cpp
22+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Pointer.cpp
23+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Ragged.cpp
24+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Random.cpp
25+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Reduction.cpp
26+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/RuntimeCrashTest.cpp
27+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Stop.cpp
28+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Support.cpp
29+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Time.cpp
30+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/TemporaryStack.cpp
31+
${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Transformational.cpp
32+
)
33+
34+
target_link_libraries(FlangRuntimeTests
35+
PRIVATE
36+
FortranRuntime
37+
)
38+
39+
target_compile_definitions(FlangRuntimeTests PRIVATE NOT_EXE="$<TARGET_FILE:not>")
40+
41+
add_subdirectory(CUDA)

0 commit comments

Comments
 (0)