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

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 09:48:43 PDT 2020


awarzynski created this revision.
Herald added subscribers: llvm-commits, mgorny.
Herald added a reviewer: sscalpone.
Herald added a project: LLVM.
awarzynski requested review of this revision.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89403

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


Index: flang/tools/flang-driver/CMakeLists.txt
===================================================================
--- flang/tools/flang-driver/CMakeLists.txt
+++ flang/tools/flang-driver/CMakeLists.txt
@@ -4,26 +4,26 @@
 # 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
 )
-
-install(TARGETS flang-new DESTINATION bin)
Index: flang/CMakeLists.txt
===================================================================
--- flang/CMakeLists.txt
+++ flang/CMakeLists.txt
@@ -82,6 +82,10 @@
   include(HandleLLVMOptions)
   include(VersionFromVCS)
 
+  if(FLANG_BUILD_NEW_DRIVER)
+    include(AddClang)
+  endif()
+
   if(LINK_WITH_FIR)
     include(TableGen)
     find_package(MLIR REQUIRED CONFIG)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89403.298170.patch
Type: text/x-patch
Size: 1169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201014/f8a1474c/attachment.bin>


More information about the llvm-commits mailing list