Skip to content

Commit

Permalink
[flang] Remove LINK_WITH_FIR cmake switch
Browse files Browse the repository at this point in the history
Most components required for this are already there.

Build and Testing clean.
ninja check-flang

Reviewed By: clementval, tskeith

Differential Revision: https://reviews.llvm.org/D96411
  • Loading branch information
SouraVX committed Feb 11, 2021
1 parent 033b1bd commit 6a7deff
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 44 deletions.
55 changes: 23 additions & 32 deletions flang/CMakeLists.txt
Expand Up @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.13.4)

set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)

option(LINK_WITH_FIR "Link driver with FIR and LLVM" ON)
option(FLANG_BUILD_NEW_DRIVER "Build the flang compiler driver" OFF)

# Flang requires C++17.
Expand Down Expand Up @@ -72,19 +71,17 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(AddClang)
endif()

if(LINK_WITH_FIR)
include(TableGen)
find_package(MLIR REQUIRED CONFIG)
# Use SYSTEM for the same reasons as for LLVM includes
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
# If the user specifies a relative path to MLIR_DIR, the calls to include
# MLIR modules fail. Append the absolute path to MLIR_DIR instead.
get_filename_component(MLIR_DIR_ABSOLUTE ${MLIR_DIR} REALPATH)
list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR_ABSOLUTE})
include(AddMLIR)
find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)
endif()
include(TableGen)
find_package(MLIR REQUIRED CONFIG)
# Use SYSTEM for the same reasons as for LLVM includes
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
# If the user specifies a relative path to MLIR_DIR, the calls to include
# MLIR modules fail. Append the absolute path to MLIR_DIR instead.
get_filename_component(MLIR_DIR_ABSOLUTE ${MLIR_DIR} REALPATH)
list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR_ABSOLUTE})
include(AddMLIR)
find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)

option(LLVM_INSTALL_TOOLCHAIN_ONLY
"Only include toolchain files in the 'install' target." OFF)
Expand Down Expand Up @@ -186,14 +183,12 @@ else()
endif()

set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
if (LINK_WITH_FIR)
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
set(MLIR_TABLEGEN_EXE $<TARGET_FILE:mlir-tblgen>)
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
set(MLIR_TABLEGEN_EXE $<TARGET_FILE:mlir-tblgen>)
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()

if(FLANG_BUILD_NEW_DRIVER)
Expand All @@ -211,17 +206,13 @@ if(FLANG_BUILD_NEW_DRIVER)
include_directories(SYSTEM ${CLANG_INCLUDE_DIR})
endif()

if(LINK_WITH_FIR)
# tco tool and FIR lib output directories
if(FLANG_STANDALONE_BUILD)
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
endif()
# Always build tco tool
set(LLVM_BUILD_TOOLS ON)
set(LLVM_COMMON_COMPONENTS Support)
message(STATUS "Linking driver with FIR and LLVM, using LLVM components: ${LLVM_COMMON_COMPONENTS}")
# tco tool and FIR lib output directories
if(FLANG_STANDALONE_BUILD)
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
endif()
# Always build tco tool
set(LLVM_BUILD_TOOLS ON)

# Add Flang-centric modules to cmake path.
include_directories(BEFORE
Expand Down
4 changes: 1 addition & 3 deletions flang/include/flang/CMakeLists.txt
@@ -1,3 +1 @@
if(LINK_WITH_FIR)
add_subdirectory(Optimizer)
endif()
add_subdirectory(Optimizer)
4 changes: 1 addition & 3 deletions flang/lib/CMakeLists.txt
Expand Up @@ -10,6 +10,4 @@ if(FLANG_BUILD_NEW_DRIVER)
add_subdirectory(FrontendTool)
endif()

if(LINK_WITH_FIR)
add_subdirectory(Optimizer)
endif()
add_subdirectory(Optimizer)
4 changes: 1 addition & 3 deletions flang/test/CMakeLists.txt
Expand Up @@ -37,9 +37,7 @@ set(FLANG_TEST_DEPENDS
f18 FileCheck count not module_files
)

if (LINK_WITH_FIR)
list(APPEND FLANG_TEST_DEPENDS tco)
endif()
list(APPEND FLANG_TEST_DEPENDS tco)

if (FLANG_BUILD_NEW_DRIVER)
list(APPEND FLANG_TEST_DEPENDS flang-new)
Expand Down
4 changes: 1 addition & 3 deletions flang/tools/CMakeLists.txt
Expand Up @@ -10,7 +10,5 @@ add_subdirectory(f18)
if(FLANG_BUILD_NEW_DRIVER)
add_subdirectory(flang-driver)
endif()
if(LINK_WITH_FIR)
add_subdirectory(tco)
endif()
add_subdirectory(tco)
add_subdirectory(f18-parse-demo)

0 comments on commit 6a7deff

Please sign in to comment.