Skip to content

Commit 87bc01f

Browse files
committed
LLVM_TARGET_TRIPLE needed
1 parent 081884b commit 87bc01f

File tree

1 file changed

+55
-54
lines changed

1 file changed

+55
-54
lines changed

runtimes/CMakeLists.txt

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -130,60 +130,6 @@ if (LLVM_LIBRARY_DIR AND LLVM_TOOLS_BINARY_DIR AND PACKAGE_VERSION)
130130
set(LLVM_TREE_AVAILABLE ON)
131131
endif()
132132

133-
if(LLVM_TREE_AVAILABLE)
134-
# In a bootstrap build emit the libraries into a default search path in the
135-
# build directory of the just-built compiler. This allows using the
136-
# just-built compiler without specifying paths to runtime libraries.
137-
# LLVM_LIBRARY_OUTPUT_INTDIR/LLVM_RUNTIME_OUTPUT_INTDIR is used by
138-
# AddLLVM.cmake as artifact output locations.
139-
set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
140-
set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
141-
142-
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang
143-
# being added to the build. Flang uses the same resource dir as Clang.
144-
include(GetClangResourceDir)
145-
get_clang_resource_dir(RUNTIMES_OUTPUT_RESOURCE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/..")
146-
get_clang_resource_dir(RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT)
147-
else()
148-
# In a standalone runtimes build, do not write into LLVM_BINARY_DIR. It may be
149-
# read-only and/or shared by multiple runtimes with different build
150-
# configurations (e.g. Debug/Release). Use the runtime's own lib dir like any
151-
# non-toolchain library. Use own build directory for artifact output.
152-
set(LLVM_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}")
153-
set(LLVM_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
154-
155-
# For the install prefix, still use the resource dir assuming that Flang will
156-
# be installed there using the same prefix. This is to not have a difference
157-
# between bootstrap and standalone runtimes builds.
158-
set(RUNTIMES_OUTPUT_RESOURCE_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}")
159-
set(RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT "lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}")
160-
endif()
161-
162-
# Determine build and install paths.
163-
# The build path is absolute, but the install dir is relative, CMake's install
164-
# command has to apply CMAKE_INSTALL_PREFIX itself.
165-
# FIXME: For shared libraries, the toolchain resource lib dir is not a good
166-
# destination because it is not a ld.so default search path.
167-
# The machine where the executable is eventually executed may not be the
168-
# machine where the Flang compiler and its resource dir is installed, so
169-
# setting RPath by the driver is not an solution. It should belong into
170-
# /usr/lib/<triple>/lib<name>.so, like e.g. libgcc_s.so.
171-
# But the linker as invoked by the Flang driver also requires
172-
# libflang_rt.so to be found when linking and the resource lib dir is
173-
# the only reliable location.
174-
include(GetToolchainDirs)
175-
get_toolchain_library_subdir(toolchain_lib_subdir)
176-
extend_path(RUNTIMES_OUTPUT_RESOURCE_LIB_DIR "${RUNTIMES_OUTPUT_RESOURCE_DIR}" "${toolchain_lib_subdir}")
177-
178-
set(RUNTIMES_INSTALL_RESOURCE_PATH "${RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT}" CACHE PATH "Path to install headers, runtime libraries, and Fortran modules to (default: Clang resource dir)")
179-
extend_path(RUNTIMES_INSTALL_RESOURCE_LIB_PATH "${RUNTIMES_INSTALL_RESOURCE_PATH}" "${toolchain_lib_subdir}")
180-
181-
cmake_path(NORMAL_PATH RUNTIMES_OUTPUT_RESOURCE_DIR)
182-
cmake_path(NORMAL_PATH RUNTIMES_INSTALL_RESOURCE_PATH)
183-
cmake_path(NORMAL_PATH RUNTIMES_OUTPUT_RESOURCE_LIB_DIR)
184-
cmake_path(NORMAL_PATH RUNTIMES_INSTALL_RESOURCE_LIB_PATH)
185-
186-
187133
# CMake omits default compiler include paths, but in runtimes build, we use
188134
# -nostdinc and -nostdinc++ and control include paths manually so this behavior
189135
# is undesirable. Filtering CMAKE_{LANG}_IMPLICIT_INCLUDE_DIRECTORIES to remove
@@ -296,6 +242,61 @@ message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
296242

297243
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
298244

245+
246+
if(LLVM_TREE_AVAILABLE)
247+
# In a bootstrap build emit the libraries into a default search path in the
248+
# build directory of the just-built compiler. This allows using the
249+
# just-built compiler without specifying paths to runtime libraries.
250+
# LLVM_LIBRARY_OUTPUT_INTDIR/LLVM_RUNTIME_OUTPUT_INTDIR is used by
251+
# AddLLVM.cmake as artifact output locations.
252+
set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
253+
set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
254+
255+
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang
256+
# being added to the build. Flang uses the same resource dir as Clang.
257+
include(GetClangResourceDir)
258+
get_clang_resource_dir(RUNTIMES_OUTPUT_RESOURCE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/..")
259+
get_clang_resource_dir(RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT)
260+
else()
261+
# In a standalone runtimes build, do not write into LLVM_BINARY_DIR. It may be
262+
# read-only and/or shared by multiple runtimes with different build
263+
# configurations (e.g. Debug/Release). Use the runtime's own lib dir like any
264+
# non-toolchain library. Use own build directory for artifact output.
265+
set(LLVM_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}")
266+
set(LLVM_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
267+
268+
# For the install prefix, still use the resource dir assuming that Flang will
269+
# be installed there using the same prefix. This is to not have a difference
270+
# between bootstrap and standalone runtimes builds.
271+
set(RUNTIMES_OUTPUT_RESOURCE_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}")
272+
set(RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT "lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}")
273+
endif()
274+
275+
# Determine build and install paths.
276+
# The build path is absolute, but the install dir is relative, CMake's install
277+
# command has to apply CMAKE_INSTALL_PREFIX itself.
278+
# FIXME: For shared libraries, the toolchain resource lib dir is not a good
279+
# destination because it is not a ld.so default search path.
280+
# The machine where the executable is eventually executed may not be the
281+
# machine where the Flang compiler and its resource dir is installed, so
282+
# setting RPath by the driver is not an solution. It should belong into
283+
# /usr/lib/<triple>/lib<name>.so, like e.g. libgcc_s.so.
284+
# But the linker as invoked by the Flang driver also requires
285+
# libflang_rt.so to be found when linking and the resource lib dir is
286+
# the only reliable location.
287+
include(GetToolchainDirs)
288+
get_toolchain_library_subdir(toolchain_lib_subdir)
289+
extend_path(RUNTIMES_OUTPUT_RESOURCE_LIB_DIR "${RUNTIMES_OUTPUT_RESOURCE_DIR}" "${toolchain_lib_subdir}")
290+
291+
set(RUNTIMES_INSTALL_RESOURCE_PATH "${RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT}" CACHE PATH "Path to install headers, runtime libraries, and Fortran modules to (default: Clang resource dir)")
292+
extend_path(RUNTIMES_INSTALL_RESOURCE_LIB_PATH "${RUNTIMES_INSTALL_RESOURCE_PATH}" "${toolchain_lib_subdir}")
293+
294+
cmake_path(NORMAL_PATH RUNTIMES_OUTPUT_RESOURCE_DIR)
295+
cmake_path(NORMAL_PATH RUNTIMES_INSTALL_RESOURCE_PATH)
296+
cmake_path(NORMAL_PATH RUNTIMES_OUTPUT_RESOURCE_LIB_DIR)
297+
cmake_path(NORMAL_PATH RUNTIMES_INSTALL_RESOURCE_LIB_PATH)
298+
299+
299300
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
300301
set(option_prefix "")
301302
if (CMAKE_C_SIMULATE_ID MATCHES "MSVC")

0 commit comments

Comments
 (0)