forked from OSchip/llvm-project
[flang] Build intrinsic .mod files in include/flang
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. Differential Revision: https://reviews.llvm.org/D98522
This commit is contained in:
parent
814339454d
commit
8e1c09ee5f
|
@ -190,6 +190,7 @@ else()
|
|||
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
|
||||
|
|
|
@ -5,8 +5,6 @@ llvm_canonicalize_cmake_booleans(
|
|||
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(
|
||||
|
|
|
@ -30,7 +30,6 @@ set(MODULES
|
|||
"__fortran_type_info"
|
||||
)
|
||||
|
||||
set(include ${FLANG_BINARY_DIR}/include/flang)
|
||||
target_include_directories(f18
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
@ -38,27 +37,24 @@ target_include_directories(f18
|
|||
|
||||
# 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})
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue