[PATCH] D98522: [flang] Build intrinsic .mod files in include/flang
Tim Keith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 12 09:32:20 PST 2021
tskeith created this revision.
tskeith added reviewers: klausler, PeteSteinfeld, schweitz, sscalpone.
tskeith added a project: Flang.
Herald added subscribers: jdoerfert, mgorny.
Herald added a reviewer: awarzynski.
tskeith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The build was putting .mod files for intrinsic modules in
tools/flang/include/flang but the install puts them in include/flang,
as does the out-of-tree build. This confused things for the driver.
This change makes the build consistent with the install and simplifies
the flang script accordingly.
Also, clean up the cmake commands for building the .mod files.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98522
Files:
flang/CMakeLists.txt
flang/test/CMakeLists.txt
flang/tools/f18/CMakeLists.txt
flang/tools/f18/flang
Index: flang/tools/f18/flang
===================================================================
--- flang/tools/f18/flang
+++ flang/tools/f18/flang
@@ -8,11 +8,7 @@
#===------------------------------------------------------------------------===#
wd=$(cd $(dirname "$0")/.. && pwd)
-module_dir=$wd/include/flang
-if [[ ! -d $module_dir ]]; then
- module_dir=$wd/tools/flang/include/flang
-fi
-opts="-module-suffix .f18.mod -intrinsic-module-directory $module_dir"
+opts="-module-suffix .f18.mod -intrinsic-module-directory $wd/include/flang"
if ! $wd/bin/f18 $opts "$@"
then status=$?
echo flang: in $PWD, f18 failed with exit status $status: $wd/bin/f18 $opts "$@" >&2
Index: flang/tools/f18/CMakeLists.txt
===================================================================
--- flang/tools/f18/CMakeLists.txt
+++ flang/tools/f18/CMakeLists.txt
@@ -30,7 +30,6 @@
"__fortran_type_info"
)
-set(include ${FLANG_BINARY_DIR}/include/flang)
target_include_directories(f18
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
@@ -38,27 +37,24 @@
# Create module files directly from the top-level module source directory
foreach(filename ${MODULES})
+ set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
if(${filename} MATCHES "__fortran_type_info")
set(depends "")
elseif(${filename} MATCHES "__fortran_builtins")
- set(depends ${include}/__fortran_type_info.mod)
+ set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_type_info.mod)
else()
- set(depends ${include}/__fortran_builtins.mod)
+ set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
endif()
- add_custom_command(OUTPUT ${include}/${filename}.mod
- COMMAND f18 -fsyntax-only -I${include}
- ${FLANG_SOURCE_DIR}/module/${filename}.f90
- WORKING_DIRECTORY ${include}
+ add_custom_command(OUTPUT ${base}.mod
+ COMMAND f18 -fsyntax-only ${FLANG_SOURCE_DIR}/module/${filename}.f90
+ WORKING_DIRECTORY ${FLANG_INTRINSIC_MODULES_DIR}
DEPENDS f18 ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${depends}
)
- add_custom_command(OUTPUT ${include}/${filename}.f18.mod
- DEPENDS ${include}/${filename}.mod
- COMMAND ${CMAKE_COMMAND} -E
- copy ${include}/${filename}.mod ${include}/${filename}.f18.mod)
- list(APPEND MODULE_FILES ${include}/${filename}.mod)
- list(APPEND MODULE_FILES ${include}/${filename}.f18.mod)
- install(FILES ${include}/${filename}.mod DESTINATION include/flang)
- install(FILES ${include}/${filename}.f18.mod DESTINATION include/flang)
+ add_custom_command(OUTPUT ${base}.f18.mod
+ DEPENDS ${base}.mod
+ COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
+ list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod)
+ install(FILES ${base}.mod ${base}.f18.mod DESTINATION include/flang)
endforeach()
add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
Index: flang/test/CMakeLists.txt
===================================================================
--- flang/test/CMakeLists.txt
+++ flang/test/CMakeLists.txt
@@ -5,8 +5,6 @@
FLANG_STANDALONE_BUILD
)
-set(FLANG_INTRINSIC_MODULES_DIR ${FLANG_BINARY_DIR}/include/flang)
-
set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/bin)
configure_lit_site_cfg(
Index: flang/CMakeLists.txt
===================================================================
--- flang/CMakeLists.txt
+++ flang/CMakeLists.txt
@@ -190,6 +190,7 @@
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()
+set(FLANG_INTRINSIC_MODULES_DIR ${CMAKE_BINARY_DIR}/include/flang)
if(FLANG_BUILD_NEW_DRIVER)
# TODO: Remove when libclangDriver is lifted out of Clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98522.330276.patch
Type: text/x-patch
Size: 3640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210312/be740eb4/attachment.bin>
More information about the llvm-commits
mailing list