From 93c63ed8c249d9abe715f52a6a3e05176daee5d5 Mon Sep 17 00:00:00 2001 From: Steve Scalpone Date: Tue, 25 Jun 2019 09:57:38 -0700 Subject: [PATCH] [flang] Compile and install the predefined module files. Change the CMakeFile.txt in tools/f18 to build the predefined modules with the just-built compiler. The mod files are created in the new "include" subdirectory of the binary target directory. The mod files are installed to ${CMAKE_INSTALL_PREFIX}/include. The f18 driver is already installed in ${CMAKE_INSTALL_PREFIX}/bin. This change change the location of the f18 binary build to a sibling directory of "include" called "bin" instead of at the top level of the binary destination directory. This change is in anticipation of changing the driver to find the include directory using a path relative to the location of f18. Update the test scripts to find f18 in the bin subdirectory. Remove the simple predefined module tests from test/semantics because they are compiled as part of the build and don't need to be recompiled as part of a test. Original-commit: flang-compiler/f18@7811ccecdc065e7e6eb004c8eaefc245f642aea3 Reviewed-on: https://github.com/flang-compiler/f18/pull/526 --- flang/test/evaluate/test_folding.sh | 2 +- flang/test/semantics/CMakeLists.txt | 5 ----- flang/test/semantics/test_any.sh | 2 +- flang/test/semantics/test_errors.sh | 2 +- flang/test/semantics/test_modfile.sh | 2 +- flang/test/semantics/test_symbols.sh | 2 +- flang/tools/f18/CMakeLists.txt | 29 +++++++++++++++++++++++++++++ 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/flang/test/evaluate/test_folding.sh b/flang/test/evaluate/test_folding.sh index 71cda86..942e281 100755 --- a/flang/test/evaluate/test_folding.sh +++ b/flang/test/evaluate/test_folding.sh @@ -35,7 +35,7 @@ PATH=/usr/bin:/bin srcdir=$(dirname $0) -F18CC=${F18:-../../../tools/f18/f18} +F18CC=${F18:-../../../tools/f18/bin/f18} CMD="$F18CC -fdebug-dump-symbols -fparse-only" if [[ $# < 1 ]]; then diff --git a/flang/test/semantics/CMakeLists.txt b/flang/test/semantics/CMakeLists.txt index 19221dc..cd3fe61 100644 --- a/flang/test/semantics/CMakeLists.txt +++ b/flang/test/semantics/CMakeLists.txt @@ -136,11 +136,6 @@ set(ERROR_TESTS omp-clause-validity01.f90 # omp-nested01.f90 equivalence01.f90 - ${PROJECT_SOURCE_DIR}/module/ieee_arithmetic.f90 - ${PROJECT_SOURCE_DIR}/module/ieee_exceptions.f90 - ${PROJECT_SOURCE_DIR}/module/ieee_features.f90 - ${PROJECT_SOURCE_DIR}/module/iso_c_binding.f90 - ${PROJECT_SOURCE_DIR}/module/iso_fortran_env.f90 ) # These test files have expected symbols in the source diff --git a/flang/test/semantics/test_any.sh b/flang/test/semantics/test_any.sh index 245fe37..e3650dd 100755 --- a/flang/test/semantics/test_any.sh +++ b/flang/test/semantics/test_any.sh @@ -19,7 +19,7 @@ # Change the compiler by setting the F18 environment variable. PATH=/usr/bin:/bin srcdir=$(dirname $0) -F18=${F18:=../../tools/f18/f18} +F18=${F18:=../../tools/f18/bin/f18} FileCheck=${FileCheck:=internal_check} function internal_check() { diff --git a/flang/test/semantics/test_errors.sh b/flang/test/semantics/test_errors.sh index 3d461d4..f746bfb 100755 --- a/flang/test/semantics/test_errors.sh +++ b/flang/test/semantics/test_errors.sh @@ -18,7 +18,7 @@ PATH=/usr/bin:/bin srcdir=$(dirname $0) -CMD="${F18:-../../../tools/f18/f18} -fdebug-resolve-names -fparse-only" +CMD="${F18:-../../../tools/f18/bin/f18} -fdebug-resolve-names -fparse-only" if [[ $# != 1 ]]; then echo "Usage: $0 " diff --git a/flang/test/semantics/test_modfile.sh b/flang/test/semantics/test_modfile.sh index 3c09b64..df43060 100755 --- a/flang/test/semantics/test_modfile.sh +++ b/flang/test/semantics/test_modfile.sh @@ -18,7 +18,7 @@ set -e PATH=/usr/bin:/bin srcdir=$(dirname $0) -CMD="${F18:-../../../tools/f18/f18} -fdebug-resolve-names -fparse-only" +CMD="${F18:-../../../tools/f18/bin/f18} -fdebug-resolve-names -fparse-only" if [[ $# != 1 ]]; then echo "Usage: $0 " exit 1 diff --git a/flang/test/semantics/test_symbols.sh b/flang/test/semantics/test_symbols.sh index f1da1ba0..ad6599e 100755 --- a/flang/test/semantics/test_symbols.sh +++ b/flang/test/semantics/test_symbols.sh @@ -20,7 +20,7 @@ PATH=/usr/bin:/bin srcdir=$(dirname $0) -CMD="${F18:-../../../tools/f18/f18} -funparse-with-symbols" +CMD="${F18:-../../../tools/f18/bin/f18} -funparse-with-symbols" if [[ $# != 1 ]]; then echo "Usage: $0 " diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt index 04fe7a7..9c74048 100644 --- a/flang/tools/f18/CMakeLists.txt +++ b/flang/tools/f18/CMakeLists.txt @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include") + add_executable(f18 f18.cc dump.cc @@ -32,4 +35,30 @@ target_link_libraries(f18-parse-demo FortranParser ) +set_target_properties(f18 f18-parse-demo + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" +) + +set(MODULES + "ieee_arithmetic" + "ieee_exceptions" + "ieee_features" + "iso_c_binding" + "iso_fortran_env" +) + +# Create module files directly from the top-level module source directory +foreach(filename ${MODULES}) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.mod + COMMAND f18 -fparse-only -fdebug-semantics ${PROJECT_SOURCE_DIR}/module/${filename}.f90 + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include" + DEPENDS f18 ${PROJECT_SOURCE_DIR}/module/${filename}.f90 + ) + list(APPEND MODULE_FILES "${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.mod") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.mod DESTINATION include) +endforeach() + +add_custom_target(module_files ALL DEPENDS ${MODULE_FILES}) + install(TARGETS f18 f18-parse-demo DESTINATION bin) -- 2.7.4