Skip to content

Commit

Permalink
[FLANG] Fix MSVC + clang-cl build
Browse files Browse the repository at this point in the history
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
  • Loading branch information
omjavaid committed Nov 2, 2022
1 parent c49db59 commit 870fbf8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions flang/CMakeLists.txt
Expand Up @@ -38,6 +38,16 @@ endif()
# Must go below project(..)
include(GNUInstallDirs)

# MSVC + clang-cl build requires clang_rt.builtin.${target} library
if (MSVC)
include(HandleCompilerRT)
find_compiler_rt_library(builtins CLANG_RT_BUILTINS_LIBRARY)
get_filename_component(LIBDIR "${CLANG_RT_BUILTINS_LIBRARY}" DIRECTORY)
if (IS_DIRECTORY "${LIBDIR}")
link_libraries(${CLANG_RT_BUILTINS_LIBRARY})
endif()
endif()

if (FLANG_STANDALONE_BUILD)
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if (NOT MSVC_IDE)
Expand Down

0 comments on commit 870fbf8

Please sign in to comment.