summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-06-28 03:11:52 +0000
committerPetr Hosek <phosek@chromium.org>2018-06-28 03:11:52 +0000
commite68c4e60449e68193ad2479e453715dcb94d59ec (patch)
treefe768a39c80dfe37d1813372263d228c29f8238e
parent7304174d41ce890097c935e137d5ae864efa01f9 (diff)
Support for multiarch runtimes layout
This change adds a support for multiarch style runtimes layout, so in addition to the existing layout where runtimes get installed to: lib/clang/$version/lib/$os Clang now allows runtimes to be installed to: lib/clang/$version/$target/lib This also includes libc++, libc++abi and libunwind; today those are assumed to be in Clang library directory built for host, with the new layout it is possible to install libc++, libc++abi and libunwind into the runtime directory built for different targets. The use of new layout is enabled by setting the LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both projects and runtimes layouts. The runtimes CMake build has been further modified to use the new layout when building runtimes for multiple targets. Differential Revision: https://reviews.llvm.org/D45604 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335809 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmake/Modules/AddCompilerRT.cmake26
-rw-r--r--cmake/Modules/CompilerRTUtils.cmake30
-rw-r--r--cmake/Modules/SanitizerUtils.cmake6
-rw-r--r--cmake/base-config-ix.cmake15
-rw-r--r--cmake/config-ix.cmake1
-rw-r--r--test/asan/lit.cfg4
-rw-r--r--test/builtins/Unit/lit.cfg8
-rw-r--r--test/fuzzer/lit.cfg4
-rw-r--r--test/fuzzer/lit.site.cfg.in5
-rw-r--r--test/lit.common.configured.in6
-rw-r--r--test/scudo/lit.cfg2
-rw-r--r--test/xray/lit.cfg7
13 files changed, 87 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f420dbba3..6ece416f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,6 +102,8 @@ pythonize_bool(ANDROID)
set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+pythonize_bool(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+
# We support running instrumented tests when we're not cross compiling
# and target a UNIX-like system or Windows.
# We can run tests on Android even when we are cross-compiling.
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index d2f314a44..e7ec4bd28 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -109,10 +109,14 @@ function(add_asm_sources output)
endfunction()
macro(set_output_name output name arch)
- if(ANDROID AND ${arch} STREQUAL "i386")
- set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}")
+ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+ set(${output} ${name})
else()
- set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}")
+ if(ANDROID AND ${arch} STREQUAL "i386")
+ set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}")
+ else()
+ set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}")
+ endif()
endif()
endmacro()
@@ -168,6 +172,8 @@ function(add_compiler_rt_runtime name type)
set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX})
set(sources_${libname} ${LIB_SOURCES})
format_object_libs(sources_${libname} ${os} ${LIB_OBJECT_LIBS})
+ get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir_${libname})
+ get_compiler_rt_install_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} install_dir_${libname})
endif()
endforeach()
else()
@@ -193,6 +199,8 @@ function(add_compiler_rt_runtime name type)
format_object_libs(sources_${libname} ${arch} ${LIB_OBJECT_LIBS})
set(libnames ${libnames} ${libname})
set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${NO_LTO_FLAGS} ${LIB_CFLAGS})
+ get_compiler_rt_output_dir(${arch} output_dir_${libname})
+ get_compiler_rt_install_dir(${arch} install_dir_${libname})
endforeach()
endif()
@@ -245,7 +253,7 @@ function(add_compiler_rt_runtime name type)
set_target_link_flags(${libname} ${extra_link_flags_${libname}})
set_property(TARGET ${libname} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
- set_target_output_directories(${libname} ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+ set_target_output_directories(${libname} ${output_dir_${libname}})
set_target_properties(${libname} PROPERTIES
OUTPUT_NAME ${output_name_${libname}})
set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime")
@@ -270,11 +278,11 @@ function(add_compiler_rt_runtime name type)
endif()
endif()
install(TARGETS ${libname}
- ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+ ARCHIVE DESTINATION ${install_dir_${libname}}
${COMPONENT_OPTION}
- LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+ LIBRARY DESTINATION ${install_dir_${libname}}
${COMPONENT_OPTION}
- RUNTIME DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+ RUNTIME DESTINATION ${install_dir_${libname}}
${COMPONENT_OPTION})
# We only want to generate per-library install targets if you aren't using
@@ -621,8 +629,10 @@ endfunction()
function(configure_compiler_rt_lit_site_cfg input output)
set_llvm_build_mode()
+ get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir)
+
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
- string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR ${output_dir})
configure_lit_site_cfg(${input} ${output})
endfunction()
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index f567202fa..ea332d37d 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -314,3 +314,33 @@ function(filter_builtin_sources output_var exclude_or_include excluded_list)
endforeach ()
set(${output_var} ${intermediate} PARENT_SCOPE)
endfunction()
+
+function(get_compiler_rt_target arch variable)
+ if(ANDROID AND ${arch} STREQUAL "i386")
+ set(target "i686${COMPILER_RT_OS_SUFFIX}-${COMPILER_RT_DEFAULT_TARGET_OS}")
+ else()
+ set(target "${arch}-${COMPILER_RT_DEFAULT_TARGET_OS}")
+ endif()
+ if(COMPILER_RT_DEFAULT_TARGET_ABI)
+ set(target "${target}-${COMPILER_RT_DEFAULT_TARGET_ABI}")
+ endif()
+ set(${variable} ${target} PARENT_SCOPE)
+endfunction()
+
+function(get_compiler_rt_install_dir arch install_dir)
+ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+ get_compiler_rt_target(${arch} target)
+ set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/${target}/lib PARENT_SCOPE)
+ else()
+ set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(get_compiler_rt_output_dir arch output_dir)
+ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+ get_compiler_rt_target(${arch} target)
+ set(${output_dir} ${COMPILER_RT_OUTPUT_DIR}/${target}/lib PARENT_SCOPE)
+ else()
+ set(${output_dir} ${COMPILER_RT_LIBRARY_OUTPUT_DIR} PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake
index f5dffb363..b6312426c 100644
--- a/cmake/Modules/SanitizerUtils.cmake
+++ b/cmake/Modules/SanitizerUtils.cmake
@@ -1,3 +1,5 @@
+include(CompilerRTUtils)
+
set(SANITIZER_GEN_DYNAMIC_LIST
${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py)
@@ -37,9 +39,9 @@ macro(add_sanitizer_rt_symbols name)
add_custom_target(${target_name}-symbols ALL
DEPENDS ${stamp}
SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA})
-
+ get_compiler_rt_install_dir(${arch} install_dir)
install(FILES $<TARGET_FILE:${target_name}>.syms
- DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ DESTINATION ${install_dir})
if(ARG_PARENT_TARGET)
add_dependencies(${ARG_PARENT_TARGET} ${target_name}-symbols)
endif()
diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake
index 49628ff91..91fe2494b 100644
--- a/cmake/base-config-ix.cmake
+++ b/cmake/base-config-ix.cmake
@@ -76,10 +76,17 @@ endif()
if(NOT DEFINED COMPILER_RT_OS_DIR)
string(TOLOWER ${CMAKE_SYSTEM_NAME} COMPILER_RT_OS_DIR)
endif()
-set(COMPILER_RT_LIBRARY_OUTPUT_DIR
- ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
-set(COMPILER_RT_LIBRARY_INSTALL_DIR
- ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+ set(COMPILER_RT_LIBRARY_OUTPUT_DIR
+ ${COMPILER_RT_OUTPUT_DIR})
+ set(COMPILER_RT_LIBRARY_INSTALL_DIR
+ ${COMPILER_RT_INSTALL_PATH})
+else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+ set(COMPILER_RT_LIBRARY_OUTPUT_DIR
+ ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
+ set(COMPILER_RT_LIBRARY_INSTALL_DIR
+ ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+endif()
if(APPLE)
# On Darwin if /usr/include doesn't exist, the user probably has Xcode but not
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index e6b775d59..8cf607d0e 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -384,7 +384,6 @@ if(APPLE)
# for list_intersect
include(CompilerRTUtils)
-
list_intersect(SANITIZER_COMMON_SUPPORTED_ARCH
ALL_SANITIZER_COMMON_SUPPORTED_ARCH
COMPILER_RT_SUPPORTED_ARCH
diff --git a/test/asan/lit.cfg b/test/asan/lit.cfg
index 855e8e848..f8994d069 100644
--- a/test/asan/lit.cfg
+++ b/test/asan/lit.cfg
@@ -101,7 +101,7 @@ config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) )
config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) )
-config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % config.target_arch))
+config.substitutions.append( ("%shared_libasan", "libclang_rt.asan%s.so" % config.target_suffix))
if config.asan_dynamic:
config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) )
config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) )
@@ -124,7 +124,7 @@ if platform.system() == 'Windows':
clang_cl_asan_invocation = clang_cl_asan_invocation.replace("clang.exe","clang-cl.exe")
config.substitutions.append( ("%clang_cl_asan ", clang_cl_asan_invocation) )
- base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.asan%%s-%s.lib" % config.target_arch)
+ base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix)
config.substitutions.append( ("%asan_lib", base_lib % "") )
config.substitutions.append( ("%asan_cxx_lib", base_lib % "_cxx") )
config.substitutions.append( ("%asan_dll_thunk", base_lib % "_dll_thunk") )
diff --git a/test/builtins/Unit/lit.cfg b/test/builtins/Unit/lit.cfg
index 0e17e479e..4b63948b5 100644
--- a/test/builtins/Unit/lit.cfg
+++ b/test/builtins/Unit/lit.cfg
@@ -26,12 +26,12 @@ config.test_source_root = os.path.dirname(__file__)
# Path to the static library
is_msvc = get_required_attr(config, "builtins_is_msvc")
if is_msvc:
- base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.builtins-%s.lib "
- % config.target_arch)
+ base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.builtins%s.lib "
+ % config.target_suffix)
config.substitutions.append( ("%librt ", base_lib) )
else:
- base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins-%s.a"
- % config.target_arch)
+ base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins%s.a"
+ % config.target_suffix)
config.substitutions.append( ("%librt ", base_lib + ' -lc -lm ') )
builtins_source_dir = os.path.join(
diff --git a/test/fuzzer/lit.cfg b/test/fuzzer/lit.cfg
index 86740e753..44d8f4e03 100644
--- a/test/fuzzer/lit.cfg
+++ b/test/fuzzer/lit.cfg
@@ -53,10 +53,10 @@ def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True):
compiler_cmd = config.clang
extra_cmd = config.target_flags
if config.clang and config.stdlib == 'libc++':
- link_cmd = '-stdlib=libc++ -Wl,-rpath=%s' % config.llvm_library_dir
+ link_cmd = '-stdlib=libc++ -Wl,-rpath=%s' % config.runtime_library_dir
elif config.clang and config.stdlib == 'static-libc++':
link_cmd = '-stdlib=libc++ -lc++abi -static-libstdc++ -Wl,-rpath=%s' % (
- config.llvm_library_dir)
+ config.runtime_library_dir)
elif any(x in config.target_triple for x in ('darwin', 'freebsd')):
link_cmd = '-lc++'
else:
diff --git a/test/fuzzer/lit.site.cfg.in b/test/fuzzer/lit.site.cfg.in
index 031d9641f..80560f020 100644
--- a/test/fuzzer/lit.site.cfg.in
+++ b/test/fuzzer/lit.site.cfg.in
@@ -18,4 +18,9 @@ config.target_triple = "@TARGET_TRIPLE@"
lit_config.load_config(config,
"@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+if config.enable_per_target_runtime_dir:
+ config.runtime_library_dir = config.compiler_rt_libdir
+else:
+ config.runtime_library_dir = "@LLVM_LIBRARY_DIR@"
+
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
diff --git a/test/lit.common.configured.in b/test/lit.common.configured.in
index fb8d59df8..17f470d1c 100644
--- a/test/lit.common.configured.in
+++ b/test/lit.common.configured.in
@@ -16,6 +16,7 @@ set_default("llvm_src_root", "@LLVM_MAIN_SRC_DIR@")
set_default("llvm_obj_root", "@LLVM_BINARY_DIR@")
set_default("compiler_rt_src_root", "@COMPILER_RT_SOURCE_DIR@")
set_default("compiler_rt_obj_root", "@COMPILER_RT_BINARY_DIR@")
+set_default("enable_per_target_runtime_dir", @LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_PYBOOL@)
set_default("llvm_tools_dir", "@LLVM_TOOLS_DIR@")
set_default("llvm_shlib_dir", "@LLVM_LIBRARY_OUTPUT_INTDIR@")
set_default("gold_executable", "@GOLD_EXECUTABLE@")
@@ -36,6 +37,11 @@ set_default("use_lto", config.use_thinlto)
set_default("android", @ANDROID_PYBOOL@)
config.available_features.add('target-is-%s' % config.target_arch)
+if config.enable_per_target_runtime_dir:
+ set_default("target_suffix", "")
+else:
+ set_default("target_suffix", "-%s" % config.target_arch)
+
# LLVM tools dir can be passed in lit parameters, so try to
# apply substitution.
try:
diff --git a/test/scudo/lit.cfg b/test/scudo/lit.cfg
index c94008782..b7f814ebc 100644
--- a/test/scudo/lit.cfg
+++ b/test/scudo/lit.cfg
@@ -9,7 +9,7 @@ config.name = 'Scudo' + config.name_suffix
config.test_source_root = os.path.dirname(__file__)
# Path to the shared library
-shared_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo-%s.so" % config.target_arch)
+shared_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo%s.so" % config.target_suffix)
# Test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
diff --git a/test/xray/lit.cfg b/test/xray/lit.cfg
index 7369f6a76..ecc6d6af9 100644
--- a/test/xray/lit.cfg
+++ b/test/xray/lit.cfg
@@ -18,9 +18,6 @@ def build_invocation(compile_flags):
# Assume that llvm-xray is in the config.llvm_tools_dir.
llvm_xray = os.path.join(config.llvm_tools_dir, 'llvm-xray')
-host_arch = config.host_arch
-if host_arch == 'amd64':
- host_arch = 'x86_64'
# Setup substitutions.
if config.host_os == "Linux":
@@ -42,8 +39,8 @@ config.substitutions.append(
config.substitutions.append(
('%xraylib',
('-lm -lpthread %s -lrt -L%s '
- '-Wl,-whole-archive -lclang_rt.xray-%s -Wl,-no-whole-archive')
- % (libdl_flag, config.compiler_rt_libdir, host_arch)))
+ '-Wl,-whole-archive -lclang_rt.xray%s -Wl,-no-whole-archive')
+ % (libdl_flag, config.compiler_rt_libdir, config.target_suffix)))
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']