Skip to content

Commit fd4c214

Browse files
committed
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' into users/meinersbur/flang_runtime_flang_rt
2 parents 516c6df + dd3ac2e commit fd4c214

File tree

10 files changed

+50
-29
lines changed

10 files changed

+50
-29
lines changed

flang/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ else()
233233
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
234234
endif()
235235

236+
option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ON)
237+
pythonize_bool(FLANG_INCLUDE_RUNTIME)
238+
236239
set(FLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
237240
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
238241
mark_as_advanced(FLANG_TOOLS_INSTALL_DIR)
@@ -473,7 +476,9 @@ if (FLANG_CUF_RUNTIME)
473476
find_package(CUDAToolkit REQUIRED)
474477
endif()
475478

476-
add_subdirectory(runtime)
479+
if (FLANG_INCLUDE_RUNTIME)
480+
add_subdirectory(runtime)
481+
endif ()
477482

478483
if (LLVM_INCLUDE_EXAMPLES)
479484
add_subdirectory(examples)

flang/test/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ set(FLANG_TEST_DEPENDS
7171
llvm-objdump
7272
llvm-readobj
7373
split-file
74-
flang_rt
7574
FortranDecimal
7675
)
76+
77+
if (FLANG_INCLUDE_RUNTIME)
78+
list(APPEND FLANG_TEST_DEPENDS flang_rt)
79+
endif ()
80+
7781
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
7882
list(APPEND FLANG_TEST_DEPENDS Bye)
7983
endif()

flang/test/Driver/ctofortran.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
! UNSUPPORTED: system-windows
2+
! REQUIRES: flang-rt
23
! RUN: split-file %s %t
34
! RUN: chmod +x %t/runtest.sh
45
! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang | FileCheck %s

flang/test/Driver/exec.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
! UNSUPPORTED: system-windows
2+
! REQUIRES: flang-rt
23
! Verify that flang can correctly build executables.
34

45
! RUN: %flang %s -o %t

flang/test/Runtime/no-cpp-dep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ This test makes sure that flang's runtime does not depend on the C++ runtime
33
library. It tries to link this simple file against libflang_rt.a with
44
a C compiler.
55
6-
REQUIRES: c-compiler
6+
REQUIRES: c-compiler, flang-rt
77
88
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
99
RUN: %cc -std=c99 %s -I%include %libruntime -lm \

flang/test/lit.cfg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,13 @@
163163
ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
164164
)
165165

166+
if config.flang_include_runtime:
167+
config.available_features.add("flang-rt")
168+
166169
# Define some variables to help us test that the flang runtime doesn't depend on
167170
# the C++ runtime libraries. For this we need a C compiler. If for some reason
168171
# we don't have one, we can just disable the test.
169-
if config.cc:
172+
if config.flang_include_runtime and config.cc:
170173
libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.a")
171174
include = os.path.join(config.flang_src_dir, "include")
172175

flang/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ else:
3232
config.openmp_module_dir = None
3333
config.flang_runtime_f128_math_lib = "@FLANG_RUNTIME_F128_MATH_LIB@"
3434
config.have_ldbl_mant_dig_113 = "@HAVE_LDBL_MANT_DIG_113@"
35+
config.flang_include_runtime = @FLANG_INCLUDE_RUNTIME@
3536

3637
import lit.llvm
3738
lit.llvm.initialize(lit_config, config)

flang/tools/f18/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if (NOT CMAKE_CROSSCOMPILING)
7272
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__cuda_builtins.mod)
7373
else()
7474
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
75-
if(${filename} STREQUAL "iso_fortran_env")
75+
if(${filename} STREQUAL "iso_fortran_env" AND FLANG_INCLUDE_RUNTIME)
7676
set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/iso_fortran_env_impl.mod)
7777
endif()
7878
if(${filename} STREQUAL "ieee_arithmetic" OR
@@ -105,7 +105,7 @@ if (NOT CMAKE_CROSSCOMPILING)
105105
set(compile_with "-fsyntax-only")
106106
set(object_output "")
107107
set(include_in_link FALSE)
108-
if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
108+
if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION AND FORTRAN_INCLUDE_RUNTIME)
109109
set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
110110
set(compile_with -c -o ${object_output})
111111
set(include_in_link TRUE)

flang/unittests/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function(add_flang_unittest_offload_properties target)
2424
# FIXME: replace 'native' in --offload-arch option with the list
2525
# of targets that Fortran Runtime was built for.
2626
# Common code must be moved from flang/runtime/CMakeLists.txt.
27-
if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
27+
if (FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD)
2828
set_target_properties(${target}
2929
PROPERTIES LINK_OPTIONS
3030
"-fopenmp;--offload-arch=native"
@@ -75,5 +75,7 @@ add_subdirectory(Optimizer)
7575
add_subdirectory(Common)
7676
add_subdirectory(Decimal)
7777
add_subdirectory(Evaluate)
78-
add_subdirectory(Runtime)
78+
if (FLANG_INCLUDE_RUNTIME)
79+
add_subdirectory(Runtime)
80+
endif ()
7981
add_subdirectory(Frontend)

flang/unittests/Evaluate/CMakeLists.txt

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ add_flang_nongtest_unittest(integer
2626
FortranSemantics
2727
)
2828

29-
add_flang_nongtest_unittest(intrinsics
30-
FortranSupport
31-
NonGTestTesting
32-
FortranEvaluate
33-
FortranDecimal
34-
FortranSemantics
35-
FortranParser
36-
flang_rt
37-
)
29+
if (FLANG_INCLUDE_RUNTIME)
30+
add_flang_nongtest_unittest(intrinsics
31+
FortranSupport
32+
NonGTestTesting
33+
FortranEvaluate
34+
FortranDecimal
35+
FortranSemantics
36+
FortranParser
37+
flang_rt
38+
)
39+
endif ()
3840

3941
add_flang_nongtest_unittest(logical
4042
NonGTestTesting
@@ -56,19 +58,21 @@ add_flang_nongtest_unittest(real
5658
)
5759
llvm_update_compile_flags(real.test)
5860

59-
add_flang_nongtest_unittest(reshape
60-
NonGTestTesting
61-
FortranSemantics
62-
FortranEvaluate
63-
flang_rt
64-
)
61+
if (FLANG_INCLUDE_RUNTIME)
62+
add_flang_nongtest_unittest(reshape
63+
NonGTestTesting
64+
FortranSemantics
65+
FortranEvaluate
66+
flang_rt
67+
)
6568

66-
add_flang_nongtest_unittest(ISO-Fortran-binding
67-
NonGTestTesting
68-
FortranEvaluate
69-
FortranSemantics
70-
flang_rt
71-
)
69+
add_flang_nongtest_unittest(ISO-Fortran-binding
70+
NonGTestTesting
71+
FortranEvaluate
72+
FortranSemantics
73+
flang_rt
74+
)
75+
endif ()
7276

7377
add_flang_nongtest_unittest(folding
7478
FortranSupport

0 commit comments

Comments
 (0)