Skip to content

Commit 4f6a242

Browse files
committed
Fixed all check.sh
1 parent 8e18401 commit 4f6a242

File tree

9 files changed

+52
-71
lines changed

9 files changed

+52
-71
lines changed

flang-rt/CMakeLists.txt

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ if (LLVM_TREE_AVAILABLE)
9696
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang
9797
# being added to the build. Flang uses the same resource dir as clang.
9898
include(GetClangResourceDir)
99-
get_clang_resource_dir(FLANG_RT_OUTPUT_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/..")
100-
get_clang_resource_dir(FLANG_RT_INSTALL_PATH)
99+
get_clang_resource_dir(FLANG_RT_OUTPUT_RESOURCE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/..")
100+
get_clang_resource_dir(FLANG_RT_INSTALL_RESOURCE_PATH)
101101
else ()
102102
# In a standalone runtimes build, do not write into LLVM_BINARY_DIR. It may be
103103
# read-only and/or shared by multiple runtimes with different build
@@ -106,29 +106,27 @@ else ()
106106
# For the install prefix, still use the resource dir assuming that Flang will
107107
# be installed there using the same prefix. This is to not have a difference
108108
# between bootstrap and standalone runtimes builds.
109-
set(FLANG_RT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
110-
set(FLANG_RT_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}/clang/${LLVM_VERSION_MAJOR}")
109+
set(FLANG_RT_OUTPUT_RESOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
110+
set(FLANG_RT_INSTALL_RESOURCE_PATH "${CMAKE_INSTALL_LIBDIR}/clang/${LLVM_VERSION_MAJOR}")
111111
endif ()
112-
cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_DIR)
113-
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_PATH)
112+
cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_DIR)
113+
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_PATH)
114114

115115
# Determine subdirectories for build output and install destinations.
116+
# FIXME: For the libflang_rt.so, the toolchain resource lib dir is not a good
117+
# destination because it is not a ld.so default search path.
118+
# The machine where the executable is eventually executed may not be the
119+
# machine where the Flang compiler and its resource dir is installed, so
120+
# setting RPath by the driver is not an solution. It should belong into
121+
# /usr/lib/<triple>/libflang_rt.so, like e.g. libgcc_s.so.
122+
# But the linker as invoked by the Flang driver also requires
123+
# libflang_rt.so to be found when linking and the resource lib dir is
124+
# the only reliable location.
116125
get_toolchain_library_subdir(toolchain_lib_subdir)
117-
get_system_library_subdir(arch_lib_subdir)
118-
extend_path(FLANG_RT_BUILD_TOOLCHAIN_LIB_DIR "${FLANG_RT_OUTPUT_DIR}" "${toolchain_lib_subdir}")
119-
if (LLVM_TREE_AVAILABLE)
120-
extend_path(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_OUTPUT_DIR}" "${arch_lib_subdir}")
121-
else ()
122-
# Only building for a single target, so no need to write into a arch-specific subirectory.
123-
extend_path(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_OUTPUT_DIR}" "${CMAKE_INSTALL_LIBDIR}")
124-
endif ()
125-
extend_path(FLANG_RT_INSTALL_TOOLCHAIN_LIB_DIR "${FLANG_RT_INSTALL_PATH}" "${toolchain_lib_subdir}")
126-
extend_path(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_PATH}" "${arch_lib_subdir}")
127-
128-
cmake_path(NORMAL_PATH FLANG_RT_BUILD_TOOLCHAIN_LIB_DIR)
129-
cmake_path(NORMAL_PATH FLANG_RT_BUILD_LIB_DIR)
130-
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_TOOLCHAIN_LIB_DIR)
131-
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_LIB_DIR)
126+
extend_path(FLANG_RT_OUTPUT_RESOURCE_LIB_DIR "${FLANG_RT_OUTPUT_RESOURCE_DIR}" "${toolchain_lib_subdir}")
127+
extend_path(FLANG_RT_INSTALL_RESOURCE_LIB_PATH "${FLANG_RT_INSTALL_RESOURCE_PATH}" "${toolchain_lib_subdir}")
128+
cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_LIB_DIR)
129+
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH)
132130

133131

134132
#################
@@ -146,7 +144,13 @@ if (WIN32)
146144
# Windows DLL currently not implemented.
147145
set(FLANG_RT_ENABLE_SHARED OFF)
148146
else ()
149-
option(FLANG_RT_ENABLE_SHARED "Build Flang-RT as a shared library." ON)
147+
# TODO: Enable by default to increase test coverage, and which version of the
148+
# library should be the user's choice anyway.
149+
# Currently, the Flang driver adds `-L"libdir" -lflang_rt` as linker
150+
# argument, which leaves the choice which library to use to the linker.
151+
# Since most linkers prefer the shared library, this would constitute a
152+
# breaking change unless the driver is changed.
153+
option(FLANG_RT_ENABLE_SHARED "Build Flang-RT as a shared library." OFF)
150154
endif ()
151155
if (NOT FLANG_RT_ENABLE_STATIC AND NOT FLANG_RT_ENABLE_SHARED)
152156
message(FATAL_ERROR "

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ function (add_flangrt_library name)
140140

141141
foreach (tgtname IN LISTS libtargets)
142142
if (NOT WIN32)
143-
# Use same stem name for .a and .so. Common in UNIX environments. Not
144-
# allowed with Windows.
143+
# Use same stem name for .a and .so. Common in UNIX environments.
144+
# Not possible in Windows environments.
145145
set_target_properties(${tgtname} PROPERTIES OUTPUT_NAME "${name}")
146146
endif ()
147147

@@ -244,13 +244,13 @@ function (add_flangrt_library name)
244244
if (ARG_INSTALL_WITH_TOOLCHAIN)
245245
set_target_properties(${tgtname}
246246
PROPERTIES
247-
ARCHIVE_OUTPUT_DIRECTORY "${FLANG_RT_BUILD_TOOLCHAIN_LIB_DIR}"
248-
LIBRARY_OUTPUT_DIRECTORY "${FLANG_RT_BUILD_LIB_DIR}"
247+
ARCHIVE_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}"
248+
LIBRARY_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}"
249249
)
250250

251251
install(TARGETS ${tgtname}
252-
ARCHIVE DESTINATION "${FLANG_RT_INSTALL_TOOLCHAIN_LIB_DIR}"
253-
LIBRARY DESTINATION "${FLANG_RT_INSTALL_LIB_DIR}"
252+
ARCHIVE DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}"
253+
LIBRARY DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}"
254254
)
255255
endif ()
256256

flang-rt/cmake/modules/AddFlangRTOffload.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
macro(enable_cuda_compilation name files)
1010
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
11-
if (BUILD_SHARED_LIBS)
11+
if (FLANG_RT_ENABLE_SHARED)
1212
message(FATAL_ERROR
13-
"BUILD_SHARED_LIBS is not supported for CUDA build of Fortran runtime"
13+
"FLANG_RT_ENABLE_SHARED is not supported for CUDA build of Flang-RT"
1414
)
1515
endif()
1616

@@ -70,9 +70,9 @@ macro(enable_omp_offload_compilation name files)
7070
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
7171
# OpenMP offload build only works with Clang compiler currently.
7272

73-
if (BUILD_SHARED_LIBS)
73+
if (FLANG_RT_ENABLE_SHARED)
7474
message(FATAL_ERROR
75-
"BUILD_SHARED_LIBS is not supported for OpenMP offload build of Fortran runtime"
75+
"FLANG_RT_ENABLE_SHARED is not supported for OpenMP offload build of Flang-RT"
7676
)
7777
endif()
7878

flang-rt/cmake/modules/GetToolchainDirs.cmake

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ function (get_toolchain_library_subdir outvar)
4949
endfunction ()
5050

5151

52-
# Return the subdir of PREFIX where the system holds target-system specific libraries.
53-
# E.g. lib/x86_64-linux-gnu in /usr
54-
function (get_system_library_subdir outvar)
55-
get_lib_arch_dirname(archdirname)
56-
set(${outvar} "${CMAKE_INSTALL_LIBDIR}/${archdirname}" PARENT_SCOPE)
57-
endfunction ()
58-
59-
6052
# Corresponds to Clang's ToolChain::getOSLibName(). Adapted from Compiler-RT.
6153
function (get_toolchain_os_dirname outvar)
6254
if (ANDROID)
@@ -133,20 +125,3 @@ function (get_toolchain_arch_dirname outvar)
133125
endif()
134126
set(${outvar} "${target}" PARENT_SCOPE)
135127
endfunction()
136-
137-
138-
# Compute the arch-specific subdir of lib.
139-
function (get_lib_arch_dirname outvar)
140-
get_toolchain_arch_dirname(normalize_triple)
141-
string(REPLACE "-" ";" triple_list "${normalize_triple}")
142-
143-
# Vendor is optional. Remove if "unknown", as done by e.g. Debian.
144-
# x86_64-unkown-linux-gnu -> x86_64-linux-gnu
145-
list(GET triple_list 1 vendor)
146-
if (vendor STREQUAL "unknown")
147-
list(REMOVE_AT triple_list 1)
148-
endif ()
149-
150-
list(JOIN triple_list "-" result)
151-
set(${outvar} "${result}" PARENT_SCOPE)
152-
endfunction ()

flang-rt/lib/flang_rt/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ if (NOT WIN32)
134134
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
135135
)
136136

137-
enable_cuda_compilation(flang_rt "${supported_sources}")
138-
enable_omp_offload_compilation(flang_rt "${supported_sources}")
137+
enable_cuda_compilation(flang_rt.static "${supported_sources}")
138+
enable_omp_offload_compilation(flang_rt.static "${supported_sources}")
139139

140-
# Select a default runtime, which is also used for unittests.
140+
# Select a default runtime, which is used for unittests.
141141
if (TARGET flang_rt.shared AND BUILD_SHARED_LIBS)
142142
set(default_flang_rt "flang_rt.shared")
143143
elseif (TARGET flang_rt.static)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ a C compiler.
66
UNSUPPORTED: system-windows
77
88
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
9-
RUN: %cc -std=c99 %s -I%include -L%libdir -lflang_rt -lm %deplibs \
9+
RUN: %cc -std=c99 %s -I%include -L"%libdir" -lflang_rt -lm %deplibs \
1010
RUN: %if system-aix %{-lpthread %}
1111
*/
1212

flang-rt/test/lit.cfg.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,24 @@ def shjoin(args, sep=" "):
8080
extra_args=isysroot_flag,
8181
unresolved="fatal",
8282
),
83-
ToolSubst("%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"),
83+
ToolSubst("%cc",
84+
command=config.cc,
85+
extra_args=isysroot_flag,
86+
unresolved="fatal"
87+
),
8488
]
8589
llvm_config.add_tool_substitutions(tools)
8690

8791
# Let tests find LLVM's standard tools (FileCheck, split-file, not, ...)
8892
llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
8993

90-
# Library path of libflang_rt.a/so
91-
config.substitutions.append(("%libdir", config.flang_rt_build_lib_dir))
94+
# Include path for C headers that define Flang's Fortran ABI.
95+
config.substitutions.append(("%include", os.path.join(config.flang_source_dir, "include")))
9296

93-
# Define some variables to help us test that the flang runtime doesn't depend on
94-
# the C++ runtime libraries. For this we need a C compiler.
95-
include = os.path.join(config.flang_source_dir, "include")
96-
config.substitutions.append(("%include", include))
97+
# Library path of libflang_rt.a/.so (for lib search path when using non-Flang driver for linking and LD_LIBRARY_PATH)
98+
config.substitutions.append(("%libdir", config.flang_rt_output_resource_lib_dir))
9799

98-
# Additional library depedendencies the that flang driver does not add itself.
100+
# Additional library depedendencies the that Flang driver does not add itself.
99101
deplibs = []
100102
if config.flang_rt_experimental_offload_support == "CUDA":
101103
deplibs.append("-lcudart")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
66
config.flang_source_dir = "@FLANG_SOURCE_DIR@"
77
config.flang_rt_source_dir = "@FLANG_RT_SOURCE_DIR@"
88
config.flang_rt_binary_test_dir = os.path.dirname(__file__)
9-
config.flang_rt_build_lib_dir = "@FLANG_RT_BUILD_TOOLCHAIN_LIB_DIR@"
9+
config.flang_rt_output_resource_lib_dir = "@FLANG_RT_OUTPUT_RESOURCE_LIB_DIR@"
1010
config.flang_rt_experimental_offload_support = "@FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT@"
1111
config.cc = "@CMAKE_C_COMPILER@"
1212
config.flang = "@CMAKE_Fortran_COMPILER@"

flang-rt/unittests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function(add_flangrt_nongtest_unittest test_name)
9191
set(suffix .test)
9292
endif()
9393

94-
add_executable(${test_name}${suffix} ${ARG_UNPARSED_ARGUMENTS})
94+
add_executable(${test_name}${suffix} EXCLUDE_FROM_ALL ${ARG_UNPARSED_ARGUMENTS})
9595
set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang-RT/Tests/Unit")
9696

9797
target_include_directories(${test_name}${suffix} PRIVATE

0 commit comments

Comments
 (0)