Simplify defining Clang compile flags in lit configs
llvm-svn: 201513
This commit is contained in:
parent
55701d25ee
commit
1c9b9bcb5c
|
@ -19,14 +19,14 @@ config.test_source_root = os.path.dirname(__file__)
|
|||
|
||||
# Setup default compiler flags used with -fsanitize=address option.
|
||||
# FIXME: Review the set of required flags and check if it can be reduced.
|
||||
target_cflags = " " + config.target_cflags
|
||||
clang_asan_cflags = (" -fsanitize=address"
|
||||
+ " -mno-omit-leaf-frame-pointer"
|
||||
+ " -fno-omit-frame-pointer"
|
||||
+ " -fno-optimize-sibling-calls"
|
||||
+ " -g"
|
||||
+ target_cflags)
|
||||
clang_asan_cxxflags = " --driver-mode=g++" + clang_asan_cflags
|
||||
target_cflags = [get_required_attr(config, "target_cflags")]
|
||||
target_cxxflags = ["--driver-mode=g++"] + target_cflags
|
||||
clang_asan_cflags = ["-fsanitize=address",
|
||||
"-mno-omit-leaf-frame-pointer",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fno-optimize-sibling-calls",
|
||||
"-g"] + target_cflags
|
||||
clang_asan_cxxflags = ["--driver-mode=g++"] + clang_asan_cflags
|
||||
|
||||
asan_lit_source_dir = get_required_attr(config, "asan_lit_source_dir")
|
||||
if config.android == "TRUE":
|
||||
|
@ -36,15 +36,13 @@ if config.android == "TRUE":
|
|||
else:
|
||||
clang_wrapper = ""
|
||||
|
||||
config.substitutions.append( ("%clang ", " " + clang_wrapper + config.clang + target_cflags + " "))
|
||||
config.substitutions.append( ("%clangxx ", (" " + clang_wrapper + config.clang +
|
||||
" --driver-mode=g++" +
|
||||
target_cflags + " ")) )
|
||||
config.substitutions.append( ("%clang_asan ", (" " + clang_wrapper + config.clang + " " +
|
||||
clang_asan_cflags + " ")) )
|
||||
config.substitutions.append( ("%clangxx_asan ", (" " + clang_wrapper + config.clang + " " +
|
||||
clang_asan_cxxflags + " ")) )
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " "
|
||||
|
||||
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)) )
|
||||
|
||||
# FIXME: De-hardcode this path.
|
||||
asan_source_dir = os.path.join(
|
||||
|
|
|
@ -10,13 +10,13 @@ config.test_source_root = os.path.dirname(__file__)
|
|||
|
||||
# Setup default compiler flags used with -fsanitize=dataflow option.
|
||||
clang_dfsan_cflags = ["-fsanitize=dataflow"]
|
||||
clang_dfsan_cxxflags = ["--driver-mode=g++ "] + clang_dfsan_cflags
|
||||
config.substitutions.append( ("%clang_dfsan ",
|
||||
" ".join([config.clang] + clang_dfsan_cflags) +
|
||||
" ") )
|
||||
config.substitutions.append( ("%clangxx_dfsan ",
|
||||
" ".join([config.clang] + clang_dfsan_cxxflags) +
|
||||
" ") )
|
||||
clang_dfsan_cxxflags = ["--driver-mode=g++"] + clang_dfsan_cflags
|
||||
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
config.substitutions.append( ("%clang_dfsan ", build_invocation(clang_dfsan_cflags)) )
|
||||
config.substitutions.append( ("%clangxx_dfsan ", build_invocation(clang_dfsan_cxxflags)) )
|
||||
|
||||
# Default test suffixes.
|
||||
config.suffixes = ['.c', '.cc', '.cpp']
|
||||
|
|
|
@ -21,14 +21,13 @@ config.available_features.add('asan')
|
|||
|
||||
config.name = 'LeakSanitizer-AddressSanitizer'
|
||||
|
||||
clang_lsan_cxxflags = config.clang_cxxflags + " -fsanitize=address "
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " +
|
||||
clang_lsan_cxxflags + " ")) )
|
||||
clang_lsan_cflags = config.clang_cflags + ["-fsanitize=address"]
|
||||
clang_lsan_cxxflags = config.clang_cxxflags + ["-fsanitize=address"]
|
||||
|
||||
clang_lsan_cflags = config.clang_cflags + " -fsanitize=address "
|
||||
|
||||
config.substitutions.append( ("%clang_lsan ", (" " + config.clang + " " +
|
||||
clang_lsan_cflags + " ")) )
|
||||
config.substitutions.append( ("%clang_lsan ", build_invocation(clang_lsan_cflags)) )
|
||||
config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
|
||||
|
||||
config.environment['ASAN_OPTIONS'] = 'detect_leaks=1'
|
||||
|
|
|
@ -19,12 +19,11 @@ lit_config.load_config(config, lsan_lit_cfg)
|
|||
|
||||
config.name = 'LeakSanitizer-Standalone'
|
||||
|
||||
clang_lsan_cxxflags = config.clang_cxxflags + " -fsanitize=leak "
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " +
|
||||
clang_lsan_cxxflags + " ")) )
|
||||
clang_lsan_cflags = config.clang_cflags + ["-fsanitize=leak"]
|
||||
clang_lsan_cxxflags = config.clang_cxxflags + ["-fsanitize=leak"]
|
||||
|
||||
clang_lsan_cflags = config.clang_cflags + " -fsanitize=leak "
|
||||
|
||||
config.substitutions.append( ("%clang_lsan ", (" " + config.clang + " " +
|
||||
clang_lsan_cflags + " ")) )
|
||||
config.substitutions.append( ("%clang_lsan ", build_invocation(clang_lsan_cflags)) )
|
||||
config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
|
||||
|
|
|
@ -17,24 +17,17 @@ def get_required_attr(config, attr_name):
|
|||
lsan_lit_src_root = get_required_attr(config, 'lsan_lit_src_root')
|
||||
config.test_source_root = os.path.join(lsan_lit_src_root, 'TestCases')
|
||||
|
||||
clang_cxxflags = ("--driver-mode=g++ "
|
||||
+ "-g "
|
||||
+ "-O0 "
|
||||
+ "-m64 ")
|
||||
|
||||
clang_cflags = ("-g "
|
||||
+ "-O0 "
|
||||
+ "-m64 ")
|
||||
|
||||
config.clang_cxxflags = clang_cxxflags
|
||||
|
||||
config.substitutions.append( ("%clangxx ", (" " + config.clang + " " +
|
||||
clang_cxxflags + " ")) )
|
||||
clang_cflags = ["-g", "-O0", "-m64"]
|
||||
clang_cxxflags = ["--driver-mode=g++"] + clang_cflags
|
||||
|
||||
config.clang_cflags = clang_cflags
|
||||
config.clang_cxxflags = clang_cxxflags
|
||||
|
||||
config.substitutions.append( ("%clang ", (" " + config.clang + " " +
|
||||
clang_cflags + " ")) )
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
|
||||
config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
|
||||
|
||||
# LeakSanitizer tests are currently supported on x86-64 Linux only.
|
||||
if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']:
|
||||
|
|
|
@ -15,13 +15,13 @@ clang_msan_cflags = ["-fsanitize=memory",
|
|||
"-fno-optimize-sibling-calls",
|
||||
"-g",
|
||||
"-m64"]
|
||||
clang_msan_cxxflags = ["--driver-mode=g++ "] + clang_msan_cflags
|
||||
config.substitutions.append( ("%clang_msan ",
|
||||
" ".join([config.clang] + clang_msan_cflags) +
|
||||
" ") )
|
||||
config.substitutions.append( ("%clangxx_msan ",
|
||||
" ".join([config.clang] + clang_msan_cxxflags) +
|
||||
" ") )
|
||||
clang_msan_cxxflags = ["--driver-mode=g++"] + clang_msan_cflags
|
||||
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
config.substitutions.append( ("%clang_msan ", build_invocation(clang_msan_cflags)) )
|
||||
config.substitutions.append( ("%clangxx_msan ", build_invocation(clang_msan_cxxflags)) )
|
||||
|
||||
# Default test suffixes.
|
||||
config.suffixes = ['.c', '.cc', '.cpp']
|
||||
|
|
|
@ -24,17 +24,19 @@ config.environment['TSAN_OPTIONS'] = tsan_options
|
|||
|
||||
# Setup default compiler flags used with -fsanitize=thread option.
|
||||
# FIXME: Review the set of required flags and check if it can be reduced.
|
||||
clang_tsan_cflags = ("-fsanitize=thread "
|
||||
+ "-g "
|
||||
+ "-Wall "
|
||||
+ "-lpthread "
|
||||
+ "-ldl "
|
||||
+ "-m64 ")
|
||||
clang_tsan_cxxflags = "--driver-mode=g++ " + clang_tsan_cflags
|
||||
config.substitutions.append( ("%clangxx_tsan ", (" " + config.clang + " " +
|
||||
clang_tsan_cxxflags + " ")) )
|
||||
config.substitutions.append( ("%clang_tsan ", (" " + config.clang + " " +
|
||||
clang_tsan_cflags + " ")) )
|
||||
clang_tsan_cflags = ["-fsanitize=thread",
|
||||
"-g",
|
||||
"-Wall",
|
||||
"-lpthread",
|
||||
"-ldl",
|
||||
"-m64"]
|
||||
clang_tsan_cxxflags = ["--driver-mode=g++"] + clang_tsan_cflags
|
||||
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
config.substitutions.append( ("%clang_tsan ", build_invocation(clang_tsan_cflags)) )
|
||||
config.substitutions.append( ("%clangxx_tsan ", build_invocation(clang_tsan_cxxflags)) )
|
||||
|
||||
# Define CHECK-%os to check for OS-dependent output.
|
||||
config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
|
||||
|
|
|
@ -17,9 +17,12 @@ lit_config.load_config(config, ubsan_lit_cfg)
|
|||
|
||||
config.name = 'UndefinedBehaviorSanitizer-AddressSanitizer'
|
||||
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
clang_ubsan_cflags = ["-fsanitize=address"]
|
||||
clang_ubsan_cxxflags = ["--driver-mode=g++"] + clang_ubsan_cflags
|
||||
|
||||
# Define %clang and %clangxx substitutions to use in test RUN lines.
|
||||
config.substitutions.append( ("%clang ", (" " + config.clang +
|
||||
" -fsanitize=address ")) )
|
||||
config.substitutions.append( ("%clangxx ", (" " + config.clang +
|
||||
" -fsanitize=address" +
|
||||
" --driver-mode=g++ ")) )
|
||||
config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) )
|
||||
config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) )
|
||||
|
|
|
@ -17,7 +17,12 @@ lit_config.load_config(config, ubsan_lit_cfg)
|
|||
|
||||
config.name = 'UndefinedBehaviorSanitizer-Standalone'
|
||||
|
||||
def build_invocation(compile_flags):
|
||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
||||
|
||||
clang_ubsan_cflags = []
|
||||
clang_ubsan_cxxflags = ["--driver-mode=g++"] + clang_ubsan_cflags
|
||||
|
||||
# Define %clang and %clangxx substitutions to use in test RUN lines.
|
||||
config.substitutions.append( ("%clang ", (" " + config.clang + " ")) )
|
||||
config.substitutions.append( ("%clangxx ", (" " + config.clang +
|
||||
" --driver-mode=g++ ")) )
|
||||
config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) )
|
||||
config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) )
|
||||
|
|
|
@ -15,11 +15,6 @@ def get_required_attr(config, attr_name):
|
|||
ubsan_lit_tests_dir = get_required_attr(config, 'ubsan_lit_tests_dir')
|
||||
config.test_source_root = os.path.join(ubsan_lit_tests_dir, 'TestCases')
|
||||
|
||||
def DisplayNoConfigMessage():
|
||||
lit_config.fatal("No site specific configuration available! " +
|
||||
"Try running your test from the build tree or running " +
|
||||
"make check-ubsan")
|
||||
|
||||
# Default test suffixes.
|
||||
config.suffixes = ['.c', '.cc', '.cpp']
|
||||
|
||||
|
|
Loading…
Reference in New Issue