From 870fbf8e300f3012470593ac087219a04d52857f Mon Sep 17 00:00:00 2001 From: Muhammad Omair Javaid Date: Tue, 1 Nov 2022 00:53:16 +0400 Subject: [PATCH] [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 --- flang/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index eff8560..41c4de3 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -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) -- 2.7.4