[flang-commits] [flang] 870fbf8 - [FLANG] Fix MSVC + clang-cl build

Muhammad Omair Javaid via flang-commits flang-commits at lists.llvm.org
Wed Nov 2 01:35:20 PDT 2022


Author: Muhammad Omair Javaid
Date: 2022-11-02T12:32:21+04:00
New Revision: 870fbf8e300f3012470593ac087219a04d52857f

URL: https://github.com/llvm/llvm-project/commit/870fbf8e300f3012470593ac087219a04d52857f
DIFF: https://github.com/llvm/llvm-project/commit/870fbf8e300f3012470593ac087219a04d52857f.diff

LOG: [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

Added: 
    

Modified: 
    flang/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index eff8560c65ba..41c4de3c9dc5 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)


        


More information about the flang-commits mailing list