llvm-project/flang/test/lit.cfg.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
3.9 KiB
Python
Raw Normal View History

# -*- Python -*-
import os
import platform
import re
import subprocess
import sys
import lit.formats
import lit.util
from lit.llvm import llvm_config
from lit.llvm.subst import ToolSubst
from lit.llvm.subst import FindTool
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
config.name = 'Flang'
# testFormat: The test format to use to interpret tests.
#
# For now we require '&&' between commands, until they get globally killed and
# the test runner updated.
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
# suffixes: A list of file extensions to treat as test files.
[flang][driver] Add the new flang compiler and frontend drivers Summary: This is the first patch implementing the new Flang driver as outlined in [1], [2] & [3]. It creates Flang driver (`flang-new`) and Flang frontend driver (`flang-new -fc1`). These will be renamed as `flang` and `flang -fc1` once the current Flang throwaway driver, `flang`, can be replaced with `flang-new`. Currently only 2 options are supported: `-help` and `--version`. `flang-new` is implemented in terms of libclangDriver, defaulting the driver mode to `FlangMode` (added to libclangDriver in [4]). This ensures that the driver runs in Flang mode regardless of the name of the binary inferred from argv[0]. The design of the new Flang compiler and frontend drivers is inspired by it counterparts in Clang [3]. Currently, the new Flang compiler and frontend drivers re-use Clang libraries: clangBasic, clangDriver and clangFrontend. To identify Flang options, this patch adds FlangOption/FC1Option enums. Driver::printHelp is updated so that `flang-new` prints only Flang options. The new Flang driver is disabled by default. To enable it, set `-DBUILD_FLANG_NEW_DRIVER=ON` when configuring CMake and add clang to `LLVM_ENABLE_PROJECTS` (e.g. -DLLVM_ENABLE_PROJECTS=“clang;flang;mlir”). [1] “RFC: new Flang driver - next steps” http://lists.llvm.org/pipermail/flang-dev/2020-July/000470.html [2] “RFC: Adding a fortran mode to the clang driver for flang” http://lists.llvm.org/pipermail/cfe-dev/2019-June/062669.html [3] “RFC: refactoring libclangDriver/libclangFrontend to share with Flang” http://lists.llvm.org/pipermail/cfe-dev/2020-July/066393.html [4] https://reviews.llvm.org/rG6bf55804924d5a1d902925ad080b1a2b57c5c75c co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com> Reviewed By: richard.barton.arm, sameeranjoshi Differential Revision: https://reviews.llvm.org/D86089
2020-09-11 17:17:31 +08:00
config.suffixes = ['.c', '.cpp', '.f', '.F', '.ff', '.FOR', '.for', '.f77', '.f90', '.F90',
[flang][driver] Add support for fixed form detection Currently the new flang driver always runs in free form mode. This patch adds support for fixed form mode detection based on the file extensions. Like `f18`, `flang-new` will treat files ending with ".f", ".F" and ".ff" as fixed form. Additionally, ".for", ".FOR", ".fpp" and ".FPP" file extensions are recognised as fixed form files. This is consistent with gfortran [1]. In summary, files with the following extensions are treated as fixed-form: * ".f", ".F", ".ff", ".for", ".FOR", ".fpp", ".FPP" For consistency with flang/test/lit.cfg.py and f18, this patch also adds support for the following file extensions: * ".ff", ".FOR", ".for", ".ff90", ".fpp", ".FPP" This is added in flang/lib/Frontend/FrontendOptions.cpp. Additionally, the following extensions are included: * ".f03", ".F03", ".f08", ".F08" This is for compatibility with gfortran [1] and other popular Fortran compilers [2]. NOTE: internally Flang will only differentiate between fixed and free form files. Currently Flang does not support switching between language standards, so in this regard file extensions are irrelevant. More specifically, both `file.f03` and `file.f18` are represented with `Language::Fortran` (as opposed to e.g. `Language::Fortran03`). Summary of changes: - Set Fortran::parser::Options::sFixedForm according to the file type - Add isFixedFormSuffix and isFreeFormSuffix helper functions to FrontendTool/Utils.h - Change FrontendOptions::GetInputKindForExtension to support the missing file extensions that f18 supports and some additional ones - FrontendActionTest.cpp is updated to make sure that the test input is treated as free-form [1] https://gcc.gnu.org/onlinedocs/gfortran/GNU-Fortran-and-GCC.html [2] https://github.com/llvm/llvm-project/blob/master/flang/docs/OptionComparison.md#notes Differential Revision: https://reviews.llvm.org/D94228
2021-01-05 00:49:33 +08:00
'.ff90', '.f95', '.F95', '.ff95', '.fpp', '.FPP', '.cuf'
'.CUF', '.f18', '.F18', '.fir', '.f03', '.F03', '.f08', '.F08']
config.substitutions.append(('%PATH%', config.environment['PATH']))
config.substitutions.append(('%llvmshlibdir', config.llvm_shlib_dir))
config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
llvm_config.use_default_substitutions()
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
# If the flang examples are built, add examples to the config
if config.flang_examples:
config.available_features.add('examples')
# Plugins (loadable modules)
if config.has_plugins:
config.available_features.add('plugins')
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.flang_obj_root, 'test')
# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.flang_tools_dir, append_path=True)
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
if config.flang_standalone_build:
# For builds with FIR, set path for tco and enable related tests
if config.flang_llvm_tools_dir != "":
config.available_features.add('fir')
if config.llvm_tools_dir != config.flang_llvm_tools_dir:
llvm_config.with_environment('PATH', config.flang_llvm_tools_dir, append_path=True)
# For each occurrence of a flang tool name, replace it with the full path to
# the build directory holding that tool.
tools = [
ToolSubst('%flang', command=FindTool('flang-new'), unresolved='fatal'),
ToolSubst('%flang_fc1', command=FindTool('flang-new'), extra_args=['-fc1'],
unresolved='fatal')]
[flang][driver] Add the new flang compiler and frontend drivers Summary: This is the first patch implementing the new Flang driver as outlined in [1], [2] & [3]. It creates Flang driver (`flang-new`) and Flang frontend driver (`flang-new -fc1`). These will be renamed as `flang` and `flang -fc1` once the current Flang throwaway driver, `flang`, can be replaced with `flang-new`. Currently only 2 options are supported: `-help` and `--version`. `flang-new` is implemented in terms of libclangDriver, defaulting the driver mode to `FlangMode` (added to libclangDriver in [4]). This ensures that the driver runs in Flang mode regardless of the name of the binary inferred from argv[0]. The design of the new Flang compiler and frontend drivers is inspired by it counterparts in Clang [3]. Currently, the new Flang compiler and frontend drivers re-use Clang libraries: clangBasic, clangDriver and clangFrontend. To identify Flang options, this patch adds FlangOption/FC1Option enums. Driver::printHelp is updated so that `flang-new` prints only Flang options. The new Flang driver is disabled by default. To enable it, set `-DBUILD_FLANG_NEW_DRIVER=ON` when configuring CMake and add clang to `LLVM_ENABLE_PROJECTS` (e.g. -DLLVM_ENABLE_PROJECTS=“clang;flang;mlir”). [1] “RFC: new Flang driver - next steps” http://lists.llvm.org/pipermail/flang-dev/2020-July/000470.html [2] “RFC: Adding a fortran mode to the clang driver for flang” http://lists.llvm.org/pipermail/cfe-dev/2019-June/062669.html [3] “RFC: refactoring libclangDriver/libclangFrontend to share with Flang” http://lists.llvm.org/pipermail/cfe-dev/2020-July/066393.html [4] https://reviews.llvm.org/rG6bf55804924d5a1d902925ad080b1a2b57c5c75c co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com> Reviewed By: richard.barton.arm, sameeranjoshi Differential Revision: https://reviews.llvm.org/D86089
2020-09-11 17:17:31 +08:00
# Define some variables to help us test that the flang runtime doesn't depend on
# the C++ runtime libraries. For this we need a C compiler. If for some reason
# we don't have one, we can just disable the test.
if config.cc:
libruntime = os.path.join(config.flang_lib_dir, 'libFortranRuntime.a')
libdecimal = os.path.join(config.flang_lib_dir, 'libFortranDecimal.a')
include = os.path.join(config.flang_src_dir, 'include')
if os.path.isfile(libruntime) and os.path.isfile(libdecimal) and os.path.isdir(include):
config.available_features.add('c-compiler')
tools.append(ToolSubst('%cc', command=config.cc, unresolved='fatal'))
tools.append(ToolSubst('%libruntime', command=libruntime,
unresolved='fatal'))
tools.append(ToolSubst('%libdecimal', command=libdecimal,
unresolved='fatal'))
tools.append(ToolSubst('%include', command=include,
unresolved='fatal'))
if config.flang_standalone_build:
llvm_config.add_tool_substitutions(tools, [config.flang_llvm_tools_dir])
else:
llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)
# Enable libpgmath testing
result = lit_config.params.get("LIBPGMATH")
if result:
[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@d1c7184159b2d3c542a8f36c58a0c817e7506845 Reviewed-on: https://github.com/flang-compiler/f18/pull/1045
2020-02-26 07:22:14 +08:00
config.environment["LIBPGMATH"] = True