2015-02-21 04:31:18 +08:00
|
|
|
import lit.formats
|
|
|
|
import os
|
|
|
|
|
2017-04-22 02:11:23 +08:00
|
|
|
config.name = 'cfi' + config.name_suffix
|
2015-09-10 10:18:02 +08:00
|
|
|
config.suffixes = ['.c', '.cpp', '.test']
|
2015-02-21 04:31:18 +08:00
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
[ubsan] Re-commit: lit changes for lld testing, future lto testing.
Summary:
As discussed in https://github.com/google/oss-fuzz/issues/933,
it would be really awesome to be able to use ThinLTO for fuzzing.
However, as @kcc has pointed out, it is currently undefined (untested)
whether the sanitizers actually function properly with LLD and/or LTO.
This patch is inspired by the cfi test, which already do test with LTO
(and/or LLD), since LTO is required for CFI to function.
I started with UBSan, because it's cmakelists / lit.* files appeared
to be the cleanest. This patch adds the infrastructure to easily add
LLD and/or LTO sub-variants of the existing lit test configurations.
Also, this patch adds the LLD flavor, that explicitly does use LLD to link.
The check-ubsan does pass on my machine. And to minimize the [initial]
potential buildbot breakage i have put some restrictions on this flavour.
Please review carefully, i have not worked with lit/sanitizer tests before.
The original attempt, r319525 was reverted in r319526 due
to the failures in compiler-rt standalone builds.
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc
Differential Revision: https://reviews.llvm.org/D39508
llvm-svn: 319575
2017-12-02 03:36:29 +08:00
|
|
|
def build_invocation(compile_flags):
|
|
|
|
return " " + " ".join([config.clang] + compile_flags) + " "
|
|
|
|
|
|
|
|
clang = build_invocation([config.target_cflags])
|
|
|
|
clangxx = build_invocation([config.target_cflags] + config.cxx_mode_flags)
|
2015-02-21 04:31:18 +08:00
|
|
|
|
2017-10-06 02:28:04 +08:00
|
|
|
config.substitutions.append((r"%clang ", clang + ' '))
|
2015-02-21 04:31:18 +08:00
|
|
|
config.substitutions.append((r"%clangxx ", clangxx + ' '))
|
2021-03-18 01:50:59 +08:00
|
|
|
|
|
|
|
if 'darwin' in config.available_features:
|
|
|
|
# -fsanitize=cfi is not supported on Darwin hosts
|
|
|
|
config.unsupported = True
|
|
|
|
elif config.lto_supported:
|
[ubsan] Re-commit: lit changes for lld testing, future lto testing.
Summary:
As discussed in https://github.com/google/oss-fuzz/issues/933,
it would be really awesome to be able to use ThinLTO for fuzzing.
However, as @kcc has pointed out, it is currently undefined (untested)
whether the sanitizers actually function properly with LLD and/or LTO.
This patch is inspired by the cfi test, which already do test with LTO
(and/or LLD), since LTO is required for CFI to function.
I started with UBSan, because it's cmakelists / lit.* files appeared
to be the cleanest. This patch adds the infrastructure to easily add
LLD and/or LTO sub-variants of the existing lit test configurations.
Also, this patch adds the LLD flavor, that explicitly does use LLD to link.
The check-ubsan does pass on my machine. And to minimize the [initial]
potential buildbot breakage i have put some restrictions on this flavour.
Please review carefully, i have not worked with lit/sanitizer tests before.
The original attempt, r319525 was reverted in r319526 due
to the failures in compiler-rt standalone builds.
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc
Differential Revision: https://reviews.llvm.org/D39508
llvm-svn: 319575
2017-12-02 03:36:29 +08:00
|
|
|
clang_cfi = clang + '-fsanitize=cfi '
|
2016-06-25 08:24:22 +08:00
|
|
|
|
|
|
|
if config.cfi_lit_test_mode == "Devirt":
|
|
|
|
config.available_features.add('devirt')
|
|
|
|
clang_cfi += '-fwhole-program-vtables '
|
|
|
|
config.substitutions.append((r"%expect_crash_unless_devirt ", ""))
|
|
|
|
else:
|
|
|
|
config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash))
|
|
|
|
|
2016-04-29 01:09:09 +08:00
|
|
|
cxx = ' '.join(config.cxx_mode_flags) + ' '
|
|
|
|
diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi '
|
|
|
|
non_dso = '-fvisibility=hidden '
|
|
|
|
dso = '-fsanitize-cfi-cross-dso -fvisibility=default '
|
2017-10-17 02:03:11 +08:00
|
|
|
if config.android:
|
|
|
|
dso += '-include ' + config.test_source_root + '/cross-dso/util/cfi_stubs.h '
|
2016-04-29 01:09:09 +08:00
|
|
|
config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso))
|
|
|
|
config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag))
|
2017-11-18 03:49:41 +08:00
|
|
|
config.substitutions.append((r"%debug_info_flags", ' '.join(config.debug_info_flags)))
|
2015-02-21 04:31:18 +08:00
|
|
|
else:
|
|
|
|
config.unsupported = True
|
2015-02-26 04:14:05 +08:00
|
|
|
|
2017-10-17 02:03:11 +08:00
|
|
|
if config.default_sanitizer_opts:
|
|
|
|
config.environment['UBSAN_OPTIONS'] = ':'.join(config.default_sanitizer_opts)
|
|
|
|
|
2015-02-26 04:14:05 +08:00
|
|
|
if lit_config.params.get('check_supported', None) and config.unsupported:
|
|
|
|
raise BaseException("Tests unsupported")
|