Skip to content

Commit 16e33ef

Browse files
committed
Windows shared library currently not supported
1 parent a3f3a7b commit 16e33ef

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

flang-rt/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES)
190190
configure_file(cmake/config.h.cmake.in config.h)
191191

192192

193+
# The bootstrap build will create a phony target with the same as the top-level
194+
# directory ("flang-rt") and delegate it to the runtimes build dir.
195+
# AddFlangRT will add all non-EXCLUDE_FROM_ALL targets to it.
196+
add_custom_target(flang-rt)
197+
198+
193199
###################
194200
# Build Artifacts #
195201
###################

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function (add_flangrt_library name)
5151
if (ARG_OBJECT)
5252
list(APPEND extra_args OBJECT)
5353
endif ()
54-
if (EXCLUDE_FROM_ALL)
54+
if (ARG_EXCLUDE_FROM_ALL)
5555
list(APPEND extra_args EXCLUDE_FROM_ALL)
5656
endif ()
5757

@@ -130,4 +130,10 @@ function (add_flangrt_library name)
130130
RUNTIME DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
131131
)
132132
endif ()
133+
134+
# flang-rt should build all the flang-rt targets that are built in an
135+
# 'all' build.
136+
if (NOT ARG_EXCLUDE_FROM_ALL)
137+
add_dependencies(flang-rt ${name})
138+
endif ()
133139
endfunction (add_flangrt_library)

flang-rt/lib/flang_rt/CMakeLists.txt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ if (NOT WIN32)
130130
add_library(flang_rt.static ALIAS flang_rt)
131131
add_library(flang_rt.unittest ALIAS flang_rt)
132132
else()
133+
# Target for building all versions of the runtime
134+
add_custom_target(flang_rt)
135+
set_target_properties(flang_rt PROPERTIES FOLDER "Fortran Runtime/Meta")
136+
133137
function (add_win_flangrt_library libtype suffix msvc_lib)
134138
set(name "flang_rt.${suffix}")
135139
add_flangrt_library(${name} ${libtype}
@@ -149,6 +153,7 @@ else()
149153

150154
enable_cuda_compilation(${name} "${supported_sources}")
151155
enable_omp_offload_compilation(${name} "${supported_sources}")
156+
add_dependencies(flang_rt ${name})
152157
endfunction ()
153158

154159
add_win_flangrt_library(STATIC static MultiThreaded)
@@ -157,18 +162,19 @@ else()
157162
# unittests link against LLVMSupport which is compiled with /MD
158163
add_win_flangrt_library(STATIC unittest MultiThreadedDLL EXCLUDE_FROM_ALL)
159164

160-
# FIXME: Before DLL versions of the runtime can be used, exported definitions
161-
# must be annotated with __declspec(dllexport).
162-
add_win_flangrt_library(SHARED dynamic MultiThreadedDLL)
163-
add_win_flangrt_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
164-
165-
# Target for building all versions of the runtime
166-
add_custom_target(flang_rt)
167-
set_target_properties(flang_rt PROPERTIES FOLDER "Fortran Runtime/Meta")
168-
add_dependencies(flang_rt
169-
flang_rt.static
170-
flang_rt.static_dbg
171-
flang_rt.dynamic
172-
flang_rt.dynamic_dbg
173-
)
165+
# FIXME: Generating runtime DLLs is currently not possible. There are two
166+
# roadblocks:
167+
#
168+
# * Flang emits /DEFAULTLIB:flang_rt.dynamic.lib into
169+
# iso_fortran_env_impl.f90.obj. Since that file is itself part of
170+
# flang_rt.dynamic, this results in a recursive dependency when invoking
171+
# the linker.
172+
#
173+
# * The externally-visible functions must either by annotated with
174+
# __declspec(dllexport), or listed in a exports file. A possible workaround
175+
# is CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS which would also export the internal
176+
# C++ symbols.
177+
#
178+
#add_win_flangrt_library(SHARED dynamic MultiThreadedDLL)
179+
#add_win_flangrt_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
174180
endif()

flang-rt/test/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,20 @@ endif ()
4444
set(FLANGRT_TEST_DEPENDS
4545
FlangRTUnitTests
4646
flang_rt.unittest
47+
flang_rt.static
4748
)
4849

4950
add_custom_target(flang-rt-test-depends)
5051
set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
5152
add_dependencies(flang-rt-test-depends ${FLANGRT_TEST_DEPENDS})
5253

5354
add_lit_testsuite(check-flang-rt "Running the flang-rt regression tests"
54-
${CMAKE_CURRENT_BINARY_DIR}
55-
DEPENDS ${FLANGRT_TEST_DEPENDS}
56-
)
55+
${CMAKE_CURRENT_BINARY_DIR}
56+
DEPENDS flang-rt-test-depends
57+
)
5758
set_target_properties(check-flang-rt PROPERTIES FOLDER "Fortran Runtime/Meta")
5859

5960

6061
add_lit_testsuites(flang-rt ${CMAKE_CURRENT_SOURCE_DIR}
61-
DEPENDS ${FLANGRT_TEST_DEPENDS})
62+
DEPENDS flang-rt-test-depends
63+
)

0 commit comments

Comments
 (0)