diff options
Diffstat (limited to 'test/cfi/lit.cfg')
-rw-r--r-- | test/cfi/lit.cfg | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/cfi/lit.cfg b/test/cfi/lit.cfg new file mode 100644 index 000000000..d78820daa --- /dev/null +++ b/test/cfi/lit.cfg @@ -0,0 +1,35 @@ +import lit.formats +import os +import subprocess +import sys + +config.name = 'cfi' +config.suffixes = ['.cpp'] +config.test_source_root = os.path.dirname(__file__) + +def is_darwin_lto_supported(): + return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')) + +def is_linux_lto_supported(): + if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')): + return False + + ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE) + ld_out = ld_cmd.stdout.read().decode() + ld_cmd.wait() + + if not '-plugin' in ld_out: + return False + + return True + +clangxx = ' '.join([config.clang] + config.cxx_mode_flags) + +config.substitutions.append((r"%clangxx ", clangxx + ' ')) + +if sys.platform == 'darwin' and is_darwin_lto_supported(): + config.substitutions.append((r"%clangxx_cfi ", 'env DYLD_LIBRARY_PATH=' + config.llvm_shlib_dir + ' ' + clangxx + ' -fsanitize=cfi ')) +elif sys.platform.startswith('linux') and is_linux_lto_supported(): + config.substitutions.append((r"%clangxx_cfi ", clangxx + ' -fuse-ld=gold -fsanitize=cfi ')) +else: + config.unsupported = True |