File: lit.cfg.py

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (60 lines) | stat: -rw-r--r-- 2,260 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import lit.formats
import os

config.name = "cfi" + config.name_suffix
config.suffixes = [".c", ".cpp", ".test"]
config.test_source_root = os.path.dirname(__file__)


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)

config.substitutions.append((r"%clang ", clang + " "))
config.substitutions.append((r"%clangxx ", clangxx + " "))

if "darwin" in config.available_features:
    # -fsanitize=cfi is not supported on Darwin hosts
    config.unsupported = True
elif config.lto_supported:
    clang_cfi = clang + "-fsanitize=cfi "

    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)
        )

    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 "
    if config.android:
        dso += "-include " + config.test_source_root + "/cross-dso/util/cfi_stubs.h "
    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)
    )
    config.substitutions.append(
        (r"%debug_info_flags", " ".join(config.debug_info_flags))
    )
else:
    config.unsupported = True

if config.default_sanitizer_opts:
    config.environment["UBSAN_OPTIONS"] = ":".join(config.default_sanitizer_opts)

if lit_config.params.get("check_supported", None) and config.unsupported:
    raise BaseException("Tests unsupported")