Skip to content

Commit 870fbf8

Browse files
committed
[FLANG] Fix MSVC + clang-cl build
Flang build on windows with MSVC environment and clang-cl compiler requires clang_rt.builtin.${target} library. This patch allows us to locate and include this link library. This is mostly needed for flang runtime and associated unittests. Clang implicitly uses this library while calling lld-link via clang driver however a standalone call to lld-link doesnt link against clang_rt library on its own. Differential Revision: https://reviews.llvm.org/D137112
1 parent c49db59 commit 870fbf8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

flang/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ endif()
3838
# Must go below project(..)
3939
include(GNUInstallDirs)
4040

41+
# MSVC + clang-cl build requires clang_rt.builtin.${target} library
42+
if (MSVC)
43+
include(HandleCompilerRT)
44+
find_compiler_rt_library(builtins CLANG_RT_BUILTINS_LIBRARY)
45+
get_filename_component(LIBDIR "${CLANG_RT_BUILTINS_LIBRARY}" DIRECTORY)
46+
if (IS_DIRECTORY "${LIBDIR}")
47+
link_libraries(${CLANG_RT_BUILTINS_LIBRARY})
48+
endif()
49+
endif()
50+
4151
if (FLANG_STANDALONE_BUILD)
4252
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
4353
if (NOT MSVC_IDE)

0 commit comments

Comments
 (0)