[flang-commits] [flang] 42e89ab - [flang] Fix CMake bug in the definition of flang-new

Andrzej Warzynski via flang-commits flang-commits at lists.llvm.org
Wed Oct 14 11:25:06 PDT 2020


Author: Andrzej Warzynski
Date: 2020-10-14T19:24:10+01:00
New Revision: 42e89ab2a668c80449a13210f07a50fe0370e99d

URL: https://github.com/llvm/llvm-project/commit/42e89ab2a668c80449a13210f07a50fe0370e99d
DIFF: https://github.com/llvm/llvm-project/commit/42e89ab2a668c80449a13210f07a50fe0370e99d.diff

LOG: [flang] Fix CMake bug in the definition of flang-new

Recent patch that improved Flang's compatibility with respect to how LLVM
dynamic libraries should be linked (and specified in CMake recipes),
introduced a bug in the definition of `flang-new`:
  * https://reviews.llvm.org/D87893
More specifically, `add_flang_tool` does not support the
`LINK_COMPONENTS` CMake argument.  Instead, one should set
`LLVM_LINK_COMPONENTS` before calling `add_flang_tool`.

This patch reverts the change for `flang-new` from
https://reviews.llvm.org/D87893, and instead:
  * sets `LLVM_LINK_COMPONENTS`
  * calls `clang_target_link_libraries` to add Clang dependencies

Differential Revision: https://reviews.llvm.org/D89403

Added: 
    

Modified: 
    flang/CMakeLists.txt
    flang/tools/flang-driver/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 2e6c5f1bd297..a73655baffe8 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -82,6 +82,10 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
 
+  if(FLANG_BUILD_NEW_DRIVER)
+    include(AddClang)
+  endif()
+
   if(LINK_WITH_FIR)
     include(TableGen)
     find_package(MLIR REQUIRED CONFIG)

diff  --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index d4bbe2339fde..35b598aa60a4 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -4,23 +4,25 @@
 # Set your project compile flags.
 link_directories(${LLVM_LIBRARY_DIR})
 
+set( LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Option
+  Support
+)
+
 add_flang_tool(flang-new
   driver.cpp
   fc1_main.cpp
-
-  LINK_COMPONENTS
-
-  ${LLVM_COMMON_COMPONENTS}
-  Support
-  Target
-  Option
 )
 
-# Link against LLVM and Clang libraries
 target_link_libraries(flang-new
   PRIVATE
   flangFrontend
   flangFrontendTool
+)
+
+clang_target_link_libraries(flang-new
+  PRIVATE
   clangDriver
   clangBasic
   clangFrontend


        


More information about the flang-commits mailing list