[flang] A rework of the cmake build components for in and out of tree builds.

In general all the basic functionality seems to work and removes some redundancy
and more complicated features in favor of borrowing infrastructure from LLVM
build configurations. Here's a quick summary of details and remaining issues:

  * Testing has spanned Ubuntu 18.04 & 19.10, CentOS 7, RHEL 8, and
    MacOS/darwin.  Architectures include x86_64 and Arm.  Without
    access to Window nothing has been tested there yet.

  * As we change file and directory naming schemes (i.e.,
    capitalization) some odd things can occur on MacOS systems with
    case preserving but not case senstive file system configurations.
    Can be painful and certainly something to watch out for as any
    any such changes continue.

  * Testing infrastructure still needs to be tuned up and worked on.
    Note that there do appear to be cases of some tests hanging (on
    MacOS in particular).  They appear unrelated to the build
    process.

  * Shared library configurations need testing (and probably fixing).

  * Tested both standalone and 'in-mono repo' builds.  Changes for
    supporting the mono repo builds will require LLVM-level changes that
    are straightforward when the time comes.

  * The configuration contains a work-around for LLVM's C++ standard mode
    passing down into Flang/F18 builds (i.e., LLVM CMake configuration would
    force a -std=c++11 flag to show up in command line arguments.  The
    current configuration removes that automatically and is more strict in
    following new CMake guidelines for enforcing C++17 mode across all the
    CMake files.

  * Cleaned up a lot of repetition in the command line arguments.  It
    is likely that more work is still needed to both allow for
    customization and working around CMake defailts (or those
    inherited from LLVM's configuration files). On some platforms agressive
    optimization flags (e.g. -O3) can actually break builds due to the inlining
    of templates in .cpp source files that then no longer are available for use
    cases outside those source files (shows up as link errors).   Sticking at -O2
    appears to fix this.  Currently this CMake configuration forces this in
    release mode but at the cost of stomping on any CMake, or user customized,
    settings for the release flags.

  * Made the lit tests non-source directory dependent where appropriate. This is
    done by configuring certain test shell files to refer to the correct paths
    whether an in or out of tree build is being performed. These configured
    files are output in the build directory. A %B substitution is introduced in
    lit to refer to the build directory, mirroring the %S substitution for the
    source directory, so that the tests can refer to the configured shell scripts.

Co-authored-by: David Truby <david.truby@arm.com>

Original-commit: flang-compiler/f18@d1c7184159
Reviewed-on: https://github.com/flang-compiler/f18/pull/1045
This commit is contained in:
Patrick McCormick 2020-02-25 16:22:14 -07:00 committed by David Truby
parent 53d5d9f631
commit 6c16aa4f67
246 changed files with 866 additions and 505 deletions

2
flang/.gitignore vendored
View File

@ -17,3 +17,5 @@ CMakeCache.txt
*/*/Makefile
cmake_install.cmake
formatted
.DS_Store
.vs_code

View File

@ -1,97 +1,140 @@
#===-- CMakeLists.txt ------------------------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
cmake_minimum_required(VERSION 3.9.0)
# RPATH settings on macOS do not affect INSTALL_NAME.
if (POLICY CMP0068)
cmake_policy(SET CMP0068 NEW)
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
endif()
# Include file check macros honor CMAKE_REQUIRED_LIBRARIES.
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW)
endif()
# option() honors normal variables.
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
option(LINK_WITH_FIR "Link driver with FIR and LLVM" ON)
# Pass -DGCC=... to cmake to use a specific gcc installation.
if( GCC )
set(CMAKE_CXX_COMPILER "${GCC}/bin/g++")
set(CMAKE_CC_COMPILER "${GCC}/bin/gcc")
set(CMAKE_BUILD_RPATH "${GCC}/lib64")
set(CMAKE_INSTALL_RPATH "${GCC}/lib64")
# Flang requires C++17.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF)
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed. \
Please create a directory and run cmake from there,\
passing the path to this source directory as the last argument.\
This process created the file `CMakeCache.txt' and the directory\
`CMakeFiles'. Please delete them.")
endif()
if(BUILD_WITH_CLANG)
file(TO_CMAKE_PATH "${BUILD_WITH_CLANG}" CLANG_PATH)
set(CMAKE_CXX_COMPILER "${CLANG_PATH}/bin/clang++")
set(CMAKE_CC_COMPILER "${CLANG_PATH}/bin/clang")
if(GCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --gcc-toolchain=${GCC}")
# Add Flang-centric modules to cmake path.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(AddFlang)
# Check for a standalone build and configure as appropriate from
# there.
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message("Building Flang as a standalone project.")
project(Flang)
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if (NOT MSVC_IDE)
set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
CACHE BOOL "Enable assertions")
# Assertions follow llvm's configuration.
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
endif()
# We need a pre-built/installed version of LLVM.
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
# If LLVM links to zlib we need the imported targets so we can too.
if(LLVM_ENABLE_ZLIB)
find_package(ZLIB REQUIRED)
endif()
include(CMakeParseArguments)
include(AddLLVM)
include(HandleLLVMOptions)
include(VersionFromVCS)
if(LINK_WITH_FIR)
include(TableGen)
include(AddMLIR)
find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)
endif()
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
option(LLVM_INSTALL_TOOLCHAIN_ONLY
"Only include toolchain files in the 'install' target." OFF)
option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
"Set to ON to force using an old, unsupported host toolchain." OFF)
# Add LLVM include files as if they were SYSTEM because there are complex unused
# parameter issues that may or may not appear depending on the environments and
# compilers (ifdefs are involved). This allows warnings from LLVM headers to be
# ignored while keeping -Wunused-parameter a fatal error inside f18 code base.
# This may have to be fine-tuned if flang headers are consider part of this
# LLVM_INCLUDE_DIRS when merging in the monorepo (Warning from flang headers
# should not be suppressed).
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# LLVM's cmake configuration files currently sneak in a c++11 flag.
# We look for it here and remove it from Flang's compile flags to
# avoid some mixed compilation flangs (e.g. -std=c++11 ... -std=c++17).
if (DEFINED LLVM_CXX_STD)
message("LLVM configuration set a C++ standard: ${LLVM_CXX_STD}")
if (NOT LLVM_CXX_STD EQUAL "c++17")
message("Flang: Overriding LLVM's 'cxx_std' setting...")
message(" removing '-std=${LLVM_CXX_STD}'")
message(" CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'")
string(REPLACE " -std=${LLVM_CXX_STD}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
message(" [NEW] CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'")
endif()
endif()
link_directories("${LLVM_LIBRARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
set(LLVM_EXTERNAL_LIT "${LLVM_TOOLS_BINARY_DIR}/llvm-lit" CACHE STRING "Command used to spawn lit")
option(FLANG_INCLUDE_TESTS
"Generate build targets for the Flang unit tests."
ON)
add_custom_target(check-all DEPENDS check-flang)
else()
option(FLANG_INCLUDE_TESTS
"Generate build targets for the Flang unit tests."
${LLVM_INCLUDE_TESTS})
set(FLANG_BINARY_DIR ${CMAKE_BINARY_DIR}/tools/flang)
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(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstring-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcovered-switch-default")
endif()
# Set RPATH in every executable, overriding the default setting.
# If you set this first variable back to true (the default),
# also set the second one.
set(CMAKE_SKIP_BUILD_RPATH false)
set(CMAKE_BUILD_WITH_INSTALL_RPATH false)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" "${CMAKE_INSTALL_RPATH}")
# Reminder: Setting CMAKE_CXX_COMPILER must be done before calling project()
project(f18 CXX)
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Debug )
endif()
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}" )
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in ${LLVM_DIR}")
# If LLVM links to zlib we need the imported targets so we can too.
if(LLVM_ENABLE_ZLIB)
find_package(ZLIB REQUIRED)
endif()
list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
include(AddLLVM)
# Get names for the LLVM libraries
#
# The full list of LLVM components can be obtained with
#
# llvm-config --components
#
# Similarly, the (static) libraries corresponding to some
# components (default is 'all') can be obtained with
#
# llvm-config --libs --link-static [component ...]
#
# See also
# http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
# https://stackoverflow.com/questions/41924375/llvm-how-to-specify-all-link-libraries-as-input-to-llvm-map-components-to-libna
# https://stackoverflow.com/questions/33948633/how-do-i-link-when-building-with-llvm-libraries
# Add LLVM include files as if they were SYSTEM because there are complex unused
# parameter issues that may or may not appear depending on the environments and
# compilers (ifdefs are involved). This allows warnings from LLVM headers to be
# ignored while keeping -Wunused-parameter a fatal error inside f18 code base.
# This may have to be fine-tuned if flang headers are consider part of this
# LLVM_INCLUDE_DIRS when merging in the monorepo (Warning from flang headers
# should not be suppressed).
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# LLVM_LIT_EXTERNAL store in cache so it could be used by AddLLVM.cmake
set(LLVM_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE STRING "Command used to spawn lit")
if(LINK_WITH_FIR)
include(TableGen)
include(AddMLIR)
find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)
# tco tool and FIR lib output directories
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
@ -102,62 +145,227 @@ if(LINK_WITH_FIR)
message(STATUS "LLVM libraries: ${LLVM_COMMON_LIBS}")
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(BUILD_WITH_CLANG_LIBRARIES)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++ -I${BUILD_WITH_CLANG_LIBRARIES}/include/c++/v1 -DCLANG_LIBRARIES")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -Wl,-rpath,${BUILD_WITH_CLANG_LIBRARIES}/lib -L${BUILD_WITH_CLANG_LIBRARIES}/lib")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
endif()
if(GCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --gcc-toolchain=${GCC}")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdelete-non-virtual-dtor")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 '-DCHECK=(void)'")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUGF18")
# Add Flang-centric modules to cmake path.
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
${FLANG_SOURCE_DIR}/include)
# Building shared libraries is death on performance with GCC by default
# due to the need to preserve the right to override external entry points
# at dynamic link time. -fno-semantic-interposition waives that right and
# recovers a little bit of that performance.
if (BUILD_SHARED_LIBS AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-semantic-interposition")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
if (NOT DEFAULT_SYSROOT)
set(DEFAULT_SYSROOT "" CACHE PATH
"The <path> to use for the system root for all compiler invocations (--sysroot=<path>).")
endif()
if (NOT ENABLE_LINKER_BUILD_ID)
set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
endif()
set(FLANG_DEFAULT_LINKER "" CACHE STRING
"Default linker to use (linker name or absolute path, empty for platform default)")
set(FLANG_DEFAULT_RTLIB "" CACHE STRING
"Default Fortran runtime library to use (\"libFortranRuntime\"), leave empty for platform default.")
if (NOT(FLANG_DEFAULT_RTLIB STREQUAL ""))
message(WARNING "Resetting Flang's default runtime library to use platform default.")
set(FLANG_DEFAULT_RTLIB "" CACHE STRING
"Default runtime library to use (empty for platform default)" FORCE)
endif()
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
# Override LLVM versioning for now...
set(FLANG_VERSION_MAJOR "0")
set(FLANG_VERSION_MINOR "1")
set(FLANG_VERSION_PATCHLEVEL "0")
if (NOT DEFINED FLANG_VERSION_MAJOR)
set(FLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
endif()
if (NOT DEFINED FLANG_VERSION_MINOR)
set(FLANG_VERSION_MINOR ${LLVM_VERSION_MINOR})
endif()
if (NOT DEFINED FLANG_VERSION_PATCHLEVEL)
set(FLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
endif()
# Unlike PACKAGE_VERSION, FLANG_VERSION does not include LLVM_VERSION_SUFFIX.
set(FLANG_VERSION "${FLANG_VERSION_MAJOR}.${FLANG_VERSION_MINOR}.${FLANG_VERSION_PATCHLEVEL}")
message(STATUS "FLANG version: ${FLANG_VERSION}")
message(STATUS "Flang version: ${FLANG_VERSION}")
# Flang executable version information
set(FLANG_EXECUTABLE_VERSION
"${FLANG_VERSION_MAJOR}" CACHE STRING
"Major version number to appended to the flang executable name.")
set(LIBFLANG_LIBRARY_VERSION
"${FLANG_VERSION_MAJOR}" CACHE STRING
"Major version number to appended to the libflang library.")
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/tools/f18/bin)
mark_as_advanced(FLANG_EXECUTABLE_VERSION LIBFLANG_LIBRARY_VERSION)
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
${FLANG_SOURCE_DIR}/include
)
set(FLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
"Vendor-specific Flang version information.")
set(FLANG_VENDOR_UTI "org.llvm.flang" CACHE STRING
"Vendor-specific uti.")
enable_testing()
if (FLANG_VENDOR)
add_definitions(-DFLANG_VENDOR="${FLANG_VENDOR} ")
endif()
add_subdirectory(include/flang)
add_subdirectory(lib)
add_subdirectory(runtime)
add_subdirectory(unittests)
add_subdirectory(tools)
add_subdirectory(test)
set(FLANG_REPOSITORY_STRING "" CACHE STRING
"Vendor-specific text for showing the repository the source is taken from.")
if (FLANG_REPOSITORY_STRING)
add_definitions(-DFLANG_REPOSITORY_STRING="${FLANG_REPOSITORY_STRING}")
endif()
# Configure Flang's Version.inc file.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/flang/Version.inc.in
${CMAKE_CURRENT_BINARY_DIR}/include/flang/Version.inc)
# Configure Flang's version info header file.
configure_file(
${FLANG_SOURCE_DIR}/include/flang/Config/config.h.cmake
${FLANG_BINARY_DIR}/include/flang/Config/config.h)
# Add global F18 flags.
set(CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions -pedantic -Wall -Wextra -Werror -Wcast-qual -Wimplicit-fallthrough -Wdelete-non-virtual-dtor ${CMAKE_CXX_FLAGS}")
# Builtin check_cxx_compiler_flag doesn't seem to work correctly
macro(check_compiler_flag flag resultVar)
unset(${resultVar} CACHE)
check_cxx_compiler_flag("${flag}" ${resultVar})
endmacro()
check_compiler_flag("-Werror -Wno-deprecated-copy" CXX_SUPPORTS_NO_DEPRECATED_COPY_FLAG)
if (CXX_SUPPORTS_NO_DEPRECATED_COPY_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
endif()
check_compiler_flag("-Wstring-conversion" CXX_SUPPORTS_NO_STRING_CONVERSION_FLAG)
if (CXX_SUPPORTS_NO_STRING_CONVERSION_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-string-conversion")
endif()
# Add appropriate flags for GCC
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fno-semantic-interposition")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument -Wstring-conversion \
-Wcovered-switch-default")
endif() # Clang.
check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
if (CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types")
endif()
# Add to or adjust build type flags.
#
# TODO: This needs some extra thought. CMake's default for release builds
# is -O3, which can cause build failures on certain platforms (and compilers)
# with the current code base -- some templated functions are inlined and don't
# become available at link time when using -O3 (with Clang under MacOS/darwin).
# If we reset CMake's default flags we also clobber any user provided settings;
# make it difficult to customize a build in this regard... The setup below
# has this side effect but enables successful builds across multiple platforms
# in release mode...
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUGF18")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DCHECK=\"(void)\"") # do we need -O2 here?
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
# Building shared libraries is bad for performance with GCC by default
# due to the need to preserve the right to override external entry points
if (BUILD_SHARED_LIBS AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-semantic-interposition")
endif()
endif()
list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS)
# Determine HOST_LINK_VERSION on Darwin.
set(HOST_LINK_VERSION)
if (APPLE)
set(LD_V_OUTPUT)
execute_process(
COMMAND sh -c "${CMAKE_LINKER} -v 2>&1 | head -1"
RESULT_VARIABLE HAD_ERROR
OUTPUT_VARIABLE LD_V_OUTPUT)
if (NOT HAD_ERROR)
if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
endif()
else()
message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
endif()
endif()
include(CMakeParseArguments)
include(AddFlang)
add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(cmake/modules)
option(FLANG_BUILD_TOOLS
"Build the Flang tools. If OFF, just generate build targets." ON)
if (FLANG_BUILD_TOOLS)
add_subdirectory(tools)
endif()
add_subdirectory(runtime)
if (FLANG_INCLUDE_TESTS)
enable_testing()
add_subdirectory(test)
add_subdirectory(unittests)
endif()
# TODO: Add doxygen support.
#option(FLANG_INCLUDE_DOCS "Generate build targets for the Flang docs."
# ${LLVM_INCLUDE_DOCS})
#if (FLANG_INCLUDE_DOCS)
# add_subdirectory(documentation)
#endif()
# Custom target to install Flang libraries.
add_custom_target(flang-libraries)
set_target_properties(flang-libraries PROPERTIES FOLDER "Misc")
if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-flang-libraries
DEPENDS flang-libraries
COMPONENT flang-libraries)
endif()
get_property(FLANG_LIBS GLOBAL PROPERTY FLANG_LIBS)
if (FLANG_LIBS)
list(REMOVE_DUPLICATES FLANG_LIBS)
foreach(lib ${FLANG_LIBS})
add_dependencies(flang-libraries ${lib})
if (NOT LLVM_ENABLE_IDE)
add_dependencies(install-flang-libraries install-${lib})
endif()
endforeach()
endif()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/flang
DESTINATION include
COMPONENT flang-headers
FILES_MATCHING
PATTERN "*.def"
PATTERN "*.h"
PATTERN "*.inc"
PATTERN "*.td"
PATTERN "config.h" EXCLUDE
PATTERN ".git" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE)
endif()

View File

@ -150,15 +150,6 @@ or
```
CXX=/opt/gcc-7.2/bin/g++-7.2 cmake ...
```
There's a third option!
The CMakeList.txt file uses the variable GCC
as the path to the bin directory containing the C++ compiler.
GCC can be defined on the cmake command line
where `<GCC_DIRECTORY>` is the path to a GCC installation with bin, lib, etc:
```
cmake -DGCC=<GCC_DIRECTORY> ...
```
### Building f18 with clang
@ -166,27 +157,11 @@ To build f18 with clang,
cmake needs to know how to find clang++
and the GCC library and tools that were used to build clang++.
The CMakeList.txt file expects either CXX or BUILD_WITH_CLANG to be set.
CXX should include the full path to clang++
or clang++ should be found on your PATH.
```
export CXX=clang++
```
BUILD_WITH_CLANG can be defined on the cmake command line
where `<CLANG_DIRECTORY>`
is the path to a clang installation with bin, lib, etc:
```
cmake -DBUILD_WITH_CLANG=<CLANG_DIRECTORY>
```
Or GCC can be defined on the f18 cmake command line
where `<GCC_DIRECTORY>` is the path to a GCC installation with bin, lib, etc:
```
cmake -DGCC=<GCC_DIRECTORY> ...
```
To use f18 after it is built,
the environment variables PATH and LD_LIBRARY_PATH
must be set to use GCC and its associated libraries.
### Installation Directory

View File

@ -0,0 +1,141 @@
macro(set_flang_windows_version_resource_properties name)
if (DEFINED windows_resource_file)
set_windows_version_resource_properties(${name} ${windows_resource_file}
VERSION_MAJOR ${FLANG_VERSION_MAJOR}
VERSION_MINOR ${FLANG_VERSION_MINOR}
VERSION_PATCHLEVEL ${FLANG_VERSION_PATCHLEVEL}
VERSION_STRING "${FLANG_VERSION} (${BACKEND_PACKAGE_STRING})"
PRODUCT_NAME "flang")
endif()
endmacro()
macro(add_flang_subdirectory name)
add_llvm_subdirectory(FLANG TOOL ${name})
endmacro()
macro(add_flang_library name)
cmake_parse_arguments(ARG
"SHARED"
""
"ADDITIONAL_HEADERS"
${ARGN})
set(srcs)
if (MSVC_IDE OR XCODE)
# Add public headers
file(RELATIVE_PATH lib_path
${FLANG_SOURCE_DIR}/lib/
${CMAKE_CURRENT_SOURCE_DIR})
if(NOT lib_path MATCHES "^[.][.]")
file( GLOB_RECURSE headers
${FLANG_SOURCE_DIR}/include/flang/${lib_path}/*.h
${FLANG_SOURCE_DIR}/include/flang/${lib_path}/*.def)
set_source_files_properties(${headers} PROPERTIES HEADER_FILE_ONLY ON)
if (headers)
set(srcs ${headers})
endif()
endif()
endif(MSVC_IDE OR XCODE)
if (srcs OR ARG_ADDITIONAL_HEADERS)
set(srcs
ADDITIONAL_HEADERS
${srcs}
${ARG_ADDITIONAL_HEADERS}) # It may contain unparsed unknown args.
endif()
if (ARG_SHARED)
set(LIBTYPE SHARED)
else()
# llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
# so we need to handle it here.
if (BUILD_SHARED_LIBS)
set(LIBTYPE SHARED OBJECT)
else()
set(LIBTYPE STATIC OBJECT)
endif()
set_property(GLOBAL APPEND PROPERTY FLANG_STATIC_LIBS ${name})
endif()
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
if (TARGET ${name})
target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libflang")
set(export_to_flangtargets)
if (${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
"flang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
set(export_to_flangtargets EXPORT FlangTargets)
set_property(GLOBAL PROPERTY FLANG_HAS_EXPORTS True)
endif()
install(TARGETS ${name}
COMPONENT ${name}
${export_to_flangtargets}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
RUNTIME DESTINATION bin)
if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
endif()
set_property(GLOBAL APPEND PROPERTY FLANG_LIBS ${name})
endif()
set_property(GLOBAL APPEND PROPERTY FLANG_EXPORTS ${name})
else()
# Add empty "phony" target
add_custom_target(${name})
endif()
set_target_properties(${name} PROPERTIES FOLDER "Flang libraries")
set_flang_windows_version_resource_properties(${name})
endmacro(add_flang_library)
macro(add_flang_executable name)
add_llvm_executable(${name} ${ARGN})
set_target_properties(${name} PROPERTIES FOLDER "Flang executables")
set_flang_windows_version_resource_properties(${name})
endmacro(add_flang_executable)
macro(add_flang_tool name)
if (NOT FLANG_BUILD_TOOLS)
set(EXCLUDE_FROM_ALL ON)
endif()
add_flang_executable(${name} ${ARGN})
add_dependencies(${name} flang-resource-headers)
if (FLANG_BUILD_TOOLS)
set(export_to_flangtargets)
if (${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
set(export_to_flangtargets EXPORT FlangTargets)
set_property(GLOBAL PROPERTY FLANG_HAS_EXPORTS True)
endif()
install(TARGETS ${name}
${export_to_flangtargets}
RUNTIME DESTINATION bin
COMPONENT ${name})
if(NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
endif()
set_property(GLOBAL APPEND PROPERTY FLANG_EXPORTS ${name})
endif()
endmacro()
macro(add_flang_symlink name dest)
add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
# Always generate install targets
llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
endmacro()

View File

@ -0,0 +1,74 @@
# Generate a list of CMake library targets so that other CMake projects can
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
# the usual CMake convention seems to be ${Project}Targets.cmake.
set(FLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/flang)
set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/${FLANG_INSTALL_PACKAGE_DIR}")
# Keep this in sync with llvm/cmake/CMakeLists.txt!
set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS)
export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake)
# Generate FlangConfig.cmake for the build tree.
set(FLANG_CONFIG_CMAKE_DIR "${flang_cmake_builddir}")
set(FLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
set(FLANG_CONFIG_EXPORTS_FILE "${flang_cmake_builddir}/FlangTargets.cmake")
set(FLANG_CONFIG_INCLUDE_DIRS
"${FLANG_SOURCE_DIR}/include"
"${FLANG_BINARY_DIR}/include"
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/FlangConfig.cmake.in
${flang_cmake_builddir}/FlangConfig.cmake
@ONLY)
set(FLANG_CONFIG_CMAKE_DIR)
set(FLANG_CONFIG_LLVM_CMAKE_DIR)
set(FLANG_CONFIG_EXPORTS_FILE)
# Generate FlangConfig.cmake for the install tree.
set(FLANG_CONFIG_CODE "
# Compute the installation prefix from this LLVMConfig.cmake file location.
get_filename_component(FLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
# Construct the proper number of get_filename_component(... PATH)
# calls to compute the installation prefix.
string(REGEX REPLACE "/" ";" _count "${FLANG_INSTALL_PACKAGE_DIR}")
foreach(p ${_count})
set(FLANG_CONFIG_CODE "${FLANG_CONFIG_CODE}
get_filename_component(FLANG_INSTALL_PREFIX \"\${FLANG_INSTALL_PREFIX}\" PATH)")
endforeach(p)
set(FLANG_CONFIG_CMAKE_DIR "\${FLANG_INSTALL_PREFIX}/${FLANG_INSTALL_PACKAGE_DIR}")
set(FLANG_CONFIG_LLVM_CMAKE_DIR "\${FLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
set(FLANG_CONFIG_EXPORTS_FILE "\${FLANG_CMAKE_DIR}/FlangTargets.cmake")
set(FLANG_CONFIG_INCLUDE_DIRS "\${FLANG_INSTALL_PREFIX}/include")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/FlangConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfig.cmake
@ONLY)
set(FLANG_CONFIG_CODE)
set(FLANG_CONFIG_CMAKE_DIR)
set(FLANG_CONFIG_EXPORTS_FILE)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
get_property(flang_has_exports GLOBAL PROPERTY FLANG_HAS_EXPORTS)
if(flang_has_exports)
install(EXPORT FlangTargets DESTINATION ${FLANG_INSTALL_PACKAGE_DIR}
COMPONENT flang-cmake-exports)
endif()
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfig.cmake
DESTINATION ${FLANG_INSTALL_PACKAGE_DIR}
COMPONENT flang-cmake-exports)
if(NOT LLVM_ENABLE_IDE)
# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
add_custom_target(flang-cmake-exports)
add_llvm_install_targets(install-flang-cmake-exports
COMPONENT flang-cmake-exports)
endif()
endif()

View File

@ -0,0 +1,13 @@
# This file allows users to call find_package(Flang) and pick up our targets.
@FLANG_CONFIG_CODE@
find_package(LLVM REQUIRED CONFIG
HINTS "@FLANG_CONFIG_LLVM_CMAKE_DIR@")
set(FLANG_EXPORTED_TARGETS "@FLANG_EXPORTS@")
set(FLANG_CMAKE_DIR "FLANG_CONFIG_CMAKE_DIR@")
set(FLANG_INCLUDE_DIRS "@FLANG_CONFIG_INCLUDE_DIRS@")
# Provide all our library targets to users.
include("@FLANG_CONFIG_EXPORTS_FILE@")

View File

@ -0,0 +1 @@
add_subdirectory(flang)

View File

@ -0,0 +1,5 @@
#define FLANG_VERSION @FLANG_VERSION@
#define FLANG_VERSION_STRING "@FLANG_VERSION@"
#define FLANG_VERSION_MAJOR @FLANG_VERSION_MAJOR@
#define FLANG_VERSION_MINOR @FLANG_VERSION_MINOR@
#define FLANG_VERSION_PATCHLEVEL @FLANG_VERSION_PATCHLEVEL@

View File

@ -1,11 +1,3 @@
#===-- lib/CMakeLists.txt --------------------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
add_subdirectory(Common)
add_subdirectory(Evaluate)
add_subdirectory(Decimal)

View File

@ -1,10 +1,3 @@
#===-- lib/Common/CMakeLists.txt -------------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
add_library(FortranCommon
Fortran.cpp
@ -13,6 +6,8 @@ add_library(FortranCommon
idioms.cpp
)
target_compile_features(FortranCommon PUBLIC cxx_std_17)
install (TARGETS FortranCommon
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib

View File

@ -1,16 +1,11 @@
#===-- lib/Decimal/CMakeLists.txt ------------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
add_library(FortranDecimal
binary-to-decimal.cpp
decimal-to-binary.cpp
)
target_compile_features(FortranDecimal PUBLIC cxx_std_17)
install (TARGETS FortranDecimal
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib

View File

@ -1,10 +1,3 @@
#===-- lib/Evaluate/CMakeLists.txt -----------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
add_library(FortranEvaluate
call.cpp
@ -34,6 +27,8 @@ add_library(FortranEvaluate
variable.cpp
)
target_compile_features(FortranEvaluate PUBLIC cxx_std_17)
target_link_libraries(FortranEvaluate
FortranCommon
FortranDecimal

View File

@ -1,10 +1,3 @@
#===-- lib/Parser/CMakeLists.txt -------------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
add_library(FortranParser
Fortran-parsers.cpp
@ -32,6 +25,8 @@ add_library(FortranParser
user-state.cpp
)
target_compile_features(FortranParser PRIVATE cxx_std_17)
target_link_libraries(FortranParser
FortranCommon
LLVMSupport

View File

@ -1,10 +1,3 @@
#===-- lib/Semantics/CMakeLists.txt ----------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
add_library(FortranSemantics
assignment.cpp
@ -43,6 +36,8 @@ add_library(FortranSemantics
unparse-with-symbols.cpp
)
target_compile_features(FortranSemantics PUBLIC cxx_std_17)
target_link_libraries(FortranSemantics
FortranCommon
FortranEvaluate

View File

@ -1,7 +1,9 @@
# Test runner infrastructure for Flang. This configures the Flang test trees
# for use by Lit, and delegates to LLVM's lit test handlers.
set(FLANG_INTRINSIC_MODULES_DIR ${FLANG_BINARY_DIR}/tools/f18/include)
set(FLANG_INTRINSIC_MODULES_DIR ${FLANG_BINARY_DIR}/include/flang)
set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/bin)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
@ -10,6 +12,8 @@ configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)
add_subdirectory(Semantics)
set(FLANG_TEST_PARAMS
flang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
@ -21,10 +25,16 @@ if (LINK_WITH_FIR)
list(APPEND FLANG_TEST_DEPENDS tco)
endif()
add_lit_testsuite(check-all "Running the Flang regression tests"
add_custom_target(flang-test-depends DEPENDS ${FLANG_TEST_DEPENDS})
add_lit_testsuite(check-flang "Running the Flang regression tests"
${CMAKE_CURRENT_BINARY_DIR}
PARAMS ${FLANG_TEST_PARAMS}
DEPENDS ${FLANG_TEST_DEPENDS}
)
set_target_properties(check-all PROPERTIES FOLDER "Tests")
set_target_properties(check-flang PROPERTIES FOLDER "Tests")
add_lit_testsuites(FLANG ${CMAKE_CURRENT_SOURCE_DIR}
PARAMS ${FLANG_TEST_PARAMS}
DEPENDS ${FLANG_TEST_DEPENDS})

View File

@ -0,0 +1 @@
configure_file(test_errors.sh.in ${FLANG_BINARY_DIR}/test/Semantics/test_errors.sh @ONLY)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
! Creating a symbol that allocate should accept

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
subroutine C933_a(b1, ca3, ca4, cp3, cp3mold, cp4, cp7, cp8, bsrc)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
subroutine C936(param_ca_4_assumed, param_ta_4_assumed, param_ca_4_deferred)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
subroutine C945_a(srca, srcb, srcc, src_complex, src_logical, &

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
subroutine C946(param_ca_4_assumed, param_ta_4_assumed, param_ca_4_deferred)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
!TODO: mixing expr and source-expr?

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
! TODO: Function Pointer in allocate and derived types!

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
subroutine C941_C942b_C950(xsrc, x1, a2, b2, cx1, ca2, cb1, cb2, c1)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in ALLOCATE statements
module not_iso_fortran_env

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check calls with alt returns
CALL TEST (N, *100, *200 )

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check subroutine with alt return
SUBROUTINE TEST (N, *, *)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for various alt return error conditions
SUBROUTINE TEST (N, *, *)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Functions cannot use alt return
REAL FUNCTION altreturn01(X)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test extension: RETURN from main program
return !ok

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! 10.2.3.1(2) All masks and LHS of assignments in a WHERE must conform
subroutine s1

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Pointer assignment constraints 10.2.2.2
module m1

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Pointer assignment constraints 10.2.2.2 (see also assign02.f90)
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! 9.4.5
subroutine s1
type :: t(k, l)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Forward references to derived types (error cases)
!ERROR: The derived type 'undef' was forward-referenced but not defined

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Confirm enforcement of constraints and restrictions in 7.5.7.3
! and C779-C785.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test BLOCK DATA subprogram (14.3)
block data foo
!ERROR: IMPORT is not allowed in a BLOCK DATA subprogram

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1107 -- COMMON, EQUIVALENCE, INTENT, NAMELIST, OPTIONAL, VALUE or
! STATEMENT FUNCTIONS not allow in specification part

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1108 -- Save statement in a BLOCK construct shall not conatin a
! saved-entity-list that does not specify a common-block-name

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Tests implemented for this standard:
! Block Construct
! C1109

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Enforce 18.2.3.3
program test

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Confirm enforcement of constraints and restrictions in 15.6.2.1
non_recursive function f01(n) result(res)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! 15.5.1 procedure reference constraints and restrictions
subroutine s01(elem, subr)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.5.2.4 constraints and restrictions for non-POINTER non-ALLOCATABLE
! dummy arguments.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 8.5.10 & 8.5.18 constraints on dummy argument declarations
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.5.2.5 constraints and restrictions for POINTER & ALLOCATABLE
! arguments when both sides of the call have the same attributes.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.5.2.6 constraints and restrictions for ALLOCATABLE
! dummy arguments.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.5.2.7 constraints and restrictions for POINTER dummy arguments.
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.5.2.8 coarray dummy arguments
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.5.2.9(2,3,5) dummy procedure requirements
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.7 (C1583-C1590, C1592-C1599) constraints and restrictions
! for pure procedures.
! (C1591 is tested in call11.f90; C1594 in call12.f90.)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.7 C1591 & others: contexts requiring pure subprograms
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.7 C1594 - prohibited assignments in pure subprograms
module used

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 15.4.2.2 constraints and restrictions for calls to implicit
! interfaces

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test 8.5.18 constraints on the VALUE attribute
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C711 An assumed-type actual argument that corresponds to an assumed-rank
! dummy argument shall be assumed-shape or assumed-rank.
subroutine s(arg1, arg2, arg3)

View File

@ -1,11 +1,11 @@
! RUN: %S/test_any.sh %s %flang %t
! RUN: %S/test_any.sh %s %f18 %t
! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1133
! By default, this is not an error and label do are rewritten to non-label do.
! A warning is generated with -Mstandard
! EXEC: ${F18} -funparse-with-symbols -Mstandard -I../../tools/f18/include %s 2>&1 | ${FileCheck} %s
! EXEC: ${F18} -funparse-with-symbols -Mstandard -I../../include/flang %s 2>&1 | ${FileCheck} %s
! CHECK: end do

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test selector and team-value in CHANGE TEAM statement
! OK

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C718 Each named constant in a complex literal constant shall be of type
! integer or real.
subroutine s()

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check that a basic computed goto compiles
INTEGER, DIMENSION (2) :: B

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check that computed goto express must be a scalar integer expression
! TODO: PGI, for example, accepts a float & converts the value to int.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
!C1117
subroutine test1(a, i)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
!C1118
subroutine test1

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
!C1119
subroutine test1(a, i)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
!Test for checking data constraints, C882-C887
module m1
type person

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check that expressions are analyzed in data statements
subroutine s1

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test that DEALLOCATE works
INTEGER, PARAMETER :: maxvalue=1024

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for type errors in DEALLOCATE statements
INTEGER, PARAMETER :: maxvalue=1024

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check for semantic errors in DEALLOCATE statements
Module share

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1141
! A reference to the procedure IEEE_SET_HALTING_MODE ! from the intrinsic
! module IEEE_EXCEPTIONS, shall not ! appear within a DO CONCURRENT construct.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1167 -- An exit-stmt shall not appear within a DO CONCURRENT construct if
! it belongs to that construct or an outer construct.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1167 -- An exit-stmt shall not appear within a DO CONCURRENT construct if
! it belongs to that construct or an outer construct.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1140 -- A statement that might result in the deallocation of a polymorphic
! entity shall not appear within a DO CONCURRENT construct.
module m1

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1131 -- check valid and invalid DO loop naming
PROGRAM C1131

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1121 -- any procedure referenced in a concurrent header must be pure
! Also, check that the step expressions are not zero. This is prohibited by

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Issue 458 -- semantic checks for a normal DO loop. The DO variable
! and the initial, final, and step expressions must be INTEGER if the
! options for standard conformance and turning warnings into errors

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1123 -- Expressions in DO CONCURRENT header cannot reference variables
! declared in the same header
PROGRAM dosemantics04

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test DO loop semantics for constraint C1130 --
! The constraint states that "If the locality-spec DEFAULT ( NONE ) appears in a
! DO CONCURRENT statement; a variable that is a local or construct entity of a

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1131, C1133 -- check valid and invalid DO loop naming
! C1131 (R1119) If the do-stmt of a do-construct specifies a do-construct-name,
! the corresponding end-do shall be an end-do-stmt specifying the same

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
!C1132
! If the do-stmt is a nonlabel-do-stmt, the corresponding end-do shall be an
! end-do-stmt.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1138 --
! A branch (11.2) within a DO CONCURRENT construct shall not have a branch
! target that is outside the construct.

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
!C1129
!A variable that is referenced by the scalar-mask-expr of a
!concurrent-header or by any concurrent-limit or concurrent-step in that

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1134 A CYCLE statement must be within a DO construct
!
! C1166 An EXIT statement must be within a DO construct

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1135 A cycle-stmt shall not appear within a CHANGE TEAM, CRITICAL, or DO
! CONCURRENT construct if it belongs to an outer construct.
!

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Tests valid and invalid ENTRY statements
module m1

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
subroutine s1
integer i, j
real r(2)

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! C1003 - can't parenthesize function call returning procedure pointer
module m1
type :: dt

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Test specification expressions
module m

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
subroutine forall1
real :: a(9)
!ERROR: 'i' is already declared in this scoping unit

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check that a basic arithmetic if compiles.
if ( A ) 100, 200, 300

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check that only labels are allowed in arithmetic if statements.
! TODO: Revisit error message "expected 'ASSIGN'" etc.
! TODO: Revisit error message "expected one of '0123456789'"

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
!ERROR: label '600' was not found

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Make sure arithmetic if expressions are non-complex numeric exprs.
INTEGER I

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Simple check that if constructs are ok.
if (a < b) then

View File

@ -1,4 +1,4 @@
! RUN: %S/test_errors.sh %s %flang %t
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
! Check that if constructs only accept scalar logical expressions.
! TODO: expand the test to check this restriction for more types.

Some files were not shown because too many files have changed in this diff Show More