Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flang] Optionally do not compile the runtime in-tree #122336

Merged
merged 49 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
72e3c5d
[Flang] Introduce FortranSupport
Meinersbur Jan 24, 2025
71015c8
[Flang] Promote FortranEvaluateTesting library
Meinersbur Jan 24, 2025
2e50a1f
[Flang] Don't use FortranDecimal for runtime
Meinersbur Jan 24, 2025
4c676f4
users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME
Meinersbur Jan 24, 2025
24fb760
Sort files alphabetically
Meinersbur Jan 27, 2025
0810293
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Jan 27, 2025
a7cd5b2
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Jan 27, 2025
962958a
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Jan 27, 2025
70326fe
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Jan 27, 2025
b9ab00d
Move files back to Common
Meinersbur Jan 29, 2025
f3e9c15
add missing includes
Meinersbur Jan 29, 2025
8349624
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Jan 29, 2025
e5f2532
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Jan 29, 2025
9e8a785
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Jan 29, 2025
6a7bd03
Use C++style comments for header guards
Meinersbur Jan 29, 2025
db749b9
Use C++style comments for header guards II
Meinersbur Jan 29, 2025
d3c1b9a
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Jan 30, 2025
d9023dd
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Jan 30, 2025
eda88d9
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Jan 30, 2025
aa1770b
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Jan 30, 2025
f4729e6
Conditionalize runtime example
Meinersbur Feb 3, 2025
7dc5f20
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Feb 4, 2025
88ecb82
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 4, 2025
993564a
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 4, 2025
7875cff
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 4, 2025
0a4dfcc
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Feb 4, 2025
0a9c5fd
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 4, 2025
d509bef
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 4, 2025
8e3ddbf
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 4, 2025
7158e15
Merge remote-tracking branch 'official/main' into users/meinersbur/fl…
Meinersbur Feb 5, 2025
b286a88
clang-format includes
Meinersbur Feb 6, 2025
40b2f71
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 6, 2025
080f30c
Merge commit 'b815a3942a0b0a9e7aab6b269ffdb0e93abc4368' into users/me…
Meinersbur Feb 6, 2025
919919f
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 6, 2025
8096d45
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 6, 2025
d35bea0
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 6, 2025
778f516
Adapt BSD test
Meinersbur Feb 6, 2025
4c9e378
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Feb 6, 2025
08a7bbc
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 6, 2025
3f99cd5
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 6, 2025
1fbd2c5
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 6, 2025
f258e0e
Use C++ header guards III
Meinersbur Feb 6, 2025
d222eee
Merge commit '02fa340711d9b990b50a0daf65eb850404884137' into users/me…
Meinersbur Feb 6, 2025
06a81de
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 6, 2025
0edd103
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 6, 2025
2f30a9a
Merge commit '8fb1b3f4b23ecc2fc39f1a1c07244304565cfb21' into users/me…
Meinersbur Feb 7, 2025
ed4c3a6
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 7, 2025
9262520
Merge commit '98e118ca435d280ff1c3540eb5e9b4140b44a1b4' into users/me…
Meinersbur Feb 7, 2025
d4909ad
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion flang/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
add_subdirectory(ExternalHelloWorld)
if (FLANG_INCLUDE_RUNTIME)
add_subdirectory(ExternalHelloWorld)
endif ()
add_subdirectory(PrintFlangFunctionNames)
add_subdirectory(FlangOmpReport)
add_subdirectory(FeatureList)
6 changes: 5 additions & 1 deletion flang/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions flang/test/Driver/ctofortran.f90
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions flang/test/Driver/exec.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
! UNSUPPORTED: system-windows
! REQUIRES: flang-rt
! Verify that flang can correctly build executables.

! RUN: %flang %s -o %t
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Runtime/no-cpp-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 4 additions & 1 deletion flang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,13 @@
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")

Expand Down
2 changes: 2 additions & 0 deletions flang/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
@@ -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@"))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion flang/tools/f18/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion flang/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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)
27 changes: 14 additions & 13 deletions flang/unittests/Evaluate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ add_flang_nongtest_unittest(intrinsics
FortranDecimal
FortranSemantics
FortranParser
FortranRuntime
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test actually does not depend on the runtime

)

add_flang_nongtest_unittest(logical
Expand All @@ -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
Expand Down