[Flang] Optionally do not compile the runtime in-tree (#122336)
Introduce the CMake switch FLANG_INCLUDE_RUNTIME. When set to off, do not add build instructions for the runtime. This is required for Flang-RT (#110217) and the current runtime CMake code to co-exist. When using `LLVM_ENABLE_RUNTIME=flang-rt`, the in-tree build instructions are in conflict and must be disabled.
This commit is contained in:
parent
343bbda140
commit
e6e8ac59ba
11 changed files with 47 additions and 20 deletions
|
|
@ -247,6 +247,8 @@ else()
|
|||
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
|
||||
endif()
|
||||
|
||||
option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ON)
|
||||
|
||||
set(FLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
|
||||
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
|
||||
mark_as_advanced(FLANG_TOOLS_INSTALL_DIR)
|
||||
|
|
@ -487,7 +489,9 @@ if (FLANG_BUILD_TOOLS)
|
|||
add_subdirectory(tools)
|
||||
endif()
|
||||
|
||||
add_subdirectory(runtime)
|
||||
if (FLANG_INCLUDE_RUNTIME)
|
||||
add_subdirectory(runtime)
|
||||
endif ()
|
||||
|
||||
if (LLVM_INCLUDE_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
add_subdirectory(ExternalHelloWorld)
|
||||
if (FLANG_INCLUDE_RUNTIME)
|
||||
add_subdirectory(ExternalHelloWorld)
|
||||
endif ()
|
||||
add_subdirectory(PrintFlangFunctionNames)
|
||||
add_subdirectory(FlangOmpReport)
|
||||
add_subdirectory(FeatureList)
|
||||
|
|
|
|||
|
|
@ -71,9 +71,13 @@ set(FLANG_TEST_DEPENDS
|
|||
llvm-objdump
|
||||
llvm-readobj
|
||||
split-file
|
||||
FortranRuntime
|
||||
FortranDecimal
|
||||
)
|
||||
|
||||
if (FLANG_INCLUDE_RUNTIME)
|
||||
list(APPEND FLANG_TEST_DEPENDS FortranRuntime)
|
||||
endif ()
|
||||
|
||||
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
|
||||
list(APPEND FLANG_TEST_DEPENDS Bye)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
! UNSUPPORTED: system-windows
|
||||
! REQUIRES: flang-rt
|
||||
! RUN: split-file %s %t
|
||||
! RUN: chmod +x %t/runtest.sh
|
||||
! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang | FileCheck %s
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
! UNSUPPORTED: system-windows
|
||||
! REQUIRES: flang-rt
|
||||
! Verify that flang can correctly build executables.
|
||||
|
||||
! RUN: %flang %s -o %t
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ This test makes sure that flang's runtime does not depend on the C++ runtime
|
|||
library. It tries to link this simple file against libFortranRuntime.a with
|
||||
a C compiler.
|
||||
|
||||
REQUIRES: c-compiler
|
||||
REQUIRES: c-compiler, flang-rt
|
||||
|
||||
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
|
||||
RUN: %cc -std=c99 %s -I%include %libruntime -lm \
|
||||
|
|
|
|||
|
|
@ -163,10 +163,13 @@ else:
|
|||
ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
|
||||
)
|
||||
|
||||
if config.flang_include_runtime:
|
||||
config.available_features.add("flang-rt")
|
||||
|
||||
# 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:
|
||||
if config.flang_include_runtime and config.cc:
|
||||
libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
|
||||
include = os.path.join(config.flang_src_dir, "include")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
@LIT_SITE_CFG_IN_HEADER@
|
||||
|
||||
import sys
|
||||
import lit.util
|
||||
|
||||
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
|
||||
config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@"))
|
||||
|
|
@ -32,6 +33,7 @@ else:
|
|||
config.openmp_module_dir = None
|
||||
config.flang_runtime_f128_math_lib = "@FLANG_RUNTIME_F128_MATH_LIB@"
|
||||
config.have_ldbl_mant_dig_113 = "@HAVE_LDBL_MANT_DIG_113@"
|
||||
config.flang_include_runtime = lit.util.pythonize_bool("@FLANG_INCLUDE_RUNTIME@")
|
||||
|
||||
import lit.llvm
|
||||
lit.llvm.initialize(lit_config, config)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ if (NOT CMAKE_CROSSCOMPILING)
|
|||
set(compile_with "-fsyntax-only")
|
||||
set(object_output "")
|
||||
set(include_in_link FALSE)
|
||||
if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
|
||||
if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION AND FLANG_INCLUDE_RUNTIME)
|
||||
set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
|
||||
set(compile_with -c -o ${object_output})
|
||||
set(include_in_link TRUE)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
include(AddFlangOffloadRuntime)
|
||||
|
||||
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
|
||||
# If Fortran runtime is built as CUDA library, the linking
|
||||
# of targets that link FortranRuntime must be done
|
||||
|
|
@ -11,6 +13,11 @@ add_custom_target(FlangUnitTests)
|
|||
set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
|
||||
|
||||
function(add_flang_unittest_offload_properties target)
|
||||
# Do not apply runtime properties if not even compiling the runtime.
|
||||
if (NOT FLANG_INCLUDE_RUNTIME)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
# Set CUDA_RESOLVE_DEVICE_SYMBOLS.
|
||||
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
|
||||
set_target_properties(${target}
|
||||
|
|
@ -75,5 +82,7 @@ add_subdirectory(Optimizer)
|
|||
add_subdirectory(Common)
|
||||
add_subdirectory(Decimal)
|
||||
add_subdirectory(Evaluate)
|
||||
add_subdirectory(Runtime)
|
||||
if (FLANG_INCLUDE_RUNTIME)
|
||||
add_subdirectory(Runtime)
|
||||
endif ()
|
||||
add_subdirectory(Frontend)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ add_flang_nongtest_unittest(intrinsics
|
|||
FortranDecimal
|
||||
FortranSemantics
|
||||
FortranParser
|
||||
FortranRuntime
|
||||
)
|
||||
|
||||
add_flang_nongtest_unittest(logical
|
||||
|
|
@ -56,19 +55,21 @@ add_flang_nongtest_unittest(real
|
|||
)
|
||||
llvm_update_compile_flags(real.test)
|
||||
|
||||
add_flang_nongtest_unittest(reshape
|
||||
NonGTestTesting
|
||||
FortranSemantics
|
||||
FortranEvaluate
|
||||
FortranRuntime
|
||||
)
|
||||
if (FLANG_INCLUDE_RUNTIME)
|
||||
add_flang_nongtest_unittest(reshape
|
||||
NonGTestTesting
|
||||
FortranSemantics
|
||||
FortranEvaluate
|
||||
FortranRuntime
|
||||
)
|
||||
|
||||
add_flang_nongtest_unittest(ISO-Fortran-binding
|
||||
NonGTestTesting
|
||||
FortranEvaluate
|
||||
FortranSemantics
|
||||
FortranRuntime
|
||||
)
|
||||
add_flang_nongtest_unittest(ISO-Fortran-binding
|
||||
NonGTestTesting
|
||||
FortranEvaluate
|
||||
FortranSemantics
|
||||
FortranRuntime
|
||||
)
|
||||
endif ()
|
||||
|
||||
add_flang_nongtest_unittest(folding
|
||||
FortranSupport
|
||||
|
|
|
|||
Loading…
Reference in a new issue