Skip to content

Commit 6093af9

Browse files
committed
Fix CufRuntime to static version
1 parent 5b79a19 commit 6093af9

File tree

3 files changed

+14
-42
lines changed

3 files changed

+14
-42
lines changed

flang-rt/cmake/modules/AddFlangRTOffload.cmake

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
macro(enable_cuda_compilation name files)
1010
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
11-
if (BUILD_SHARED_LIBS)
12-
message(FATAL_ERROR
13-
"BUILD_SHARED_LIBS is not supported for CUDA build of Fortran runtime"
14-
)
15-
endif()
16-
1711
enable_language(CUDA)
1812

1913
# TODO: figure out how to make target property CUDA_SEPARABLE_COMPILATION
@@ -70,12 +64,6 @@ macro(enable_omp_offload_compilation name files)
7064
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
7165
# OpenMP offload build only works with Clang compiler currently.
7266

73-
if (BUILD_SHARED_LIBS)
74-
message(FATAL_ERROR
75-
"BUILD_SHARED_LIBS is not supported for OpenMP offload build of Fortran runtime"
76-
)
77-
endif()
78-
7967
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND
8068
"${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
8169

flang-rt/lib/flang_rt/CUDA/CMakeLists.txt

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
#
77
#===------------------------------------------------------------------------===#
88

9-
# libCufRuntime depends on a certain version of CUDA. To be able to have
10-
# multiple build of this library with different CUDA version, the version is
11-
# added to the library name.
12-
set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
139

14-
add_flangrt_library(${CUFRT_LIBNAME}
10+
add_flangrt_library(CufRuntime STATIC
1511
allocatable.cpp
1612
allocator.cpp
1713
descriptor.cpp
@@ -20,21 +16,19 @@ add_flangrt_library(${CUFRT_LIBNAME}
2016
memory.cpp
2117
registration.cpp
2218
)
23-
target_include_directories(${CUFRT_LIBNAME} PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
2419

25-
if (BUILD_SHARED_LIBS)
26-
set(CUDA_RT_TARGET CUDA::cudart)
27-
else()
28-
set(CUDA_RT_TARGET CUDA::cudart_static)
29-
endif()
30-
31-
target_link_libraries(${CUFRT_LIBNAME}
32-
PRIVATE
33-
flang_rt
34-
${CUDA_RT_TARGET}
20+
# libCufRuntime depends on a certain version of CUDA. To be able to have
21+
# multiple build of this library with different CUDA version, the version is
22+
# added to the library name.
23+
set_target_properties(CufRuntime
24+
PROPERTIES
25+
OUTPUT_NAME "CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}"
3526
)
3627

37-
# Phony build target that does not include the CUDA version.
38-
add_custom_target(CufRuntime)
39-
add_dependencies(CufRuntime ${CUFRT_LIBNAME})
28+
target_include_directories(CufRuntime PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
4029

30+
target_link_libraries(CufRuntime
31+
PUBLIC
32+
flang_rt
33+
CUDA::cudart_static
34+
)

flang-rt/unittests/Runtime/CUDA/CMakeLists.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,7 @@ add_flangrt_unittest(FlangCufRuntimeTests
1212
Memory.cpp
1313
)
1414

15-
if (BUILD_SHARED_LIBS)
16-
set(CUDA_RT_TARGET CUDA::cudart)
17-
else()
18-
set(CUDA_RT_TARGET CUDA::cudart_static)
19-
endif()
20-
2115
target_link_libraries(FlangCufRuntimeTests
2216
PRIVATE
23-
${CUDA_RT_TARGET}
24-
CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
25-
flang_rt.unittest
17+
CufRuntime
2618
)
27-
28-
target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})

0 commit comments

Comments
 (0)