From f31bcc68c72371a2bf63aead9f3373a1ff2053b6 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 6 Sep 2015 18:41:23 +0000 Subject: Import compiler-rt 3.7.0 release (r246257). --- CMakeLists.txt | 69 +- LICENSE.TXT | 4 +- SDKs/README.txt | 9 - SDKs/linux/README.txt | 2 - SDKs/linux/usr/include/endian.h | 29 - SDKs/linux/usr/include/fcntl.h | 17 - SDKs/linux/usr/include/limits.h | 23 - SDKs/linux/usr/include/stdio.h | 44 -- SDKs/linux/usr/include/stdlib.h | 36 - SDKs/linux/usr/include/string.h | 31 - SDKs/linux/usr/include/sys/fcntl.h | 29 - SDKs/linux/usr/include/sys/mman.h | 47 -- SDKs/linux/usr/include/sys/stat.h | 24 - SDKs/linux/usr/include/sys/types.h | 20 - SDKs/linux/usr/include/unistd.h | 26 - cmake/Modules/AddCompilerRT.cmake | 93 +-- cmake/Modules/CompilerRTCompile.cmake | 38 +- cmake/Modules/CompilerRTLink.cmake | 4 +- cmake/Modules/CompilerRTUtils.cmake | 8 + cmake/Modules/SanitizerUtils.cmake | 31 +- cmake/config-ix.cmake | 145 ++-- include/sanitizer/coverage_interface.h | 17 + include/sanitizer/dfsan_interface.h | 10 + include/sanitizer/lsan_interface.h | 23 +- include/sanitizer/msan_interface.h | 5 + lib/CMakeLists.txt | 16 +- lib/asan/CMakeLists.txt | 105 ++- lib/asan/asan_allocator.cc | 9 +- lib/asan/asan_allocator.h | 2 +- lib/asan/asan_fake_stack.cc | 23 + lib/asan/asan_flags.cc | 22 +- lib/asan/asan_globals.cc | 76 +-- lib/asan/asan_interceptors.cc | 156 +---- lib/asan/asan_interceptors.h | 12 + lib/asan/asan_interface_internal.h | 21 +- lib/asan/asan_internal.h | 18 +- lib/asan/asan_linux.cc | 77 +-- lib/asan/asan_mac.cc | 66 +- lib/asan/asan_mapping.h | 15 +- lib/asan/asan_poisoning.cc | 6 +- lib/asan/asan_poisoning.h | 2 +- lib/asan/asan_posix.cc | 8 +- lib/asan/asan_report.cc | 65 +- lib/asan/asan_report.h | 13 +- lib/asan/asan_rtl.cc | 161 +++-- lib/asan/asan_stats.cc | 9 +- lib/asan/asan_stats.h | 8 +- lib/asan/asan_suppressions.cc | 33 +- lib/asan/asan_suppressions.h | 1 + lib/asan/asan_thread.h | 13 +- lib/asan/asan_win.cc | 148 +++- lib/asan/asan_win_dll_thunk.cc | 9 +- lib/asan/asan_win_dynamic_runtime_thunk.cc | 94 +-- lib/asan/scripts/asan_symbolize.py | 3 + lib/asan/tests/CMakeLists.txt | 22 +- lib/asan/tests/asan_asm_test.cc | 4 +- lib/asan/tests/asan_str_test.cc | 33 +- lib/asan/tests/asan_test.cc | 32 +- lib/builtins/CMakeLists.txt | 17 +- lib/builtins/atomic_flag_clear.c | 19 + lib/builtins/atomic_flag_clear_explicit.c | 20 + lib/builtins/atomic_flag_test_and_set.c | 19 + lib/builtins/atomic_flag_test_and_set_explicit.c | 20 + lib/builtins/atomic_signal_fence.c | 19 + lib/builtins/atomic_thread_fence.c | 19 + lib/builtins/clear_cache.c | 11 +- lib/builtins/enable_execute_stack.c | 14 + lib/builtins/extendhfsf2.c | 23 + lib/builtins/fixdfdi.c | 57 +- lib/builtins/fixdfsi.c | 56 +- lib/builtins/fixdfti.c | 33 +- lib/builtins/fixsfdi.c | 54 +- lib/builtins/fixsfsi.c | 53 +- lib/builtins/fixsfti.c | 33 +- lib/builtins/fixtfdi.c | 23 + lib/builtins/fixtfsi.c | 23 + lib/builtins/fixtfti.c | 23 + lib/builtins/fixunsdfdi.c | 55 +- lib/builtins/fixunsdfsi.c | 35 +- lib/builtins/fixunsdfti.c | 36 +- lib/builtins/fixunssfdi.c | 55 +- lib/builtins/fixunssfsi.c | 32 +- lib/builtins/fixunssfti.c | 37 +- lib/builtins/fixunstfdi.c | 22 + lib/builtins/fixunstfsi.c | 22 + lib/builtins/fixunstfti.c | 22 + lib/builtins/fixunsxfdi.c | 2 + lib/builtins/fixunsxfsi.c | 3 +- lib/builtins/fixunsxfti.c | 5 +- lib/builtins/fixxfdi.c | 6 +- lib/builtins/fixxfti.c | 8 +- lib/builtins/fp_extend.h | 19 +- lib/builtins/fp_extend_impl.inc | 4 +- lib/builtins/fp_fixint_impl.inc | 41 ++ lib/builtins/fp_fixuint_impl.inc | 39 ++ lib/builtins/fp_trunc.h | 14 +- lib/builtins/fp_trunc_impl.inc | 2 +- lib/builtins/i386/chkstk.S | 34 + lib/builtins/int_endianness.h | 28 +- lib/builtins/int_lib.h | 6 +- lib/builtins/truncdfhf2.c | 16 + lib/builtins/truncsfhf2.c | 22 + lib/builtins/x86_64/chkstk.S | 39 ++ lib/dfsan/dfsan.cc | 14 +- lib/dfsan/dfsan_custom.cc | 410 ++++++----- lib/dfsan/done_abilist.txt | 15 + lib/dfsan/scripts/check_custom_wrappers.sh | 6 +- lib/interception/CMakeLists.txt | 20 +- lib/interception/interception.h | 1 - lib/interception/interception_win.cc | 13 +- lib/lsan/CMakeLists.txt | 19 +- lib/lsan/lsan_common.cc | 110 +-- lib/lsan/lsan_common.h | 3 + lib/lsan/lsan_common_linux.cc | 31 +- lib/lsan/lsan_interceptors.cc | 2 +- lib/lsan/lsan_thread.h | 4 +- lib/msan/CMakeLists.txt | 20 +- lib/msan/msan.cc | 44 +- lib/msan/msan.h | 27 +- lib/msan/msan.syms.extra | 1 + lib/msan/msan_allocator.cc | 9 + lib/msan/msan_interceptors.cc | 30 +- lib/msan/msan_interface_internal.h | 7 + lib/msan/msan_linux.cc | 43 +- lib/msan/msan_new_delete.cc | 7 - lib/msan/msan_origin.h | 2 +- lib/msan/msan_poisoning.cc | 2 +- lib/msan/msan_report.cc | 4 +- lib/msan/msan_thread.cc | 2 +- lib/msan/tests/CMakeLists.txt | 3 +- lib/msan/tests/msan_test.cc | 46 +- lib/profile/CMakeLists.txt | 5 +- lib/profile/GCDAProfiling.c | 35 +- lib/profile/InstrProfiling.h | 17 +- lib/profile/InstrProfilingFile.c | 95 ++- lib/profile/InstrProfilingUtil.c | 35 + lib/profile/InstrProfilingUtil.h | 16 + lib/safestack/CMakeLists.txt | 28 + lib/safestack/safestack.cc | 246 +++++++ lib/sanitizer_common/CMakeLists.txt | 49 +- lib/sanitizer_common/sanitizer_allocator.h | 2 +- lib/sanitizer_common/sanitizer_atomic.h | 2 +- lib/sanitizer_common/sanitizer_atomic_msvc.h | 36 +- lib/sanitizer_common/sanitizer_common.cc | 100 ++- lib/sanitizer_common/sanitizer_common.h | 144 +++- .../sanitizer_common_interceptors.inc | 286 +++++++- .../sanitizer_common_interceptors_ioctl.inc | 20 +- lib/sanitizer_common/sanitizer_common_libcdep.cc | 35 +- lib/sanitizer_common/sanitizer_common_syscalls.inc | 8 +- lib/sanitizer_common/sanitizer_coverage_libcdep.cc | 498 ++++++++++---- .../sanitizer_coverage_mapping_libcdep.cc | 17 +- .../sanitizer_deadlock_detector1.cc | 21 +- lib/sanitizer_common/sanitizer_flags.cc | 2 +- lib/sanitizer_common/sanitizer_flags.inc | 33 +- lib/sanitizer_common/sanitizer_internal_defs.h | 11 +- lib/sanitizer_common/sanitizer_libc.h | 55 +- lib/sanitizer_common/sanitizer_libignore.cc | 1 + lib/sanitizer_common/sanitizer_linux.cc | 240 ++++++- lib/sanitizer_common/sanitizer_linux.h | 6 +- lib/sanitizer_common/sanitizer_linux_libcdep.cc | 56 +- lib/sanitizer_common/sanitizer_mac.cc | 105 ++- lib/sanitizer_common/sanitizer_mac.h | 3 + lib/sanitizer_common/sanitizer_platform.h | 25 + .../sanitizer_platform_interceptors.h | 28 +- .../sanitizer_platform_limits_posix.cc | 41 +- .../sanitizer_platform_limits_posix.h | 45 +- lib/sanitizer_common/sanitizer_posix.cc | 104 ++- lib/sanitizer_common/sanitizer_posix.h | 81 +++ lib/sanitizer_common/sanitizer_posix_libcdep.cc | 79 ++- lib/sanitizer_common/sanitizer_printf.cc | 30 +- lib/sanitizer_common/sanitizer_procmaps_common.cc | 4 +- lib/sanitizer_common/sanitizer_procmaps_mac.cc | 6 +- lib/sanitizer_common/sanitizer_stacktrace.cc | 2 + .../sanitizer_stacktrace_libcdep.cc | 7 +- .../sanitizer_stacktrace_printer.cc | 27 +- .../sanitizer_stacktrace_printer.h | 6 +- lib/sanitizer_common/sanitizer_stoptheworld.h | 3 +- .../sanitizer_stoptheworld_linux_libcdep.cc | 93 ++- lib/sanitizer_common/sanitizer_suppressions.cc | 36 +- lib/sanitizer_common/sanitizer_symbolizer.cc | 37 +- lib/sanitizer_common/sanitizer_symbolizer.h | 86 ++- .../sanitizer_symbolizer_internal.h | 109 +++ .../sanitizer_symbolizer_libbacktrace.cc | 74 +- .../sanitizer_symbolizer_libbacktrace.h | 11 +- .../sanitizer_symbolizer_libcdep.cc | 167 ++++- lib/sanitizer_common/sanitizer_symbolizer_mac.cc | 148 ++++ lib/sanitizer_common/sanitizer_symbolizer_mac.h | 48 ++ .../sanitizer_symbolizer_posix_libcdep.cc | 755 ++++++--------------- .../sanitizer_symbolizer_process_libcdep.cc | 229 +++++++ lib/sanitizer_common/sanitizer_symbolizer_win.cc | 233 +++---- lib/sanitizer_common/sanitizer_symbolizer_win.h | 31 + lib/sanitizer_common/sanitizer_tls_get_addr.cc | 8 +- lib/sanitizer_common/sanitizer_tls_get_addr.h | 3 +- .../sanitizer_unwind_linux_libcdep.cc | 158 +++++ .../sanitizer_unwind_posix_libcdep.cc | 158 ----- lib/sanitizer_common/sanitizer_win.cc | 341 ++++++---- lib/sanitizer_common/scripts/check_lint.sh | 4 - lib/sanitizer_common/scripts/cpplint.py | 2 +- lib/sanitizer_common/scripts/gen_dynamic_list.py | 39 +- lib/sanitizer_common/scripts/litlint.py | 2 +- lib/sanitizer_common/scripts/sancov.py | 138 +++- lib/sanitizer_common/tests/CMakeLists.txt | 15 +- lib/sanitizer_common/tests/sanitizer_libc_test.cc | 26 +- lib/sanitizer_common/tests/sanitizer_posix_test.cc | 4 +- .../tests/sanitizer_procmaps_test.cc | 4 +- .../tests/sanitizer_stacktrace_printer_test.cc | 58 +- .../tests/sanitizer_stacktrace_test.cc | 24 +- .../tests/sanitizer_stoptheworld_test.cc | 10 + .../tests/sanitizer_symbolizer_test.cc | 58 ++ lib/tsan/CMakeLists.txt | 79 ++- lib/tsan/Makefile.old | 7 +- lib/tsan/dd/CMakeLists.txt | 4 +- lib/tsan/dd/dd_rtl.h | 2 +- lib/tsan/go/buildgo.sh | 2 +- lib/tsan/rtl/Makefile.old | 3 +- lib/tsan/rtl/tsan.syms.extra | 1 + lib/tsan/rtl/tsan_defs.h | 5 + lib/tsan/rtl/tsan_fd.cc | 36 +- lib/tsan/rtl/tsan_fd.h | 4 +- lib/tsan/rtl/tsan_flags.cc | 33 +- lib/tsan/rtl/tsan_interceptors.cc | 308 +++++---- lib/tsan/rtl/tsan_interceptors.h | 37 + lib/tsan/rtl/tsan_interface.cc | 10 + lib/tsan/rtl/tsan_interface.h | 12 + lib/tsan/rtl/tsan_interface_inl.h | 32 + lib/tsan/rtl/tsan_mman.cc | 17 + lib/tsan/rtl/tsan_new_delete.cc | 88 +++ lib/tsan/rtl/tsan_platform_linux.cc | 16 +- lib/tsan/rtl/tsan_platform_mac.cc | 2 + lib/tsan/rtl/tsan_report.cc | 7 +- lib/tsan/rtl/tsan_rtl.cc | 32 +- lib/tsan/rtl/tsan_rtl.h | 21 +- lib/tsan/rtl/tsan_rtl_mutex.cc | 8 +- lib/tsan/rtl/tsan_rtl_thread.cc | 1 + lib/tsan/rtl/tsan_suppressions.cc | 36 +- lib/tsan/rtl/tsan_suppressions.h | 1 + lib/tsan/rtl/tsan_symbolize.cc | 14 +- lib/tsan/rtl/tsan_symbolize.h | 4 - lib/tsan/rtl/tsan_sync.cc | 70 +- lib/tsan/rtl/tsan_sync.h | 3 +- lib/tsan/rtl/tsan_update_shadow_word_inl.h | 3 +- lib/tsan/tests/CMakeLists.txt | 2 +- lib/ubsan/CMakeLists.txt | 102 ++- lib/ubsan/Makefile.mk | 4 +- lib/ubsan/ubsan_diag.cc | 49 +- lib/ubsan/ubsan_diag.h | 12 +- lib/ubsan/ubsan_flags.cc | 48 +- lib/ubsan/ubsan_flags.h | 9 +- lib/ubsan/ubsan_handlers.cc | 4 + lib/ubsan/ubsan_handlers_cxx.cc | 51 +- lib/ubsan/ubsan_handlers_cxx.h | 13 + lib/ubsan/ubsan_init.cc | 83 ++- lib/ubsan/ubsan_init.h | 13 +- lib/ubsan/ubsan_init_standalone.cc | 35 + lib/ubsan/ubsan_platform.h | 27 + lib/ubsan/ubsan_type_hash.cc | 234 +------ lib/ubsan/ubsan_type_hash.h | 5 +- lib/ubsan/ubsan_type_hash_itanium.cc | 251 +++++++ lib/ubsan/ubsan_type_hash_win.cc | 81 +++ lib/ubsan/ubsan_value.cc | 13 +- lib/ubsan/ubsan_value.h | 7 - make/platform/clang_darwin.mk | 108 ++- make/platform/clang_linux.mk | 8 +- make/platform/clang_macho_embedded.mk | 11 +- make/platform/darwin_bni.mk | 15 +- test/CMakeLists.txt | 6 + test/asan/CMakeLists.txt | 5 +- test/asan/TestCases/Android/coverage-android.cc | 36 +- .../Darwin/atos-symbolizer-dyld-root-path.cc | 26 + test/asan/TestCases/Darwin/atos-symbolizer.cc | 24 + test/asan/TestCases/Darwin/dladdr-demangling.cc | 33 + .../Darwin/dyld_insert_libraries_reexec.cc | 22 +- test/asan/TestCases/Darwin/empty-section.cc | 12 + .../Darwin/interception-in-shared-lib-test.cc | 32 - .../TestCases/Darwin/interface_symbols_darwin.c | 12 + .../Darwin/reexec-insert-libraries-env.cc | 2 +- test/asan/TestCases/Darwin/sandbox-symbolizer.cc | 29 + test/asan/TestCases/Darwin/suppressions-darwin.cc | 8 +- test/asan/TestCases/Darwin/suppressions-sandbox.cc | 26 + .../Darwin/unset-insert-libraries-on-exec.cc | 2 +- .../Helpers/init-order-pthread-create-extra.cc | 4 +- .../TestCases/Linux/asan_default_suppressions.cc | 7 + test/asan/TestCases/Linux/asan_prelink_test.cc | 2 +- test/asan/TestCases/Linux/asan_preload_test-1.cc | 2 +- test/asan/TestCases/Linux/asan_preload_test-2.cc | 2 +- .../asan/TestCases/Linux/asan_rt_confict_test-1.cc | 2 +- test/asan/TestCases/Linux/clang_gcc_abi.cc | 3 +- test/asan/TestCases/Linux/coverage-and-lsan.cc | 20 - .../Linux/coverage-caller-callee-total-count.cc | 41 -- .../asan/TestCases/Linux/coverage-caller-callee.cc | 74 -- .../TestCases/Linux/coverage-direct-activation.cc | 59 -- test/asan/TestCases/Linux/coverage-direct-large.cc | 65 -- test/asan/TestCases/Linux/coverage-direct.cc | 83 --- test/asan/TestCases/Linux/coverage-disabled.cc | 20 - test/asan/TestCases/Linux/coverage-fork-direct.cc | 38 -- test/asan/TestCases/Linux/coverage-fork.cc | 38 -- test/asan/TestCases/Linux/coverage-levels.cc | 29 - .../TestCases/Linux/coverage-maybe-open-file.cc | 31 - test/asan/TestCases/Linux/coverage-missing.cc | 84 +++ .../TestCases/Linux/coverage-module-unloaded.cc | 56 -- test/asan/TestCases/Linux/coverage-reset.cc | 52 -- test/asan/TestCases/Linux/coverage-sandboxing.cc | 85 --- test/asan/TestCases/Linux/coverage-tracing.cc | 50 -- test/asan/TestCases/Linux/coverage.cc | 71 -- test/asan/TestCases/Linux/init-order-dlopen.cc | 47 ++ .../Linux/initialization-bug-any-order.cc | 4 +- .../Linux/interception-in-shared-lib-test.cc | 32 - .../asan/TestCases/Linux/interface_symbols_linux.c | 14 + test/asan/TestCases/Linux/kernel-area.cc | 20 +- test/asan/TestCases/Linux/leak.cc | 6 +- test/asan/TestCases/Linux/leak_check_segv.cc | 23 + test/asan/TestCases/Linux/malloc-in-qsort.cc | 4 +- .../asan/TestCases/Linux/malloc_delete_mismatch.cc | 8 +- test/asan/TestCases/Linux/nohugepage_test.cc | 24 +- test/asan/TestCases/Linux/odr-violation.cc | 22 +- test/asan/TestCases/Linux/overflow-in-qsort.cc | 4 +- test/asan/TestCases/Linux/ptrace.cc | 6 +- test/asan/TestCases/Linux/quarantine_size_mb.cc | 10 +- .../TestCases/Linux/read_binary_name_regtest.c | 50 ++ .../Linux/signal_during_stop_the_world.cc | 60 ++ test/asan/TestCases/Linux/sized_delete_test.cc | 18 +- test/asan/TestCases/Linux/stack-overflow-sigbus.cc | 2 +- test/asan/TestCases/Linux/stack-trace-dlclose.cc | 4 +- test/asan/TestCases/Linux/static_tls.cc | 29 + test/asan/TestCases/Linux/stress_dtls.c | 6 +- test/asan/TestCases/Posix/allow_user_segv.cc | 4 +- .../TestCases/Posix/asan-symbolize-sanity-test.cc | 2 +- .../TestCases/Posix/coverage-direct-activation.cc | 59 ++ test/asan/TestCases/Posix/coverage-direct-large.cc | 65 ++ test/asan/TestCases/Posix/coverage-direct.cc | 83 +++ test/asan/TestCases/Posix/coverage-fork-direct.cc | 38 ++ test/asan/TestCases/Posix/coverage-fork.cc | 38 ++ .../TestCases/Posix/coverage-module-unloaded.cc | 55 ++ test/asan/TestCases/Posix/coverage-sandboxing.cc | 85 +++ test/asan/TestCases/Posix/coverage.cc | 81 +++ test/asan/TestCases/Posix/init-order-dlopen.cc | 72 -- .../Posix/interception-in-shared-lib-test.cc | 27 + test/asan/TestCases/Posix/ioctl.cc | 4 +- .../Posix/large_allocator_unpoisons_on_free.cc | 2 +- .../TestCases/Posix/log_path_fork_test.cc.disabled | 22 + test/asan/TestCases/Posix/new_array_cookie_test.cc | 4 +- .../TestCases/Posix/new_array_cookie_uaf_test.cc | 4 +- test/asan/TestCases/Posix/start-deactivated.cc | 11 +- test/asan/TestCases/Posix/tsd_dtor_leak.cc | 2 +- .../Windows/bind_io_completion_callback.cc | 70 ++ test/asan/TestCases/Windows/coverage-basic.cc | 25 + test/asan/TestCases/Windows/default_options.cc | 18 + test/asan/TestCases/Windows/dll_noreturn.cc | 2 +- .../dll_report_globals_symbolization_at_startup.cc | 40 ++ .../Windows/dll_thread_stack_array_left_oob.cc | 2 +- test/asan/TestCases/Windows/free_hook_realloc.cc | 37 + .../TestCases/Windows/globals_multiple_dlls.cc | 51 -- test/asan/TestCases/Windows/on_error_callback.cc | 20 + .../asan/TestCases/Windows/queue_user_work_item.cc | 55 ++ .../Windows/queue_user_work_item_report.cc | 29 + .../TestCases/Windows/report_globals_reload_dll.cc | 51 ++ .../Windows/report_globals_vs_freelibrary.cc | 47 ++ .../asan/TestCases/Windows/stack_array_left_oob.cc | 2 +- .../Windows/thread_stack_array_left_oob.cc | 2 +- .../TestCases/alloca_instruments_all_paddings.cc | 1 + test/asan/TestCases/alloca_loop_unpoisoning.cc | 33 + test/asan/TestCases/alloca_vla_interact.cc | 41 ++ test/asan/TestCases/allocator_returns_null.cc | 20 +- test/asan/TestCases/asan_and_llvm_coverage_test.cc | 2 +- test/asan/TestCases/asan_options-help.cc | 2 +- test/asan/TestCases/atexit_stats.cc | 2 +- test/asan/TestCases/atoi_strict.c | 55 ++ test/asan/TestCases/atol_strict.c | 55 ++ test/asan/TestCases/atoll_strict.c | 55 ++ test/asan/TestCases/closed-fds.cc | 33 + test/asan/TestCases/contiguous_container_crash.cc | 19 +- test/asan/TestCases/coverage-and-lsan.cc | 20 + .../coverage-caller-callee-total-count.cc | 41 ++ test/asan/TestCases/coverage-caller-callee.cc | 74 ++ test/asan/TestCases/coverage-disabled.cc | 20 + test/asan/TestCases/coverage-levels.cc | 34 + test/asan/TestCases/coverage-maybe-open-file.cc | 32 + test/asan/TestCases/coverage-order-pcs.cc | 56 ++ test/asan/TestCases/coverage-reset.cc | 52 ++ test/asan/TestCases/coverage-tracing.cc | 50 ++ test/asan/TestCases/debug_mapping.cc | 8 +- test/asan/TestCases/debug_ppc64_mapping.cc | 4 +- test/asan/TestCases/debug_stacks.cc | 3 + test/asan/TestCases/deep_call_stack.cc | 4 +- test/asan/TestCases/deep_stack_uaf.cc | 2 +- test/asan/TestCases/default_options.cc | 3 - test/asan/TestCases/double-free.cc | 4 +- test/asan/TestCases/dump_instruction_bytes.cc | 2 +- test/asan/TestCases/free_hook_realloc.cc | 3 - test/asan/TestCases/gc-test.cc | 8 +- test/asan/TestCases/heap-overflow-large.cc | 4 +- test/asan/TestCases/heap-overflow.cc | 2 +- test/asan/TestCases/heavy_uar_test.cc | 2 +- test/asan/TestCases/init-order-atexit.cc | 5 +- test/asan/TestCases/init-order-pthread-create.cc | 39 +- test/asan/TestCases/initialization-blacklist.cc | 6 +- test/asan/TestCases/initialization-bug.cc | 6 +- test/asan/TestCases/initialization-constexpr.cc | 8 +- test/asan/TestCases/initialization-nobug.cc | 8 +- test/asan/TestCases/interface_test.cc | 4 +- test/asan/TestCases/invalid-free.cc | 4 +- test/asan/TestCases/log-path_test.cc | 8 +- test/asan/TestCases/log_path_fork_test.cc.disabled | 22 - test/asan/TestCases/malloc_context_size.cc | 10 +- test/asan/TestCases/malloc_fill.cc | 4 +- test/asan/TestCases/max_redzone.cc | 4 +- test/asan/TestCases/memcmp_strict_test.cc | 4 +- test/asan/TestCases/mmap_limit_mb.cc | 8 +- test/asan/TestCases/no_asan_gen_globals.c | 2 + test/asan/TestCases/on_error_callback.cc | 3 - test/asan/TestCases/poison_partial.cc | 4 +- test/asan/TestCases/print_summary.cc | 16 +- test/asan/TestCases/printf-1.c | 4 +- test/asan/TestCases/printf-2.c | 6 +- test/asan/TestCases/printf-3.c | 4 +- test/asan/TestCases/printf-4.c | 4 +- test/asan/TestCases/printf-5.c | 6 +- test/asan/TestCases/sleep_before_dying.c | 2 +- test/asan/TestCases/stack-overflow.cc | 24 +- test/asan/TestCases/stack-use-after-return.cc | 4 +- test/asan/TestCases/strcasestr-1.c | 24 + test/asan/TestCases/strcasestr-2.c | 24 + test/asan/TestCases/strcasestr_strict.c | 28 + test/asan/TestCases/strcat_strict.c | 44 ++ test/asan/TestCases/strchr_strict.c | 22 + test/asan/TestCases/strcmp_strict.c | 26 + test/asan/TestCases/strcspn-1.c | 19 + test/asan/TestCases/strcspn-2.c | 19 + test/asan/TestCases/strcspn_strict.c | 26 + test/asan/TestCases/strip_path_prefix.c | 4 +- test/asan/TestCases/strncat_strict.c | 44 ++ test/asan/TestCases/strpbrk-1.c | 19 + test/asan/TestCases/strpbrk-2.c | 19 + test/asan/TestCases/strpbrk_strict.c | 25 + test/asan/TestCases/strspn-1.c | 19 + test/asan/TestCases/strspn-2.c | 19 + test/asan/TestCases/strspn_strict.c | 25 + test/asan/TestCases/strstr-1.c | 20 + test/asan/TestCases/strstr-2.c | 20 + test/asan/TestCases/strstr_strict.c | 25 + test/asan/TestCases/strtol_strict.c | 116 ++++ test/asan/TestCases/strtoll_strict.c | 116 ++++ .../suppressions-exec-relative-location.cc | 47 ++ test/asan/TestCases/suppressions-function.cc | 4 +- test/asan/TestCases/suppressions-interceptor.cc | 2 +- test/asan/TestCases/suppressions-library.cc | 8 +- test/asan/TestCases/uar_and_exceptions.cc | 2 +- test/asan/TestCases/use-after-poison.cc | 2 +- test/asan/TestCases/use-after-scope.cc | 2 +- test/asan/TestCases/verbose-log-path_test.cc | 21 + test/asan/TestCases/vla_chrome_testcase.cc | 30 + test/asan/TestCases/vla_condition_overflow.cc | 22 + test/asan/TestCases/vla_loop_overfow.cc | 22 + test/asan/lit.cfg | 17 + test/builtins/Unit/absvdi2_test.c | 2 +- test/builtins/Unit/absvsi2_test.c | 2 +- test/builtins/Unit/absvti2_test.c | 2 +- test/builtins/Unit/adddf3vfp_test.c | 3 +- test/builtins/Unit/addsf3vfp_test.c | 3 +- test/builtins/Unit/addtf3_test.c | 3 +- test/builtins/Unit/addvdi3_test.c | 2 +- test/builtins/Unit/addvsi3_test.c | 2 +- test/builtins/Unit/addvti3_test.c | 2 +- test/builtins/Unit/ashldi3_test.c | 2 +- test/builtins/Unit/ashlti3_test.c | 2 +- test/builtins/Unit/ashrdi3_test.c | 2 +- test/builtins/Unit/ashrti3_test.c | 2 +- test/builtins/Unit/clzdi2_test.c | 2 +- test/builtins/Unit/clzsi2_test.c | 2 +- test/builtins/Unit/clzti2_test.c | 2 +- test/builtins/Unit/cmpdi2_test.c | 2 +- test/builtins/Unit/cmpti2_test.c | 2 +- test/builtins/Unit/ctzdi2_test.c | 2 +- test/builtins/Unit/ctzsi2_test.c | 2 +- test/builtins/Unit/ctzti2_test.c | 2 +- test/builtins/Unit/divdc3_test.c | 3 +- test/builtins/Unit/divdf3vfp_test.c | 3 +- test/builtins/Unit/divdi3_test.c | 2 +- test/builtins/Unit/divmodsi4_test.c | 2 +- test/builtins/Unit/divsc3_test.c | 3 +- test/builtins/Unit/divsf3vfp_test.c | 3 +- test/builtins/Unit/divsi3_test.c | 2 +- test/builtins/Unit/divtc3_test.c | 5 +- test/builtins/Unit/divtf3_test.c | 3 +- test/builtins/Unit/divti3_test.c | 2 +- test/builtins/Unit/divxc3_test.c | 2 +- test/builtins/Unit/extebdsfdf2vfp_test.c | 3 +- test/builtins/Unit/extenddftf2_test.c | 3 +- test/builtins/Unit/extendhfsf2_test.c | 113 +++ test/builtins/Unit/extendsftf2_test.c | 3 +- test/builtins/Unit/ffsdi2_test.c | 2 +- test/builtins/Unit/ffsti2_test.c | 2 +- test/builtins/Unit/fixdfdi_test.c | 2 +- test/builtins/Unit/fixdfti_test.c | 2 +- test/builtins/Unit/fixsfdi_test.c | 2 +- test/builtins/Unit/fixsfti_test.c | 2 +- test/builtins/Unit/fixtfsi_test.c | 65 ++ test/builtins/Unit/fixunsdfdi_test.c | 2 +- test/builtins/Unit/fixunsdfsi_test.c | 2 +- test/builtins/Unit/fixunsdfsivfp_test.c | 3 +- test/builtins/Unit/fixunsdfti_test.c | 2 +- test/builtins/Unit/fixunssfdi_test.c | 2 +- test/builtins/Unit/fixunssfsi_test.c | 2 +- test/builtins/Unit/fixunssfti_test.c | 2 +- test/builtins/Unit/fixunstfdi_test.c | 5 +- test/builtins/Unit/fixunstfsi_test.c | 64 ++ test/builtins/Unit/fixunsxfdi_test.c | 2 +- test/builtins/Unit/fixunsxfsi_test.c | 2 +- test/builtins/Unit/fixunsxfti_test.c | 2 +- test/builtins/Unit/fixxfdi_test.c | 2 +- test/builtins/Unit/fixxfti_test.c | 2 +- test/builtins/Unit/floatdidf_test.c | 2 +- test/builtins/Unit/floatdisf_test.c | 2 +- test/builtins/Unit/floatdixf_test.c | 2 +- test/builtins/Unit/floatsidfvfp_test.c | 3 +- test/builtins/Unit/floatsisfvfp_test.c | 3 +- test/builtins/Unit/floatsitf_test.c | 3 +- test/builtins/Unit/floattidf_test.c | 2 +- test/builtins/Unit/floattisf_test.c | 2 +- test/builtins/Unit/floattixf_test.c | 2 +- test/builtins/Unit/floatundidf_test.c | 2 +- test/builtins/Unit/floatundisf_test.c | 2 +- test/builtins/Unit/floatundixf_test.c | 2 +- test/builtins/Unit/floatunsitf_test.c | 3 +- test/builtins/Unit/floatunssidfvfp_test.c | 3 +- test/builtins/Unit/floatunssisfvfp_test.c | 4 +- test/builtins/Unit/floatuntidf_test.c | 2 +- test/builtins/Unit/floatuntisf_test.c | 2 +- test/builtins/Unit/floatuntixf_test.c | 2 +- test/builtins/Unit/fp_test.h | 56 ++ test/builtins/Unit/lshrdi3_test.c | 2 +- test/builtins/Unit/lshrti3_test.c | 2 +- test/builtins/Unit/moddi3_test.c | 2 +- test/builtins/Unit/modsi3_test.c | 2 +- test/builtins/Unit/modti3_test.c | 2 +- test/builtins/Unit/muldc3_test.c | 3 +- test/builtins/Unit/muldf3vfp_test.c | 3 +- test/builtins/Unit/muldi3_test.c | 2 +- test/builtins/Unit/mulodi4_test.c | 2 +- test/builtins/Unit/mulosi4_test.c | 2 +- test/builtins/Unit/muloti4_test.c | 2 +- test/builtins/Unit/mulsc3_test.c | 3 +- test/builtins/Unit/mulsf3vfp_test.c | 3 +- test/builtins/Unit/multc3_test.c | 5 +- test/builtins/Unit/multf3_test.c | 2 +- test/builtins/Unit/multi3_test.c | 2 +- test/builtins/Unit/mulvdi3_test.c | 2 +- test/builtins/Unit/mulvsi3_test.c | 2 +- test/builtins/Unit/mulvti3_test.c | 2 +- test/builtins/Unit/mulxc3_test.c | 2 +- test/builtins/Unit/negdf2vfp_test.c | 2 +- test/builtins/Unit/negdi2_test.c | 2 +- test/builtins/Unit/negsf2vfp_test.c | 3 +- test/builtins/Unit/negti2_test.c | 2 +- test/builtins/Unit/negvdi2_test.c | 2 +- test/builtins/Unit/negvsi2_test.c | 2 +- test/builtins/Unit/negvti2_test.c | 4 +- test/builtins/Unit/paritydi2_test.c | 2 +- test/builtins/Unit/paritysi2_test.c | 2 +- test/builtins/Unit/parityti2_test.c | 2 +- test/builtins/Unit/popcountdi2_test.c | 2 +- test/builtins/Unit/popcountsi2_test.c | 2 +- test/builtins/Unit/popcountti2_test.c | 2 +- test/builtins/Unit/powidf2_test.c | 2 +- test/builtins/Unit/powisf2_test.c | 2 +- test/builtins/Unit/powitf2_test.c | 5 +- test/builtins/Unit/powixf2_test.c | 2 +- test/builtins/Unit/ppc/floatditf_test.c | 2 +- test/builtins/Unit/ppc/floatunditf_test.c | 2 +- test/builtins/Unit/subdf3vfp_test.c | 2 +- test/builtins/Unit/subsf3vfp_test.c | 3 +- test/builtins/Unit/subtf3_test.c | 2 +- test/builtins/Unit/subvdi3_test.c | 2 +- test/builtins/Unit/subvsi3_test.c | 2 +- test/builtins/Unit/subvti3_test.c | 2 +- test/builtins/Unit/truncdfhf2_test.c | 114 ++++ test/builtins/Unit/truncdfsf2_test.c | 38 ++ test/builtins/Unit/truncdfsf2vfp_test.c | 3 +- test/builtins/Unit/truncsfhf2_test.c | 114 ++++ test/builtins/Unit/trunctfdf2_test.c | 3 +- test/builtins/Unit/trunctfsf2_test.c | 3 +- test/builtins/Unit/ucmpdi2_test.c | 2 +- test/builtins/Unit/ucmpti2_test.c | 2 +- test/builtins/Unit/udivdi3_test.c | 2 +- test/builtins/Unit/udivmoddi4_test.c | 2 +- test/builtins/Unit/udivmodsi4_test.c | 2 +- test/builtins/Unit/udivmodti4_test.c | 2 +- test/builtins/Unit/udivsi3_test.c | 2 +- test/builtins/Unit/udivti3_test.c | 2 +- test/builtins/Unit/umoddi3_test.c | 2 +- test/builtins/Unit/umodsi3_test.c | 2 +- test/builtins/Unit/umodti3_test.c | 2 +- test/cfi/CMakeLists.txt | 17 + test/cfi/README.txt | 8 + test/cfi/anon-namespace.cpp | 35 +- test/cfi/bad-cast.cpp | 150 ++++ test/cfi/lit.cfg | 30 +- test/cfi/multiple-inheritance.cpp | 44 +- test/cfi/nvcall.cpp | 72 ++ test/cfi/overwrite.cpp | 35 +- test/cfi/sibling.cpp | 67 ++ test/cfi/simple-fail.cpp | 81 ++- test/cfi/simple-pass.cpp | 26 +- test/cfi/vdtor.cpp | 31 +- test/dfsan/basic.c | 4 +- test/dfsan/custom.cc | 13 +- test/dfsan/dump_labels.c | 2 +- test/dfsan/flags.c | 6 +- test/dfsan/fncall.c | 4 +- test/dfsan/label_count.c | 12 +- test/dfsan/lit.cfg | 2 +- test/dfsan/propagate.c | 4 +- test/dfsan/vararg.c | 4 +- test/dfsan/write_callback.c | 4 +- test/lit.common.cfg | 52 +- test/lit.common.configured.in | 1 + test/lsan/CMakeLists.txt | 18 +- test/lsan/TestCases/recoverable_leak_check.cc | 32 + test/msan/Linux/fopencookie.cc | 65 ++ test/msan/Linux/getresid.cc | 6 +- test/msan/Linux/glob.cc | 6 +- test/msan/Linux/glob_altdirfunc.cc | 6 +- test/msan/Linux/glob_nomatch.cc | 4 +- test/msan/Linux/ioctl_sound.cc | 29 + test/msan/Linux/mallinfo.cc | 12 + test/msan/Linux/obstack.cc | 37 + test/msan/Linux/sunrpc.cc | 12 +- test/msan/Linux/sunrpc_bytes.cc | 4 +- test/msan/Linux/sunrpc_string.cc | 4 +- test/msan/Linux/syscalls.cc | 4 +- test/msan/Linux/tcgetattr.cc | 2 +- test/msan/Linux/xattr.cc | 6 +- test/msan/backtrace.cc | 4 +- test/msan/c-strdup.c | 8 +- test/msan/chained_origin.cc | 8 +- test/msan/chained_origin_empty_stack.cc | 2 +- test/msan/chained_origin_limits.cc | 8 +- test/msan/chained_origin_memcpy.cc | 8 +- test/msan/chained_origin_with_signals.cc | 4 +- test/msan/check_mem_is_initialized.cc | 16 +- test/msan/coverage-levels.cc | 8 +- test/msan/cxa_atexit.cc | 2 +- test/msan/death-callback.cc | 8 +- test/msan/dlerror.cc | 2 +- test/msan/dso-origin.cc | 4 +- test/msan/dtls_test.c | 4 +- test/msan/errno.cc | 2 +- test/msan/fork.cc | 2 +- test/msan/ftime.cc | 5 +- test/msan/getaddrinfo-positive.cc | 4 +- test/msan/getaddrinfo.cc | 2 +- test/msan/getc_unlocked.c | 16 +- test/msan/getline.cc | 4 + test/msan/heap-origin.cc | 16 +- test/msan/iconv.cc | 9 +- test/msan/if_indextoname.cc | 8 +- test/msan/ifaddrs.cc | 10 +- test/msan/initgroups.cc | 3 +- test/msan/insertvalue_origin.cc | 4 +- test/msan/ioctl.cc | 4 +- test/msan/ioctl_custom.cc | 8 +- test/msan/ioctl_sound.cc | 29 - test/msan/keep-going-dso.cc | 12 +- test/msan/keep-going.cc | 16 +- test/msan/lit.cfg | 3 + test/msan/mallinfo.cc | 12 - test/msan/mktime.cc | 4 +- test/msan/mmap.cc | 45 ++ test/msan/mmap_below_shadow.cc | 16 +- test/msan/msan_check_mem_is_initialized.cc | 4 +- test/msan/msan_dump_shadow.cc | 6 +- test/msan/msan_print_shadow.cc | 6 +- test/msan/msan_print_shadow2.cc | 6 +- test/msan/msan_print_shadow3.cc | 2 +- test/msan/mul_by_const.cc | 2 +- test/msan/no_sanitize_memory.cc | 16 +- test/msan/no_sanitize_memory_prop.cc | 8 +- test/msan/obstack.cc | 37 - test/msan/origin-store-long.cc | 4 +- test/msan/param_tls_limit.cc | 6 +- test/msan/print_stats.cc | 6 +- test/msan/pthread_getattr_np_deadlock.cc | 2 +- test/msan/rand_r.cc | 4 +- test/msan/readdir64.cc | 16 +- test/msan/realloc-large-origin.cc | 4 +- test/msan/realloc-origin.cc | 4 +- test/msan/report-demangling.cc | 4 +- test/msan/scandir.cc | 6 +- test/msan/scandir_null.cc | 6 +- test/msan/select.cc | 8 +- test/msan/setlocale.cc | 2 +- test/msan/stack-origin.cc | 16 +- test/msan/stack-origin2.cc | 16 +- test/msan/strlen_of_shadow.cc | 6 +- test/msan/strxfrm.cc | 2 +- test/msan/sync_lock_set_and_test.cc | 2 +- test/msan/textdomain.cc | 2 +- test/msan/times.cc | 2 +- test/msan/tls_reuse.cc | 2 +- test/msan/tzset.cc | 2 +- test/msan/unaligned_read_origin.cc | 4 +- test/msan/unpoison_string.cc | 4 +- test/msan/use-after-free.cc | 16 +- test/msan/vector_cvt.cc | 5 +- test/msan/vector_select.cc | 6 +- test/profile/Inputs/gcc-flag-compatibility.c | 8 + test/profile/Inputs/instrprof-dynamic-a.cpp | 4 +- test/profile/Inputs/instrprof-dynamic-b.cpp | 4 +- test/profile/Inputs/instrprof-dynamic-header.h | 6 +- test/profile/Inputs/instrprof-dynamic-main.cpp | 2 +- test/profile/gcc-flag-compatibility.test | 17 + ...nstrprof-override-filename-then-reset-default.c | 19 + .../profile/instrprof-override-filename-with-env.c | 14 + test/profile/instrprof-override-filename.c | 14 + .../instrprof-set-filename-then-reset-default.c | 18 + test/profile/lit.cfg | 2 + test/safestack/CMakeLists.txt | 29 + test/safestack/buffer-copy-vla.c | 26 + test/safestack/buffer-copy.c | 25 + test/safestack/init.c | 9 + test/safestack/lit.cfg | 24 + test/safestack/lit.site.cfg.in | 8 + test/safestack/lto.c | 12 + test/safestack/overflow.c | 23 + test/safestack/pthread-cleanup.c | 31 + test/safestack/pthread.c | 42 ++ test/safestack/utils.h | 8 + test/sanitizer_common/CMakeLists.txt | 29 +- test/sanitizer_common/TestCases/Linux/assert.cc | 24 + .../TestCases/Linux/getpwnam_r_invalid_user.cc | 3 +- .../TestCases/Linux/open_memstream.cc | 1 + .../TestCases/Linux/signal_segv_handler.cc | 48 ++ .../TestCases/Posix/decorate_proc_maps.cc | 60 ++ .../sanitizer_common/TestCases/Posix/lit.local.cfg | 9 + test/sanitizer_common/TestCases/strcasestr.c | 16 + test/sanitizer_common/TestCases/strcspn.c | 13 + test/sanitizer_common/TestCases/strpbrk.c | 14 + test/sanitizer_common/TestCases/strspn.c | 13 + test/sanitizer_common/TestCases/strstr.c | 12 + test/sanitizer_common/lit.common.cfg | 1 + test/sanitizer_common/lit.site.cfg.in | 2 + test/tsan/CMakeLists.txt | 4 +- test/tsan/cond_cancel.c | 7 +- test/tsan/cond_destruction.cc | 53 ++ test/tsan/cond_race.cc | 2 +- test/tsan/deadlock_detector_stress_test.cc | 2 +- test/tsan/dl_iterate_phdr.cc | 56 ++ test/tsan/fd_dup_norace2.cc | 60 ++ test/tsan/fd_dup_race.cc | 33 + test/tsan/heap_race.cc | 4 + test/tsan/ignore_free.cc | 2 +- test/tsan/ignore_malloc.cc | 2 +- test/tsan/java.h | 5 + test/tsan/java_heap_init.cc | 28 + test/tsan/java_race.cc | 3 + test/tsan/java_race_pc.cc | 36 + test/tsan/java_symbolization.cc | 44 ++ test/tsan/large_malloc_meta.cc | 28 + test/tsan/longjmp.cc | 4 + test/tsan/longjmp2.cc | 4 + test/tsan/longjmp3.cc | 4 + test/tsan/longjmp4.cc | 4 + test/tsan/malloc_stack.cc | 2 +- test/tsan/mmap_large.cc | 7 + test/tsan/mmap_stress.cc | 47 ++ test/tsan/mop1.c | 40 ++ test/tsan/race_top_suppression.cc | 29 + test/tsan/race_top_suppression1.cc | 32 + test/tsan/setuid.c | 26 + test/tsan/setuid2.c | 21 + test/tsan/signal_cond.cc | 51 ++ test/tsan/signal_longjmp.cc | 3 + test/tsan/signal_recursive.cc | 2 + test/tsan/signal_segv_handler.cc | 39 -- test/tsan/test.h | 10 +- test/tsan/thread_detach2.c | 28 + test/ubsan/CMakeLists.txt | 48 +- test/ubsan/TestCases/Float/cast-overflow.cpp | 50 +- test/ubsan/TestCases/Integer/add-overflow.cpp | 8 +- test/ubsan/TestCases/Integer/div-zero.cpp | 2 +- test/ubsan/TestCases/Integer/incdec-overflow.cpp | 12 +- test/ubsan/TestCases/Integer/negate-overflow.cpp | 4 +- test/ubsan/TestCases/Integer/shift.cpp | 34 +- test/ubsan/TestCases/Integer/sub-overflow.cpp | 8 +- test/ubsan/TestCases/Integer/summary.cpp | 2 +- test/ubsan/TestCases/Integer/uadd-overflow.cpp | 8 +- test/ubsan/TestCases/Integer/uincdec-overflow.cpp | 8 +- test/ubsan/TestCases/Integer/usub-overflow.cpp | 8 +- test/ubsan/TestCases/Misc/Linux/coverage-levels.cc | 39 ++ test/ubsan/TestCases/Misc/Linux/lit.local.cfg | 9 + test/ubsan/TestCases/Misc/Linux/ubsan_options.cc | 18 + test/ubsan/TestCases/Misc/bounds.cpp | 2 +- test/ubsan/TestCases/Misc/coverage-levels.cc | 38 -- test/ubsan/TestCases/Misc/deduplication.cpp | 1 + test/ubsan/TestCases/Misc/enum.cpp | 4 + test/ubsan/TestCases/Misc/log-path_test.cc | 33 + test/ubsan/TestCases/Misc/missing_return.cpp | 10 +- .../TestCases/TypeCheck/Function/function.cpp | 2 +- test/ubsan/TestCases/TypeCheck/misaligned.cpp | 20 +- test/ubsan/TestCases/TypeCheck/null.cpp | 2 +- .../TypeCheck/vptr-virtual-base-construction.cpp | 13 + .../TestCases/TypeCheck/vptr-virtual-base.cpp | 3 +- test/ubsan/TestCases/TypeCheck/vptr.cpp | 72 +- test/ubsan/lit.common.cfg | 23 +- test/ubsan/lit.site.cfg.in | 2 + www/index.html | 4 +- www/menu.html.incl | 4 +- 807 files changed, 14343 insertions(+), 6373 deletions(-) delete mode 100644 SDKs/README.txt delete mode 100644 SDKs/linux/README.txt delete mode 100644 SDKs/linux/usr/include/endian.h delete mode 100644 SDKs/linux/usr/include/fcntl.h delete mode 100644 SDKs/linux/usr/include/limits.h delete mode 100644 SDKs/linux/usr/include/stdio.h delete mode 100644 SDKs/linux/usr/include/stdlib.h delete mode 100644 SDKs/linux/usr/include/string.h delete mode 100644 SDKs/linux/usr/include/sys/fcntl.h delete mode 100644 SDKs/linux/usr/include/sys/mman.h delete mode 100644 SDKs/linux/usr/include/sys/stat.h delete mode 100644 SDKs/linux/usr/include/sys/types.h delete mode 100644 SDKs/linux/usr/include/unistd.h create mode 100644 lib/builtins/atomic_flag_clear.c create mode 100644 lib/builtins/atomic_flag_clear_explicit.c create mode 100644 lib/builtins/atomic_flag_test_and_set.c create mode 100644 lib/builtins/atomic_flag_test_and_set_explicit.c create mode 100644 lib/builtins/atomic_signal_fence.c create mode 100644 lib/builtins/atomic_thread_fence.c create mode 100644 lib/builtins/extendhfsf2.c create mode 100644 lib/builtins/fixtfdi.c create mode 100644 lib/builtins/fixtfsi.c create mode 100644 lib/builtins/fixtfti.c create mode 100644 lib/builtins/fixunstfdi.c create mode 100644 lib/builtins/fixunstfsi.c create mode 100644 lib/builtins/fixunstfti.c create mode 100644 lib/builtins/fp_fixint_impl.inc create mode 100644 lib/builtins/fp_fixuint_impl.inc create mode 100644 lib/builtins/i386/chkstk.S create mode 100644 lib/builtins/truncdfhf2.c create mode 100644 lib/builtins/truncsfhf2.c create mode 100644 lib/builtins/x86_64/chkstk.S create mode 100644 lib/profile/InstrProfilingUtil.c create mode 100644 lib/profile/InstrProfilingUtil.h create mode 100644 lib/safestack/CMakeLists.txt create mode 100644 lib/safestack/safestack.cc create mode 100644 lib/sanitizer_common/sanitizer_posix.h create mode 100644 lib/sanitizer_common/sanitizer_symbolizer_internal.h create mode 100644 lib/sanitizer_common/sanitizer_symbolizer_mac.cc create mode 100644 lib/sanitizer_common/sanitizer_symbolizer_mac.h create mode 100644 lib/sanitizer_common/sanitizer_symbolizer_process_libcdep.cc create mode 100644 lib/sanitizer_common/sanitizer_symbolizer_win.h create mode 100644 lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc delete mode 100644 lib/sanitizer_common/sanitizer_unwind_posix_libcdep.cc create mode 100644 lib/sanitizer_common/tests/sanitizer_symbolizer_test.cc create mode 100644 lib/tsan/rtl/tsan_interceptors.h create mode 100644 lib/tsan/rtl/tsan_new_delete.cc create mode 100644 lib/ubsan/ubsan_init_standalone.cc create mode 100644 lib/ubsan/ubsan_platform.h create mode 100644 lib/ubsan/ubsan_type_hash_itanium.cc create mode 100644 lib/ubsan/ubsan_type_hash_win.cc create mode 100644 test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cc create mode 100644 test/asan/TestCases/Darwin/atos-symbolizer.cc create mode 100644 test/asan/TestCases/Darwin/dladdr-demangling.cc create mode 100644 test/asan/TestCases/Darwin/empty-section.cc delete mode 100644 test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc create mode 100644 test/asan/TestCases/Darwin/sandbox-symbolizer.cc create mode 100644 test/asan/TestCases/Darwin/suppressions-sandbox.cc create mode 100644 test/asan/TestCases/Linux/asan_default_suppressions.cc delete mode 100644 test/asan/TestCases/Linux/coverage-and-lsan.cc delete mode 100644 test/asan/TestCases/Linux/coverage-caller-callee-total-count.cc delete mode 100644 test/asan/TestCases/Linux/coverage-caller-callee.cc delete mode 100644 test/asan/TestCases/Linux/coverage-direct-activation.cc delete mode 100644 test/asan/TestCases/Linux/coverage-direct-large.cc delete mode 100644 test/asan/TestCases/Linux/coverage-direct.cc delete mode 100644 test/asan/TestCases/Linux/coverage-disabled.cc delete mode 100644 test/asan/TestCases/Linux/coverage-fork-direct.cc delete mode 100644 test/asan/TestCases/Linux/coverage-fork.cc delete mode 100644 test/asan/TestCases/Linux/coverage-levels.cc delete mode 100644 test/asan/TestCases/Linux/coverage-maybe-open-file.cc create mode 100644 test/asan/TestCases/Linux/coverage-missing.cc delete mode 100644 test/asan/TestCases/Linux/coverage-module-unloaded.cc delete mode 100644 test/asan/TestCases/Linux/coverage-reset.cc delete mode 100644 test/asan/TestCases/Linux/coverage-sandboxing.cc delete mode 100644 test/asan/TestCases/Linux/coverage-tracing.cc delete mode 100644 test/asan/TestCases/Linux/coverage.cc create mode 100644 test/asan/TestCases/Linux/init-order-dlopen.cc delete mode 100644 test/asan/TestCases/Linux/interception-in-shared-lib-test.cc create mode 100644 test/asan/TestCases/Linux/leak_check_segv.cc create mode 100644 test/asan/TestCases/Linux/read_binary_name_regtest.c create mode 100644 test/asan/TestCases/Linux/signal_during_stop_the_world.cc create mode 100644 test/asan/TestCases/Linux/static_tls.cc create mode 100644 test/asan/TestCases/Posix/coverage-direct-activation.cc create mode 100644 test/asan/TestCases/Posix/coverage-direct-large.cc create mode 100644 test/asan/TestCases/Posix/coverage-direct.cc create mode 100644 test/asan/TestCases/Posix/coverage-fork-direct.cc create mode 100644 test/asan/TestCases/Posix/coverage-fork.cc create mode 100644 test/asan/TestCases/Posix/coverage-module-unloaded.cc create mode 100644 test/asan/TestCases/Posix/coverage-sandboxing.cc create mode 100644 test/asan/TestCases/Posix/coverage.cc delete mode 100644 test/asan/TestCases/Posix/init-order-dlopen.cc create mode 100644 test/asan/TestCases/Posix/interception-in-shared-lib-test.cc create mode 100644 test/asan/TestCases/Posix/log_path_fork_test.cc.disabled create mode 100644 test/asan/TestCases/Windows/bind_io_completion_callback.cc create mode 100644 test/asan/TestCases/Windows/coverage-basic.cc create mode 100644 test/asan/TestCases/Windows/default_options.cc create mode 100644 test/asan/TestCases/Windows/dll_report_globals_symbolization_at_startup.cc create mode 100644 test/asan/TestCases/Windows/free_hook_realloc.cc delete mode 100644 test/asan/TestCases/Windows/globals_multiple_dlls.cc create mode 100644 test/asan/TestCases/Windows/on_error_callback.cc create mode 100644 test/asan/TestCases/Windows/queue_user_work_item.cc create mode 100644 test/asan/TestCases/Windows/queue_user_work_item_report.cc create mode 100644 test/asan/TestCases/Windows/report_globals_reload_dll.cc create mode 100644 test/asan/TestCases/Windows/report_globals_vs_freelibrary.cc create mode 100644 test/asan/TestCases/alloca_loop_unpoisoning.cc create mode 100644 test/asan/TestCases/alloca_vla_interact.cc create mode 100644 test/asan/TestCases/atoi_strict.c create mode 100644 test/asan/TestCases/atol_strict.c create mode 100644 test/asan/TestCases/atoll_strict.c create mode 100644 test/asan/TestCases/closed-fds.cc create mode 100644 test/asan/TestCases/coverage-and-lsan.cc create mode 100644 test/asan/TestCases/coverage-caller-callee-total-count.cc create mode 100644 test/asan/TestCases/coverage-caller-callee.cc create mode 100644 test/asan/TestCases/coverage-disabled.cc create mode 100644 test/asan/TestCases/coverage-levels.cc create mode 100644 test/asan/TestCases/coverage-maybe-open-file.cc create mode 100644 test/asan/TestCases/coverage-order-pcs.cc create mode 100644 test/asan/TestCases/coverage-reset.cc create mode 100644 test/asan/TestCases/coverage-tracing.cc delete mode 100644 test/asan/TestCases/log_path_fork_test.cc.disabled create mode 100644 test/asan/TestCases/strcasestr-1.c create mode 100644 test/asan/TestCases/strcasestr-2.c create mode 100644 test/asan/TestCases/strcasestr_strict.c create mode 100644 test/asan/TestCases/strcat_strict.c create mode 100644 test/asan/TestCases/strchr_strict.c create mode 100644 test/asan/TestCases/strcmp_strict.c create mode 100644 test/asan/TestCases/strcspn-1.c create mode 100644 test/asan/TestCases/strcspn-2.c create mode 100644 test/asan/TestCases/strcspn_strict.c create mode 100644 test/asan/TestCases/strncat_strict.c create mode 100644 test/asan/TestCases/strpbrk-1.c create mode 100644 test/asan/TestCases/strpbrk-2.c create mode 100644 test/asan/TestCases/strpbrk_strict.c create mode 100644 test/asan/TestCases/strspn-1.c create mode 100644 test/asan/TestCases/strspn-2.c create mode 100644 test/asan/TestCases/strspn_strict.c create mode 100644 test/asan/TestCases/strstr-1.c create mode 100644 test/asan/TestCases/strstr-2.c create mode 100644 test/asan/TestCases/strstr_strict.c create mode 100644 test/asan/TestCases/strtol_strict.c create mode 100644 test/asan/TestCases/strtoll_strict.c create mode 100644 test/asan/TestCases/suppressions-exec-relative-location.cc create mode 100644 test/asan/TestCases/verbose-log-path_test.cc create mode 100644 test/asan/TestCases/vla_chrome_testcase.cc create mode 100644 test/asan/TestCases/vla_condition_overflow.cc create mode 100644 test/asan/TestCases/vla_loop_overfow.cc create mode 100644 test/builtins/Unit/extendhfsf2_test.c create mode 100644 test/builtins/Unit/fixtfsi_test.c create mode 100644 test/builtins/Unit/fixunstfsi_test.c create mode 100644 test/builtins/Unit/truncdfhf2_test.c create mode 100644 test/builtins/Unit/truncdfsf2_test.c create mode 100644 test/builtins/Unit/truncsfhf2_test.c create mode 100644 test/cfi/README.txt create mode 100644 test/cfi/bad-cast.cpp create mode 100644 test/cfi/nvcall.cpp create mode 100644 test/cfi/sibling.cpp create mode 100644 test/lsan/TestCases/recoverable_leak_check.cc create mode 100644 test/msan/Linux/fopencookie.cc create mode 100644 test/msan/Linux/ioctl_sound.cc create mode 100644 test/msan/Linux/mallinfo.cc create mode 100644 test/msan/Linux/obstack.cc delete mode 100644 test/msan/ioctl_sound.cc delete mode 100644 test/msan/mallinfo.cc create mode 100644 test/msan/mmap.cc delete mode 100644 test/msan/obstack.cc create mode 100644 test/profile/Inputs/gcc-flag-compatibility.c create mode 100644 test/profile/gcc-flag-compatibility.test create mode 100644 test/profile/instrprof-override-filename-then-reset-default.c create mode 100644 test/profile/instrprof-override-filename-with-env.c create mode 100644 test/profile/instrprof-override-filename.c create mode 100644 test/profile/instrprof-set-filename-then-reset-default.c create mode 100644 test/safestack/CMakeLists.txt create mode 100644 test/safestack/buffer-copy-vla.c create mode 100644 test/safestack/buffer-copy.c create mode 100644 test/safestack/init.c create mode 100644 test/safestack/lit.cfg create mode 100644 test/safestack/lit.site.cfg.in create mode 100644 test/safestack/lto.c create mode 100644 test/safestack/overflow.c create mode 100644 test/safestack/pthread-cleanup.c create mode 100644 test/safestack/pthread.c create mode 100644 test/safestack/utils.h create mode 100644 test/sanitizer_common/TestCases/Linux/assert.cc create mode 100644 test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc create mode 100644 test/sanitizer_common/TestCases/Posix/decorate_proc_maps.cc create mode 100644 test/sanitizer_common/TestCases/Posix/lit.local.cfg create mode 100644 test/sanitizer_common/TestCases/strcasestr.c create mode 100644 test/sanitizer_common/TestCases/strcspn.c create mode 100644 test/sanitizer_common/TestCases/strpbrk.c create mode 100644 test/sanitizer_common/TestCases/strspn.c create mode 100644 test/sanitizer_common/TestCases/strstr.c create mode 100644 test/tsan/cond_destruction.cc create mode 100644 test/tsan/dl_iterate_phdr.cc create mode 100644 test/tsan/fd_dup_norace2.cc create mode 100644 test/tsan/fd_dup_race.cc create mode 100644 test/tsan/java_heap_init.cc create mode 100644 test/tsan/java_race_pc.cc create mode 100644 test/tsan/java_symbolization.cc create mode 100644 test/tsan/large_malloc_meta.cc create mode 100644 test/tsan/mmap_stress.cc create mode 100644 test/tsan/mop1.c create mode 100644 test/tsan/race_top_suppression.cc create mode 100644 test/tsan/race_top_suppression1.cc create mode 100644 test/tsan/setuid.c create mode 100644 test/tsan/setuid2.c create mode 100644 test/tsan/signal_cond.cc delete mode 100644 test/tsan/signal_segv_handler.cc create mode 100644 test/tsan/thread_detach2.c create mode 100644 test/ubsan/TestCases/Misc/Linux/coverage-levels.cc create mode 100644 test/ubsan/TestCases/Misc/Linux/lit.local.cfg create mode 100644 test/ubsan/TestCases/Misc/Linux/ubsan_options.cc delete mode 100644 test/ubsan/TestCases/Misc/coverage-levels.cc create mode 100644 test/ubsan/TestCases/Misc/log-path_test.cc create mode 100644 test/ubsan/TestCases/TypeCheck/vptr-virtual-base-construction.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f3485853f0f2..cae5981b2b46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,13 @@ string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_TEST_TARGET_TRIPLE}) list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_TEST_TARGET_ARCH) list(GET TARGET_TRIPLE_LIST 1 COMPILER_RT_TEST_TARGET_OS) list(GET TARGET_TRIPLE_LIST 2 COMPILER_RT_TEST_TARGET_ABI) +# Determine if test target triple is specified explicitly, and doesn't match the +# default. +if(NOT COMPILER_RT_TEST_TARGET_TRIPLE STREQUAL TARGET_TRIPLE) + set(COMPILER_RT_HAS_EXPLICIT_TEST_TARGET_TRIPLE TRUE) +else() + set(COMPILER_RT_HAS_EXPLICIT_TEST_TARGET_TRIPLE FALSE) +endif() if ("${COMPILER_RT_TEST_TARGET_ABI}" STREQUAL "androideabi") set(ANDROID 1) @@ -160,13 +167,11 @@ include(CompilerRTUtils) set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) -# Setup custom SDK sysroots. -set(COMPILER_RT_LINUX_SDK_SYSROOT ${COMPILER_RT_SOURCE_DIR}/SDKs/linux) # We support running instrumented tests when we're not cross compiling # and target a UNIX-like system or Windows. # We can run tests on Android even when we are cross-compiling. -if(("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND (UNIX OR MSVC)) OR ANDROID +if(("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND (UNIX OR WIN32)) OR ANDROID OR COMPILER_RT_EMULATOR) option(COMPILER_RT_CAN_EXECUTE_TESTS "Can we execute instrumented tests" ON) else() @@ -209,22 +214,22 @@ append_list_if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions SANITIZER_COM append_list_if(COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG -fomit-frame-pointer SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_FUNWIND_TABLES_FLAG -funwind-tables SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG -fno-stack-protector SANITIZER_COMMON_CFLAGS) +append_list_if(COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG -fno-sanitize=safe-stack SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS) if(MSVC) - # Replace the /MD[d] flags with /MT. + # Replace the /M[DT][d] flags with /MT, and strip any definitions of _DEBUG, + # which cause definition mismatches at link time. # FIXME: In fact, sanitizers should support both /MT and /MD, see PR20214. if(COMPILER_RT_HAS_MT_FLAG) foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if(${flag_var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - elseif(${flag_var} MATCHES "/MDd") - string(REGEX REPLACE "/MDd" "/MT" ${flag_var} "${${flag_var}}") - endif() + string(REGEX REPLACE "/M[DT]d" "/MT" ${flag_var} "${${flag_var}}") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + string(REGEX REPLACE "/D_DEBUG" "" ${flag_var} "${${flag_var}}") endforeach() endif() append_list_if(COMPILER_RT_HAS_Oy_FLAG /Oy- SANITIZER_COMMON_CFLAGS) @@ -240,12 +245,13 @@ if(NOT COMPILER_RT_DEBUG AND NOT MSVC) endif() # Determine if we should restrict stack frame sizes. -# Stack frames on PowerPC and in debug biuld can be much larger than +# Stack frames on PowerPC and Mips and in debug biuld can be much larger than # anticipated. # FIXME: Fix all sanitizers and add -Wframe-larger-than to # SANITIZER_COMMON_FLAGS if(COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG AND NOT COMPILER_RT_DEBUG - AND NOT ${LLVM_NATIVE_ARCH} STREQUAL "PowerPC") + AND NOT ${LLVM_NATIVE_ARCH} STREQUAL "PowerPC" + AND NOT ${LLVM_NATIVE_ARCH} STREQUAL "Mips") set(SANITIZER_LIMIT_FRAME_SIZE TRUE) else() set(SANITIZER_LIMIT_FRAME_SIZE FALSE) @@ -292,26 +298,51 @@ if(APPLE) find_darwin_sdk_dir(OSX_SDK_DIR macosx) find_darwin_sdk_dir(IOSSIM_SDK_DIR iphonesimulator) - string(REGEX MATCH "-mmacosx-version-min=" + set(SANITIZER_COMMON_SUPPORTED_OS osx) + string(REGEX MATCH "-mmacosx-version-min=([.0-9]+)" MACOSX_VERSION_MIN_FLAG "${CMAKE_CXX_FLAGS}") - set(SANITIZER_COMMON_SUPPORTED_DARWIN_OS osx) - if (IOSSIM_SDK_DIR AND NOT MACOSX_VERSION_MIN_FLAG) - list(APPEND SANITIZER_COMMON_SUPPORTED_DARWIN_OS iossim) + if(MACOSX_VERSION_MIN_FLAG) + set(SANITIZER_MIN_OSX_VERSION "${CMAKE_MATCH_1}") + elseif(CMAKE_OSX_DEPLOYMENT_TARGET) + set(SANITIZER_MIN_OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET}) + else() + set(SANITIZER_MIN_OSX_VERSION 10.9) + if(IOSSIM_SDK_DIR) + list(APPEND SANITIZER_COMMON_SUPPORTED_OS iossim) + endif() + endif() + if(SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.7") + message(FATAL_ERROR "Too old OS X version: ${SANITIZER_MIN_OSX_VERSION}") endif() - set(SANITIZER_MIN_OSX_VERSION 10.7) - set(CMAKE_OSX_DEPLOYMENT_TARGET "") # We're setting the flag manually below. + set(CMAKE_OSX_DEPLOYMENT_TARGET "") # We evaluate target OS X version above. set(DARWIN_osx_CFLAGS -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION} - -isysroot ${OSX_SDK_DIR} -stdlib=libc++) + -stdlib=libc++) set(DARWIN_iossim_CFLAGS + -stdlib=libc++ -mios-simulator-version-min=7.0 -isysroot ${IOSSIM_SDK_DIR}) set(DARWIN_osx_LINKFLAGS -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION} - -isysroot ${OSX_SDK_DIR} -stdlib=libc++) + -stdlib=libc++ -lc++ -lc++abi) set(DARWIN_iossim_LINKFLAGS + -stdlib=libc++ -lc++ -lc++abi -Wl,-ios_simulator_version_min,7.0.0 -mios-simulator-version-min=7.0 -isysroot ${IOSSIM_SDK_DIR}) + + if(OSX_SDK_DIR) + list(APPEND DARWIN_osx_CFLAGS -isysroot ${OSX_SDK_DIR}) + list(APPEND DARWIN_osx_LINKFLAGS -isysroot ${OSX_SDK_DIR}) + endif() +endif() + +if(APPLE AND SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.9") + # Mac OS X prior to 10.9 had problems with exporting symbols from + # libc++/libc++abi. + set(SANITIZER_CAN_USE_CXXABI FALSE) +else() + set(SANITIZER_CAN_USE_CXXABI TRUE) endif() +pythonize_bool(SANITIZER_CAN_USE_CXXABI) add_subdirectory(include) diff --git a/LICENSE.TXT b/LICENSE.TXT index aee8347b0c35..aa4115e2a790 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -14,7 +14,7 @@ Full text of the relevant licenses is included below. University of Illinois/NCSA Open Source License -Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT All rights reserved. @@ -55,7 +55,7 @@ SOFTWARE. ============================================================================== -Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/SDKs/README.txt b/SDKs/README.txt deleted file mode 100644 index b95575e8c9a1..000000000000 --- a/SDKs/README.txt +++ /dev/null @@ -1,9 +0,0 @@ -It is often convenient to be able to build compiler-rt libraries for a certain -platform without having a full SDK or development environment installed. - -This makes it easy for users to build a compiler which can target a number of -different platforms, without having to actively maintain full development -environments for those platforms. - -Since compiler-rt's libraries typically have minimal interaction with the -system, we achieve this by stubbing out the SDKs of certain platforms. diff --git a/SDKs/linux/README.txt b/SDKs/linux/README.txt deleted file mode 100644 index aa0604af7992..000000000000 --- a/SDKs/linux/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is a stub SDK for Linux. Currently, this has only been tested on i386 and -x86_64 using the Clang compiler. diff --git a/SDKs/linux/usr/include/endian.h b/SDKs/linux/usr/include/endian.h deleted file mode 100644 index 95528db157a9..000000000000 --- a/SDKs/linux/usr/include/endian.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ===-- endian.h - stub SDK header for compiler-rt -------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __ENDIAN_H__ -#define __ENDIAN_H__ - -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 - -#if defined(__LITTLE_ENDIAN__) || defined(__ORDER_LITTLE_ENDIAN__) -#define __BYTE_ORDER __LITTLE_ENDIAN -#else -#define __BYTE_ORDER __BIG_ENDIAN -#endif - -#endif /* __ENDIAN_H__ */ diff --git a/SDKs/linux/usr/include/fcntl.h b/SDKs/linux/usr/include/fcntl.h deleted file mode 100644 index a5f91e3a5bc6..000000000000 --- a/SDKs/linux/usr/include/fcntl.h +++ /dev/null @@ -1,17 +0,0 @@ -/* ===-- fcntl.h - stub SDK header for compiler-rt --------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#include diff --git a/SDKs/linux/usr/include/limits.h b/SDKs/linux/usr/include/limits.h deleted file mode 100644 index 5495a784f12f..000000000000 --- a/SDKs/linux/usr/include/limits.h +++ /dev/null @@ -1,23 +0,0 @@ -/* ===-- limits.h - stub SDK header for compiler-rt -------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __LIMITS_H__ -#define __LIMITS_H__ - -/* This is only here as a landing pad for the include_next from the compiler's - built-in limits.h. */ - -#endif /* __LIMITS_H__ */ diff --git a/SDKs/linux/usr/include/stdio.h b/SDKs/linux/usr/include/stdio.h deleted file mode 100644 index e2161daa4680..000000000000 --- a/SDKs/linux/usr/include/stdio.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ===-- stdio.h - stub SDK header for compiler-rt --------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __STDIO_H__ -#define __STDIO_H__ - -typedef __SIZE_TYPE__ size_t; - -struct _IO_FILE; -typedef struct _IO_FILE FILE; - -extern struct _IO_FILE *stdin; -extern struct _IO_FILE *stdout; -extern struct _IO_FILE *stderr; - -#define SEEK_SET 0 /* set file offset to offset */ -#define SEEK_CUR 1 /* set file offset to current plus offset */ -#define SEEK_END 2 /* set file offset to EOF plus offset */ - -extern int fclose(FILE *); -extern int fflush(FILE *); -extern FILE *fopen(const char * restrict, const char * restrict); -extern FILE *fdopen(int, const char * restrict); -extern int fprintf(FILE * restrict, const char * restrict, ...); -extern int fputc(int, FILE *); -extern size_t fwrite(const void * restrict, size_t, size_t, FILE * restrict); -extern size_t fread(void * restrict, size_t, size_t, FILE * restrict); -extern long ftell(FILE *); -extern int fseek(FILE *, long, int); - -#endif /* __STDIO_H__ */ diff --git a/SDKs/linux/usr/include/stdlib.h b/SDKs/linux/usr/include/stdlib.h deleted file mode 100644 index 966b29db6e10..000000000000 --- a/SDKs/linux/usr/include/stdlib.h +++ /dev/null @@ -1,36 +0,0 @@ -/* ===-- stdlib.h - stub SDK header for compiler-rt -------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __STDLIB_H__ -#define __STDLIB_H__ - -#define NULL ((void *)0) - -typedef __SIZE_TYPE__ size_t; - -void abort(void) __attribute__((__nothrow__)) __attribute__((__noreturn__)); -int atexit(void (*)(void)) __attribute__((__nothrow__)); -int atoi(const char *) __attribute__((__nothrow__)); -void free(void *) __attribute__((__nothrow__)); -char *getenv(const char *) __attribute__((__nothrow__)) - __attribute__((__nonnull__(1))); - __attribute__((__warn_unused_result__)); -void *malloc(size_t) __attribute__((__nothrow__)) __attribute((__malloc__)) - __attribute__((__warn_unused_result__)); -void *realloc(void *, size_t) __attribute__((__nothrow__)) __attribute((__malloc__)) - __attribute__((__warn_unused_result__)); - -#endif /* __STDLIB_H__ */ diff --git a/SDKs/linux/usr/include/string.h b/SDKs/linux/usr/include/string.h deleted file mode 100644 index c7da1f57ba57..000000000000 --- a/SDKs/linux/usr/include/string.h +++ /dev/null @@ -1,31 +0,0 @@ -/* ===-- string.h - stub SDK header for compiler-rt -------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __STRING_H__ -#define __STRING_H__ - -typedef __SIZE_TYPE__ size_t; - -int memcmp(const void *, const void *, size_t); -void *memcpy(void *, const void *, size_t); -void *memset(void *, int, size_t); -char *strcat(char *, const char *); -char *strcpy(char *, const char *); -char *strdup(const char *); -size_t strlen(const char *); -char *strncpy(char *, const char *, size_t); - -#endif /* __STRING_H__ */ diff --git a/SDKs/linux/usr/include/sys/fcntl.h b/SDKs/linux/usr/include/sys/fcntl.h deleted file mode 100644 index 1512bf9b4e55..000000000000 --- a/SDKs/linux/usr/include/sys/fcntl.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ===-- fcntl.h - stub SDK header for compiler-rt --------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef _SYS_FCNTL_H_ -#define _SYS_FCNTL_H_ - -#define O_RDONLY 0x0000 -#define O_WRONLY 0x0001 -#define O_RDWR 0x0002 -#define O_ACCMODE 0x0003 - -#define O_CREAT 0x0200 - -int open(const char *, int, ...); - -#endif /* _SYS_FCNTL_H_ */ diff --git a/SDKs/linux/usr/include/sys/mman.h b/SDKs/linux/usr/include/sys/mman.h deleted file mode 100644 index bfb7f8bb02de..000000000000 --- a/SDKs/linux/usr/include/sys/mman.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ===-- limits.h - stub SDK header for compiler-rt -------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __SYS_MMAN_H__ -#define __SYS_MMAN_H__ - -typedef __SIZE_TYPE__ size_t; - -#define PROT_NONE 0x00 -#define PROT_READ 0x01 -#define PROT_WRITE 0x02 -#define PROT_EXEC 0x04 - -#define MAP_SHARED 0x0001 -#define MAP_PRIVATE 0x0002 - -#define MAP_FILE 0x0000 -#define MAP_ANON 0x1000 - -#define MS_ASYNC 0x0001 -#define MS_INVALIDATE 0x0002 -#define MS_SYNC 0x0010 - -extern void *mmap(void *addr, size_t len, int prot, int flags, int fd, - long long offset) - __attribute__((__nothrow__)); -extern int munmap(void *addr, size_t len) - __attribute__((__nothrow__)); -extern int msync(void *addr, size_t len, int flags) - __attribute__((__nothrow__)); -extern int mprotect (void *__addr, size_t __len, int __prot) - __attribute__((__nothrow__)); - -#endif /* __SYS_MMAN_H__ */ diff --git a/SDKs/linux/usr/include/sys/stat.h b/SDKs/linux/usr/include/sys/stat.h deleted file mode 100644 index 0449fddb0665..000000000000 --- a/SDKs/linux/usr/include/sys/stat.h +++ /dev/null @@ -1,24 +0,0 @@ -/* ===-- stat.h - stub SDK header for compiler-rt ---------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __SYS_STAT_H__ -#define __SYS_STAT_H__ - -typedef unsigned int mode_t; - -int mkdir(const char *, mode_t); - -#endif /* __SYS_STAT_H__ */ diff --git a/SDKs/linux/usr/include/sys/types.h b/SDKs/linux/usr/include/sys/types.h deleted file mode 100644 index 10e74bbd0b02..000000000000 --- a/SDKs/linux/usr/include/sys/types.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ===-- stat.h - stub SDK header for compiler-rt ---------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __SYS_TYPES_H__ -#define __SYS_TYPES_H__ - -#endif /* __SYS_TYPES_H__ */ diff --git a/SDKs/linux/usr/include/unistd.h b/SDKs/linux/usr/include/unistd.h deleted file mode 100644 index 773b081d4516..000000000000 --- a/SDKs/linux/usr/include/unistd.h +++ /dev/null @@ -1,26 +0,0 @@ -/* ===-- unistd.h - stub SDK header for compiler-rt -------------------------=== - * - * The LLVM Compiler Infrastructure - * - * This file is dual licensed under the MIT and the University of Illinois Open - * Source Licenses. See LICENSE.TXT for details. - * - * ===-----------------------------------------------------------------------=== - * - * This is a stub SDK header file. This file is not part of the interface of - * this library nor an official version of the appropriate SDK header. It is - * intended only to stub the features of this header required by compiler-rt. - * - * ===-----------------------------------------------------------------------=== - */ - -#ifndef __UNISTD_H__ -#define __UNISTD_H__ - -enum { - _SC_PAGESIZE = 30 -}; - -extern long int sysconf (int __name) __attribute__ ((__nothrow__)); - -#endif /* __UNISTD_H__ */ diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index a7782a194847..5ea313ba7162 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -1,42 +1,48 @@ include(AddLLVM) include(ExternalProject) -include(LLVMParseArguments) include(CompilerRTUtils) -# Tries to add "object library" target for a given architecture -# with name "." if architecture can be targeted. -# add_compiler_rt_object_library( -# SOURCES -# CFLAGS -# DEFS ) -macro(add_compiler_rt_object_library name arch) - if(CAN_TARGET_${arch}) - parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN}) - add_library(${name}.${arch} OBJECT ${LIB_SOURCES}) - set_target_compile_flags(${name}.${arch} - ${CMAKE_CXX_FLAGS} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) - set_property(TARGET ${name}.${arch} APPEND PROPERTY - COMPILE_DEFINITIONS ${LIB_DEFS}) +# Tries to add an "object library" target for a given list of OSs and/or +# architectures with name "." for non-Darwin platforms if +# architecture can be targeted, and "." for Darwin platforms. +# add_compiler_rt_object_libraries( +# OS +# ARCHS +# SOURCES +# CFLAGS +# DEFS ) +function(add_compiler_rt_object_libraries name) + cmake_parse_arguments(LIB "" "" "OS;ARCHS;SOURCES;CFLAGS;DEFS" ${ARGN}) + set(libnames) + if(APPLE) + foreach(os ${LIB_OS}) + set(libname "${name}.${os}") + set(libnames ${libnames} ${libname}) + set(extra_cflags_${libname} ${DARWIN_${os}_CFLAGS}) + endforeach() else() - message(FATAL_ERROR "Archtecture ${arch} can't be targeted") + foreach(arch ${LIB_ARCHS}) + set(libname "${name}.${arch}") + set(libnames ${libnames} ${libname}) + set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS}) + if(NOT CAN_TARGET_${arch}) + message(FATAL_ERROR "Archtecture ${arch} can't be targeted") + return() + endif() + endforeach() endif() -endmacro() - -# Same as above, but adds universal osx library for either OSX or iOS simulator -# with name "." targeting multiple architectures. -# add_compiler_rt_darwin_object_library( ARCH -# SOURCES -# CFLAGS -# DEFS ) -macro(add_compiler_rt_darwin_object_library name os) - parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN}) - set(libname "${name}.${os}") - add_library(${libname} OBJECT ${LIB_SOURCES}) - set_target_compile_flags(${libname} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS}) - set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCH}") - set_property(TARGET ${libname} APPEND PROPERTY - COMPILE_DEFINITIONS ${LIB_DEFS}) -endmacro() + + foreach(libname ${libnames}) + add_library(${libname} OBJECT ${LIB_SOURCES}) + set_target_compile_flags(${libname} + ${CMAKE_CXX_FLAGS} ${extra_cflags_${libname}} ${LIB_CFLAGS}) + set_property(TARGET ${libname} APPEND PROPERTY + COMPILE_DEFINITIONS ${LIB_DEFS}) + if(APPLE) + set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCHS}") + endif() + endforeach() +endfunction() # Adds static or shared runtime for a given architecture and puts it in the # proper directory in the build and install trees. @@ -47,13 +53,13 @@ endmacro() # OUTPUT_NAME ) macro(add_compiler_rt_runtime name arch type) if(CAN_TARGET_${arch}) - parse_arguments(LIB "SOURCES;CFLAGS;DEFS;OUTPUT_NAME" "" ${ARGN}) + cmake_parse_arguments(LIB "" "OUTPUT_NAME" "SOURCES;CFLAGS;LINKFLAGS;DEFS" ${ARGN}) add_library(${name} ${type} ${LIB_SOURCES}) # Setup compile flags and definitions. set_target_compile_flags(${name} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) set_target_link_flags(${name} - ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) + ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS} ${LIB_LINKFLAGS}) set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LIB_DEFS}) # Setup correct output directory in the build tree. @@ -80,18 +86,18 @@ endmacro() # Same as add_compiler_rt_runtime(... STATIC), but creates a universal library # for several architectures. -# add_compiler_rt_osx_static_runtime( ARCH +# add_compiler_rt_osx_static_runtime( ARCHS # SOURCES # CFLAGS # DEFS ) macro(add_compiler_rt_osx_static_runtime name) - parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN}) + cmake_parse_arguments(LIB "" "" "ARCHS;SOURCES;CFLAGS;DEFS" ${ARGN}) add_library(${name} STATIC ${LIB_SOURCES}) set_target_compile_flags(${name} ${LIB_CFLAGS}) set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LIB_DEFS}) set_target_properties(${name} PROPERTIES - OSX_ARCHITECTURES "${LIB_ARCH}" + OSX_ARCHITECTURES "${LIB_ARCHS}" ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) install(TARGETS ${name} ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) @@ -100,20 +106,20 @@ endmacro() # Adds dynamic runtime library on osx/iossim, which supports multiple # architectures. # add_compiler_rt_darwin_dynamic_runtime( -# ARCH +# ARCHS # SOURCES # CFLAGS # DEFS # LINKFLAGS ) macro(add_compiler_rt_darwin_dynamic_runtime name os) - parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS;LINKFLAGS" "" ${ARGN}) + cmake_parse_arguments(LIB "" "" "ARCHS;SOURCES;CFLAGS;DEFS;LINKFLAGS" ${ARGN}) add_library(${name} SHARED ${LIB_SOURCES}) set_target_compile_flags(${name} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS}) set_target_link_flags(${name} ${LIB_LINKFLAGS} ${DARWIN_${os}_LINKFLAGS}) set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LIB_DEFS}) set_target_properties(${name} PROPERTIES - OSX_ARCHITECTURES "${LIB_ARCH}" + OSX_ARCHITECTURES "${LIB_ARCHS}" LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) install(TARGETS ${name} LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) @@ -162,7 +168,7 @@ endif() # DEPS # LINK_FLAGS ) macro(add_compiler_rt_test test_suite test_name) - parse_arguments(TEST "SUBDIR;OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN}) + cmake_parse_arguments(TEST "" "SUBDIR" "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN}) if(TEST_SUBDIR) set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SUBDIR}/${test_name}") else() @@ -229,7 +235,7 @@ macro(add_custom_libcxx name prefix) message(FATAL_ERROR "libcxx not found!") endif() - parse_arguments(LIBCXX "DEPS;CFLAGS" "" ${ARGN}) + cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS" ${ARGN}) foreach(flag ${LIBCXX_CFLAGS}) set(flagstr "${flagstr} ${flag}") endforeach() @@ -252,6 +258,7 @@ macro(add_custom_libcxx name prefix) LOG_CONFIGURE 1 LOG_INSTALL 1 ) + set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL TRUE) ExternalProject_Add_Step(${name} force-reconfigure DEPENDERS configure diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake index de73ccfc5cb8..b2e62dd0bac6 100644 --- a/cmake/Modules/CompilerRTCompile.cmake +++ b/cmake/Modules/CompilerRTCompile.cmake @@ -1,4 +1,28 @@ -include(LLVMParseArguments) +# On Windows, CMAKE_*_FLAGS are built for MSVC but we use the GCC clang.exe, +# which uses completely different flags. Translate some common flag types, and +# drop the rest. +function(translate_msvc_cflags out_flags msvc_flags) + # Insert an empty string in the list to simplify processing. + set(msvc_flags ";${msvc_flags}") + + # Canonicalize /flag to -flag. + string(REPLACE ";/" ";-" msvc_flags "${msvc_flags}") + + # Make space separated -D and -U flags into joined flags. + string(REGEX REPLACE ";-\([DU]\);" ";-\\1" msvc_flags "${msvc_flags}") + + set(clang_flags "") + foreach(flag ${msvc_flags}) + if ("${flag}" MATCHES "^-[DU]") + # Pass through basic command line macro definitions (-DNDEBUG). + list(APPEND clang_flags "${flag}") + elseif ("${flag}" MATCHES "^-O[2x]") + # Canonicalize normal optimization flags to -O2. + list(APPEND clang_flags "-O2") + endif() + endforeach() + set(${out_flags} "${clang_flags}" PARENT_SCOPE) +endfunction() # Compile a source into an object file with COMPILER_RT_TEST_COMPILER using # a provided compile flags and dependenices. @@ -6,7 +30,7 @@ include(LLVMParseArguments) # CFLAGS # DEPS ) macro(clang_compile object_file source) - parse_arguments(SOURCE "CFLAGS;DEPS" "" ${ARGN}) + cmake_parse_arguments(SOURCE "" "" "CFLAGS;DEPS" ${ARGN}) get_filename_component(source_rpath ${source} REALPATH) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND SOURCE_DEPS clang compiler-rt-headers) @@ -20,13 +44,11 @@ macro(clang_compile object_file source) else() string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}") endif() - # On Windows, CMAKE_*_FLAGS are built for MSVC but we use the GCC clang.exe - # which doesn't support flags starting with "/smth". Replace those with - # "-smth" equivalents. - if(MSVC) - string(REGEX REPLACE "^/" "-" global_flags "${global_flags}") - string(REPLACE ";/" ";-" global_flags "${global_flags}") + + if (MSVC) + translate_msvc_cflags(global_flags "${global_flags}") endif() + # Ignore unknown warnings. CMAKE_CXX_FLAGS may contain GCC-specific options # which are not supported by Clang. list(APPEND global_flags -Wno-unknown-warning-option) diff --git a/cmake/Modules/CompilerRTLink.cmake b/cmake/Modules/CompilerRTLink.cmake index 0f0e53a3b2f4..bb96869844c1 100644 --- a/cmake/Modules/CompilerRTLink.cmake +++ b/cmake/Modules/CompilerRTLink.cmake @@ -1,12 +1,10 @@ -include(LLVMParseArguments) - # Link a shared library with COMPILER_RT_TEST_COMPILER. # clang_link_shared( # OBJECTS # LINKFLAGS # DEPS ) macro(clang_link_shared so_file) - parse_arguments(SOURCE "OBJECTS;LINKFLAGS;DEPS" "" ${ARGN}) + cmake_parse_arguments(SOURCE "" "" "OBJECTS;LINKFLAGS;DEPS" ${ARGN}) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND SOURCE_DEPS clang) endif() diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake index ae59732928a1..f7f60a4ac6f4 100644 --- a/cmake/Modules/CompilerRTUtils.cmake +++ b/cmake/Modules/CompilerRTUtils.cmake @@ -49,3 +49,11 @@ macro(append_no_rtti_flag list) append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list}) append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list}) endmacro() + +macro(append_have_file_definition filename varname list) + check_include_file("${filename}" "${varname}") + if (NOT ${varname}) + set("${varname}" 0) + endif() + list(APPEND ${list} "${varname}=${${varname}}") +endmacro() diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake index 1ebc7030a57b..c040b42122ce 100644 --- a/cmake/Modules/SanitizerUtils.cmake +++ b/cmake/Modules/SanitizerUtils.cmake @@ -1,5 +1,3 @@ -include(LLVMParseArguments) - set(SANITIZER_GEN_DYNAMIC_LIST ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py) @@ -13,9 +11,13 @@ set(SANITIZER_LINT_SCRIPT # add_sanitizer_rt_symbols( ) macro(add_sanitizer_rt_symbols name) set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${name}.syms-stamp) + set(extra_args) + foreach(arg ${ARGN}) + list(APPEND extra_args "--extra" ${arg}) + endforeach() add_custom_command(OUTPUT ${stamp} COMMAND ${PYTHON_EXECUTABLE} - ${SANITIZER_GEN_DYNAMIC_LIST} $ ${ARGN} + ${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $ > $.syms COMMAND ${CMAKE_COMMAND} -E touch ${stamp} DEPENDS ${name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN} @@ -44,6 +46,29 @@ macro(add_sanitizer_rt_symbols name) endif() endmacro() +macro(add_sanitizer_rt_version_list name) + set(vers ${CMAKE_CURRENT_BINARY_DIR}/${name}.vers) + cmake_parse_arguments(ARG "" "" "LIBS;EXTRA" ${ARGN}) + set(args) + foreach(arg ${ARG_EXTRA}) + list(APPEND args "--extra" ${arg}) + endforeach() + foreach(arg ${ARG_LIBS}) + list(APPEND args "$") + endforeach() + add_custom_command(OUTPUT ${vers} + COMMAND ${PYTHON_EXECUTABLE} + ${SANITIZER_GEN_DYNAMIC_LIST} --version-list ${args} + > ${vers} + DEPENDS ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} ${ARG_LIBS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating version list for ${name}" + VERBATIM) + + add_custom_target(${name}-version-list ALL + DEPENDS ${vers}) +endmacro() + # Add target to check code style for sanitizer runtimes. if(UNIX) add_custom_target(SanitizerLintCheck diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 97a22cbdc7b9..c645be4d88d6 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -1,8 +1,16 @@ +include(CMakePushCheckState) include(CheckCXXCompilerFlag) include(CheckLibraryExists) include(CheckSymbolExists) include(TestBigEndian) +function(check_linker_flag flag out_var) + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") + check_cxx_compiler_flag("" ${out_var}) + cmake_pop_check_state() +endfunction() + # CodeGen options. check_cxx_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG) check_cxx_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG) @@ -11,6 +19,7 @@ check_cxx_compiler_flag(-fno-exceptions COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG) check_cxx_compiler_flag(-funwind-tables COMPILER_RT_HAS_FUNWIND_TABLES_FLAG) check_cxx_compiler_flag(-fno-stack-protector COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG) +check_cxx_compiler_flag(-fno-sanitize=safe-stack COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG) check_cxx_compiler_flag(-fno-rtti COMPILER_RT_HAS_FNO_RTTI_FLAG) check_cxx_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG) @@ -54,10 +63,16 @@ check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL) # Libraries. check_library_exists(c printf "" COMPILER_RT_HAS_LIBC) check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL) +check_library_exists(rt shm_open "" COMPILER_RT_HAS_LIBRT) check_library_exists(m pow "" COMPILER_RT_HAS_LIBM) check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD) check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX) +# Linker flags. +if(ANDROID) + check_linker_flag("-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL) +endif() + # Architectures. # List of all architectures we can target. @@ -70,22 +85,43 @@ set(COMPILER_RT_SUPPORTED_ARCH) set(SIMPLE_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/simple.cc) file(WRITE ${SIMPLE_SOURCE} "#include \n#include \nint main() {}\n") -# test_target_arch( ) -# Sets the target flags for a given architecture and determines if this -# architecture is supported by trying to build a simple file. -macro(test_target_arch arch) +function(check_compile_definition def argstring out_var) + if("${def}" STREQUAL "") + set(${out_var} TRUE PARENT_SCOPE) + return() + endif() + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${argstring}") + check_symbol_exists(${def} "" ${out_var}) + cmake_pop_check_state() +endfunction() + +# test_target_arch( ) +# Checks if architecture is supported: runs host compiler with provided +# flags to verify that: +# 1) is defined (if non-empty) +# 2) simple file can be successfully built. +# If successful, saves target flags for this architecture. +macro(test_target_arch arch def) set(TARGET_${arch}_CFLAGS ${ARGN}) - set(argstring "${CMAKE_EXE_LINKER_FLAGS}") + set(argstring "") foreach(arg ${ARGN}) set(argstring "${argstring} ${arg}") endforeach() - try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE} - COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS}" - OUTPUT_VARIABLE TARGET_${arch}_OUTPUT - CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${argstring}") + check_compile_definition("${def}" "${argstring}" HAS_${arch}_DEF) + if(NOT HAS_${arch}_DEF) + set(CAN_TARGET_${arch} FALSE) + else() + set(argstring "${CMAKE_EXE_LINKER_FLAGS} ${argstring}") + try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE} + COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS}" + OUTPUT_VARIABLE TARGET_${arch}_OUTPUT + CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${argstring}") + endif() if(${CAN_TARGET_${arch}}) list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) - elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "${arch}") + elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "${arch}" AND + COMPILER_RT_HAS_EXPLICIT_TEST_TARGET_TRIPLE) # Bail out if we cannot target the architecture we plan to test. message(FATAL_ERROR "Cannot compile for ${arch}:\n${TARGET_${arch}_OUTPUT}") endif() @@ -139,33 +175,46 @@ if(ANDROID) else() if("${LLVM_NATIVE_ARCH}" STREQUAL "X86") if(NOT MSVC) - test_target_arch(x86_64 "-m64") - test_target_arch(i386 "-m32") + test_target_arch(x86_64 "" "-m64") + # FIXME: We build runtimes for both i686 and i386, as "clang -m32" may + # target different variant than "$CMAKE_C_COMPILER -m32". This part should + # be gone after we resolve PR14109. + test_target_arch(i686 __i686__ "-m32") + test_target_arch(i386 __i386__ "-m32") else() - test_target_arch(i386 "") + if (CMAKE_SIZEOF_VOID_P EQUAL 4) + test_target_arch(i386 "" "") + else() + test_target_arch(x86_64 "" "") + endif() endif() elseif("${LLVM_NATIVE_ARCH}" STREQUAL "PowerPC") TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN) if(HOST_IS_BIG_ENDIAN) - test_target_arch(powerpc64 "-m64") + test_target_arch(powerpc64 "" "-m64") else() - test_target_arch(powerpc64le "-m64") + test_target_arch(powerpc64le "" "-m64") endif() elseif("${LLVM_NATIVE_ARCH}" STREQUAL "Mips") + # Gcc doesn't accept -m32/-m64 so we do the next best thing and use + # -mips32r2/-mips64r2. We don't use -mips1/-mips3 because we want to match + # clang's default CPU's. In the 64-bit case, we must also specify the ABI + # since the default ABI differs between gcc and clang. + # FIXME: Ideally, we would build the N32 library too. if("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "mipsel|mips64el") # regex for mipsel, mips64el - test_target_arch(mipsel "-m32") - test_target_arch(mips64el "-m64") + test_target_arch(mipsel "" "-mips32r2" "--target=mipsel-linux-gnu") + test_target_arch(mips64el "" "-mips64r2" "-mabi=n64") else() - test_target_arch(mips "-m32") - test_target_arch(mips64 "-m64") + test_target_arch(mips "" "-mips32r2" "--target=mips-linux-gnu") + test_target_arch(mips64 "" "-mips64r2" "-mabi=n64") endif() elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "arm") - test_target_arch(arm "-march=armv7-a") + test_target_arch(arm "" "-march=armv7-a") elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "aarch32") - test_target_arch(aarch32 "-march=armv8-a") + test_target_arch(aarch32 "" "-march=armv8-a") elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "aarch64") - test_target_arch(aarch64 "-march=armv8-a") + test_target_arch(aarch64 "" "-march=armv8-a") endif() set(COMPILER_RT_OS_SUFFIX "") endif() @@ -184,6 +233,7 @@ function(filter_available_targets out_var) set(${out_var} ${archs} PARENT_SCOPE) endfunction() +# Returns a list of architecture specific target cflags in @out_var list. function(get_target_flags_for_arch arch out_var) list(FIND COMPILER_RT_SUPPORTED_ARCH ${arch} ARCH_INDEX) if(ARCH_INDEX EQUAL -1) @@ -196,19 +246,23 @@ endfunction() # Architectures supported by compiler-rt libraries. filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH x86_64 i386 i686 powerpc64 powerpc64le arm aarch64 mips mips64 mipsel mips64el) +# LSan and UBSan common files should be available on all architectures supported +# by other sanitizers (even if they build into dummy object files). +filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH + ${SANITIZER_COMMON_SUPPORTED_ARCH}) +filter_available_targets(UBSAN_COMMON_SUPPORTED_ARCH + ${SANITIZER_COMMON_SUPPORTED_ARCH}) filter_available_targets(ASAN_SUPPORTED_ARCH x86_64 i386 i686 powerpc64 powerpc64le arm mips mipsel mips64 mips64el) filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64 mips64 mips64el) filter_available_targets(LSAN_SUPPORTED_ARCH x86_64 mips64 mips64el) -# LSan common files should be available on all architectures supported -# by other sanitizers (even if they build into dummy object files). -filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH - ${SANITIZER_COMMON_SUPPORTED_ARCH}) filter_available_targets(MSAN_SUPPORTED_ARCH x86_64 mips64 mips64el) filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 i686 arm mips mips64 mipsel mips64el aarch64 powerpc64 powerpc64le) filter_available_targets(TSAN_SUPPORTED_ARCH x86_64 mips64 mips64el) -filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386 i686 arm aarch64 mips mipsel mips64 mips64el) +filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386 i686 arm aarch64 mips + mipsel mips64 mips64el powerpc64 powerpc64le) +filter_available_targets(SAFESTACK_SUPPORTED_ARCH x86_64 i386 i686) if(ANDROID) set(OS_NAME "Android") @@ -218,13 +272,21 @@ endif() if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR - (OS_NAME MATCHES "Windows" AND MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 4))) + (OS_NAME MATCHES "Windows" AND MSVC))) set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE) else() set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE) endif() -if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH) +if (COMPILER_RT_HAS_SANITIZER_COMMON AND + (NOT OS_NAME MATCHES "Windows" OR CMAKE_SIZEOF_VOID_P EQUAL 4)) + set(COMPILER_RT_HAS_INTERCEPTION TRUE) +else() + set(COMPILER_RT_HAS_INTERCEPTION FALSE) +endif() + +if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH AND + (NOT OS_NAME MATCHES "Windows" OR CMAKE_SIZEOF_VOID_P EQUAL 4)) set(COMPILER_RT_HAS_ASAN TRUE) else() set(COMPILER_RT_HAS_ASAN FALSE) @@ -246,19 +308,12 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND LSAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD") + OS_NAME MATCHES "Linux|FreeBSD") set(COMPILER_RT_HAS_LSAN TRUE) else() set(COMPILER_RT_HAS_LSAN FALSE) endif() -if (COMPILER_RT_HAS_SANITIZER_COMMON AND LSAN_COMMON_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD|Android") - set(COMPILER_RT_HAS_LSAN_COMMON TRUE) -else() - set(COMPILER_RT_HAS_LSAN_COMMON FALSE) -endif() - if (COMPILER_RT_HAS_SANITIZER_COMMON AND MSAN_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux") set(COMPILER_RT_HAS_MSAN TRUE) @@ -281,9 +336,23 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD") + OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows") set(COMPILER_RT_HAS_UBSAN TRUE) else() set(COMPILER_RT_HAS_UBSAN FALSE) endif() +# -msse3 flag is not valid for Mips therefore clang gives a warning +# message with -msse3. But check_c_compiler_flags() checks only for +# compiler error messages. Therefore COMPILER_RT_HAS_MSSE3_FLAG turns out to be +# true on Mips, so we make it false here. +if("${LLVM_NATIVE_ARCH}" STREQUAL "Mips") + set(COMPILER_RT_HAS_MSSE3_FLAG FALSE) +endif() + +if (COMPILER_RT_HAS_SANITIZER_COMMON AND SAFESTACK_SUPPORTED_ARCH AND + OS_NAME MATCHES "Darwin|Linux|FreeBSD") + set(COMPILER_RT_HAS_SAFESTACK TRUE) +else() + set(COMPILER_RT_HAS_SAFESTACK FALSE) +endif() diff --git a/include/sanitizer/coverage_interface.h b/include/sanitizer/coverage_interface.h index 88a7e480081d..404b71e3086f 100644 --- a/include/sanitizer/coverage_interface.h +++ b/include/sanitizer/coverage_interface.h @@ -39,6 +39,23 @@ extern "C" { // Some of the entries in *data will be zero. uintptr_t __sanitizer_get_coverage_guards(uintptr_t **data); + // The coverage instrumentation may optionally provide imprecise counters. + // Rather than exposing the counter values to the user we instead map + // the counters to a bitset. + // Every counter is associated with 8 bits in the bitset. + // We define 8 value ranges: 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+ + // The i-th bit is set to 1 if the counter value is in the i-th range. + // This counter-based coverage implementation is *not* thread-safe. + + // Returns the number of registered coverage counters. + uintptr_t __sanitizer_get_number_of_counters(); + // Updates the counter 'bitset', clears the counters and returns the number of + // new bits in 'bitset'. + // If 'bitset' is nullptr, only clears the counters. + // Otherwise 'bitset' should be at least + // __sanitizer_get_number_of_counters bytes long and 8-aligned. + uintptr_t + __sanitizer_update_counter_bitset_and_clear_counters(uint8_t *bitset); #ifdef __cplusplus } // extern "C" #endif diff --git a/include/sanitizer/dfsan_interface.h b/include/sanitizer/dfsan_interface.h index 79dbf2f364c2..84ffd49f8afe 100644 --- a/include/sanitizer/dfsan_interface.h +++ b/include/sanitizer/dfsan_interface.h @@ -91,6 +91,16 @@ void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback); ///