Skip to content

Commit 55a82e6

Browse files
committed
Dependency fix
1 parent 51cfcec commit 55a82e6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

flang-rt/cmake/modules/AddFlangRTOffload.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ macro(enable_omp_offload_compilation name files)
105105
set_source_files_properties(${files}
106106
PROPERTIES COMPILE_DEFINITIONS OMP_OFFLOAD_BUILD
107107
)
108+
109+
# If building flang-rt together with libomp, ensure that libomp is built first and found because -fopenmp will try to link it.
110+
if (TARGET omp)
111+
add_dependencies(${name} omp)
112+
target_link_options(${name}.static PUBLIC "-L$<TARGET_FILE_DIR:omp>")
113+
#target_link_libraries(${name}.static PRIVATE omp)
114+
endif ()
108115
else()
109116
message(FATAL_ERROR
110117
"Flang-rt build with OpenMP offload is not supported for these compilers:\n"

flang-rt/unittests/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ function(add_flangrt_unittest_offload_properties target)
5353
# FIXME: replace 'native' in --offload-arch option with the list
5454
# of targets that Fortran Runtime was built for.
5555
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
56-
set_target_properties(${target}
57-
PROPERTIES LINK_OPTIONS
58-
"-fopenmp;--offload-arch=native"
59-
)
56+
set_property(TARGET ${target} APPEND
57+
PROPERTY LINK_OPTIONS "-fopenmp;--offload-arch=native"
58+
)
6059
endif()
6160
endfunction()
6261

0 commit comments

Comments
 (0)