2016-08-08 11:10:22 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Setup config name.
|
|
|
|
config.name = 'XRay' + config.name_suffix
|
|
|
|
|
|
|
|
# Setup source root.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
# Setup default compiler flags use with -fxray-instrument option.
|
|
|
|
clang_xray_cflags = (['-fxray-instrument', config.target_cflags])
|
|
|
|
|
Add libc++ to link XRay test cases if libc++ is used to build CLANG
Summary: When libc++ is used to build CLANG, its XRay libraries libclang_rt.xray-*.a have dependencies on libc++. Therefore, libc++ is needed to link and run XRay test cases. For Linux -rpath is also needed to specify where to load libc++. This change sets macro LLVM_LIBCXX_USED to 1 if libc++ is actually used in the build. XRay tests then check the flag and add -L<llvm_shlib_dir> -lc++ and -Wl,-rpath=<llvm_shlib_dir> if needed.
Reviewers: hubert.reinterpretcast, amyk, dberris, jasonliu, sfertile, EricWF
Subscribers: dberris, mgorny, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61016
llvm-svn: 360060
2019-05-07 01:45:21 +08:00
|
|
|
# If libc++ was used to build XRAY libraries, libc++ is needed. Fix applied
|
|
|
|
# to Linux only since -rpath may not be portable. This can be extended to
|
|
|
|
# other platforms.
|
|
|
|
if config.libcxx_used == "1" and config.host_os == "Linux":
|
|
|
|
clang_xray_cflags = clang_xray_cflags + (['-L%s -lc++ -Wl,-rpath=%s'
|
|
|
|
% (config.llvm_shlib_dir,
|
|
|
|
config.llvm_shlib_dir)])
|
|
|
|
|
|
|
|
clang_xray_cxxflags = config.cxx_mode_flags + clang_xray_cflags
|
2016-08-08 11:10:22 +08:00
|
|
|
|
|
|
|
def build_invocation(compile_flags):
|
|
|
|
return ' ' + ' '.join([config.clang] + compile_flags) + ' '
|
|
|
|
|
2017-03-29 13:19:24 +08:00
|
|
|
# Assume that llvm-xray is in the config.llvm_tools_dir.
|
|
|
|
llvm_xray = os.path.join(config.llvm_tools_dir, 'llvm-xray')
|
|
|
|
|
2016-08-08 11:10:22 +08:00
|
|
|
# Setup substitutions.
|
2018-02-16 12:20:33 +08:00
|
|
|
if config.host_os == "Linux":
|
|
|
|
libdl_flag = "-ldl"
|
|
|
|
else:
|
|
|
|
libdl_flag = ""
|
|
|
|
|
2016-08-08 11:10:22 +08:00
|
|
|
config.substitutions.append(
|
|
|
|
('%clang ', build_invocation([config.target_cflags])))
|
|
|
|
config.substitutions.append(
|
|
|
|
('%clangxx ',
|
|
|
|
build_invocation(config.cxx_mode_flags + [config.target_cflags])))
|
|
|
|
config.substitutions.append(
|
|
|
|
('%clang_xray ', build_invocation(clang_xray_cflags)))
|
|
|
|
config.substitutions.append(
|
|
|
|
('%clangxx_xray', build_invocation(clang_xray_cxxflags)))
|
2017-03-29 13:19:24 +08:00
|
|
|
config.substitutions.append(
|
|
|
|
('%llvm_xray', llvm_xray))
|
2017-07-31 13:16:20 +08:00
|
|
|
config.substitutions.append(
|
|
|
|
('%xraylib',
|
2018-02-16 12:20:33 +08:00
|
|
|
('-lm -lpthread %s -lrt -L%s '
|
2018-06-28 11:11:52 +08:00
|
|
|
'-Wl,-whole-archive -lclang_rt.xray%s -Wl,-no-whole-archive')
|
|
|
|
% (libdl_flag, config.compiler_rt_libdir, config.target_suffix)))
|
2016-08-08 11:10:22 +08:00
|
|
|
|
|
|
|
# Default test suffixes.
|
2019-08-02 13:49:58 +08:00
|
|
|
config.suffixes = ['.c', '.cpp']
|
2016-08-08 11:10:22 +08:00
|
|
|
|
2018-07-01 05:35:05 +08:00
|
|
|
if config.host_os not in ['FreeBSD', 'Linux', 'NetBSD', 'OpenBSD']:
|
2016-08-08 11:10:22 +08:00
|
|
|
config.unsupported = True
|
2017-01-20 04:27:11 +08:00
|
|
|
elif '64' not in config.host_arch:
|
|
|
|
if 'arm' in config.host_arch:
|
|
|
|
if '-mthumb' in config.target_cflags:
|
|
|
|
config.unsupported = True
|
|
|
|
else:
|
|
|
|
config.unsupported = True
|
2019-12-21 05:08:01 +08:00
|
|
|
|
|
|
|
if config.host_os == 'NetBSD':
|
|
|
|
config.substitutions.insert(0, ('%run', config.netbsd_nomprotect_prefix))
|