LLVM/project ffc67bb — clang/lib/Driver/ToolChains CommonArgs.cpp, flang CMakeLists.txt
Revert "[Flang] [FlangRT] Introduce FlangRT project as solution to Flang's runtime LLVM integration" This reverts commit 6403287eff71a3d6f6c862346d6ed3f0f000eb70. This is failing on all but 1 of Linaro's flang builders. CMake Error at /home/tcwg-buildbot/worker/clang-aarch64-full-2stage/llvm/flang-rt/unittests/CMakeLists.txt:37 (message): Target llvm_gtest not found.
@@ -969,41 +969,29 @@ void tools::addFortra | |||
llvm::opt::ArgStringList &CmdArgs) { | llvm::opt::ArgStringList &CmdArgs) { | ||
if (TC.getTriple().isKnownWindowsMS | if (TC.getTriple().isKnownWindowsMS | ||
CmdArgs.push_back("Fortran_main.lib"); | CmdArgs.push_back("Fortran_main.lib"); | ||
- CmdArgs.push_back( | + CmdArgs.push_back("FortranRuntime.lib"); | ||
+ CmdArgs.push_back("FortranDecimal.lib"); | |||
} else { | } else { | ||
CmdArgs.push_back("-lFortran_main"); | CmdArgs.push_back("-lFortran_main"); | ||
- CmdArgs.push_back("- | + CmdArgs.push_back("-lFortranRuntime"); | ||
+ CmdArgs.push_back("-lFortranDecimal"); | |||
} | } | ||
} | } | ||
void tools::addFortranRuntim | void tools::addFortranRuntim | ||
const llvm::opt::ArgList &Args, | const llvm::opt::ArgList &Args, | ||
ArgStringList &CmdArgs) { | ArgStringList &CmdArgs) { | ||
- // Default to the <driver-path>/../lib | + // Default to the <driver-path>/../lib directory. This works fine on the | ||
- // <driver-path>/../runtimes/runtimes-bins/flang-rt/lib directories. This | + // platforms that we have tested so far. We will probably have to re-fine | ||
- // | + // this in the future. In particular, on some platforms, we may need to use | ||
- // have to re-fine this in the future. In particular, on some platforms, we | + // lib64 instead of lib. | ||
- // may need to use lib64 instead of lib. | + SmallString<256> DefaultLibPath = | ||
- SmallString<256> BuildLibPath = | |||
- llvm::sys::path::parent_path(TC.getDriver().Dir); | |||
- SmallString<256> FlangRTLibPath = | |||
- llvm::sys::path::parent_path(TC.getDriver().Dir); | |||
- SmallString<256> RuntimesLibPath = | |||
llvm::sys::path::parent_path(TC.getDriver().Dir); | llvm::sys::path::parent_path(TC.getDriver().Dir); | ||
- // Search path for Fortran_main and Flang-rt libraries. | + llvm::sys::path::append(DefaultLibPath, "lib"); | ||
- llvm::sys::path::append(BuildLibPath, "lib"); | + if (TC.getTriple().isKnownWindowsMS | ||
- llvm::sys::path::append(FlangRTLibPath, "flang-rt/lib"); | + CmdArgs.push_back(Args.MakeArgString("-libpath:" + DefaultLibPath)); | ||
- llvm::sys::path::append(RuntimesLibPath, | + else | ||
- "runtimes/runtimes-bins/flang-rt/lib"); | + CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath)); | ||
- if (TC.getTriple().isKnownWindowsMS | |||
- CmdArgs.push_back(Args.MakeArgString("-libpath:" + BuildLibPath)); | |||
- CmdArgs.push_back(Args.MakeArgString("-libpath:" + FlangRTLibPath)); | |||
- CmdArgs.push_back(Args.MakeArgString("-libpath:" + RuntimesLibPath)); | |||
- } else { | |||
- CmdArgs.push_back(Args.MakeArgString("-L" + BuildLibPath)); | |||
- CmdArgs.push_back(Args.MakeArgString("-L" + FlangRTLibPath)); | |||
- CmdArgs.push_back(Args.MakeArgString("-L" + RuntimesLibPath)); | |||
- } | |||
} | } | ||
static void addSanitizerRunt | static void addSanitizerRunt |
@@ -1,148 +0,0 @@ | |||
-# CMake build for the Flang runtime libraries | |||
-# The source for the flang runtime libraries (FortranDecimalRT | |||
-# exist in the flang top-level directory. | |||
-# Flang-rt is only scaffolding and does not provide any additional source files. | |||
- | |||
-cmake_minimum_re | |||
- | |||
-#=============================================================================== | |||
-# Configure CMake | |||
-#=============================================================================== | |||
-set(LLVM_COMMON_CMAK | |||
-include(${LLVM_COMMON_CMAK | |||
- NO_POLICY_SCOPE) | |||
- | |||
-set(CMAKE_BUILD_WITH | |||
-set(CMAKE_INCLUDE_CU | |||
- | |||
-set(CMAKE_RUNTIME_OU | |||
-set(CMAKE_LIBRARY_OU | |||
- ${CMAKE_BINARY_DIR | |||
-set(CMAKE_ARCHIVE_OU | |||
- ${CMAKE_BINARY_DIR | |||
-set(CMAKE_CURRENT_BI | |||
- | |||
-set(FLANG_RT_SOURCE_ | |||
-set(FLANG_RT_BINARY_ | |||
- | |||
-#=============================================================================== | |||
-# Setup Options and Defaults | |||
-#=============================================================================== | |||
-option(FLANG_RT_ENABLE_ | |||
-option(FLANG_RT_ENABLE_ | |||
- | |||
-option(FLANG_RT_INCLUDE | |||
- "Generate build targets for the Flang-rt unit tests." ${LLVM_INCLUDE_TES | |||
- | |||
-# MLIR_DIR must be passed on invocation of flang-rt because it is needed for the Flang package. | |||
-if(NOT DEFINED MLIR_DIR OR MLIR_DIR STREQUAL "") | |||
- message(FATAL_ERROR "MLIR_DIR must be set to the directory of the MLIRConfig cmake file in order to find the MLIR package.") | |||
-endif() | |||
-# Flang-rt requires a pre-built/installed version of flang that requires MLIR. | |||
-find_package(MLIR REQUIRED HINTS "${MLIR_DIR}") | |||
- | |||
-# FLANG_DIR must be passed on invocation of flang-rt. | |||
-if(NOT DEFINED FLANG_DIR OR FLANG_DIR STREQUAL "") | |||
- message(FATAL_ERROR "FLANG_DIR must be set to the directory of the FlangConfig cmake file in order to find the Flang package.") | |||
-endif() | |||
-# Flang-rt requires a pre-built/installed version of flang. | |||
-# Flang-rt uses flang/Common headers. | |||
-# Finding this package exposes FLANG_SOURCE_DIR | |||
-find_package(Flang REQUIRED HINTS "${FLANG_DIR}") | |||
-# If the user specifies a relative path to LLVM_DIR, the calls to include | |||
-# LLVM modules fail. Append the absolute path to LLVM_DIR instead. | |||
-get_filename_com | |||
-list(APPEND CMAKE_MODULE_PAT | |||
- | |||
-set(LLVM_COMMON_CMAK | |||
-set(LLVM_CMAKE_UTILS | |||
-set(CLANG_CMAKE_UTIL | |||
- | |||
-if (FLANG_RT_INCLUDE | |||
- # LLVM_DIR must be passed on invocation of flang-rt when tests are enabled. | |||
- if(NOT DEFINED LLVM_DIR OR LLVM_DIR STREQUAL "") | |||
- message(FATAL_ERROR "LLVM_DIR must be set to the directory of the LLVMConfig cmake file in order to find the LLVM package.") | |||
- endif() | |||
- # We need a pre-built/installed version of LLVM for gtest. | |||
- find_package(LLVM REQUIRED HINTS "${LLVM_DIR}") | |||
- # If the user specifies a relative path to LLVM_DIR, the calls to include | |||
- # LLVM modules fail. Append the absolute path to LLVM_DIR instead. | |||
- get_filename_com | |||
- list(APPEND CMAKE_MODULE_PAT | |||
- | |||
- add_compile_defi | |||
- | |||
- if (DEFINED FLANG_BINARY_DIR | |||
- set(FLANG_BINARY_DIR | |||
- else() | |||
- message(FATAL_ERROR "FLANG_BINARY_DIR | |||
- endif() | |||
- set(FLANG_RT_TEST_CO | |||
- CACHE PATH "Compiler to use for testing") | |||
- set(FLANG_RT_GTEST_A | |||
-endif() | |||
- | |||
-# Add path for custom modules | |||
-list(INSERT CMAKE_MODULE_PAT | |||
- "${FLANG_SOURCE_DIR | |||
- "${FLANG_SOURCE_DIR | |||
- "${CLANG_CMAKE_UTIL | |||
- "${LLVM_CMAKE_UTILS | |||
-) | |||
- | |||
-include(AddClang) | |||
-include(AddFlang) | |||
-include(TestBigEndian) | |||
-test_big_endian(IS_BIGENDIAN) | |||
-if (IS_BIGENDIAN) | |||
- add_compile_defi | |||
-else () | |||
- add_compile_defi | |||
-endif () | |||
- | |||
-# Flang's include directories are needed for flang/Common. | |||
-include_director | |||
- | |||
-# LLVM's include directories are needed for gtest. | |||
-include_director | |||
- | |||
-#=============================================================================== | |||
-# Add Subdirectories | |||
-#=============================================================================== | |||
-set(FORTRAN_DECIMAL_ | |||
-set(FORTRAN_RUNTIME_ | |||
-set(FORTRAN_MAIN_SRC | |||
- | |||
-add_subdirectory | |||
-add_subdirectory | |||
-add_subdirectory | |||
- | |||
-if (FLANG_RT_INCLUDE | |||
- add_subdirectory | |||
- if (FLANG_RT_GTEST_A | |||
- add_subdirectory | |||
- endif() | |||
-endif() | |||
- | |||
-#=============================================================================== | |||
-# Create Flang-rt wrapper library | |||
-#=============================================================================== | |||
-# Build as shared by default if no linkage type option set. | |||
-if (NOT FLANG_RT_ENABLE_ | |||
- add_library(flang-rt SHARED $<TARGET_OBJECTS:obj.FortranDecimalRT | |||
- $<TARGET_OBJECTS:obj.FortranRuntime>) | |||
-endif() | |||
-if (FLANG_RT_ENABLE_ | |||
- add_library(flang-rt SHARED $<TARGET_OBJECTS:obj.FortranDecimalRT | |||
- $<TARGET_OBJECTS:obj.FortranRuntime>) | |||
-endif() | |||
-if (FLANG_RT_ENABLE_ | |||
- add_library(flang-rt STATIC $<TARGET_OBJECTS:obj.FortranDecimalRT | |||
- $<TARGET_OBJECTS:obj.FortranRuntime>) | |||
-endif() | |||
-# When building both static and shared, we need to append _static to the name | |||
-# to avoid naming conflicts. | |||
-if (FLANG_RT_ENABLE_ | |||
- add_library(flang-rt_static STATIC $<TARGET_OBJECTS:obj.FortranDecimalRT | |||
- $<TARGET_OBJECTS:obj.FortranRuntime>) | |||
-endif() |
@@ -1,156 +0,0 @@ | |||
-<!--===- docs/GettingStarted.md | |||
- | |||
- 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 | |||
- | |||
---> | |||
- | |||
-# Flang-rt Runtime Library | |||
- | |||
-```eval_rst | |||
-.. contents:: | |||
- :local: | |||
-``` | |||
-## What is Flang-rt | |||
-Flang-rt is the runtime library project for Flang. The Flang driver requires | |||
-the Fortran_main and Flang-rt libraries at runtime in order to generate | |||
-user executables. Building this Flang-rt project will build both Fortran_main | |||
-and the Flang-rt library, which is comprised of the FortranRuntime and | |||
-FortranDecimalRT | |||
- | |||
-### Fortran_main | |||
-Fortran_main is left out of the Flang-rt library because it is required to | |||
-always be static unlike the link type of the Flang-rt library which can be | |||
-configured. Fortran_main implements the main entry point into Fortran's | |||
-`PROGRAM` in Flang by being the bridge between object files generated by Flang | |||
-and the C runtime that takes care of program set-up at system-level. For | |||
-every Fortran `PROGRAM`, Flang generates the `_QQmain` function. | |||
-Fortran_main implements the C `main` function that simply calls | |||
-`_QQmain`. | |||
- | |||
-### FortranDecimalRT | |||
-In order to decouple the common dependency between compiler and runtime, | |||
-[FortranDecimal's sources](../../flang/lib/Decimal/CMakeLists.txt) are built | |||
-separately for the compiler and the runtime. When the library is built for | |||
-Flang-rt, the name FortranDecimalRT | |||
-confusion. | |||
- | |||
-### FortranRuntime | |||
-This is the core runtime library in Flang-rt. The sources for this library | |||
-currently still exist in the | |||
-[Flang source directory](../../flang/runtime/CMakeLists.txt). We hope to | |||
-migrate the sources to the Flang-rt directory in the future in order to further | |||
-decouple the runtime from the Flang compiler. | |||
- | |||
-## Building Flang-rt | |||
-Like other LLVM runtimes, Flang-rt can be built by targetting the | |||
-[runtimes LLVM target](../../runtimes/CMakelists.txt). It can also be built | |||
-when targetting the [llvm target](../../llvm/CMakeLists.txt) as an enabled | |||
-runtime. Flang-rt will implicitly be added as an enabled runtime when Flang | |||
-is an enabled project built by llvm. Flang-rt does not support standalone | |||
-builds. | |||
- | |||
-In the future, we may be interested in supporting in optionally building | |||
-Flang-rt when doing a Flang standalone build. | |||
- | |||
-### Building with the llvm target | |||
-Assuming you are building Flang-rt to use with Flang, see | |||
-[Flang's Getting Started guide](../../flang/docs/GettingStarted.md) for more | |||
-information. To build Flang-rt when building the Flang compiler, once you have | |||
-the llvm-project source ready, make a clean build directory. Let root be the | |||
-root directory that you cloned llvm-project into. | |||
-```bash | |||
-cd root | |||
-rm -rf build | |||
-mkdir build | |||
-cd build | |||
-``` | |||
-Now invoke the cmake configuration command for llvm that would build Flang with | |||
-Flang-rt. | |||
-```bash | |||
-cmake \ | |||
- -G Ninja \ | |||
- -DLLVM_ENABLE_RUN | |||
- -DCMAKE_CXX_STAND | |||
- -DLLVM_INSTALL_UT | |||
- # New Flang-rt flags for enabled link types | |||
- -DFLANG_RT_ENABLE | |||
- -DFLANG_RT_ENABLE | |||
- # We need to enable GTest if we want to run Flang-rt's testsuites | |||
- -DLLVM_INSTALL_GT | |||
- -DFLANG_ENABLE_WE | |||
- -DLLVM_LIT_ARGS=-v \ | |||
- -DCMAKE_BUILD_TYP | |||
- -DLLVM_ENABLE_PRO | |||
- ../llvm-project/llvm | |||
-``` | |||
-Flang requires other llvm projects (see LLVM_ENABLE_PROJ | |||
-Getting Started Guide](../../flang/docs/GettingStarted.md) for more specifics | |||
-on building Flang. | |||
- | |||
-By targetting the LLVM project, we are letting LLVM infrastructure handle | |||
-invoking the runtimes target that will build Flang-rt. This includes finding | |||
-the cmake packages for Clang, LLVM, Flang and MLIR that Flang-rt depends on. | |||
- | |||
-### Building with the runtimes target | |||
-If you already have a pre-built/installed version of LLVM, Flang, Clang and | |||
-MLIR, and would like to build Flang-rt without rebuilding the sources for these | |||
-other projects. You can simply target the runtimes project directly and passing | |||
-the paths to the directories of these files. If you built LLVM as we did above | |||
-with default build directories, your runtimes invocation should look something | |||
-like: | |||
-```bash | |||
-cd build | |||
-BUILDDIR=`pwd` | |||
- | |||
-cmake \ | |||
- -G Ninja \ | |||
- -DCMAKE_CXX_STAND | |||
- # New Flang-rt flags for enabled link types | |||
- -DFLANG_RT_ENABLE | |||
- -DFLANG_RT_ENABLE | |||
- -DLLVM_LIT_ARGS=-v \ | |||
- -DCMAKE_BUILD_TYP | |||
- -DCMAKE_CXX_LINK_ | |||
- -DLLVM_TARGETS_TO | |||
- -DLLVM_EXTERNAL_L | |||
- # We need to specify the paths to the cmake packages of the dependencies | |||
- -DLLVM_DIR=$BUILD_DIR/lib/cmake/llvm \ | |||
- -DMLIR_DIR=$BUILD_DIR/lib/cmake/mlir \ | |||
- -DFLANG_DIR=$BUILD_DIR/lib/cmake/flang \ | |||
- -DLLVM_ENABLE_RUN | |||
- ../llvm-project/runtimes/ | |||
-``` | |||
- | |||
-## Library locations | |||
-When building the llvm target with flang as an enabled project, the Flang-rt | |||
-library will be built to `$BUILDDIR/runtimes/runtimes-bins/flang-rt/lib`. When | |||
-building the runtimes target with flang-rt as an enabled runtime, the libraries | |||
-will be built to `$BUILDDIR/flang-rt/lib` by default. In either configuration, | |||
-the Fortran_main library will be built to `$BUILDDIR/lib` by default. | |||
- | |||
-## Using Flang-rt | |||
-The two build paths mentioned above get implicitly added as library paths at the | |||
-invocation of the driver. If Flang-rt is a shared library, you must make the | |||
-dynamic linker aware of where to look. One method to do so is to set the | |||
-environment variable `LD_LIBRARY_PATH` include the path to Flang-rt's directory. | |||
- | |||
-## Options | |||
-Flang-rt introduces 2 CMake options used to configure the library's link type: | |||
-``` | |||
-option(FLANG_RT_ENABLE_ | |||
-option(FLANG_RT_ENABLE_ | |||
-``` | |||
-Both can be specified if you want to build both shared and static versions of | |||
-the Flang-rt runtime. If both are specified, the static library will be named | |||
-Flang-rt_static.a to avoid naming conflicts, as per the LLVM standard. | |||
- | |||
-## Usage Examples | |||
-```bash | |||
-# Example of using Flang with the shared Flang-rt runtime | |||
-# First we need to explicitly tell the dynamic linker where to find Flang-rt | |||
-# since it was built as shared. | |||
-$ $ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$BUILDDIR/runtimes/runtimes-bins/flang-rt/lib" | |||
-$ flang-new -ffree-form hello.f95 -o hello | |||
-``` |
@@ -1,73 +0,0 @@ | |||
-# Test runner infrastructure for Flang-rt. This configures the Flang-rt test | |||
-# trees for use by Lit, and delegates to LLVM's lit test handlers. | |||
- | |||
-llvm_canonicaliz | |||
- FLANG_STANDALONE | |||
- LLVM_BUILD_EXAMP | |||
- LLVM_BYE_LINK_IN | |||
- LLVM_ENABLE_PLUG | |||
-) | |||
- | |||
-set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR | |||
- | |||
-configure_lit_si | |||
- ${CMAKE_CURRENT_SO | |||
- ${CMAKE_CURRENT_BI | |||
- MAIN_CONFIG | |||
- ${CMAKE_CURRENT_SO | |||
- PATHS | |||
- ${PATHS_FOR_PLUGIN | |||
-) | |||
- | |||
-configure_lit_si | |||
- ${CMAKE_CURRENT_SO | |||
- ${CMAKE_CURRENT_BI | |||
- MAIN_CONFIG | |||
- ${CMAKE_CURRENT_SO | |||
-) | |||
- | |||
-configure_lit_si | |||
- ${CMAKE_CURRENT_SO | |||
- ${CMAKE_CURRENT_BI | |||
- MAIN_CONFIG | |||
- ${CMAKE_CURRENT_SO | |||
-) | |||
- | |||
-set(FLANG_RT_TEST_PA | |||
- flang_rt_site_co | |||
- | |||
-set(FLANG_RT_TEST_DE | |||
- LLVMSupport | |||
- flang-rt | |||
- Fortran_main | |||
-) | |||
-if (LLVM_ENABLE_PLUG | |||
- list(APPEND FLANG_RT_TEST_DE | |||
-endif() | |||
- | |||
-if (FLANG_RT_INCLUDE | |||
- if (FLANG_RT_GTEST_A | |||
- list(APPEND FLANG_RT_TEST_DE | |||
- endif() | |||
-endif() | |||
- | |||
-add_custom_targe | |||
- | |||
-add_lit_testsuit | |||
- ${CMAKE_CURRENT_BI | |||
- PARAMS ${FLANG_RT_TEST_PA | |||
- DEPENDS ${FLANG_RT_TEST_DE | |||
-) | |||
-set_target_prope | |||
- | |||
-add_lit_testsuit | |||
- PARAMS ${FLANG_RT_TEST_PA | |||
- DEPENDS ${FLANG_RT_TEST_DE | |||
- | |||
-# To modify the default target triple for flang-rt tests. | |||
-if (DEFINED FLANG_RT_TEST_TA | |||
- if (NOT DEFINED LLVM_TARGET_TRIP | |||
- message(FATAL_ERROR "LLVM_TARGET_TRIP | |||
- "to use FLANG_RT_TEST_TA | |||
- endif() | |||
-endif() |
@@ -1,38 +0,0 @@ | |||
-/* | |||
-This test makes sure that flang's runtime does not depend on the C++ runtime | |||
-library. It tries to link this simple file against libFortranRuntim | |||
-a C compiler. | |||
- | |||
-REQUIRES: c-compiler | |||
- | |||
-RUN: %cc -std=c99 %s -I%include %libruntime -lm -o /dev/null | |||
-*/ | |||
- | |||
-#include "flang/Runtime/entry-names.h" | |||
-#include <stdint.h> | |||
- | |||
-/* | |||
-Manually add declarations for the runtime functions that we want to make sure | |||
-we're testing. We can't include any headers directly since they likely contain | |||
-C++ code that would explode here. | |||
-*/ | |||
-struct EnvironmentDefau | |||
-struct Descriptor; | |||
- | |||
-double RTNAME(CpuTime)(); | |||
- | |||
-void RTNAME(ProgramStart)( | |||
- int, const char *[], const char *[], const struct EnvironmentDefau | |||
-int32_t RTNAME(ArgumentCount)(); | |||
-int32_t RTNAME(GetCommandArgume | |||
- const struct Descriptor *, const struct Descriptor *); | |||
-int32_t RTNAME(GetEnvVariable)(); | |||
- | |||
-int main() { | |||
- double x = RTNAME(CpuTime)(); | |||
- RTNAME(ProgramStart)(0, 0, 0, 0); | |||
- int32_t c = RTNAME(ArgumentCount)(); | |||
- int32_t v = RTNAME(GetCommandArgume | |||
- int32_t e = RTNAME(GetEnvVariable)("FOO", 0, 0); | |||
- return x + c + v + e; | |||
-} |
@@ -1,22 +0,0 @@ | |||
-import os | |||
- | |||
-import lit.Test | |||
- | |||
-config.name = "flang-rt-OldUnit" | |||
- | |||
-config.suffixes = [".test"] | |||
- | |||
-config.test_source_root | |||
-config.test_exec_root = config.test_source_root | |||
- | |||
-config.test_format = lit.formats.ExecutableTest() | |||
- | |||
-path = os.path.pathsep.join( | |||
- ( | |||
- config.flang_rt_lib_dir | |||
- config.flang_bin_dir, | |||
- config.flang_libs_dir, | |||
- config.environment.get("LD_LIBRARY_PATH", ""), | |||
- ) | |||
-) | |||
-config.environment["LD_LIBRARY_PATH"] = path |
@@ -1,23 +0,0 @@ | |||
-@LIT_SITE_CFG_IN_ | |||
- | |||
-config.llvm_src_root = "@LLVM_SOURCE_DIR@" | |||
-config.llvm_obj_root = "@LLVM_BINARY_DIR@" | |||
-config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") | |||
-config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") | |||
-config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@") | |||
-config.lit_tools_dir = "@LLVM_LIT_TOOLS_D | |||
-config.flang_src_dir = "@FLANG_SOURCE_DIR | |||
-config.flang_bin_dir = "@FLANG_BINARY_DIR | |||
-config.flang_libs_dir = "@FLANG_BINARY_DIR | |||
-config.flang_rt_obj_roo | |||
-config.flang_tools_dir = lit_config.substitute("@FLANG_TOOLS_DIR@") | |||
-config.flang_llvm_tools | |||
-config.flang_rt_src_dir | |||
-config.flang_rt_lib_dir | |||
-config.flang_rt_test_co | |||
-config.flang_rt_test_tr | |||
-config.target_triple = "@LLVM_TARGET_TRIP | |||
-config.python_executabl | |||
- | |||
-# Let the main config do the real work. | |||
-lit_config.load_config(config, "@FLANG_RT_SOURCE_ |
@@ -1,58 +0,0 @@ | |||
-# -*- Python -*- | |||
- | |||
-# Configuration file for the 'lit' test runner. | |||
- | |||
-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 | |||
- | |||
-# name: The name of this test suite. | |||
-config.name = "flang-rt-Unit" | |||
- | |||
-# suffixes: A list of file extensions to treat as test files. | |||
-config.suffixes = [] | |||
- | |||
-# test_source_root | |||
-# test_exec_root: The root path where tests should be run. | |||
-config.test_source_root | |||
-config.test_exec_root = config.test_source_root | |||
- | |||
-# testFormat: The test format to use to interpret tests. | |||
-config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, | |||
- | |||
-# Tweak the PATH to include the flang bin and libs dirs. | |||
-path = os.path.pathsep.join( | |||
- ( | |||
- config.flang_bin_dir, | |||
- config.llvm_tools_dir, | |||
- config.environment["PATH"] | |||
- ) | |||
-) | |||
-config.environment["PATH"] = path | |||
- | |||
-path = os.path.pathsep.join( | |||
- ( | |||
- config.flang_rt_lib_dir | |||
- config.flang_libs_dir, | |||
- config.flang_bin_dir, | |||
- config.environment.get("LD_LIBRARY_PATH", ""), | |||
- ) | |||
-) | |||
-config.environment["LD_LIBRARY_PATH"] = path | |||
- | |||
-# Propagate PYTHON_EXECUTABL | |||
-# config.environment['PYTHON_EXECUTABL | |||
- | |||
-# To modify the default target triple for flang-rt tests. | |||
-if config.flang_rt_test_tr | |||
- config.target_triple = config.flang_rt_test_tr | |||
- config.environment[config.llvm_target_trip |
@@ -1,22 +0,0 @@ | |||
-@LIT_SITE_CFG_IN_ | |||
- | |||
-config.llvm_src_root = "@LLVM_SOURCE_DIR@" | |||
-config.llvm_obj_root = "@LLVM_BINARY_DIR@" | |||
-config.llvm_target_trip | |||
-config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") | |||
-config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@") | |||
-config.lit_tools_dir = "@LLVM_LIT_TOOLS_D | |||
-config.flang_bin_dir = "@FLANG_BINARY_DIR | |||
-config.flang_src_dir = "@FLANG_SOURCE_DIR | |||
-config.flang_libs_dir = "@FLANG_BINARY_DIR | |||
-config.flang_rt_obj_roo | |||
-config.flang_rt_src_dir | |||
-config.flang_rt_lib_dir | |||
-config.flang_rt_test_co | |||
-config.flang_rt_test_tr | |||
-config.flang_tools_dir = lit_config.substitute("@FLANG_TOOLS_DIR@") | |||
-config.target_triple = "@LLVM_TARGET_TRIP | |||
-config.python_executabl | |||
- | |||
-# Let the main config do the real work. | |||
-lit_config.load_config(config, "@FLANG_RT_SOURCE_ |
@@ -1,173 +0,0 @@ | |||
-# -*- 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-rt" | |||
- | |||
-# 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. | |||
-config.suffixes = [ | |||
- ".c", | |||
- ".cpp", | |||
- ".f", | |||
- ".F", | |||
- ".ff", | |||
- ".FOR", | |||
- ".for", | |||
- ".f77", | |||
- ".f90", | |||
- ".F90", | |||
- ".ff90", | |||
- ".f95", | |||
- ".F95", | |||
- ".ff95", | |||
- ".fpp", | |||
- ".FPP", | |||
- ".cuf", | |||
- ".CUF", | |||
- ".f18", | |||
- ".F18", | |||
- ".f03", | |||
- ".F03", | |||
- ".f08", | |||
- ".F08", | |||
- ".ll", | |||
- ".fir", | |||
- ".mlir", | |||
-] | |||
- | |||
-config.substitutions.append(("%PATH%", config.environment["PATH"])) | |||
-config.substitutions.append(("%pluginext", config.llvm_plugin_ext)) | |||
- | |||
-llvm_config.use_default_subs | |||
- | |||
-# ask llvm-config about asserts | |||
-llvm_config.feature_config([("--assertion-mode", {"ON": "asserts"})]) | |||
- | |||
-# Targets | |||
-config.targets = frozenset(config.targets_to_build | |||
-for arch in config.targets_to_build | |||
- config.available_featur | |||
- | |||
-# To modify the default target triple for flang-rt tests. | |||
-if config.flang_rt_test_tr | |||
- config.target_triple = config.flang_rt_test_tr | |||
- config.environment[config.llvm_target_trip | |||
- | |||
-# 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"] | |||
- | |||
-# Plugins (loadable modules) | |||
-if config.has_plugins: | |||
- config.available_featur | |||
- | |||
-if config.linked_bye_exten | |||
- config.substitutions.append(("%loadbye", "")) | |||
-else: | |||
- config.substitutions.append( | |||
- ( | |||
- "%loadbye", | |||
- "-fpass-plugin={}/Bye{}".format( | |||
- config.llvm_shlib_dir, config.llvm_plugin_ext | |||
- ), | |||
- ) | |||
- ) | |||
- | |||
-# test_source_root | |||
-config.test_source_root | |||
- | |||
-# test_exec_root: The root path where tests should be run. | |||
-config.test_exec_root = os.path.join(config.flang_rt_obj_roo | |||
- | |||
-llvm_config.with_environment | |||
-llvm_config.with_environment | |||
-llvm_config.with_environment | |||
-llvm_config.with_environment | |||
- | |||
-# 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 has several unimplemented features. TODO messages are used to mark | |||
-# and fail if these features are exercised. Some TODOs exit with a non-zero | |||
-# exit code, but others abort the execution in assert builds. | |||
-# To catch aborts, the `--crash` option for the `not` command has to be used. | |||
-tools.append(ToolSubst("%not_todo_cmd", command=FindTool("not"), unresolved="fatal")) | |||
-if "asserts" in config.available_featur | |||
- tools.append( | |||
- ToolSubst( | |||
- "%not_todo_abort_c | |||
- command=FindTool("not"), | |||
- extra_args=["--crash"], | |||
- unresolved="fatal", | |||
- ) | |||
- ) | |||
-else: | |||
- tools.append( | |||
- ToolSubst("%not_todo_abort_c | |||
- ) | |||
- | |||
-# 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_stati | |||
- libruntime_share | |||
- include = os.path.join(config.flang_src_dir, "include") | |||
- | |||
- if ( | |||
- os.path.isfile(libruntime_stati | |||
- and os.path.isdir(include) | |||
- ): | |||
- config.available_featur | |||
- tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal")) | |||
- tools.append(ToolSubst("%libruntime", command=libruntime_stati | |||
- tools.append(ToolSubst("%include", command=include, unresolved="fatal")) | |||
- | |||
- elif ( | |||
- os.path.isfile(libruntime_share | |||
- and os.path.isdir(include) | |||
- ): | |||
- config.available_featur | |||
- tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal")) | |||
- tools.append(ToolSubst("%libruntime", command=libruntime_share | |||
- tools.append(ToolSubst("%include", command=include, unresolved="fatal")) | |||
- | |||
- | |||
-# Add all the tools and their substitutions (if applicable). Use the search paths provided for | |||
-# finding the tools. | |||
-llvm_config.add_tool_substit | |||
- | |||
-# Enable libpgmath testing | |||
-result = lit_config.params.get("LIBPGMATH") | |||
-if result: | |||
- config.environment["LIBPGMATH"] = True |
@@ -1,31 +0,0 @@ | |||
-@LIT_SITE_CFG_IN_ | |||
- | |||
-import sys | |||
- | |||
-config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") | |||
-config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@")) | |||
-config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@" | |||
-config.target_triple = "@LLVM_TARGET_TRIP | |||
-config.llvm_target_trip | |||
-config.lit_tools_dir = "@LLVM_LIT_TOOLS_D | |||
-config.errc_messages = "@LLVM_LIT_ERRC_ME | |||
-config.flang_src_dir = "@FLANG_SOURCE_DIR | |||
-config.flang_bin_dir = "@FLANG_BINARY_DIR | |||
-config.flang_libs_dir = "@FLANG_BINARY_DIR | |||
-config.flang_tools_dir = lit_config.substitute("@FLANG_TOOLS_DIR@") | |||
-config.flang_llvm_tools | |||
-config.flang_rt_obj_roo | |||
-config.flang_rt_src_dir | |||
-config.flang_rt_lib_dir | |||
-config.flang_rt_test_tr | |||
-config.python_executabl | |||
-config.has_plugins = @LLVM_ENABLE_PLUG | |||
-config.linked_bye_exten | |||
-config.cc = "@CMAKE_C_COMPILER | |||
-config.targets_to_build | |||
- | |||
-import lit.llvm | |||
-lit.llvm.initialize(lit_config, config) | |||
- | |||
-# Let the main config do the real work. | |||
-lit_config.load_config(config, "@FLANG_RT_SOURCE_ |
@@ -1,81 +0,0 @@ | |||
-if (FLANG_EXPERIMENT | |||
- # If Fortran runtime is built as CUDA library, the linking | |||
- # of targets that link FortranRuntime must be done | |||
- # with CUDA_RESOLVE_DEV | |||
- # CUDA language must be enabled for CUDA_RESOLVE_DEV | |||
- # to take effect. | |||
- enable_language(CUDA) | |||
-endif() | |||
- | |||
-add_custom_targe | |||
-set_target_prope | |||
- | |||
-function(add_flang_rt_uni | |||
- # Set CUDA_RESOLVE_DEV | |||
- if (FLANG_EXPERIMENT | |||
- set_target_prope | |||
- PROPERTIES CUDA_RESOLVE_DEV | |||
- ) | |||
- endif() | |||
- # Enable OpenMP offload during linking. We may need to replace | |||
- # LINK_OPTIONS with COMPILE_OPTIONS when there are OpenMP offload | |||
- # unittests. | |||
- # | |||
- # FIXME: replace 'native' in --offload-arch option with the list | |||
- # of targets that Fortran Runtime was built for. | |||
- # Common code must be moved from flang/runtime/CMakeLists.txt. | |||
- # TODO: Revisit this because of Flang-rt. runtime is no longer an added subdirectory of flang. | |||
- if (NOT FLANG_EXPERIMENT | |||
- set_target_prope | |||
- PROPERTIES LINK_OPTIONS | |||
- "-fopenmp;--offload-arch=native" | |||
- ) | |||
- endif() | |||
-endfunction() | |||
- | |||
-if(NOT TARGET llvm_gtest) | |||
- message(FATAL_ERROR "Target llvm_gtest not found.") | |||
-endif() | |||
- | |||
-function(add_flang_rt_uni | |||
- add_unittest(FlangRTUnitTests | |||
- add_flang_rt_uni | |||
-endfunction() | |||
- | |||
-if (CXX_SUPPORTS_SUG | |||
- add_compile_opti | |||
-endif() | |||
- | |||
-function(add_flang_rt_non | |||
- cmake_parse_argu | |||
- "SLOW_TEST" | |||
- "" | |||
- "" | |||
- ${ARGN}) | |||
- | |||
- list(APPEND LLVM_COMPILE_FLA | |||
- if(ARG_SLOW_TEST) | |||
- set(suffix .slow) | |||
- else() | |||
- set(suffix .test) | |||
- endif() | |||
- | |||
- add_executable(${test_name}${suffix} ${test_name}.cpp) | |||
- | |||
- if (LLVM_LINK_LLVM_D | |||
- set(llvm_libs LLVM) | |||
- else() | |||
- llvm_map_compone | |||
- endif() | |||
- target_link_libr | |||
- | |||
- if(NOT ARG_SLOW_TEST) | |||
- add_dependencies | |||
- endif() | |||
- | |||
- add_flang_rt_uni | |||
-endfunction() | |||
- | |||
-add_subdirectory | |||
-# TODO: We may want to find a better location for these tests that use the runtime | |||
-add_subdirectory |
@@ -1,21 +0,0 @@ | |||
-set(CMAKE_RUNTIME_OU | |||
-add_library(FlangRTFortranEv | |||
- testing.cpp | |||
-) | |||
-if (LLVM_LINK_LLVM_D | |||
- set(llvm_libs LLVM) | |||
-else() | |||
- llvm_map_compone | |||
-endif() | |||
-target_link_libr | |||
- ${llvm_libs}) | |||
- | |||
-add_flang_rt_non | |||
- FlangRTFortranEv | |||
- flang-rt | |||
-) | |||
- | |||
-add_flang_rt_non | |||
- FlangRTFortranEv | |||
- flang-rt | |||
-) |
@@ -1,128 +0,0 @@ | |||
-#include "testing.h" | |||
-#include <cstdarg> | |||
-#include <cstdio> | |||
-#include <cstdlib> | |||
- | |||
-namespace testing { | |||
- | |||
-namespace { | |||
-int passes{0}; | |||
-int failures{0}; | |||
-} // namespace | |||
- | |||
-static void BitBucket(const char *, ...) {} | |||
- | |||
-static void PrintFailureDeta | |||
- va_list ap; | |||
- va_start(ap, format); | |||
- fputs("\t", stderr); | |||
- vfprintf(stderr, format, ap); | |||
- va_end(ap); | |||
- fputc('\n', stderr); | |||
-} | |||
- | |||
-FailureDetailPri | |||
- bool pass) { | |||
- if (pass) { | |||
- ++passes; | |||
- return BitBucket; | |||
- } else { | |||
- ++failures; | |||
- fprintf(stderr, "%s:%d: FAIL: %s\n", file, line, predicate); | |||
- return PrintFailureDeta | |||
- } | |||
-} | |||
- | |||
-FailureDetailPri | |||
- const char *gots, std::uint64_t got) { | |||
- if (want == got) { | |||
- ++passes; | |||
- return BitBucket; | |||
- } else { | |||
- ++failures; | |||
- fprintf(stderr, "%s:%d: FAIL: %s == 0x%jx, not 0x%jx\n", file, line, gots, | |||
- static_cast<std::uintmax_t>(got), | |||
- static_cast<std::uintmax_t>(want)); | |||
- return PrintFailureDeta | |||
- } | |||
-} | |||
- | |||
-FailureDetailPri | |||
- const char *gots, const std::string &got) { | |||
- if (want == got) { | |||
- ++passes; | |||
- return BitBucket; | |||
- } else { | |||
- ++failures; | |||
- fprintf(stderr, "%s:%d: FAIL: %s == \"%s\", not \"%s\"\n", file, line, gots, | |||
- got.data(), want); | |||
- return PrintFailureDeta | |||
- } | |||
-} | |||
- | |||
-FailureDetailPri | |||
- const char *gots, const std::string &got) { | |||
- return Match(file, line, want.data(), gots, got); | |||
-} | |||
- | |||
-FailureDetailPri | |||
- const char *rel, const char *ys, std::uint64_t x, | |||
- std::uint64_t y) { | |||
- while (*rel == ' ') { | |||
- ++rel; | |||
- } | |||
- bool pass{false}; | |||
- if (*rel == '<') { | |||
- if (rel[1] == '=') { | |||
- pass = x <= y; | |||
- } else { | |||
- pass = x < y; | |||
- } | |||
- } else if (*rel == '>') { | |||
- if (rel[1] == '=') { | |||
- pass = x >= y; | |||
- } else { | |||
- pass = x > y; | |||
- } | |||
- } else if (*rel == '=') { | |||
- pass = x == y; | |||
- } else if (*rel == '!') { | |||
- pass = x != y; | |||
- } | |||
- if (pass) { | |||
- ++passes; | |||
- return BitBucket; | |||
- } else { | |||
- ++failures; | |||
- fprintf(stderr, "%s:%d: FAIL: %s[0x%jx] %s %s[0x%jx]\n", file, line, xs, | |||
- static_cast<std::uintmax_t>(x), rel, ys, | |||
- static_cast<std::uintmax_t>(y)); | |||
- return PrintFailureDeta | |||
- } | |||
-} | |||
- | |||
-int Complete() { | |||
- if (failures == 0) { | |||
- if (passes == 1) { | |||
- fprintf(stdout, "single test PASSES\n"); | |||
- } else { | |||
- fprintf(stdout, "all %d tests PASS\n", passes); | |||
- } | |||
- passes = 0; | |||
- return EXIT_SUCCESS; | |||
- } else { | |||
- if (passes == 1) { | |||
- fprintf(stderr, "1 test passes, "); | |||
- } else { | |||
- fprintf(stderr, "%d tests pass, ", passes); | |||
- } | |||
- if (failures == 1) { | |||
- fprintf(stderr, "1 test FAILS\n"); | |||
- } else { | |||
- fprintf(stderr, "%d tests FAIL\n", failures); | |||
- } | |||
- passes = failures = 0; | |||
- return EXIT_FAILURE; | |||
- } | |||
-} | |||
-} // namespace testing |
@@ -1,37 +0,0 @@ | |||
-#ifndef FORTRAN_EVALUATE | |||
-#define FORTRAN_EVALUATE | |||
- | |||
-#include <cinttypes> | |||
-#include <string> | |||
- | |||
-namespace testing { | |||
- | |||
-// Returns EXIT_SUCCESS or EXIT_FAILURE, so a test's main() should end | |||
-// with "return testing::Complete()". | |||
-int Complete(); | |||
- | |||
-// Pass/fail testing. These macros return a pointer to a printf-like | |||
-// function that can be optionally called to print more detail, e.g. | |||
-// COMPARE(x, ==, y)("z is 0x%llx", z); | |||
-// will also print z after the usual failure message if x != y. | |||
-#define TEST(predicate) \ | |||
- testing::Test(__FILE__, __LINE__, #predicate, (predicate)) | |||
-#define MATCH(want, got) testing::Match(__FILE__, __LINE__, (want), #got, (got)) | |||
-#define COMPARE(x, rel, y) \ | |||
- testing::Compare(__FILE__, __LINE__, #x, #rel, #y, (x), (y)) | |||
- | |||
-// Functions called by these macros; do not call directly. | |||
-using FailureDetailPri | |||
-FailureDetailPri | |||
- bool pass); | |||
-FailureDetailPri | |||
- const char *gots, std::uint64_t got); | |||
-FailureDetailPri | |||
- const char *gots, const std::string &got); | |||
-FailureDetailPri | |||
- const char *gots, const std::string &got); | |||
-FailureDetailPri | |||
- const char *rel, const char *ys, std::uint64_t x, | |||
- std::uint64_t y); | |||
-} // namespace testing | |||
-#endif // FORTRAN_EVALUATE |
@@ -188,7 +188,7 @@ if (FLANG_STANDALON | |||
if (FLANG_GTEST_AVAI | if (FLANG_GTEST_AVAI | ||
add_custom_targe | add_custom_targe | ||
else() | else() | ||
- add_custom_target(check-all DEPENDS check-flang) | + add_custom_target(check-all DEPENDS check-flang ) | ||
endif() | endif() | ||
if (LLVM_BUILD_DOCS) | if (LLVM_BUILD_DOCS) | ||
add_custom_targe | add_custom_targe | ||
@@ -421,11 +421,6 @@ if (FLANG_INCLUDE_T | |||
add_compile_defi | add_compile_defi | ||
endif() | endif() | ||
-# Add Flang subdirectories. | |||
-# NOTE: The runtime subdirectory is no longer added here. | |||
-# Sources for the runtime are added in Flang-rt. | |||
-# TODO: Move the runtime sources to the flang-rt top level directory. | |||
- | |||
add_subdirectory | add_subdirectory | ||
add_subdirectory | add_subdirectory | ||
add_subdirectory | add_subdirectory | ||
@@ -435,6 +430,7 @@ option(FLANG_BUI | |||
if (FLANG_BUILD_TOOL | if (FLANG_BUILD_TOOL | ||
add_subdirectory | add_subdirectory | ||
endif() | endif() | ||
+add_subdirectory | |||
if (LLVM_INCLUDE_EXA | if (LLVM_INCLUDE_EXA | ||
add_subdirectory | add_subdirectory |
@@ -17,7 +17,7 @@ macro(add_flang_ | |||
endmacro() | endmacro() | ||
function(add_flang_librar | function(add_flang_librar | ||
- set(options SHARED STATIC INSTALL_WITH_TOOLCHAIN | + set(options SHARED STATIC INSTALL_WITH_TOOLCHAIN) | ||
set(multiValueArgs ADDITIONAL_HEADE | set(multiValueArgs ADDITIONAL_HEADE | ||
cmake_parse_argu | cmake_parse_argu | ||
"${options}" | "${options}" | ||
@@ -65,9 +65,6 @@ function(add_fla | |||
endif() | endif() | ||
llvm_add_library | llvm_add_library | ||
- if (ARG_PIC) | |||
- set_target_prope | |||
- endif() | |||
clang_target_lin | clang_target_lin | ||
@@ -9,8 +9,6 @@ find_package(LLV | |||
set(FLANG_EXPORTED_T | set(FLANG_EXPORTED_T | ||
set(FLANG_CMAKE_DIR "@FLANG_CONFIG_CMA | set(FLANG_CMAKE_DIR "@FLANG_CONFIG_CMA | ||
set(FLANG_INCLUDE_DI | set(FLANG_INCLUDE_DI | ||
-set(FLANG_SOURCE_DIR | |||
-set(FLANG_BINARY_DIR | |||
# Provide all our library targets to users. | # Provide all our library targets to users. | ||
@FLANG_CONFIG_INC | @FLANG_CONFIG_INC |
@@ -49,19 +49,7 @@ endif() | |||
# avoid an unwanted dependency on libstdc++.so. | # avoid an unwanted dependency on libstdc++.so. | ||
add_definitions(-U_GLIBCXX_ASSERT | add_definitions(-U_GLIBCXX_ASSERT | ||
-# Build FortranDecimal when the build target is Flang or LLVM. | +add_flang_librar | ||
-if (CMAKE_SOURCE_DIR | + binary-to-decimal.cpp | ||
- add_flang_librar | + decimal-to-binary.cpp | ||
- binary-to-decimal.cpp | +) | ||
- decimal-to-binary.cpp | |||
- ) | |||
-# Build FortranDecimalRT | |||
-# Standalone builds of FlangRT is not supported. | |||
-elseif (CMAKE_SOURCE_DIR | |||
- add_flang_librar | |||
- binary-to-decimal.cpp | |||
- decimal-to-binary.cpp | |||
- ) | |||
-else() | |||
- message(FATAL_ERROR "CMAKE_SOURCE_DIR | |||
-endif() |
@@ -6,14 +6,10 @@ | |||
# | # | ||
#===------------------------------------------------------------------------===# | #===------------------------------------------------------------------------===# | ||
-# TODO: Maybe this file should still be added by flang/CMakeLists.txt and | |||
-# when FLANG_STANDALONE | |||
-# we should invoke an ExternalProject_ | |||
- | |||
if (CMAKE_SOURCE_DIR | if (CMAKE_SOURCE_DIR | ||
cmake_minimum_re | cmake_minimum_re | ||
- project( | + project(FlangRuntime C CXX) | ||
set(CMAKE_CXX_STANDA | set(CMAKE_CXX_STANDA | ||
set(CMAKE_CXX_STANDA | set(CMAKE_CXX_STANDA | ||
@@ -86,6 +82,8 @@ append(${NO_LTO_ | |||
add_definitions(-U_GLIBCXX_ASSERT | add_definitions(-U_GLIBCXX_ASSERT | ||
add_definitions(-U_LIBCPP_ENABLE_ | add_definitions(-U_LIBCPP_ENABLE_ | ||
+add_subdirectory | |||
+ | |||
set(sources | set(sources | ||
ISO_Fortran_bind | ISO_Fortran_bind | ||
allocatable.cpp | allocatable.cpp | ||
@@ -270,13 +268,10 @@ if (NOT FLANG_EXPERIMENT | |||
endif() | endif() | ||
endif() | endif() | ||
-add_compile_opti | +add_flang_librar | ||
- | |||
-add_flang_librar | |||
${sources} | ${sources} | ||
LINK_LIBS | LINK_LIBS | ||
- | + FortranDecimal | ||
INSTALL_WITH_TOO | INSTALL_WITH_TOO | ||
- PIC | |||
) | ) |
@@ -138,15 +138,10 @@ CppTypeFor<TypeC | |||
} | } | ||
#endif | #endif | ||
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128 | #if LDBL_MANT_DIG == 113 || HAS_FLOAT128 | ||
-#if HAS_FLOAT128 | |||
-using AccumType = __float128; | |||
-#else // if LDBL_MANT_DIG == 113 | |||
-using AccumType = long double; | |||
-#endif | |||
CppTypeFor<TypeCategory::Real, 16> RTNAME(SumReal16)(const Descriptor &x, | CppTypeFor<TypeCategory::Real, 16> RTNAME(SumReal16)(const Descriptor &x, | ||
const char *source, int line, int dim, const Descriptor *mask) { | const char *source, int line, int dim, const Descriptor *mask) { | ||
return GetTotalReductio | return GetTotalReductio | ||
- x, source, line, dim, mask, | + x, source, line, dim, mask, RealSumAccumulator<long double>{x}, "SUM"); | ||
} | } | ||
#endif | #endif | ||
@@ -61,6 +61,9 @@ set(FLANG_TEST_D | |||
llvm-objdump | llvm-objdump | ||
llvm-readobj | llvm-readobj | ||
split-file | split-file | ||
+ FortranRuntime | |||
+ Fortran_main | |||
+ FortranDecimal | |||
) | ) | ||
if (LLVM_ENABLE_PLUG | if (LLVM_ENABLE_PLUG | ||
list(APPEND FLANG_TEST_DEPEN | list(APPEND FLANG_TEST_DEPEN |
@@ -24,18 +24,21 @@ | |||
! GNU-LABEL: "{{.*}}ld{{(\.exe)?}}" | ! GNU-LABEL: "{{.*}}ld{{(\.exe)?}}" | ||
! GNU-SAME: "[[object_file]]" | ! GNU-SAME: "[[object_file]]" | ||
! GNU-SAME: -lFortran_main | ! GNU-SAME: -lFortran_main | ||
-! GNU-SAME: -lflang-rt | +! GNU-SAME: -lFortranRuntime | ||
+! GNU-SAME: -lFortranDecimal | |||
! GNU-SAME: -lm | ! GNU-SAME: -lm | ||
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}" | ! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}" | ||
! DARWIN-SAME: "[[object_file]]" | ! DARWIN-SAME: "[[object_file]]" | ||
! DARWIN-SAME: -lFortran_main | ! DARWIN-SAME: -lFortran_main | ||
-! DARWIN-SAME: -lflang-rt | +! DARWIN-SAME: -lFortranRuntime | ||
+! DARWIN-SAME: -lFortranDecimal | |||
! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}" | ! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}" | ||
! MINGW-SAME: "[[object_file]]" | ! MINGW-SAME: "[[object_file]]" | ||
! MINGW-SAME: -lFortran_main | ! MINGW-SAME: -lFortran_main | ||
-! MINGW-SAME: -lflang-rt | +! MINGW-SAME: -lFortranRuntime | ||
+! MINGW-SAME: -lFortranDecimal | |||
! NOTE: This also matches lld-link (when CLANG_DEFAULT_LI | ! NOTE: This also matches lld-link (when CLANG_DEFAULT_LI | ||
! any .exe suffix that is added when resolving to the full path of | ! any .exe suffix that is added when resolving to the full path of | ||
@@ -43,6 +46,7 @@ | |||
! when the executable is not found or on non-Windows platforms. | ! when the executable is not found or on non-Windows platforms. | ||
! MSVC-LABEL: link | ! MSVC-LABEL: link | ||
! MSVC-SAME: Fortran_main.lib | ! MSVC-SAME: Fortran_main.lib | ||
-! MSVC-SAME: | +! MSVC-SAME: FortranRuntime.lib | ||
+! MSVC-SAME: FortranDecimal.lib | |||
! MSVC-SAME: /subsystem:console | ! MSVC-SAME: /subsystem:console | ||
! MSVC-SAME: "[[object_file]]" | ! MSVC-SAME: "[[object_file]]" |
@@ -153,16 +153,19 @@ else: | |||
# the C++ runtime libraries. For this we need a C compiler. If for some reason | # 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. | # we don't have one, we can just disable the test. | ||
if config.cc: | if config.cc: | ||
- libruntime = os.path.join(config.flang_lib_dir, | + libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a") | ||
+ libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecima | |||
include = os.path.join(config.flang_src_dir, "include") | include = os.path.join(config.flang_src_dir, "include") | ||
if ( | if ( | ||
os.path.isfile(libruntime) | os.path.isfile(libruntime) | ||
+ and os.path.isfile(libdecimal) | |||
and os.path.isdir(include) | and os.path.isdir(include) | ||
): | ): | ||
config.available_featur | config.available_featur | ||
tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal")) | tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal")) | ||
tools.append(ToolSubst("%libruntime", command=libruntime, 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")) | tools.append(ToolSubst("%include", command=include, unresolved="fatal")) | ||
# Add all the tools and their substitutions (if applicable). Use the search paths provided for | # Add all the tools and their substitutions (if applicable). Use the search paths provided for |
@@ -14,6 +14,14 @@ set( LLVM_LINK_COMPON | |||
add_flang_tool(flang-new | add_flang_tool(flang-new | ||
driver.cpp | driver.cpp | ||
fc1_main.cpp | fc1_main.cpp | ||
+ | |||
+ DEPENDS | |||
+ # These libraries are used in the linker invocation generated by the driver | |||
+ # (i.e. when constructing the linker job). Without them the driver would be | |||
+ # unable to generate executables. | |||
+ FortranRuntime | |||
+ FortranDecimal | |||
+ Fortran_main | |||
) | ) | ||
target_link_libr | target_link_libr |
@@ -24,15 +24,11 @@ function(add_fla | |||
# FIXME: replace 'native' in --offload-arch option with the list | # FIXME: replace 'native' in --offload-arch option with the list | ||
# of targets that Fortran Runtime was built for. | # of targets that Fortran Runtime was built for. | ||
# Common code must be moved from flang/runtime/CMakeLists.txt. | # Common code must be moved from flang/runtime/CMakeLists.txt. | ||
- # TODO: Revisit this because of Flang-rt. runtime is no longer an added subdirectory of flang. So we temporarily duplicated the option definition to here. This is not a permanent solution. | |||
- set(FLANG_EXPERIMENT | |||
- "Compile Fortran runtime as OpenMP target offload sources (experimental). Valid options are 'off', 'host_device', 'nohost'") | |||
- | |||
if (NOT FLANG_EXPERIMENT | if (NOT FLANG_EXPERIMENT | ||
set_target_prope | set_target_prope | ||
- | + PROPERTIES LINK_OPTIONS | ||
- | + "-fopenmp;--offload-arch=native" | ||
- | + ) | ||
endif() | endif() | ||
endfunction() | endfunction() | ||
@@ -78,4 +74,5 @@ add_subdirectory | |||
add_subdirectory | add_subdirectory | ||
add_subdirectory | add_subdirectory | ||
add_subdirectory | add_subdirectory | ||
+add_subdirectory | |||
add_subdirectory | add_subdirectory |
@@ -45,6 +45,7 @@ add_flang_nongte | |||
FortranDecimal | FortranDecimal | ||
FortranSemantics | FortranSemantics | ||
FortranParser | FortranParser | ||
+ FortranRuntime | |||
) | ) | ||
add_flang_nongte | add_flang_nongte | ||
@@ -67,6 +68,20 @@ add_flang_nongte | |||
) | ) | ||
llvm_update_comp | llvm_update_comp | ||
+add_flang_nongte | |||
+ FortranEvaluateT | |||
+ FortranSemantics | |||
+ FortranEvaluate | |||
+ FortranRuntime | |||
+) | |||
+ | |||
+add_flang_nongte | |||
+ FortranEvaluateT | |||
+ FortranEvaluate | |||
+ FortranSemantics | |||
+ FortranRuntime | |||
+) | |||
+ | |||
add_flang_nongte | add_flang_nongte | ||
FortranCommon | FortranCommon | ||
FortranEvaluateT | FortranEvaluateT |
@@ -19,6 +19,16 @@ add_flang_unitte | |||
Builder/DoLoopHelperTest | Builder/DoLoopHelperTest | ||
Builder/FIRBuilderTest.cpp | Builder/FIRBuilderTest.cpp | ||
Builder/HLFIRToolsTest.cpp | Builder/HLFIRToolsTest.cpp | ||
+ Builder/Runtime/AllocatableTest.cpp | |||
+ Builder/Runtime/AssignTest.cpp | |||
+ Builder/Runtime/CommandTest.cpp | |||
+ Builder/Runtime/CharacterTest.cpp | |||
+ Builder/Runtime/DerivedTest.cpp | |||
+ Builder/Runtime/NumericTest.cpp | |||
+ Builder/Runtime/RaggedTest.cpp | |||
+ Builder/Runtime/ReductionTest.cpp | |||
+ Builder/Runtime/StopTest.cpp | |||
+ Builder/Runtime/Transformational | |||
FIRContextTest.cpp | FIRContextTest.cpp | ||
FIRTypesTest.cpp | FIRTypesTest.cpp | ||
FortranVariableT | FortranVariableT |
@@ -6,7 +6,7 @@ | |||
// | // | ||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||
-#include | +#include "../../runtime/buffer.h" | ||
#include "CrashHandlerFixt | #include "CrashHandlerFixt | ||
#include "gtest/gtest.h" | #include "gtest/gtest.h" | ||
#include <algorithm> | #include <algorithm> | ||
@@ -30,16 +30,15 @@ public: | |||
void set_expect(FileOffset to) { expect_ = to; } | void set_expect(FileOffset to) { expect_ = to; } | ||
std::size_t Read(FileOffset at, char *to, std::size_t minBytes, | std::size_t Read(FileOffset at, char *to, std::size_t minBytes, | ||
- | + std::size_t maxBytes, IoErrorHandler &handler) { | ||
if (enforceSequence_ | if (enforceSequence_ | ||
handler.SignalError("Read(%d,%d,%d) not at expected %d", | handler.SignalError("Read(%d,%d,%d) not at expected %d", | ||
- | + static_cast<int>(at), static_cast<int>(minBytes), | ||
- static_cast<int>(maxBytes), | + static_cast<int>(maxBytes), static_cast<int>(expect_)); | ||
- static_cast<int>(expect_)); | |||
} else if (at < 0 || at + minBytes > bytes_) { | } else if (at < 0 || at + minBytes > bytes_) { | ||
handler.SignalError("Read(%d,%d,%d) is out of bounds", | handler.SignalError("Read(%d,%d,%d) is out of bounds", | ||
- | + static_cast<int>(at), static_cast<int>(minBytes), | ||
- | + static_cast<int>(maxBytes)); | ||
} | } | ||
auto result{std::min<std::size_t>(maxBytes, bytes_ - at)}; | auto result{std::min<std::size_t>(maxBytes, bytes_ - at)}; | ||
std::memcpy(to, &data_[at], result); | std::memcpy(to, &data_[at], result); | ||
@@ -47,14 +46,14 @@ public: | |||
return result; | return result; | ||
} | } | ||
std::size_t Write(FileOffset at, const char *from, std::size_t bytes, | std::size_t Write(FileOffset at, const char *from, std::size_t bytes, | ||
- | + IoErrorHandler &handler) { | ||
if (enforceSequence_ | if (enforceSequence_ | ||
handler.SignalError("Write(%d,%d) not at expected %d", | handler.SignalError("Write(%d,%d) not at expected %d", | ||
- | + static_cast<int>(at), static_cast<int>(bytes), | ||
- | + static_cast<int>(expect_)); | ||
} else if (at < 0 || at + bytes > bytes_) { | } else if (at < 0 || at + bytes > bytes_) { | ||
handler.SignalError("Write(%d,%d) is out of bounds", static_cast<int>(at), | handler.SignalError("Write(%d,%d) is out of bounds", static_cast<int>(at), | ||
- | + static_cast<int>(bytes)); | ||
} | } | ||
std::memcpy(&data_[at], from, bytes); | std::memcpy(&data_[at], from, bytes); | ||
expect_ = at + bytes; | expect_ = at + bytes; | ||
@@ -71,8 +70,8 @@ private: | |||
inline int ChunkSize(int j, int most) { | inline int ChunkSize(int j, int most) { | ||
// 31, 1, 29, 3, 27, ... | // 31, 1, 29, 3, 27, ... | ||
j %= tinyBufferSize; | j %= tinyBufferSize; | ||
- auto chunk{static_cast<int>( | + auto chunk{static_cast<int>( | ||
- tinyBufferSize)}; | + ((j % 2) ? j : (tinyBufferSize - 1 - j)) % tinyBufferSize)}; | ||
return std::min(chunk, most); | return std::min(chunk, most); | ||
} | } | ||
@@ -1,4 +1,4 @@ | |||
- | +add_flang_unittest(FlangRuntimeTests | ||
Allocatable.cpp | Allocatable.cpp | ||
ArrayConstructor | ArrayConstructor | ||
BufferTest.cpp | BufferTest.cpp | ||
@@ -29,7 +29,7 @@ add_flang_rt_uni | |||
Transformational | Transformational | ||
) | ) | ||
-target_link_libraries( | +target_link_libraries(FlangRuntimeTests | ||
PRIVATE | PRIVATE | ||
- flang-rt | + FortranRuntime | ||
) | ) |
@@ -6,13 +6,13 @@ | |||
// | // | ||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||
#include "CrashHandlerFixt | #include "CrashHandlerFixt | ||
-#include | +#include "../../runtime/terminator.h" | ||
#include <cstdarg> | #include <cstdarg> | ||
#include <cstdlib> | #include <cstdlib> | ||
// Replaces Fortran runtime's crash handler so we can verify the crash message | // Replaces Fortran runtime's crash handler so we can verify the crash message | ||
-[[noreturn]] static void CatchCrash( | +[[noreturn]] static void CatchCrash( | ||
- const char *message, va_list &ap) { | + const char *sourceFile, int sourceLine, const char *message, va_list &ap) { | ||
char buffer[1000]; | char buffer[1000]; | ||
std::vsnprintf(buffer, sizeof buffer, message, ap); | std::vsnprintf(buffer, sizeof buffer, message, ap); | ||
va_end(ap); | va_end(ap); |
@@ -7,7 +7,7 @@ | |||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||
#include "CrashHandlerFixt | #include "CrashHandlerFixt | ||
-#include | +#include "../../runtime/io-error.h" | ||
#include "flang/Runtime/descriptor.h" | #include "flang/Runtime/descriptor.h" | ||
#include "flang/Runtime/io-api.h" | #include "flang/Runtime/io-api.h" | ||
@@ -36,15 +36,15 @@ TEST(InputTest, TestListInputAlp | |||
// Use _two_ input buffers and _three_ output buffers. Note the `3*` in the | // Use _two_ input buffers and _three_ output buffers. Note the `3*` in the | ||
// _inputBuffers_. | // _inputBuffers_. | ||
SetCharacter(inputBuffers[j++], maxInputBufferLe | SetCharacter(inputBuffers[j++], maxInputBufferLe | ||
- | + "3*'abcdefghijklmnopqrstuvwxyzABC"); | ||
- SetCharacter( | + SetCharacter( | ||
- | + inputBuffers[j++], maxInputBufferLength, "DEFGHIJKLMNOPQRSTUVWXYZ'"); | ||
StaticDescriptor | StaticDescriptor | ||
Descriptor &whole{staticDescriptor | Descriptor &whole{staticDescriptor | ||
SubscriptValue extent[]{numInputBuffers}; | SubscriptValue extent[]{numInputBuffers}; | ||
whole.Establish(TypeCode{CFI_type_char}, maxInputBufferLe | whole.Establish(TypeCode{CFI_type_char}, maxInputBufferLe | ||
- | + 1, extent, CFI_attribute_pointer); | ||
whole.Check(); | whole.Check(); | ||
auto *cookie{IONAME(BeginInternalArr | auto *cookie{IONAME(BeginInternalArr | ||
@@ -79,7 +79,7 @@ TEST(InputTest, TestListInputInt | |||
Descriptor &whole{staticDescriptor | Descriptor &whole{staticDescriptor | ||
SubscriptValue extent[]{numBuffers}; | SubscriptValue extent[]{numBuffers}; | ||
whole.Establish(TypeCode{CFI_type_char}, maxBufferLength, | whole.Establish(TypeCode{CFI_type_char}, maxBufferLength, | ||
- | + CFI_attribute_pointer); | ||
whole.Check(); | whole.Check(); | ||
auto *cookie{IONAME(BeginInternalArr | auto *cookie{IONAME(BeginInternalArr | ||
@@ -88,10 +88,10 @@ TEST(InputTest, TestListInputInt | |||
// Negative numbers will be overwritten by _expectedOutput_ | // Negative numbers will be overwritten by _expectedOutput_ | ||
// numbers will not be as their indices are "Null values" of the Fortran 2018 | // numbers will not be as their indices are "Null values" of the Fortran 2018 | ||
// standard 13.10.3.2 in the format strings _buffer_ | // standard 13.10.3.2 in the format strings _buffer_ | ||
- std::int64_t actualOutput[listInputLength]{ | + std::int64_t actualOutput[listInputLength]{ | ||
- -6, 7, -8, 9, 10}; | + -1, -2, -3, -4, 5, -6, 7, -8, 9, 10}; | ||
- const std::int64_t expectedOutput[listInputLength]{ | + const std::int64_t expectedOutput[listInputLength]{ | ||
- 6, 7, 8, 9, 10}; | + 1, 2, 3, 3, 5, 6, 7, 8, 9, 10}; | ||
for (j = 0; j < listInputLength; ++j) { | for (j = 0; j < listInputLength; ++j) { | ||
IONAME(InputInteger)(cookie, actualOutput[j]); | IONAME(InputInteger)(cookie, actualOutput[j]); | ||
} | } | ||
@@ -116,7 +116,7 @@ TEST(InputTest, TestListInputInv | |||
Descriptor &whole{staticDescriptor | Descriptor &whole{staticDescriptor | ||
SubscriptValue extent[]{numBuffers}; | SubscriptValue extent[]{numBuffers}; | ||
whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(), | whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(), | ||
- | + formatBuffer.data(), 1, extent, CFI_attribute_pointer); | ||
whole.Check(); | whole.Check(); | ||
auto *cookie{IONAME(BeginInternalArr | auto *cookie{IONAME(BeginInternalArr | ||
@@ -127,7 +127,7 @@ TEST(InputTest, TestListInputInv | |||
// Perform failing InputInteger | // Perform failing InputInteger | ||
ASSERT_DEATH(IONAME(InputInteger)(cookie, dummy), | ASSERT_DEATH(IONAME(InputInteger)(cookie, dummy), | ||
- | + "Bad character 'g' in INTEGER input field"); | ||
} | } | ||
// Same test as _TestListInputIn | // Same test as _TestListInputIn | ||
@@ -140,7 +140,7 @@ TEST(InputTest, TestListInputInv | |||
Descriptor &whole{staticDescriptor | Descriptor &whole{staticDescriptor | ||
SubscriptValue extent[]{numBuffers}; | SubscriptValue extent[]{numBuffers}; | ||
whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(), | whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(), | ||
- | + formatBuffer.data(), 1, extent, CFI_attribute_pointer); | ||
whole.Check(); | whole.Check(); | ||
auto *cookie{IONAME(BeginInternalArr | auto *cookie{IONAME(BeginInternalArr | ||
@@ -148,7 +148,7 @@ TEST(InputTest, TestListInputInv | |||
// Perform failing InputInteger | // Perform failing InputInteger | ||
ASSERT_DEATH(IONAME(InputInteger)(cookie, dummy), | ASSERT_DEATH(IONAME(InputInteger)(cookie, dummy), | ||
- | + "Bad character 'g' in INTEGER input field"); | ||
} | } | ||
using ParamTy = std::tuple<std::string, std::vector<int>>; | using ParamTy = std::tuple<std::string, std::vector<int>>; | ||
@@ -163,7 +163,7 @@ TEST_P(SimpleLis | |||
Descriptor &whole{staticDescriptor | Descriptor &whole{staticDescriptor | ||
SubscriptValue extent[]{numBuffers}; | SubscriptValue extent[]{numBuffers}; | ||
whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(), | whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(), | ||
- | + formatBuffer.data(), 1, extent, CFI_attribute_pointer); | ||
whole.Check(); | whole.Check(); | ||
auto *cookie{IONAME(BeginInternalArr | auto *cookie{IONAME(BeginInternalArr | ||
@@ -185,10 +185,9 @@ TEST_P(SimpleLis | |||
} | } | ||
} | } | ||
-INSTANTIATE_TEST_SUITE_P( | +INSTANTIATE_TEST_SUITE_P(SimpleListInputTestInstantiation, SimpleListInputTest, | ||
- SimpleListInputT | |||
testing::Values(std::make_tuple("", std::vector<int>{}), | testing::Values(std::make_tuple("", std::vector<int>{}), | ||
- | + std::make_tuple("0", std::vector<int>{}), | ||
- | + std::make_tuple("1", std::vector<int>{1}), | ||
- | + std::make_tuple("1, 2", std::vector<int>{1, 2}), | ||
- | + std::make_tuple("3*2", std::vector<int>{2, 2, 2}))); |
@@ -6,11 +6,11 @@ | |||
// | // | ||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||
-#include | +#include "../../runtime/namelist.h" | ||
#include "CrashHandlerFixt | #include "CrashHandlerFixt | ||
+#include "tools.h" | |||
#include "flang/Runtime/descriptor.h" | #include "flang/Runtime/descriptor.h" | ||
#include "flang/Runtime/io-api.h" | #include "flang/Runtime/io-api.h" | ||
-#include "tools.h" | |||
#include <algorithm> | #include <algorithm> | ||
#include <cinttypes> | #include <cinttypes> | ||
#include <complex> | #include <complex> | ||
@@ -27,7 +27,7 @@ struct NamelistTests : CrashHandlerFixt | |||
static void ClearDescriptorS | static void ClearDescriptorS | ||
std::memset(descriptor.raw().base_addr, 0, | std::memset(descriptor.raw().base_addr, 0, | ||
- | + descriptor.Elements() * descriptor.ElementBytes()); | ||
} | } | ||
TEST(NamelistTests, BasicSanity) { | TEST(NamelistTests, BasicSanity) { | ||
@@ -38,20 +38,17 @@ TEST(NamelistTes | |||
Descriptor &internalDesc{statDescs[0].descriptor()}; | Descriptor &internalDesc{statDescs[0].descriptor()}; | ||
SubscriptValue extent[]{numLines}; | SubscriptValue extent[]{numLines}; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/lineLength, | internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/lineLength, | ||
- | + &buffer, 1, extent, CFI_attribute_pointer); | ||
// Set up data arrays | // Set up data arrays | ||
std::vector<int> ints; | std::vector<int> ints; | ||
for (int j{0}; j < 20; ++j) { | for (int j{0}; j < 20; ++j) { | ||
ints.push_back(j % 2 == 0 ? (1 << j) : -(1 << j)); | ints.push_back(j % 2 == 0 ? (1 << j) : -(1 << j)); | ||
} | } | ||
- std::vector<double> reals{0.0, | + std::vector<double> reals{0.0, -0.0, std::numeric_limits<double>::infinity(), | ||
- -0.0, | + -std::numeric_limits<double>::infinity(), | ||
- | + std::numeric_limits<double>::quiet_NaN(), | ||
- -std::numeric_limits<double>::infinity(), | + std::numeric_limits<double>::max(), std::numeric_limits<double>::lowest(), | ||
- | + std::numeric_limits<double>::epsilon()}; | ||
- std::numeric_limits<double>::max(), | |||
- std::numeric_limits<double>::lowest(), | |||
- std::numeric_limits<double>::epsilon()}; | |||
std::vector<std::uint8_t> logicals; | std::vector<std::uint8_t> logicals; | ||
logicals.push_back(false); | logicals.push_back(false); | ||
logicals.push_back(true); | logicals.push_back(true); | ||
@@ -79,14 +76,12 @@ TEST(NamelistTes | |||
// Create a NAMELIST group | // Create a NAMELIST group | ||
static constexpr int items{5}; | static constexpr int items{5}; | ||
const NamelistGroup::Item itemArray[items]{{"ints", *intDesc}, | const NamelistGroup::Item itemArray[items]{{"ints", *intDesc}, | ||
- {"reals", *realDesc}, | + {"reals", *realDesc}, {"logicals", *logicalDesc}, | ||
- {"logicals", *logicalDesc}, | + {"complexes", *complexDesc}, {"characters", *characterDesc}}; | ||
- {"complexes", *complexDesc}, | |||
- {"characters", *characterDesc}}; | |||
const NamelistGroup group{"group1", items, itemArray}; | const NamelistGroup group{"group1", items, itemArray}; | ||
// Do an internal NAMELIST write and check results | // Do an internal NAMELIST write and check results | ||
- auto outCookie1{IONAME(BeginInternalArrayListOutput)( | + auto outCookie1{IONAME(BeginInternalArrayListOutput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(SetDelim)(outCookie1, "APOSTROPHE", 10)); | ASSERT_TRUE(IONAME(SetDelim)(outCookie1, "APOSTROPHE", 10)); | ||
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie1, group)); | ASSERT_TRUE(IONAME(OutputNamelist)(outCookie1, group)); | ||
auto outStatus1{IONAME(EndIoStatement)(outCookie1)}; | auto outStatus1{IONAME(EndIoStatement)(outCookie1)}; | ||
@@ -114,14 +109,14 @@ TEST(NamelistTes | |||
ClearDescriptorS | ClearDescriptorS | ||
ClearDescriptorS | ClearDescriptorS | ||
ClearDescriptorS | ClearDescriptorS | ||
- auto inCookie{IONAME(BeginInternalArrayListInput)( | + auto inCookie{IONAME(BeginInternalArrayListInput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ||
auto inStatus{IONAME(EndIoStatement)(inCookie)}; | auto inStatus{IONAME(EndIoStatement)(inCookie)}; | ||
ASSERT_EQ(inStatus, 0) << "Failed namelist input sanity, status " | ASSERT_EQ(inStatus, 0) << "Failed namelist input sanity, status " | ||
<< static_cast<int>(inStatus); | << static_cast<int>(inStatus); | ||
- auto outCookie2{IONAME(BeginInternalArrayListOutput)( | + auto outCookie2{IONAME(BeginInternalArrayListOutput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(SetDelim)(outCookie2, "APOSTROPHE", 10)); | ASSERT_TRUE(IONAME(SetDelim)(outCookie2, "APOSTROPHE", 10)); | ||
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie2, group)); | ASSERT_TRUE(IONAME(OutputNamelist)(outCookie2, group)); | ||
auto outStatus2{IONAME(EndIoStatement)(outCookie2)}; | auto outStatus2{IONAME(EndIoStatement)(outCookie2)}; | ||
@@ -144,19 +139,18 @@ TEST(NamelistTes | |||
StaticDescriptor | StaticDescriptor | ||
Descriptor &internalDesc{statDesc.descriptor()}; | Descriptor &internalDesc{statDesc.descriptor()}; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, | internalDesc.Establish(TypeCode{CFI_type_char}, | ||
- /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, | + /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_po | ||
- CFI_attribute_po | + auto inCookie{IONAME(BeginInternalArr | ||
- auto inCookie{IONAME(BeginInternalArr | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
- __FILE__, __LINE__)}; | |||
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ||
auto inStatus{IONAME(EndIoStatement)(inCookie)}; | auto inStatus{IONAME(EndIoStatement)(inCookie)}; | ||
ASSERT_EQ(inStatus, 0) << "Failed namelist input subscripts, status " | ASSERT_EQ(inStatus, 0) << "Failed namelist input subscripts, status " | ||
<< static_cast<int>(inStatus); | << static_cast<int>(inStatus); | ||
char out[40]; | char out[40]; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | ||
- | + out, 0, nullptr, CFI_attribute_pointer); | ||
- auto outCookie{IONAME(BeginInternalArrayListOutput)( | + auto outCookie{IONAME(BeginInternalArrayListOutput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ||
auto outStatus{IONAME(EndIoStatement)(outCookie)}; | auto outStatus{IONAME(EndIoStatement)(outCookie)}; | ||
ASSERT_EQ(outStatus, 0) | ASSERT_EQ(outStatus, 0) | ||
@@ -183,8 +177,8 @@ TEST(NamelistTes | |||
Descriptor &internalDesc{statDesc.descriptor()}; | Descriptor &internalDesc{statDesc.descriptor()}; | ||
SubscriptValue shape{2}; | SubscriptValue shape{2}; | ||
internalDesc.Establish(1, 12, t1, 1, &shape, CFI_attribute_po | internalDesc.Establish(1, 12, t1, 1, &shape, CFI_attribute_po | ||
- auto inCookie{IONAME(BeginInternalArrayListInput)( | + auto inCookie{IONAME(BeginInternalArrayListInput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ||
auto inStatus{IONAME(EndIoStatement)(inCookie)}; | auto inStatus{IONAME(EndIoStatement)(inCookie)}; | ||
ASSERT_EQ(inStatus, 0) << "Failed namelist input subscripts, status " | ASSERT_EQ(inStatus, 0) << "Failed namelist input subscripts, status " | ||
@@ -204,18 +198,17 @@ TEST(NamelistTes | |||
StaticDescriptor | StaticDescriptor | ||
Descriptor &internalDesc{statDesc.descriptor()}; | Descriptor &internalDesc{statDesc.descriptor()}; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, | internalDesc.Establish(TypeCode{CFI_type_char}, | ||
- /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, | + /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_po | ||
- CFI_attribute_po | + auto inCookie{IONAME(BeginInternalArr | ||
- auto inCookie{IONAME(BeginInternalArr | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
- __FILE__, __LINE__)}; | |||
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ||
<< "namelist scalar substring input"; | << "namelist scalar substring input"; | ||
char out[32]; | char out[32]; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | ||
- | + out, 0, nullptr, CFI_attribute_pointer); | ||
- auto outCookie{IONAME(BeginInternalArrayListOutput)( | + auto outCookie{IONAME(BeginInternalArrayListOutput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(SetDelim)(outCookie, "apostrophe", 10)); | ASSERT_TRUE(IONAME(SetDelim)(outCookie, "apostrophe", 10)); | ||
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; | ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; | ||
@@ -225,27 +218,26 @@ TEST(NamelistTes | |||
} | } | ||
TEST(NamelistTests, ArraySubstring) { | TEST(NamelistTests, ArraySubstring) { | ||
- OwningPtr<Descriptor> scDesc{ | + OwningPtr<Descriptor> scDesc{ | ||
- std::vector<int>{2}, std::vector<std::string>{"abcdefgh", "ijklmnop"}, | + MakeArray<TypeCategory::Character, 1>(std::vector<int>{2}, | ||
- 8)}; | + std::vector<std::string>{"abcdefgh", "ijklmnop"}, 8)}; | ||
const NamelistGroup::Item items[]{{"a", *scDesc}}; | const NamelistGroup::Item items[]{{"a", *scDesc}}; | ||
const NamelistGroup group{"justa", 1, items}; | const NamelistGroup group{"justa", 1, items}; | ||
static char t1[]{"&justa A(:)(2:+5)='BCDE' 'JKLM'/"}; | static char t1[]{"&justa A(:)(2:+5)='BCDE' 'JKLM'/"}; | ||
StaticDescriptor | StaticDescriptor | ||
Descriptor &internalDesc{statDesc.descriptor()}; | Descriptor &internalDesc{statDesc.descriptor()}; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, | internalDesc.Establish(TypeCode{CFI_type_char}, | ||
- /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, | + /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_po | ||
- CFI_attribute_po | + auto inCookie{IONAME(BeginInternalArr | ||
- auto inCookie{IONAME(BeginInternalArr | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
- __FILE__, __LINE__)}; | |||
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ||
<< "namelist scalar substring input"; | << "namelist scalar substring input"; | ||
char out[40]; | char out[40]; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | ||
- | + out, 0, nullptr, CFI_attribute_pointer); | ||
- auto outCookie{IONAME(BeginInternalArrayListOutput)( | + auto outCookie{IONAME(BeginInternalArrayListOutput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(SetDelim)(outCookie, "apostrophe", 10)); | ASSERT_TRUE(IONAME(SetDelim)(outCookie, "apostrophe", 10)); | ||
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; | ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; | ||
@@ -264,18 +256,17 @@ TEST(NamelistTes | |||
StaticDescriptor | StaticDescriptor | ||
Descriptor &internalDesc{statDesc.descriptor()}; | Descriptor &internalDesc{statDesc.descriptor()}; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, | internalDesc.Establish(TypeCode{CFI_type_char}, | ||
- /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, | + /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_po | ||
- CFI_attribute_po | + auto inCookie{IONAME(BeginInternalArr | ||
- auto inCookie{IONAME(BeginInternalArr | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
- __FILE__, __LINE__)}; | |||
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ||
<< "namelist input with skipping"; | << "namelist input with skipping"; | ||
char out[20]; | char out[20]; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | ||
- | + out, 0, nullptr, CFI_attribute_pointer); | ||
- auto outCookie{IONAME(BeginInternalArrayListOutput)( | + auto outCookie{IONAME(BeginInternalArrayListOutput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; | ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; | ||
std::string got{out, sizeof out}; | std::string got{out, sizeof out}; | ||
@@ -294,19 +285,18 @@ TEST(NamelistTes | |||
StaticDescriptor | StaticDescriptor | ||
Descriptor &internalDesc{statDesc.descriptor()}; | Descriptor &internalDesc{statDesc.descriptor()}; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, | internalDesc.Establish(TypeCode{CFI_type_char}, | ||
- /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, | + /*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_po | ||
- CFI_attribute_po | + auto inCookie{IONAME(BeginInternalArr | ||
- auto inCookie{IONAME(BeginInternalArr | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
- __FILE__, __LINE__)}; | |||
ASSERT_TRUE(IONAME(SetDecimal)(inCookie, "COMMA", 5)); | ASSERT_TRUE(IONAME(SetDecimal)(inCookie, "COMMA", 5)); | ||
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk) | ||
<< "namelist input with skipping"; | << "namelist input with skipping"; | ||
char out[30]; | char out[30]; | ||
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out, | ||
- | + out, 0, nullptr, CFI_attribute_pointer); | ||
- auto outCookie{IONAME(BeginInternalArrayListOutput)( | + auto outCookie{IONAME(BeginInternalArrayListOutput)( | ||
- __FILE__, __LINE__)}; | + internalDesc, nullptr, 0, __FILE__, __LINE__)}; | ||
ASSERT_TRUE(IONAME(SetDecimal)(outCookie, "COMMA", 5)); | ASSERT_TRUE(IONAME(SetDecimal)(outCookie, "COMMA", 5)); | ||
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group)); | ||
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; | ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output"; |
@@ -11,10 +11,10 @@ | |||
// | // | ||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||
#include "CrashHandlerFixt | #include "CrashHandlerFixt | ||
-#include "flang/../../runtime/terminator.h" | +#include "tools.h" | ||
+#include "../../runtime/terminator.h" | |||
#include "flang/Runtime/io-api.h" | #include "flang/Runtime/io-api.h" | ||
#include "flang/Runtime/transformational | #include "flang/Runtime/transformational | ||
-#include "tools.h" | |||
#include <gtest/gtest.h> | #include <gtest/gtest.h> | ||
using namespace Fortran::runtime; | using namespace Fortran::runtime; | ||
@@ -26,7 +26,7 @@ using Fortran::common: | |||
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||
struct TestTerminator : CrashHandlerFixt | struct TestTerminator : CrashHandlerFixt | ||
-#define TEST_CRASH_HANDLER_MESSAGE | +#define TEST_CRASH_HANDLER_MESSAGE \ | ||
"Intentionally crashing runtime for unit test" | "Intentionally crashing runtime for unit test" | ||
TEST(TestTerminator, CrashTest) { | TEST(TestTerminator, CrashTest) { | ||
@@ -39,13 +39,13 @@ TEST(TestTermina | |||
TEST(TestTerminator, CheckFailedLocat | TEST(TestTerminator, CheckFailedLocat | ||
static Fortran::runtime::Terminator t; | static Fortran::runtime::Terminator t; | ||
ASSERT_DEATH(t.CheckFailed("predicate", "someFileName", 789), | ASSERT_DEATH(t.CheckFailed("predicate", "someFileName", 789), | ||
- | + "RUNTIME_CHECK\\(predicate\\) failed at someFileName\\(789\\)"); | ||
} | } | ||
TEST(TestTerminator, CheckFailedTest) { | TEST(TestTerminator, CheckFailedTest) { | ||
static Fortran::runtime::Terminator t; | static Fortran::runtime::Terminator t; | ||
ASSERT_DEATH(t.CheckFailed("predicate"), | ASSERT_DEATH(t.CheckFailed("predicate"), | ||
- | + "RUNTIME_CHECK\\(predicate\\) failed at \\(null\\)\\(0\\)"); | ||
} | } | ||
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||
@@ -57,10 +57,9 @@ TEST(TestIOCrash | |||
static constexpr int bufferSize{4}; | static constexpr int bufferSize{4}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(A4)"}; | static const char *format{"(A4)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
- ASSERT_DEATH( | + ASSERT_DEATH(IONAME(OutputLogical)(cookie, true), | ||
- IONAME(OutputLogical)(cookie, true), | |||
"Data edit descriptor 'A' may not be used with a LOGICAL data item"); | "Data edit descriptor 'A' may not be used with a LOGICAL data item"); | ||
} | } | ||
@@ -68,10 +67,10 @@ TEST(TestIOCrash | |||
static constexpr int bufferSize{1}; | static constexpr int bufferSize{1}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(C1)"}; | static const char *format{"(C1)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xfeedface), | ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xfeedface), | ||
- | + "Unknown 'C' edit descriptor in FORMAT"); | ||
} | } | ||
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||
@@ -84,80 +83,80 @@ TEST(TestIOCrash | |||
static constexpr int bufferSize{4}; | static constexpr int bufferSize{4}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(A4)"}; | static const char *format{"(A4)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
IONAME(OutputAscii)(cookie, "four", bufferSize); | IONAME(OutputAscii)(cookie, "four", bufferSize); | ||
ASSERT_DEATH(IONAME(OutputAscii)(cookie, "Too many characters!", 20), | ASSERT_DEATH(IONAME(OutputAscii)(cookie, "Too many characters!", 20), | ||
- | + "Internal write overran available records"); | ||
} | } | ||
TEST(TestIOCrash, OverwriteBufferC | TEST(TestIOCrash, OverwriteBufferC | ||
static constexpr int bufferSize{1}; | static constexpr int bufferSize{1}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(A1)"}; | static const char *format{"(A1)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
IONAME(OutputCharacter)(cookie, "a", 1); | IONAME(OutputCharacter)(cookie, "a", 1); | ||
ASSERT_DEATH(IONAME(OutputCharacter)(cookie, "a", 1), | ASSERT_DEATH(IONAME(OutputCharacter)(cookie, "a", 1), | ||
- | + "Internal write overran available records"); | ||
} | } | ||
TEST(TestIOCrash, OverwriteBufferL | TEST(TestIOCrash, OverwriteBufferL | ||
static constexpr int bufferSize{1}; | static constexpr int bufferSize{1}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(L1)"}; | static const char *format{"(L1)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
IONAME(OutputLogical)(cookie, true); | IONAME(OutputLogical)(cookie, true); | ||
ASSERT_DEATH(IONAME(OutputLogical)(cookie, true), | ASSERT_DEATH(IONAME(OutputLogical)(cookie, true), | ||
- | + "Internal write overran available records"); | ||
} | } | ||
TEST(TestIOCrash, OverwriteBufferR | TEST(TestIOCrash, OverwriteBufferR | ||
static constexpr int bufferSize{1}; | static constexpr int bufferSize{1}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(F1)"}; | static const char *format{"(F1)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
IONAME(OutputReal32)(cookie, 1.); | IONAME(OutputReal32)(cookie, 1.); | ||
EXPECT_DEATH(IONAME(OutputReal32)(cookie, 1.), | EXPECT_DEATH(IONAME(OutputReal32)(cookie, 1.), | ||
- | + "Internal write overran available records"); | ||
std::memset(buffer, '\0', bufferSize); | std::memset(buffer, '\0', bufferSize); | ||
- cookie = IONAME(BeginInternalFormattedOutput)( | + cookie = IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format)); | + buffer, bufferSize, format, std::strlen(format)); | ||
IONAME(OutputReal64)(cookie, 1.); | IONAME(OutputReal64)(cookie, 1.); | ||
EXPECT_DEATH(IONAME(OutputReal64)(cookie, 1.), | EXPECT_DEATH(IONAME(OutputReal64)(cookie, 1.), | ||
- | + "Internal write overran available records"); | ||
} | } | ||
TEST(TestIOCrash, OverwriteBufferC | TEST(TestIOCrash, OverwriteBufferC | ||
static constexpr int bufferSize{8}; | static constexpr int bufferSize{8}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(Z1,Z1)"}; | static const char *format{"(Z1,Z1)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
IONAME(OutputComplex32)(cookie, 1., 1.); | IONAME(OutputComplex32)(cookie, 1., 1.); | ||
EXPECT_DEATH(IONAME(OutputComplex32)(cookie, 1., 1.), | EXPECT_DEATH(IONAME(OutputComplex32)(cookie, 1., 1.), | ||
- | + "Internal write overran available records"); | ||
std::memset(buffer, '\0', bufferSize); | std::memset(buffer, '\0', bufferSize); | ||
- cookie = IONAME(BeginInternalFormattedOutput)( | + cookie = IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format)); | + buffer, bufferSize, format, std::strlen(format)); | ||
IONAME(OutputComplex64)(cookie, 1., 1.); | IONAME(OutputComplex64)(cookie, 1., 1.); | ||
EXPECT_DEATH(IONAME(OutputComplex64)(cookie, 1., 1.), | EXPECT_DEATH(IONAME(OutputComplex64)(cookie, 1., 1.), | ||
- | + "Internal write overran available records"); | ||
} | } | ||
TEST(TestIOCrash, OverwriteBufferI | TEST(TestIOCrash, OverwriteBufferI | ||
static constexpr int bufferSize{1}; | static constexpr int bufferSize{1}; | ||
static char buffer[bufferSize]; | static char buffer[bufferSize]; | ||
static const char *format{"(I1)"}; | static const char *format{"(I1)"}; | ||
- auto *cookie{IONAME(BeginInternalFormattedOutput)( | + auto *cookie{IONAME(BeginInternalFormattedOutput)( | ||
- std::strlen(format))}; | + buffer, bufferSize, format, std::strlen(format))}; | ||
IONAME(OutputInteger64)(cookie, 0xdeadbeef); | IONAME(OutputInteger64)(cookie, 0xdeadbeef); | ||
ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xdeadbeef), | ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xdeadbeef), | ||
- | + "Internal write overran available records"); | ||
} | } | ||
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||
@@ -169,15 +168,13 @@ TEST(TestIntrins | |||
// ARRAY(2,3) and MASK(2,4) should trigger a runtime error. | // ARRAY(2,3) and MASK(2,4) should trigger a runtime error. | ||
auto array{MakeArray<TypeCategory::Integer, 4>( | auto array{MakeArray<TypeCategory::Integer, 4>( | ||
std::vector<int>{2, 3}, std::vector<std::int32_t>{1, 2, 3, 4, 5, 6})}; | std::vector<int>{2, 3}, std::vector<std::int32_t>{1, 2, 3, 4, 5, 6})}; | ||
- auto mask{MakeArray<TypeCategory::Logical, 1>( | + auto mask{MakeArray<TypeCategory::Logical, 1>(std::vector<int>{2, 4}, | ||
- | + std::vector<std::uint8_t>{ | ||
- | + false, true, true, false, false, true, true, true})}; | ||
- true})}; | |||
StaticDescriptor | StaticDescriptor | ||
Descriptor &result{statDesc.descriptor()}; | Descriptor &result{statDesc.descriptor()}; | ||
- ASSERT_DEATH( | + ASSERT_DEATH(RTNAME(Pack)(result, *array, *mask, nullptr, __FILE__, __LINE__), | ||
- RTNAME(Pack)(result, *array, *mask, nullptr, __FILE__, __LINE__), | |||
"Incompatible array arguments to PACK: dimension 2 of ARRAY= has extent " | "Incompatible array arguments to PACK: dimension 2 of ARRAY= has extent " | ||
"3 but MASK= has extent 4"); | "3 but MASK= has extent 4"); | ||
} | } |
@@ -11,7 +11,7 @@ | |||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||
#include "flang/Runtime/stop.h" | #include "flang/Runtime/stop.h" | ||
#include "CrashHandlerFixt | #include "CrashHandlerFixt | ||
-#include | +#include "../../runtime/environment.h" | ||
#include <cstdlib> | #include <cstdlib> | ||
#include <gtest/gtest.h> | #include <gtest/gtest.h> | ||
@@ -21,69 +21,67 @@ struct TestProgramEnd : CrashHandlerFixt | |||
TEST(TestProgramEnd, StopTest) { | TEST(TestProgramEnd, StopTest) { | ||
EXPECT_EXIT(RTNAME(StopStatement)(), testing::ExitedWithCode(EXIT_SUCCESS), | EXPECT_EXIT(RTNAME(StopStatement)(), testing::ExitedWithCode(EXIT_SUCCESS), | ||
- | + "Fortran STOP"); | ||
} | } | ||
TEST(TestProgramEnd, StopTestNoStopMe | TEST(TestProgramEnd, StopTestNoStopMe | ||
putenv(const_cast<char *>("NO_STOP_MESSAGE=1")); | putenv(const_cast<char *>("NO_STOP_MESSAGE=1")); | ||
- Fortran::runtime::executionEnvironment.Configure( | + Fortran::runtime::executionEnvironment.Configure( | ||
- nullptr); | + 0, nullptr, nullptr, nullptr); | ||
- EXPECT_EXIT( | + EXPECT_EXIT( | ||
- ""); | + RTNAME(StopStatement)(), testing::ExitedWithCode(EXIT_SUCCESS), ""); | ||
} | } | ||
TEST(TestProgramEnd, StopMessageTest) { | TEST(TestProgramEnd, StopMessageTest) { | ||
static const char *message{"bye bye"}; | static const char *message{"bye bye"}; | ||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/false, /*quiet=*/false), | ||
- | + testing::ExitedWithCode(EXIT_SUCCESS), "Fortran STOP: bye bye"); | ||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/false, /*quiet=*/true), | ||
- | + testing::ExitedWithCode(EXIT_SUCCESS), ""); | ||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/true, /*quiet=*/false), | ||
- testing::ExitedWithCode(EXIT_FAILURE), | + testing::ExitedWithCode(EXIT_FAILURE), "Fortran ERROR STOP: bye bye"); | ||
- "Fortran ERROR STOP: bye bye"); | |||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/true, /*quiet=*/true), | ||
- | + testing::ExitedWithCode(EXIT_FAILURE), ""); | ||
} | } | ||
TEST(TestProgramEnd, NoStopMessageTes | TEST(TestProgramEnd, NoStopMessageTes | ||
putenv(const_cast<char *>("NO_STOP_MESSAGE=1")); | putenv(const_cast<char *>("NO_STOP_MESSAGE=1")); | ||
- Fortran::runtime::executionEnvironment.Configure( | + Fortran::runtime::executionEnvironment.Configure( | ||
- nullptr); | + 0, nullptr, nullptr, nullptr); | ||
static const char *message{"bye bye"}; | static const char *message{"bye bye"}; | ||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/false, /*quiet=*/false), | ||
- | + testing::ExitedWithCode(EXIT_SUCCESS), "bye bye"); | ||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/false, /*quiet=*/true), | ||
- | + testing::ExitedWithCode(EXIT_SUCCESS), ""); | ||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/true, /*quiet=*/false), | ||
- testing::ExitedWithCode(EXIT_FAILURE), | + testing::ExitedWithCode(EXIT_FAILURE), "Fortran ERROR STOP: bye bye"); | ||
- "Fortran ERROR STOP: bye bye"); | |||
EXPECT_EXIT(RTNAME(StopStatementTex | EXPECT_EXIT(RTNAME(StopStatementTex | ||
- | + /*isErrorStop=*/true, /*quiet=*/true), | ||
- | + testing::ExitedWithCode(EXIT_FAILURE), ""); | ||
} | } | ||
TEST(TestProgramEnd, FailImageTest) { | TEST(TestProgramEnd, FailImageTest) { | ||
- EXPECT_EXIT( | + EXPECT_EXIT( | ||
- testing::ExitedWithCode(EXIT_FAILURE), ""); | + RTNAME(FailImageStateme | ||
} | } | ||
TEST(TestProgramEnd, ExitTest) { | TEST(TestProgramEnd, ExitTest) { | ||
EXPECT_EXIT(RTNAME(Exit)(), testing::ExitedWithCode(EXIT_SUCCESS), ""); | EXPECT_EXIT(RTNAME(Exit)(), testing::ExitedWithCode(EXIT_SUCCESS), ""); | ||
- EXPECT_EXIT( | + EXPECT_EXIT( | ||
- ""); | + RTNAME(Exit)(EXIT_FAILURE), testing::ExitedWithCode(EXIT_FAILURE), ""); | ||
} | } | ||
TEST(TestProgramEnd, AbortTest) { EXPECT_DEATH(RTNAME(Abort)(), ""); } | TEST(TestProgramEnd, AbortTest) { EXPECT_DEATH(RTNAME(Abort)(), ""); } | ||
@@ -93,8 +91,8 @@ TEST(TestProgram | |||
static const std::string fileName{"file name"}; | static const std::string fileName{"file name"}; | ||
static const std::string headMessage{"fatal Fortran runtime error\\("}; | static const std::string headMessage{"fatal Fortran runtime error\\("}; | ||
static const std::string tailMessage{":343\\): "}; | static const std::string tailMessage{":343\\): "}; | ||
- static const std::string fullMessage{ | + static const std::string fullMessage{ | ||
- crashMessage}; | + headMessage + fileName + tailMessage + crashMessage}; | ||
EXPECT_DEATH( | EXPECT_DEATH( | ||
RTNAME(ReportFatalUserE | RTNAME(ReportFatalUserE | ||
fullMessage.c_str()); | fullMessage.c_str()); |
@@ -50,7 +50,8 @@ AutoExporter::Au | |||
"libc++", | "libc++", | ||
"libc++abi", | "libc++abi", | ||
"libFortran_main", | "libFortran_main", | ||
- | + "libFortranRuntime", | ||
+ "libFortranDecima | |||
"libunwind", | "libunwind", | ||
"libmsvcrt", | "libmsvcrt", | ||
"libucrtbase", | "libucrtbase", |
@@ -156,10 +156,7 @@ endif() | |||
# As we migrate runtimes to using the bootstrapping build, the set of default runtimes | # As we migrate runtimes to using the bootstrapping build, the set of default runtimes | ||
# should grow as we remove those runtimes from LLVM_ENABLE_PROJ | # should grow as we remove those runtimes from LLVM_ENABLE_PROJ | ||
set(LLVM_DEFAULT_RUN | set(LLVM_DEFAULT_RUN | ||
-if ("flang" IN_LIST LLVM_ENABLE_PROJ | +set(LLVM_SUPPORTED_R | ||
- set(LLVM_DEFAULT_RUN | |||
-endif() | |||
-set(LLVM_SUPPORTED_R | |||
set(LLVM_ENABLE_RUNT | set(LLVM_ENABLE_RUNT | ||
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUN | "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUN | ||
if(LLVM_ENABLE_RUNT | if(LLVM_ENABLE_RUNT | ||
@@ -181,11 +178,6 @@ if ("libc" IN_LIST LLVM_ENABLE_RUNT | |||
endif() | endif() | ||
endif() | endif() | ||
-if ("flang" IN_LIST LLVM_ENABLE_PROJ | |||
- message(STATUS "Enabling Flang-rt to be built with the Flang project.") | |||
- list(APPEND LLVM_ENABLE_RUNT | |||
-endif() | |||
- | |||
# LLVM_ENABLE_PROJ | # LLVM_ENABLE_PROJ | ||
# `LLVM_ENABLE_PROJ | # `LLVM_ENABLE_PROJ | ||
# several reasons: | # several reasons: |
@@ -6,7 +6,6 @@ foreach(entry ${entries}) | |||
if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt) | if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt) | ||
if((NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | if((NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | ||
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | ||
- (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | |||
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | ||
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | ||
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SO | ||
@@ -38,8 +37,6 @@ if(${LLVM_BUILD_ | |||
if(NOT LLVM_BUILD_EXTER | if(NOT LLVM_BUILD_EXTER | ||
add_llvm_externa | add_llvm_externa | ||
endif() | endif() | ||
- | |||
- add_llvm_externa | |||
endif() | endif() | ||
add_llvm_externa | add_llvm_externa |
@@ -401,24 +401,17 @@ if(runtimes) | |||
endforeach() | endforeach() | ||
endif() | endif() | ||
endif() | endif() | ||
- set(EXTRA_CMAKE_ARGS | |||
- if("flang-rt" IN_LIST LLVM_ENABLE_RUNT | |||
- list(APPEND EXTRA_CMAKE_ARGS | |||
- list(APPEND EXTRA_CMAKE_ARGS | |||
- list(APPEND EXTRA_CMAKE_ARGS | |||
- list(APPEND EXTRA_CMAKE_ARGS | |||
- endif() | |||
if(NOT LLVM_RUNTIME_TAR | if(NOT LLVM_RUNTIME_TAR | ||
runtime_default_ | runtime_default_ | ||
DEPENDS ${builtins_dep} ${extra_deps} | DEPENDS ${builtins_dep} ${extra_deps} | ||
- CMAKE_ARGS ${libc_cmake_args} | + CMAKE_ARGS ${libc_cmake_args} | ||
PREFIXES ${prefixes}) | PREFIXES ${prefixes}) | ||
set(test_targets check-runtimes) | set(test_targets check-runtimes) | ||
else() | else() | ||
if("default" IN_LIST LLVM_RUNTIME_TAR | if("default" IN_LIST LLVM_RUNTIME_TAR | ||
runtime_default_ | runtime_default_ | ||
DEPENDS ${builtins_dep} ${extra_deps} | DEPENDS ${builtins_dep} ${extra_deps} | ||
- CMAKE_ARGS ${libc_cmake_args} | + CMAKE_ARGS ${libc_cmake_args} | ||
PREFIXES ${prefixes}) | PREFIXES ${prefixes}) | ||
list(REMOVE_ITEM LLVM_RUNTIME_TAR | list(REMOVE_ITEM LLVM_RUNTIME_TAR | ||
else() | else() | ||
@@ -458,7 +451,7 @@ if(runtimes) | |||
runtime_register | runtime_register | ||
DEPENDS ${builtins_dep_nam | DEPENDS ${builtins_dep_nam | ||
- CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args} | + CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args} | ||
EXTRA_ARGS TARGET_TRIPLE ${name}) | EXTRA_ARGS TARGET_TRIPLE ${name}) | ||
add_dependencies | add_dependencies | ||
@@ -488,7 +481,6 @@ if(runtimes) | |||
CMAKE_ARGS -DLLVM_DEFAULT_TA | CMAKE_ARGS -DLLVM_DEFAULT_TA | ||
-DLLVM_RUNTIMES_P | -DLLVM_RUNTIMES_P | ||
-DLLVM_RUNTIMES_L | -DLLVM_RUNTIMES_L | ||
- ${EXTRA_CMAKE_ARGS | |||
BASE_NAME ${name} | BASE_NAME ${name} | ||
EXTRA_ARGS TARGET_TRIPLE ${name}) | EXTRA_ARGS TARGET_TRIPLE ${name}) | ||
@@ -19,7 +19,7 @@ list(INSERT CMAKE_MODULE_PAT | |||
# We order libraries to mirror roughly how they are layered, except that compiler-rt can depend | # We order libraries to mirror roughly how they are layered, except that compiler-rt can depend | ||
# on libc++, so we put it after. | # on libc++, so we put it after. | ||
-set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler- | +set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp") | ||
set(LLVM_SUPPORTED_R | set(LLVM_SUPPORTED_R | ||
set(LLVM_ENABLE_RUNT | set(LLVM_ENABLE_RUNT | ||
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUN | "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUN |