From d89ec533011f513df1010f142a111086a0785f09 Mon Sep 17 00:00:00 2001 From: patrick Date: Fri, 17 Dec 2021 12:26:52 +0000 Subject: [PATCH] Import LLVM 13.0.0 release. --- gnu/llvm/compiler-rt/.clang-tidy | 2 + gnu/llvm/compiler-rt/.gitignore | 6 + gnu/llvm/compiler-rt/CMakeLists.txt | 187 +- .../cmake/Modules/AddCompilerRT.cmake | 83 +- .../cmake/Modules/CompilerRTAIXUtils.cmake | 80 + .../cmake/Modules/CompilerRTCompile.cmake | 43 +- .../cmake/Modules/CompilerRTDarwinUtils.cmake | 58 +- .../CompilerRTMockLLVMCMakeConfig.cmake | 75 + .../cmake/Modules/CompilerRTUtils.cmake | 143 +- .../cmake/Modules/CustomLibcxx/CMakeLists.txt | 9 +- .../cmake/Modules/UseLibtool.cmake | 8 + .../compiler-rt/cmake/base-config-ix.cmake | 74 +- .../compiler-rt/cmake/builtin-config-ix.cmake | 21 +- gnu/llvm/compiler-rt/cmake/config-ix.cmake | 117 +- .../compiler-rt/docs/BuildingCompilerRT.rst | 92 + gnu/llvm/compiler-rt/include/CMakeLists.txt | 15 +- .../include/fuzzer/FuzzedDataProvider.h | 12 +- .../include/profile/InstrProfData.inc | 150 +- .../include/sanitizer/asan_interface.h | 16 +- .../include/sanitizer/common_interface_defs.h | 9 +- .../include/sanitizer/dfsan_interface.h | 119 +- .../include/sanitizer/hwasan_interface.h | 3 + .../include/sanitizer/memprof_interface.h | 65 + .../include/sanitizer/msan_interface.h | 3 + .../include/sanitizer/netbsd_syscall_hooks.h | 213 +- .../include/sanitizer/tsan_interface.h | 17 +- .../include/sanitizer/tsan_interface_atomic.h | 2 +- gnu/llvm/compiler-rt/lib/CMakeLists.txt | 14 +- gnu/llvm/compiler-rt/lib/asan/.clang-format | 1 + gnu/llvm/compiler-rt/lib/asan/CMakeLists.txt | 37 +- .../compiler-rt/lib/asan/asan_allocator.cpp | 489 +++-- .../compiler-rt/lib/asan/asan_allocator.h | 11 +- .../lib/asan/asan_descriptions.cpp | 19 +- .../compiler-rt/lib/asan/asan_descriptions.h | 13 +- gnu/llvm/compiler-rt/lib/asan/asan_errors.cpp | 8 +- .../compiler-rt/lib/asan/asan_fake_stack.cpp | 52 +- gnu/llvm/compiler-rt/lib/asan/asan_flags.cpp | 14 +- gnu/llvm/compiler-rt/lib/asan/asan_flags.inc | 3 +- .../compiler-rt/lib/asan/asan_fuchsia.cpp | 37 +- .../compiler-rt/lib/asan/asan_ignorelist.txt | 13 + .../lib/asan/asan_interceptors.cpp | 74 +- .../compiler-rt/lib/asan/asan_interceptors.h | 33 +- .../asan/asan_interceptors_memintrinsics.cpp | 6 +- .../lib/asan/asan_interceptors_vfork.S | 3 +- .../compiler-rt/lib/asan/asan_interface.inc | 11 + .../lib/asan/asan_interface_internal.h | 4 +- gnu/llvm/compiler-rt/lib/asan/asan_internal.h | 17 +- gnu/llvm/compiler-rt/lib/asan/asan_linux.cpp | 45 +- gnu/llvm/compiler-rt/lib/asan/asan_mac.cpp | 48 +- .../lib/asan/asan_malloc_linux.cpp | 44 +- gnu/llvm/compiler-rt/lib/asan/asan_mapping.h | 43 +- .../compiler-rt/lib/asan/asan_new_delete.cpp | 22 +- .../compiler-rt/lib/asan/asan_poisoning.cpp | 27 +- .../compiler-rt/lib/asan/asan_poisoning.h | 3 - gnu/llvm/compiler-rt/lib/asan/asan_posix.cpp | 2 +- .../lib/asan/asan_premap_shadow.cpp | 18 +- gnu/llvm/compiler-rt/lib/asan/asan_report.cpp | 5 +- gnu/llvm/compiler-rt/lib/asan/asan_rtl.cpp | 80 +- .../lib/asan/asan_shadow_setup.cpp | 56 +- gnu/llvm/compiler-rt/lib/asan/asan_stack.cpp | 3 +- gnu/llvm/compiler-rt/lib/asan/asan_stack.h | 14 - gnu/llvm/compiler-rt/lib/asan/asan_thread.cpp | 113 +- gnu/llvm/compiler-rt/lib/asan/asan_thread.h | 25 +- gnu/llvm/compiler-rt/lib/asan/asan_win.cpp | 19 +- .../lib/asan/scripts/asan_device_setup | 4 +- .../lib/asan/scripts/asan_symbolize.py | 12 +- .../compiler-rt/lib/asan/tests/CMakeLists.txt | 13 +- .../lib/asan/tests/asan_interface_test.cpp | 3 +- .../lib/asan/tests/asan_mem_test.cpp | 2 +- .../compiler-rt/lib/asan/tests/asan_test.cpp | 15 +- .../lib/asan/tests/asan_test.ignore | 2 +- .../lib/asan/tests/asan_test_config.h | 4 +- .../compiler-rt/lib/builtins/CMakeLists.txt | 251 ++- gnu/llvm/compiler-rt/lib/builtins/README.txt | 2 + .../lib/builtins/aarch64/fp_mode.c | 13 +- .../compiler-rt/lib/builtins/aarch64/lse.S | 236 +++ .../compiler-rt/lib/builtins/arm/fp_mode.c | 15 +- gnu/llvm/compiler-rt/lib/builtins/assembly.h | 98 +- gnu/llvm/compiler-rt/lib/builtins/atomic.c | 98 +- .../compiler-rt/lib/builtins/comparedf2.c | 84 +- .../compiler-rt/lib/builtins/comparesf2.c | 84 +- .../compiler-rt/lib/builtins/comparetf2.c | 81 +- gnu/llvm/compiler-rt/lib/builtins/cpu_model.c | 71 +- gnu/llvm/compiler-rt/lib/builtins/divdc3.c | 12 +- gnu/llvm/compiler-rt/lib/builtins/divdf3.c | 189 +- gnu/llvm/compiler-rt/lib/builtins/divdi3.c | 15 +- gnu/llvm/compiler-rt/lib/builtins/divmoddi4.c | 13 +- gnu/llvm/compiler-rt/lib/builtins/divmodsi4.c | 13 +- gnu/llvm/compiler-rt/lib/builtins/divmodti4.c | 32 + gnu/llvm/compiler-rt/lib/builtins/divsc3.c | 11 +- gnu/llvm/compiler-rt/lib/builtins/divsf3.c | 174 +- gnu/llvm/compiler-rt/lib/builtins/divsi3.c | 25 +- gnu/llvm/compiler-rt/lib/builtins/divtc3.c | 11 +- gnu/llvm/compiler-rt/lib/builtins/divtf3.c | 203 +- gnu/llvm/compiler-rt/lib/builtins/divti3.c | 15 +- .../compiler-rt/lib/builtins/extendhfsf2.c | 6 +- .../compiler-rt/lib/builtins/extendhftf2.c | 23 + gnu/llvm/compiler-rt/lib/builtins/fixdfdi.c | 2 +- gnu/llvm/compiler-rt/lib/builtins/fixsfdi.c | 2 +- .../compiler-rt/lib/builtins/fixunsdfdi.c | 2 +- .../compiler-rt/lib/builtins/fixunssfdi.c | 2 +- gnu/llvm/compiler-rt/lib/builtins/floatdidf.c | 2 +- .../compiler-rt/lib/builtins/floatundidf.c | 2 +- .../compiler-rt/lib/builtins/fp_add_impl.inc | 8 +- .../lib/builtins/fp_compare_impl.inc | 116 ++ .../compiler-rt/lib/builtins/fp_div_impl.inc | 419 ++++ gnu/llvm/compiler-rt/lib/builtins/fp_extend.h | 4 + gnu/llvm/compiler-rt/lib/builtins/fp_lib.h | 102 +- gnu/llvm/compiler-rt/lib/builtins/fp_mode.c | 4 +- gnu/llvm/compiler-rt/lib/builtins/fp_mode.h | 12 +- gnu/llvm/compiler-rt/lib/builtins/fp_trunc.h | 4 + .../lib/builtins/gcc_personality_v0.c | 33 +- .../compiler-rt/lib/builtins/i386/fp_mode.c | 12 +- .../compiler-rt/lib/builtins/int_div_impl.inc | 25 + gnu/llvm/compiler-rt/lib/builtins/int_lib.h | 24 +- gnu/llvm/compiler-rt/lib/builtins/int_math.h | 8 - .../lib/builtins/int_mulo_impl.inc | 49 + .../lib/builtins/int_mulv_impl.inc | 47 + gnu/llvm/compiler-rt/lib/builtins/int_types.h | 12 + gnu/llvm/compiler-rt/lib/builtins/int_util.c | 22 +- gnu/llvm/compiler-rt/lib/builtins/int_util.h | 16 + gnu/llvm/compiler-rt/lib/builtins/moddi3.c | 16 +- gnu/llvm/compiler-rt/lib/builtins/modti3.c | 16 +- gnu/llvm/compiler-rt/lib/builtins/mulodi4.c | 33 +- gnu/llvm/compiler-rt/lib/builtins/mulosi4.c | 33 +- gnu/llvm/compiler-rt/lib/builtins/muloti4.c | 33 +- gnu/llvm/compiler-rt/lib/builtins/mulvdi3.c | 33 +- gnu/llvm/compiler-rt/lib/builtins/mulvsi3.c | 33 +- gnu/llvm/compiler-rt/lib/builtins/mulvti3.c | 33 +- .../lib/builtins/os_version_check.c | 108 +- gnu/llvm/compiler-rt/lib/builtins/paritydi2.c | 6 +- gnu/llvm/compiler-rt/lib/builtins/parityti2.c | 8 +- .../compiler-rt/lib/builtins/ppc/atomic.exp | 41 + .../compiler-rt/lib/builtins/ppc/divtc3.c | 19 +- .../lib/builtins/riscv/int_mul_impl.inc | 6 +- .../compiler-rt/lib/builtins/riscv/restore.S | 166 ++ .../compiler-rt/lib/builtins/riscv/save.S | 184 ++ .../compiler-rt/lib/builtins/truncdfhf2.c | 4 +- .../compiler-rt/lib/builtins/truncsfhf2.c | 6 +- .../compiler-rt/lib/builtins/trunctfhf2.c | 23 + gnu/llvm/compiler-rt/lib/cfi/CMakeLists.txt | 2 +- gnu/llvm/compiler-rt/lib/cfi/cfi.cpp | 6 +- .../compiler-rt/lib/cfi/cfi_ignorelist.txt | 17 + gnu/llvm/compiler-rt/lib/crt/crtbegin.c | 8 + gnu/llvm/compiler-rt/lib/dfsan/.clang-format | 1 + gnu/llvm/compiler-rt/lib/dfsan/CMakeLists.txt | 11 +- gnu/llvm/compiler-rt/lib/dfsan/dfsan.cpp | 1134 ++++++++--- gnu/llvm/compiler-rt/lib/dfsan/dfsan.h | 70 +- .../compiler-rt/lib/dfsan/dfsan.syms.extra | 1 + .../compiler-rt/lib/dfsan/dfsan_allocator.cpp | 287 +++ .../compiler-rt/lib/dfsan/dfsan_allocator.h | 30 + .../lib/dfsan/dfsan_chained_origin_depot.cpp | 22 + .../lib/dfsan/dfsan_chained_origin_depot.h | 26 + .../compiler-rt/lib/dfsan/dfsan_custom.cpp | 1712 +++++++++++++++-- gnu/llvm/compiler-rt/lib/dfsan/dfsan_flags.h | 32 + .../compiler-rt/lib/dfsan/dfsan_flags.inc | 24 +- .../lib/dfsan/dfsan_interceptors.cpp | 216 ++- .../lib/dfsan/dfsan_new_delete.cpp | 124 ++ gnu/llvm/compiler-rt/lib/dfsan/dfsan_origin.h | 127 ++ .../compiler-rt/lib/dfsan/dfsan_platform.h | 133 +- .../compiler-rt/lib/dfsan/dfsan_thread.cpp | 146 ++ gnu/llvm/compiler-rt/lib/dfsan/dfsan_thread.h | 83 + .../compiler-rt/lib/dfsan/done_abilist.txt | 153 +- .../dfsan/scripts/check_custom_wrappers.sh | 6 +- .../compiler-rt/lib/fuzzer/CMakeLists.txt | 28 +- .../compiler-rt/lib/fuzzer/FuzzerBuiltins.h | 1 - .../lib/fuzzer/FuzzerBuiltinsMsvc.h | 6 - .../compiler-rt/lib/fuzzer/FuzzerCorpus.h | 100 +- .../lib/fuzzer/FuzzerDataFlowTrace.cpp | 6 +- .../lib/fuzzer/FuzzerDataFlowTrace.h | 14 +- .../compiler-rt/lib/fuzzer/FuzzerDictionary.h | 8 +- .../compiler-rt/lib/fuzzer/FuzzerDriver.cpp | 103 +- .../lib/fuzzer/FuzzerExtFunctionsWeak.cpp | 2 +- .../lib/fuzzer/FuzzerExtraCounters.cpp | 2 +- .../compiler-rt/lib/fuzzer/FuzzerFlags.def | 37 +- .../compiler-rt/lib/fuzzer/FuzzerFork.cpp | 21 +- gnu/llvm/compiler-rt/lib/fuzzer/FuzzerIO.cpp | 56 +- gnu/llvm/compiler-rt/lib/fuzzer/FuzzerIO.h | 11 +- .../compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp | 8 +- .../lib/fuzzer/FuzzerIOWindows.cpp | 14 +- .../lib/fuzzer/FuzzerInterceptors.cpp | 254 +++ .../compiler-rt/lib/fuzzer/FuzzerInternal.h | 4 +- .../compiler-rt/lib/fuzzer/FuzzerLoop.cpp | 99 +- .../compiler-rt/lib/fuzzer/FuzzerMerge.cpp | 8 +- .../compiler-rt/lib/fuzzer/FuzzerMutate.cpp | 88 +- .../compiler-rt/lib/fuzzer/FuzzerMutate.h | 14 +- .../compiler-rt/lib/fuzzer/FuzzerOptions.h | 9 +- .../compiler-rt/lib/fuzzer/FuzzerPlatform.h | 18 +- .../compiler-rt/lib/fuzzer/FuzzerRandom.h | 23 +- .../compiler-rt/lib/fuzzer/FuzzerSHA1.cpp | 9 +- .../compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | 45 +- .../compiler-rt/lib/fuzzer/FuzzerTracePC.h | 45 +- .../compiler-rt/lib/fuzzer/FuzzerUtil.cpp | 9 +- gnu/llvm/compiler-rt/lib/fuzzer/FuzzerUtil.h | 12 +- .../lib/fuzzer/FuzzerUtilFuchsia.cpp | 21 +- .../lib/fuzzer/FuzzerUtilLinux.cpp | 2 +- .../lib/fuzzer/FuzzerUtilPosix.cpp | 15 +- .../lib/fuzzer/FuzzerUtilWindows.cpp | 14 +- .../compiler-rt/lib/fuzzer/afl/afl_driver.cpp | 10 - .../lib/fuzzer/dataflow/DataFlow.cpp | 8 +- .../lib/fuzzer/tests/CMakeLists.txt | 4 + .../tests/FuzzedDataProviderUnittest.cpp | 14 + .../lib/fuzzer/tests/FuzzerUnittest.cpp | 334 ++-- .../compiler-rt/lib/gwp_asan/CMakeLists.txt | 31 +- gnu/llvm/compiler-rt/lib/gwp_asan/common.cpp | 5 +- gnu/llvm/compiler-rt/lib/gwp_asan/common.h | 6 +- .../lib/gwp_asan/crash_handler.cpp | 26 +- .../compiler-rt/lib/gwp_asan/crash_handler.h | 2 +- .../compiler-rt/lib/gwp_asan/definitions.h | 2 +- .../lib/gwp_asan/guarded_pool_allocator.cpp | 222 ++- .../lib/gwp_asan/guarded_pool_allocator.h | 106 +- gnu/llvm/compiler-rt/lib/gwp_asan/mutex.h | 14 +- .../lib/gwp_asan/optional/backtrace.h | 48 +- .../gwp_asan/optional/backtrace_fuchsia.cpp | 27 + .../optional/backtrace_linux_libc.cpp | 25 +- .../optional/backtrace_sanitizer_common.cpp | 49 +- .../lib/gwp_asan/optional/options_parser.cpp | 249 ++- .../lib/gwp_asan/optional/options_parser.h | 12 +- .../lib/gwp_asan/optional/printf.h | 33 + .../lib/gwp_asan/optional/segv_handler.h | 70 +- .../optional/segv_handler_fuchsia.cpp | 22 + .../gwp_asan/optional/segv_handler_posix.cpp | 182 +- gnu/llvm/compiler-rt/lib/gwp_asan/options.inc | 38 +- .../platform_specific/common_fuchsia.cpp | 15 + .../platform_specific/common_posix.cpp | 6 +- .../guarded_pool_allocator_fuchsia.cpp | 104 + .../guarded_pool_allocator_fuchsia.h | 22 + .../guarded_pool_allocator_posix.cpp | 64 +- .../guarded_pool_allocator_posix.h | 18 + .../guarded_pool_allocator_tls.h | 55 + .../platform_specific/mutex_fuchsia.cpp | 21 + .../platform_specific/mutex_fuchsia.h | 23 + .../gwp_asan/platform_specific/mutex_posix.h | 23 + .../platform_specific/utilities_fuchsia.cpp | 19 + .../platform_specific/utilities_posix.cpp | 66 +- .../lib/gwp_asan/scripts/symbolize.sh | 6 +- .../lib/gwp_asan/tests/CMakeLists.txt | 9 +- .../lib/gwp_asan/tests/alignment.cpp | 126 +- .../lib/gwp_asan/tests/backtrace.cpp | 53 +- .../compiler-rt/lib/gwp_asan/tests/basic.cpp | 31 + .../lib/gwp_asan/tests/compression.cpp | 2 +- .../lib/gwp_asan/tests/crash_handler_api.cpp | 7 +- .../compiler-rt/lib/gwp_asan/tests/driver.cpp | 2 +- .../lib/gwp_asan/tests/enable_disable.cpp | 2 +- .../lib/gwp_asan/tests/harness.cpp | 10 +- .../compiler-rt/lib/gwp_asan/tests/harness.h | 29 +- .../lib/gwp_asan/tests/iterate.cpp | 3 + .../lib/gwp_asan/tests/late_init.cpp | 2 +- .../lib/gwp_asan/tests/mutex_test.cpp | 2 +- .../lib/gwp_asan/tests/options.cpp | 63 + .../printf_sanitizer_common.cpp | 19 + .../lib/gwp_asan/tests/slot_reuse.cpp | 2 + gnu/llvm/compiler-rt/lib/gwp_asan/utilities.h | 29 +- gnu/llvm/compiler-rt/lib/hwasan/.clang-format | 1 + .../compiler-rt/lib/hwasan/CMakeLists.txt | 95 +- gnu/llvm/compiler-rt/lib/hwasan/hwasan.cpp | 100 +- gnu/llvm/compiler-rt/lib/hwasan/hwasan.h | 88 +- .../hwasan/hwasan_allocation_functions.cpp | 172 ++ .../lib/hwasan/hwasan_allocator.cpp | 79 +- .../compiler-rt/lib/hwasan/hwasan_allocator.h | 34 +- .../compiler-rt/lib/hwasan/hwasan_checks.h | 5 +- .../lib/hwasan/hwasan_dynamic_shadow.cpp | 75 +- .../compiler-rt/lib/hwasan/hwasan_flags.h | 2 + .../compiler-rt/lib/hwasan/hwasan_flags.inc | 9 + .../compiler-rt/lib/hwasan/hwasan_fuchsia.cpp | 213 ++ .../lib/hwasan/hwasan_ignorelist.txt | 7 + .../lib/hwasan/hwasan_interceptors.cpp | 185 +- .../lib/hwasan/hwasan_interceptors_vfork.S | 4 + .../lib/hwasan/hwasan_interface_internal.h | 3 + .../compiler-rt/lib/hwasan/hwasan_linux.cpp | 235 +-- .../lib/hwasan/hwasan_malloc_bisect.h | 2 +- .../compiler-rt/lib/hwasan/hwasan_mapping.h | 24 +- .../lib/hwasan/hwasan_memintrinsics.cpp | 4 +- .../lib/hwasan/hwasan_new_delete.cpp | 107 +- .../lib/hwasan/hwasan_poisoning.cpp | 24 - .../compiler-rt/lib/hwasan/hwasan_report.cpp | 235 ++- .../compiler-rt/lib/hwasan/hwasan_setjmp.S | 6 + .../lib/hwasan/hwasan_tag_mismatch_aarch64.S | 6 + .../compiler-rt/lib/hwasan/hwasan_thread.cpp | 36 +- .../compiler-rt/lib/hwasan/hwasan_thread.h | 15 +- .../lib/hwasan/hwasan_thread_list.cpp | 2 +- .../lib/hwasan/hwasan_thread_list.h | 98 +- .../lib/interception/.clang-format | 1 + .../lib/interception/interception.h | 35 +- .../lib/interception/interception_linux.cpp | 10 +- .../lib/interception/interception_linux.h | 10 +- .../lib/interception/interception_win.cpp | 6 +- .../lib/interception/tests/CMakeLists.txt | 3 +- gnu/llvm/compiler-rt/lib/lsan/.clang-format | 1 + gnu/llvm/compiler-rt/lib/lsan/lsan.cpp | 18 +- .../compiler-rt/lib/lsan/lsan_allocator.cpp | 26 +- .../compiler-rt/lib/lsan/lsan_allocator.h | 2 +- gnu/llvm/compiler-rt/lib/lsan/lsan_common.cpp | 300 ++- gnu/llvm/compiler-rt/lib/lsan/lsan_common.h | 28 +- .../lib/lsan/lsan_common_fuchsia.cpp | 7 +- .../lib/lsan/lsan_common_linux.cpp | 5 + gnu/llvm/compiler-rt/lib/lsan/lsan_fuchsia.h | 2 +- .../lib/lsan/lsan_interceptors.cpp | 19 +- gnu/llvm/compiler-rt/lib/lsan/lsan_posix.cpp | 6 +- gnu/llvm/compiler-rt/lib/lsan/lsan_posix.h | 2 +- gnu/llvm/compiler-rt/lib/lsan/lsan_thread.cpp | 14 +- gnu/llvm/compiler-rt/lib/lsan/lsan_thread.h | 2 + .../compiler-rt/lib/memprof/CMakeLists.txt | 191 ++ gnu/llvm/compiler-rt/lib/memprof/README.txt | 17 + .../lib/memprof/memprof.syms.extra | 1 + .../lib/memprof/memprof_allocator.cpp | 905 +++++++++ .../lib/memprof/memprof_allocator.h | 104 + .../lib/memprof/memprof_descriptions.cpp | 70 + .../lib/memprof/memprof_descriptions.h | 45 + .../compiler-rt/lib/memprof/memprof_flags.cpp | 93 + .../compiler-rt/lib/memprof/memprof_flags.h | 45 + .../compiler-rt/lib/memprof/memprof_flags.inc | 49 + .../lib/memprof/memprof_init_version.h | 26 + .../lib/memprof/memprof_interceptors.cpp | 368 ++++ .../lib/memprof/memprof_interceptors.h | 60 + .../memprof_interceptors_memintrinsics.cpp | 29 + .../memprof_interceptors_memintrinsics.h | 79 + .../lib/memprof/memprof_interface_internal.h | 64 + .../lib/memprof/memprof_internal.h | 104 + .../compiler-rt/lib/memprof/memprof_linux.cpp | 80 + .../lib/memprof/memprof_malloc_linux.cpp | 226 +++ .../compiler-rt/lib/memprof/memprof_mapping.h | 113 ++ .../lib/memprof/memprof_new_delete.cpp | 145 ++ .../compiler-rt/lib/memprof/memprof_posix.cpp | 55 + .../lib/memprof/memprof_preinit.cpp | 23 + .../compiler-rt/lib/memprof/memprof_rtl.cpp | 311 +++ .../lib/memprof/memprof_shadow_setup.cpp | 62 + .../compiler-rt/lib/memprof/memprof_stack.cpp | 59 + .../compiler-rt/lib/memprof/memprof_stack.h | 66 + .../compiler-rt/lib/memprof/memprof_stats.cpp | 157 ++ .../compiler-rt/lib/memprof/memprof_stats.h | 61 + .../lib/memprof/memprof_thread.cpp | 220 +++ .../compiler-rt/lib/memprof/memprof_thread.h | 135 ++ .../compiler-rt/lib/memprof/weak_symbols.txt | 1 + gnu/llvm/compiler-rt/lib/msan/.clang-format | 1 + gnu/llvm/compiler-rt/lib/msan/CMakeLists.txt | 7 +- gnu/llvm/compiler-rt/lib/msan/msan.cpp | 65 +- gnu/llvm/compiler-rt/lib/msan/msan.h | 10 - .../compiler-rt/lib/msan/msan_allocator.cpp | 6 +- .../compiler-rt/lib/msan/msan_allocator.h | 1 - .../lib/msan/msan_chained_origin_depot.cpp | 103 +- .../lib/msan/msan_chained_origin_depot.h | 14 +- .../compiler-rt/lib/msan/msan_ignorelist.txt | 10 + .../lib/msan/msan_interceptors.cpp | 31 +- .../lib/msan/msan_interface_internal.h | 10 +- gnu/llvm/compiler-rt/lib/msan/msan_linux.cpp | 3 +- .../compiler-rt/lib/msan/msan_poisoning.cpp | 83 +- gnu/llvm/compiler-rt/lib/msan/msan_thread.cpp | 58 +- gnu/llvm/compiler-rt/lib/msan/msan_thread.h | 24 +- .../compiler-rt/lib/msan/tests/CMakeLists.txt | 6 +- .../compiler-rt/lib/msan/tests/msan_test.cpp | 120 +- gnu/llvm/compiler-rt/lib/orc/CMakeLists.txt | 104 + gnu/llvm/compiler-rt/lib/orc/adt.h | 113 ++ gnu/llvm/compiler-rt/lib/orc/c_api.h | 208 ++ gnu/llvm/compiler-rt/lib/orc/common.h | 48 + gnu/llvm/compiler-rt/lib/orc/compiler.h | 65 + gnu/llvm/compiler-rt/lib/orc/endianness.h | 143 ++ gnu/llvm/compiler-rt/lib/orc/error.h | 428 +++++ .../compiler-rt/lib/orc/executor_address.h | 208 ++ .../compiler-rt/lib/orc/extensible_rtti.cpp | 24 + .../compiler-rt/lib/orc/extensible_rtti.h | 145 ++ .../lib/orc/log_error_to_stderr.cpp | 19 + .../compiler-rt/lib/orc/macho_platform.cpp | 731 +++++++ gnu/llvm/compiler-rt/lib/orc/macho_platform.h | 135 ++ .../compiler-rt/lib/orc/macho_tlv.x86-64.S | 68 + .../lib/orc/run_program_wrapper.cpp | 51 + .../lib/orc/simple_packed_serialization.h | 579 ++++++ gnu/llvm/compiler-rt/lib/orc/stl_extras.h | 46 + .../lib/orc/unittests/CMakeLists.txt | 108 ++ .../lib/orc/unittests/adt_test.cpp | 87 + .../lib/orc/unittests/c_api_test.cpp | 200 ++ .../lib/orc/unittests/endian_test.cpp | 174 ++ .../lib/orc/unittests/error_test.cpp | 295 +++ .../orc/unittests/extensible_rtti_test.cpp | 54 + .../lib/orc/unittests/orc_unit_test_main.cpp | 18 + .../simple_packed_serialization_test.cpp | 163 ++ .../lib/orc/unittests/stl_extras_test.cpp | 65 + .../unittests/wrapper_function_utils_test.cpp | 105 + .../lib/orc/wrapper_function_utils.h | 367 ++++ .../compiler-rt/lib/profile/CMakeLists.txt | 9 +- .../compiler-rt/lib/profile/GCDAProfiling.c | 104 +- .../compiler-rt/lib/profile/InstrProfiling.c | 6 +- .../compiler-rt/lib/profile/InstrProfiling.h | 28 +- .../lib/profile/InstrProfilingBuffer.c | 37 +- .../lib/profile/InstrProfilingFile.c | 379 ++-- .../lib/profile/InstrProfilingInternal.c | 13 +- .../lib/profile/InstrProfilingInternal.h | 10 +- .../lib/profile/InstrProfilingMerge.c | 57 +- .../profile/InstrProfilingPlatformDarwin.c | 9 + .../profile/InstrProfilingPlatformFuchsia.c | 38 +- .../lib/profile/InstrProfilingPlatformLinux.c | 158 +- .../lib/profile/InstrProfilingPlatformOther.c | 5 + .../profile/InstrProfilingPlatformWindows.c | 5 + .../lib/profile/InstrProfilingPort.h | 12 +- .../lib/profile/InstrProfilingUtil.c | 27 +- .../lib/profile/InstrProfilingUtil.h | 11 + .../lib/profile/InstrProfilingValue.c | 39 +- .../lib/profile/InstrProfilingVersionVar.c | 17 + .../lib/profile/InstrProfilingWriter.c | 19 +- .../compiler-rt/lib/profile/WindowsMMap.c | 12 + .../compiler-rt/lib/profile/WindowsMMap.h | 10 + .../compiler-rt/lib/safestack/.clang-format | 1 + .../lib/sanitizer_common/.clang-format | 1 + .../lib/sanitizer_common/CMakeLists.txt | 11 +- .../sanitizer_common/sanitizer_addrhashmap.h | 106 +- .../sanitizer_common/sanitizer_allocator.cpp | 25 +- .../sanitizer_common/sanitizer_allocator.h | 6 +- .../sanitizer_allocator_checks.h | 10 +- .../sanitizer_allocator_combined.h | 8 +- .../sanitizer_allocator_local_cache.h | 19 +- .../sanitizer_allocator_primary32.h | 8 +- .../sanitizer_allocator_primary64.h | 256 +-- .../sanitizer_allocator_report.cpp | 8 + .../sanitizer_allocator_report.h | 1 + .../sanitizer_allocator_secondary.h | 16 +- .../sanitizer_allocator_size_class_map.h | 2 +- .../lib/sanitizer_common/sanitizer_atomic.h | 4 +- .../sanitizer_common/sanitizer_atomic_clang.h | 14 +- .../sanitizer_atomic_clang_mips.h | 18 +- .../sanitizer_atomic_clang_other.h | 24 +- .../sanitizer_atomic_clang_x86.h | 6 +- .../sanitizer_common/sanitizer_atomic_msvc.h | 36 +- .../sanitizer_chained_origin_depot.cpp | 108 ++ .../sanitizer_chained_origin_depot.h | 88 + .../lib/sanitizer_common/sanitizer_common.cpp | 25 +- .../lib/sanitizer_common/sanitizer_common.h | 192 +- .../sanitizer_common_interceptors.inc | 312 ++- .../sanitizer_common_interceptors_format.inc | 6 + .../sanitizer_common_interceptors_ioctl.inc | 15 +- ...er_common_interceptors_vfork_aarch64.inc.S | 5 + ...er_common_interceptors_vfork_riscv64.inc.S | 56 + .../sanitizer_common_interface.inc | 1 + .../sanitizer_common_libcdep.cpp | 60 +- .../sanitizer_common_nolibc.cpp | 5 +- .../sanitizer_common_syscalls.inc | 14 +- .../sanitizer_deadlock_detector1.cpp | 4 +- .../sanitizer_deadlock_detector2.cpp | 34 +- .../sanitizer_deadlock_detector_interface.h | 6 + .../lib/sanitizer_common/sanitizer_errno.h | 3 +- .../sanitizer_common/sanitizer_errno_codes.h | 1 + .../lib/sanitizer_common/sanitizer_file.cpp | 40 +- .../lib/sanitizer_common/sanitizer_file.h | 1 + .../sanitizer_common/sanitizer_flag_parser.h | 2 +- .../lib/sanitizer_common/sanitizer_flags.cpp | 16 +- .../lib/sanitizer_common/sanitizer_flags.h | 4 + .../lib/sanitizer_common/sanitizer_flags.inc | 21 +- .../sanitizer_common/sanitizer_fuchsia.cpp | 122 +- .../lib/sanitizer_common/sanitizer_fuchsia.h | 2 + .../sanitizer_common/sanitizer_getauxval.h | 5 +- .../sanitizer_interface_internal.h | 4 + .../sanitizer_internal_defs.h | 24 +- .../lib/sanitizer_common/sanitizer_libc.h | 3 +- .../sanitizer_common/sanitizer_libignore.cpp | 4 +- .../lib/sanitizer_common/sanitizer_linux.cpp | 291 +-- .../lib/sanitizer_common/sanitizer_linux.h | 14 +- .../sanitizer_linux_libcdep.cpp | 612 +++--- .../sanitizer_local_address_space_view.h | 2 +- .../lib/sanitizer_common/sanitizer_mac.cpp | 320 ++- .../lib/sanitizer_common/sanitizer_mac.h | 18 +- .../sanitizer_common/sanitizer_malloc_mac.inc | 6 +- .../lib/sanitizer_common/sanitizer_mutex.cpp | 225 +++ .../lib/sanitizer_common/sanitizer_mutex.h | 368 +++- .../lib/sanitizer_common/sanitizer_netbsd.cpp | 22 +- .../sanitizer_common/sanitizer_openbsd.cpp | 115 -- .../lib/sanitizer_common/sanitizer_platform.h | 68 +- .../sanitizer_platform_interceptors.h | 374 ++-- .../sanitizer_platform_limits_freebsd.cpp | 5 +- .../sanitizer_platform_limits_netbsd.cpp | 155 +- .../sanitizer_platform_limits_netbsd.h | 6 +- .../sanitizer_platform_limits_openbsd.cpp | 279 --- .../sanitizer_platform_limits_openbsd.h | 382 ---- .../sanitizer_platform_limits_posix.cpp | 119 +- .../sanitizer_platform_limits_posix.h | 28 +- .../sanitizer_platform_limits_solaris.cpp | 3 +- .../lib/sanitizer_common/sanitizer_posix.cpp | 16 +- .../lib/sanitizer_common/sanitizer_posix.h | 6 +- .../sanitizer_posix_libcdep.cpp | 40 +- .../lib/sanitizer_common/sanitizer_printf.cpp | 84 +- .../lib/sanitizer_common/sanitizer_procmaps.h | 2 +- .../sanitizer_procmaps_bsd.cpp | 31 +- .../sanitizer_procmaps_common.cpp | 4 +- .../sanitizer_procmaps_mac.cpp | 4 +- .../sanitizer_procmaps_solaris.cpp | 7 +- .../lib/sanitizer_common/sanitizer_ptrauth.h | 20 + .../sanitizer_common/sanitizer_quarantine.h | 3 +- .../sanitizer_signal_interceptors.inc | 5 +- .../sanitizer_common/sanitizer_solaris.cpp | 32 +- .../sanitizer_common/sanitizer_stackdepot.cpp | 9 +- .../sanitizer_common/sanitizer_stackdepot.h | 1 + .../sanitizer_stackdepotbase.h | 20 +- .../sanitizer_common/sanitizer_stacktrace.cpp | 40 +- .../sanitizer_common/sanitizer_stacktrace.h | 59 +- .../sanitizer_stacktrace_libcdep.cpp | 174 +- .../sanitizer_stacktrace_printer.cpp | 92 +- .../sanitizer_stacktrace_printer.h | 4 +- .../sanitizer_common/sanitizer_stoptheworld.h | 13 +- .../sanitizer_stoptheworld_fuchsia.cpp | 3 +- .../sanitizer_stoptheworld_fuchsia.h | 20 + .../sanitizer_stoptheworld_linux_libcdep.cpp | 106 +- .../sanitizer_stoptheworld_mac.cpp | 20 +- .../sanitizer_stoptheworld_netbsd_libcdep.cpp | 16 +- .../sanitizer_suppressions.cpp | 4 +- .../sanitizer_symbolizer_internal.h | 7 +- .../sanitizer_symbolizer_libbacktrace.h | 2 +- .../sanitizer_symbolizer_libcdep.cpp | 11 +- .../sanitizer_symbolizer_mac.cpp | 21 +- .../sanitizer_symbolizer_mac.h | 4 +- .../sanitizer_symbolizer_markup.cpp | 24 +- .../sanitizer_symbolizer_posix_libcdep.cpp | 19 +- .../sanitizer_symbolizer_report.cpp | 35 +- .../sanitizer_symbolizer_win.cpp | 20 +- .../sanitizer_syscall_generic.inc | 2 +- .../sanitizer_syscall_linux_riscv64.inc | 174 ++ .../sanitizer_syscalls_netbsd.inc | 119 +- .../sanitizer_termination.cpp | 33 +- .../sanitizer_thread_registry.cpp | 41 +- .../sanitizer_thread_registry.h | 30 +- .../sanitizer_thread_safety.h | 42 + .../sanitizer_tls_get_addr.cpp | 86 +- .../sanitizer_common/sanitizer_tls_get_addr.h | 21 +- .../sanitizer_common/sanitizer_unwind_win.cpp | 11 + .../lib/sanitizer_common/sanitizer_win.cpp | 130 +- .../sanitizer_common/scripts/check_lint.sh | 2 +- .../lib/sanitizer_common/scripts/litlint.py | 3 +- .../sanitizer_common/scripts/litlint_test.py | 2 +- .../lib/sanitizer_common/scripts/sancov.py | 12 +- .../symbolizer/sanitizer_symbolize.cpp | 57 +- .../symbolizer/scripts/build_symbolizer.sh | 4 +- .../symbolizer/scripts/global_symbols.txt | 2 + .../lib/sanitizer_common/tests/CMakeLists.txt | 13 +- .../tests/sanitizer_allocator_test.cpp | 199 +- .../tests/sanitizer_atomic_test.cpp | 20 + .../sanitizer_chained_origin_depot_test.cpp | 90 + .../tests/sanitizer_common_test.cpp | 105 +- .../sanitizer_format_interceptor_test.cpp | 41 +- .../tests/sanitizer_libc_test.cpp | 6 +- .../tests/sanitizer_linux_test.cpp | 17 +- .../tests/sanitizer_mac_test.cpp | 50 +- .../tests/sanitizer_mutex_test.cpp | 64 + .../tests/sanitizer_printf_test.cpp | 18 + .../tests/sanitizer_stackdepot_test.cpp | 24 +- .../sanitizer_stacktrace_printer_test.cpp | 39 +- .../tests/sanitizer_stacktrace_test.cpp | 162 +- .../tests/sanitizer_test_utils.h | 4 +- .../tests/sanitizer_thread_registry_test.cpp | 16 +- gnu/llvm/compiler-rt/lib/scudo/CMakeLists.txt | 9 +- .../compiler-rt/lib/scudo/scudo_allocator.cpp | 56 +- gnu/llvm/compiler-rt/lib/scudo/scudo_crc32.h | 2 +- .../lib/scudo/scudo_termination.cpp | 2 +- gnu/llvm/compiler-rt/lib/scudo/scudo_tsd.h | 8 +- .../lib/scudo/scudo_tsd_exclusive.inc | 16 +- .../lib/scudo/scudo_tsd_shared.cpp | 2 +- .../lib/scudo/scudo_tsd_shared.inc | 3 +- .../compiler-rt/lib/scudo/scudo_utils.cpp | 2 +- gnu/llvm/compiler-rt/lib/scudo/scudo_utils.h | 2 +- .../lib/scudo/standalone/CMakeLists.txt | 62 +- .../lib/scudo/standalone/allocator_config.h | 164 +- .../lib/scudo/standalone/atomic_helpers.h | 22 +- .../standalone/benchmarks/CMakeLists.txt | 12 + .../benchmarks/malloc_benchmark.cpp | 16 +- .../lib/scudo/standalone/bytemap.h | 7 +- .../compiler-rt/lib/scudo/standalone/chunk.h | 3 +- .../lib/scudo/standalone/combined.h | 942 ++++++--- .../lib/scudo/standalone/common.cpp | 16 +- .../compiler-rt/lib/scudo/standalone/common.h | 19 +- .../lib/scudo/standalone/flags.inc | 6 - .../lib/scudo/standalone/flags_parser.h | 2 +- .../lib/scudo/standalone/fuchsia.cpp | 29 +- .../standalone/fuzz/get_error_info_fuzzer.cpp | 26 +- .../standalone/include/scudo/interface.h | 64 +- .../lib/scudo/standalone/internal_defs.h | 66 +- .../lib/scudo/standalone/linux.cpp | 34 +- .../compiler-rt/lib/scudo/standalone/linux.h | 45 - .../compiler-rt/lib/scudo/standalone/list.h | 6 +- .../lib/scudo/standalone/local_cache.h | 86 +- .../compiler-rt/lib/scudo/standalone/memtag.h | 327 ++-- .../compiler-rt/lib/scudo/standalone/mutex.h | 5 +- .../lib/scudo/standalone/options.h | 74 + .../lib/scudo/standalone/platform.h | 8 +- .../lib/scudo/standalone/primary32.h | 268 +-- .../lib/scudo/standalone/primary64.h | 274 +-- .../lib/scudo/standalone/quarantine.h | 30 +- .../lib/scudo/standalone/release.cpp | 2 +- .../lib/scudo/standalone/release.h | 188 +- .../lib/scudo/standalone/report.cpp | 6 +- .../lib/scudo/standalone/secondary.h | 526 +++-- .../lib/scudo/standalone/size_class_map.h | 129 +- .../lib/scudo/standalone/stack_depot.h | 8 +- .../compiler-rt/lib/scudo/standalone/stats.h | 27 +- .../lib/scudo/standalone/string_utils.cpp | 43 +- .../lib/scudo/standalone/string_utils.h | 12 +- .../lib/scudo/standalone/tests/CMakeLists.txt | 20 +- .../scudo/standalone/tests/atomic_test.cpp | 26 +- .../scudo/standalone/tests/checksum_test.cpp | 4 +- .../lib/scudo/standalone/tests/chunk_test.cpp | 6 +- .../scudo/standalone/tests/combined_test.cpp | 624 +++--- .../scudo/standalone/tests/common_test.cpp | 72 + .../lib/scudo/standalone/tests/map_test.cpp | 24 +- .../scudo/standalone/tests/memtag_test.cpp | 188 ++ .../lib/scudo/standalone/tests/mutex_test.cpp | 2 - .../scudo/standalone/tests/primary_test.cpp | 245 ++- .../standalone/tests/quarantine_test.cpp | 30 +- .../scudo/standalone/tests/release_test.cpp | 33 +- .../scudo/standalone/tests/report_test.cpp | 11 +- .../scudo/standalone/tests/scudo_unit_test.h | 21 +- .../standalone/tests/scudo_unit_test_main.cpp | 25 +- .../scudo/standalone/tests/secondary_test.cpp | 213 +- .../standalone/tests/size_class_map_test.cpp | 2 + .../scudo/standalone/tests/strings_test.cpp | 31 +- .../lib/scudo/standalone/tests/tsd_test.cpp | 101 +- .../scudo/standalone/tests/vector_test.cpp | 14 +- .../standalone/tests/wrappers_c_test.cpp | 61 +- .../standalone/tests/wrappers_cpp_test.cpp | 18 +- .../tools/compute_size_class_config.cpp | 11 +- .../lib/scudo/standalone/trusty.cpp | 100 + .../compiler-rt/lib/scudo/standalone/trusty.h | 24 + .../compiler-rt/lib/scudo/standalone/tsd.h | 13 +- .../lib/scudo/standalone/tsd_exclusive.h | 82 +- .../lib/scudo/standalone/tsd_shared.h | 192 +- .../compiler-rt/lib/scudo/standalone/vector.h | 31 +- .../lib/scudo/standalone/wrappers_c.cpp | 1 + .../lib/scudo/standalone/wrappers_c.h | 8 - .../lib/scudo/standalone/wrappers_c.inc | 45 +- .../scudo/standalone/wrappers_c_bionic.cpp | 23 +- gnu/llvm/compiler-rt/lib/tsan/.clang-format | 1 + gnu/llvm/compiler-rt/lib/tsan/CMakeLists.txt | 68 +- .../lib/tsan/dd/dd_interceptors.cpp | 11 +- gnu/llvm/compiler-rt/lib/tsan/dd/dd_rtl.h | 2 +- gnu/llvm/compiler-rt/lib/tsan/go/build.bat | 3 +- gnu/llvm/compiler-rt/lib/tsan/go/buildgo.sh | 64 +- .../compiler-rt/lib/tsan/rtl/tsan_clock.cpp | 66 +- .../compiler-rt/lib/tsan/rtl/tsan_clock.h | 16 +- gnu/llvm/compiler-rt/lib/tsan/rtl/tsan_defs.h | 30 +- .../lib/tsan/rtl/tsan_dense_alloc.h | 33 +- .../lib/tsan/rtl/tsan_dispatch_defs.h | 11 +- .../lib/tsan/rtl/tsan_external.cpp | 11 +- .../compiler-rt/lib/tsan/rtl/tsan_flags.cpp | 2 +- .../lib/tsan/rtl/tsan_interceptors.h | 18 +- .../rtl/tsan_interceptors_libdispatch.cpp | 32 + .../lib/tsan/rtl/tsan_interceptors_mac.cpp | 10 +- .../tsan/rtl/tsan_interceptors_mach_vm.cpp | 19 +- .../lib/tsan/rtl/tsan_interceptors_posix.cpp | 238 ++- .../lib/tsan/rtl/tsan_interface.cpp | 13 +- .../compiler-rt/lib/tsan/rtl/tsan_interface.h | 12 +- .../lib/tsan/rtl/tsan_interface_ann.cpp | 9 +- .../lib/tsan/rtl/tsan_interface_atomic.cpp | 74 +- .../lib/tsan/rtl/tsan_interface_inl.h | 23 +- .../lib/tsan/rtl/tsan_interface_java.cpp | 1 - .../compiler-rt/lib/tsan/rtl/tsan_mman.cpp | 7 +- .../compiler-rt/lib/tsan/rtl/tsan_platform.h | 199 +- .../lib/tsan/rtl/tsan_platform_linux.cpp | 46 +- .../lib/tsan/rtl/tsan_platform_mac.cpp | 9 +- .../lib/tsan/rtl/tsan_platform_posix.cpp | 69 +- .../compiler-rt/lib/tsan/rtl/tsan_report.cpp | 20 +- .../compiler-rt/lib/tsan/rtl/tsan_rtl.cpp | 214 ++- gnu/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl.h | 47 +- .../lib/tsan/rtl/tsan_rtl_mutex.cpp | 75 +- .../lib/tsan/rtl/tsan_rtl_report.cpp | 64 +- .../compiler-rt/lib/tsan/rtl/tsan_rtl_s390x.S | 47 + .../lib/tsan/rtl/tsan_rtl_thread.cpp | 25 +- .../lib/tsan/rtl/tsan_stack_trace.cpp | 8 +- .../compiler-rt/lib/tsan/rtl/tsan_sync.cpp | 15 +- gnu/llvm/compiler-rt/lib/tsan/rtl/tsan_sync.h | 9 +- .../compiler-rt/lib/tsan/rtl/tsan_trace.h | 5 +- .../tsan/rtl/tsan_update_shadow_word_inl.h | 12 +- .../compiler-rt/lib/tsan/tests/CMakeLists.txt | 19 +- .../lib/tsan/tests/rtl/tsan_bench.cpp | 2 +- .../lib/tsan/tests/rtl/tsan_mop.cpp | 4 +- .../lib/tsan/tests/rtl/tsan_mutex.cpp | 14 +- .../lib/tsan/tests/rtl/tsan_test_util.h | 26 +- .../tsan/tests/rtl/tsan_test_util_posix.cpp | 59 +- .../lib/tsan/tests/unit/CMakeLists.txt | 2 +- .../tsan/tests/unit/tsan_dense_alloc_test.cpp | 15 +- .../lib/tsan/tests/unit/tsan_sync_test.cpp | 11 +- gnu/llvm/compiler-rt/lib/ubsan/CMakeLists.txt | 4 +- gnu/llvm/compiler-rt/lib/ubsan/ubsan_diag.cpp | 8 +- .../lib/ubsan/ubsan_diag_standalone.cpp | 8 +- .../compiler-rt/lib/ubsan/ubsan_flags.cpp | 6 +- gnu/llvm/compiler-rt/lib/ubsan/ubsan_flags.h | 2 - gnu/llvm/compiler-rt/lib/ubsan/ubsan_init.cpp | 9 + .../compiler-rt/lib/ubsan/ubsan_monitor.cpp | 6 +- .../compiler-rt/lib/ubsan/ubsan_platform.h | 8 +- .../lib/ubsan/ubsan_type_hash_itanium.cpp | 2 +- .../lib/ubsan/ubsan_type_hash_win.cpp | 2 +- .../compiler-rt/lib/ubsan/ubsan_value.cpp | 2 +- .../ubsan_minimal/ubsan_minimal_handlers.cpp | 2 +- gnu/llvm/compiler-rt/lib/xray/CMakeLists.txt | 3 +- .../compiler-rt/lib/xray/tests/CMakeLists.txt | 2 +- .../lib/xray/xray_basic_logging.cpp | 2 +- .../compiler-rt/lib/xray/xray_fdr_logging.cpp | 11 +- gnu/llvm/compiler-rt/lib/xray/xray_mips.cpp | 45 +- gnu/llvm/compiler-rt/lib/xray/xray_mips64.cpp | 64 +- .../lib/xray/xray_trampoline_x86_64.S | 77 +- gnu/llvm/compiler-rt/lib/xray/xray_utils.cpp | 1 + gnu/llvm/compiler-rt/lib/xray/xray_x86_64.cpp | 13 +- gnu/llvm/compiler-rt/lib/xray/xray_x86_64.inc | 1 - .../compiler-rt/tools/gwp_asan/CMakeLists.txt | 15 +- .../tools/gwp_asan/options_parser_fuzzer.cpp | 12 + .../unittests/lit.common.unit.cfg.py | 14 +- .../unittests/lit.common.unit.configured.in | 1 + .../utils/generate_netbsd_syscalls.awk | 34 + gnu/llvm/compiler-rt/www/menu.html.incl | 2 +- 702 files changed, 32235 insertions(+), 10752 deletions(-) create mode 100644 gnu/llvm/compiler-rt/.clang-tidy create mode 100644 gnu/llvm/compiler-rt/.gitignore create mode 100644 gnu/llvm/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake create mode 100644 gnu/llvm/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake create mode 100644 gnu/llvm/compiler-rt/docs/BuildingCompilerRT.rst create mode 100644 gnu/llvm/compiler-rt/include/sanitizer/memprof_interface.h create mode 100644 gnu/llvm/compiler-rt/lib/asan/asan_ignorelist.txt create mode 100644 gnu/llvm/compiler-rt/lib/builtins/aarch64/lse.S create mode 100644 gnu/llvm/compiler-rt/lib/builtins/divmodti4.c create mode 100644 gnu/llvm/compiler-rt/lib/builtins/extendhftf2.c create mode 100644 gnu/llvm/compiler-rt/lib/builtins/fp_compare_impl.inc create mode 100644 gnu/llvm/compiler-rt/lib/builtins/fp_div_impl.inc create mode 100644 gnu/llvm/compiler-rt/lib/builtins/int_mulo_impl.inc create mode 100644 gnu/llvm/compiler-rt/lib/builtins/int_mulv_impl.inc create mode 100644 gnu/llvm/compiler-rt/lib/builtins/ppc/atomic.exp create mode 100644 gnu/llvm/compiler-rt/lib/builtins/riscv/restore.S create mode 100644 gnu/llvm/compiler-rt/lib/builtins/riscv/save.S create mode 100644 gnu/llvm/compiler-rt/lib/builtins/trunctfhf2.c create mode 100644 gnu/llvm/compiler-rt/lib/cfi/cfi_ignorelist.txt create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_allocator.cpp create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_allocator.h create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.h create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_flags.h create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_new_delete.cpp create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_origin.h create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_thread.cpp create mode 100644 gnu/llvm/compiler-rt/lib/dfsan/dfsan_thread.h create mode 100644 gnu/llvm/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/optional/backtrace_fuchsia.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/optional/printf.h create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/optional/segv_handler_fuchsia.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/common_fuchsia.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_fuchsia.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_fuchsia.h create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.h create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_tls.h create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/mutex_fuchsia.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/mutex_fuchsia.h create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/mutex_posix.h create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/platform_specific/utilities_fuchsia.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/tests/options.cpp create mode 100644 gnu/llvm/compiler-rt/lib/gwp_asan/tests/platform_specific/printf_sanitizer_common.cpp create mode 100644 gnu/llvm/compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp create mode 100644 gnu/llvm/compiler-rt/lib/hwasan/hwasan_fuchsia.cpp create mode 100644 gnu/llvm/compiler-rt/lib/hwasan/hwasan_ignorelist.txt create mode 100644 gnu/llvm/compiler-rt/lib/memprof/CMakeLists.txt create mode 100644 gnu/llvm/compiler-rt/lib/memprof/README.txt create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof.syms.extra create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_allocator.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_allocator.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_descriptions.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_descriptions.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_flags.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_flags.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_flags.inc create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_init_version.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_interceptors.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_interceptors.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_interceptors_memintrinsics.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_interceptors_memintrinsics.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_interface_internal.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_internal.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_linux.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_malloc_linux.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_mapping.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_new_delete.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_posix.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_preinit.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_rtl.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_shadow_setup.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_stack.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_stack.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_stats.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_stats.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_thread.cpp create mode 100644 gnu/llvm/compiler-rt/lib/memprof/memprof_thread.h create mode 100644 gnu/llvm/compiler-rt/lib/memprof/weak_symbols.txt create mode 100644 gnu/llvm/compiler-rt/lib/msan/msan_ignorelist.txt create mode 100644 gnu/llvm/compiler-rt/lib/orc/CMakeLists.txt create mode 100644 gnu/llvm/compiler-rt/lib/orc/adt.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/c_api.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/common.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/compiler.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/endianness.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/error.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/executor_address.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/extensible_rtti.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/extensible_rtti.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/log_error_to_stderr.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/macho_platform.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/macho_platform.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/macho_tlv.x86-64.S create mode 100644 gnu/llvm/compiler-rt/lib/orc/run_program_wrapper.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/simple_packed_serialization.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/stl_extras.h create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/CMakeLists.txt create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/adt_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/c_api_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/endian_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/error_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/extensible_rtti_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/orc_unit_test_main.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/simple_packed_serialization_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/stl_extras_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/unittests/wrapper_function_utils_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/orc/wrapper_function_utils.h create mode 100644 gnu/llvm/compiler-rt/lib/profile/InstrProfilingVersionVar.c create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_riscv64.inc.S create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_mutex.cpp create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_fuchsia.h create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_riscv64.inc create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_thread_safety.h create mode 100644 gnu/llvm/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/scudo/standalone/options.h create mode 100644 gnu/llvm/compiler-rt/lib/scudo/standalone/tests/common_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp create mode 100644 gnu/llvm/compiler-rt/lib/scudo/standalone/trusty.cpp create mode 100644 gnu/llvm/compiler-rt/lib/scudo/standalone/trusty.h create mode 100644 gnu/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_s390x.S create mode 100644 gnu/llvm/compiler-rt/tools/gwp_asan/options_parser_fuzzer.cpp diff --git a/gnu/llvm/compiler-rt/.clang-tidy b/gnu/llvm/compiler-rt/.clang-tidy new file mode 100644 index 00000000000..c7dba46ad74 --- /dev/null +++ b/gnu/llvm/compiler-rt/.clang-tidy @@ -0,0 +1,2 @@ +Checks: '-readability-identifier-naming,-llvm-header-guard' +InheritParentConfig: true diff --git a/gnu/llvm/compiler-rt/.gitignore b/gnu/llvm/compiler-rt/.gitignore new file mode 100644 index 00000000000..f7d4697ebc5 --- /dev/null +++ b/gnu/llvm/compiler-rt/.gitignore @@ -0,0 +1,6 @@ +*~ +darwin_fat +clang_darwin +multi_arch +*.sw? +*.pyc diff --git a/gnu/llvm/compiler-rt/CMakeLists.txt b/gnu/llvm/compiler-rt/CMakeLists.txt index fa62814b635..e12d1eb1ceb 100644 --- a/gnu/llvm/compiler-rt/CMakeLists.txt +++ b/gnu/llvm/compiler-rt/CMakeLists.txt @@ -3,11 +3,7 @@ # An important constraint of the build is that it only produces libraries # based on the ability of the host toolchain to target various platforms. -cmake_minimum_required(VERSION 3.4.3) - -if(POLICY CMP0075) - cmake_policy(SET CMP0075 NEW) -endif() +cmake_minimum_required(VERSION 3.13.4) # Check if compiler-rt is built as a standalone project. if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD) @@ -45,8 +41,12 @@ option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON) mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER) option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON) mark_as_advanced(COMPILER_RT_BUILD_PROFILE) +option(COMPILER_RT_BUILD_MEMPROF "Build memory profiling runtime" ON) +mark_as_advanced(COMPILER_RT_BUILD_MEMPROF) option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" OFF) mark_as_advanced(COMPILER_RT_BUILD_XRAY_NO_PREINIT) +option(COMPILER_RT_BUILD_ORC "Build ORC runtime" ON) +mark_as_advanced(COMPILER_RT_BUILD_ORC) set(COMPILER_RT_ASAN_SHADOW_SCALE "" CACHE STRING "Override the shadow scale to be used in ASan runtime") @@ -67,8 +67,12 @@ if (NOT COMPILER_RT_ASAN_SHADOW_SCALE STREQUAL "") -D${COMPILER_RT_ASAN_SHADOW_SCALE_DEFINITION}) endif() -set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS ON CACHE BOOL - "Enable libc interceptors in HWASan (testing mode)") +if(FUCHSIA) + set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT OFF) +else() + set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT ON) +endif() +set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS ${COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT} CACHE BOOL "Enable libc interceptors in HWASan (testing mode)") set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOL "Build for a bare-metal target.") @@ -81,38 +85,23 @@ if (COMPILER_RT_STANDALONE_BUILD) set_target_properties(intrinsics_gen PROPERTIES FOLDER "Compiler-RT Misc") endif() - if(CMAKE_VERSION VERSION_LESS 3.12) - # Find Python interpreter. - include(FindPythonInterp) - if(NOT PYTHONINTERP_FOUND) - message(FATAL_ERROR " - Unable to find Python interpreter required testing. Please install Python - or specify the PYTHON_EXECUTABLE CMake variable.") + find_package(Python3 COMPONENTS Interpreter) + if(NOT Python3_Interpreter_FOUND) + message(WARNING "Python3 not found, using python2 as a fallback") + find_package(Python2 COMPONENTS Interpreter REQUIRED) + if(Python2_VERSION VERSION_LESS 2.7) + message(SEND_ERROR "Python 2.7 or newer is required") endif() + # Treat python2 as python3 add_executable(Python3::Interpreter IMPORTED) set_target_properties(Python3::Interpreter PROPERTIES - IMPORTED_LOCATION ${PYTHON_EXECUTABLE}) - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) - else() - find_package(Python3 COMPONENTS Interpreter) - if(NOT Python3_Interpreter_FOUND) - message(WARNING "Python3 not found, using python2 as a fallback") - find_package(Python2 COMPONENTS Interpreter REQUIRED) - if(Python2_VERSION VERSION_LESS 2.7) - message(SEND_ERROR "Python 2.7 or newer is required") - endif() - - # Treat python2 as python3 - add_executable(Python3::Interpreter IMPORTED) - set_target_properties(Python3::Interpreter PROPERTIES - IMPORTED_LOCATION ${Python2_EXECUTABLE}) - set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) - endif() + IMPORTED_LOCATION ${Python2_EXECUTABLE}) + set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) endif() # Ensure that fat libraries are built correctly on Darwin - if(CMAKE_HOST_APPLE AND APPLE) + if(APPLE) include(UseLibtool) endif() @@ -129,16 +118,16 @@ construct_compiler_rt_default_triple() if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*hf$") if (${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "^arm") set(COMPILER_RT_DEFAULT_TARGET_ARCH "armhf") + CHECK_SYMBOL_EXISTS (__thumb__ "" COMPILER_RT_ARM_THUMB) endif() endif() if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*android.*") set(ANDROID 1) + string(REGEX MATCH "-target(=| +)[^ ]+android[a-z]*([0-9]+)" ANDROID_API_LEVEL "${CMAKE_C_FLAGS}") + set(ANDROID_API_LEVEL ${CMAKE_MATCH_2}) endif() pythonize_bool(ANDROID) -set(ANDROID_NDK_VERSION 18 - CACHE STRING "Set this to the Android NDK version that you are using") - set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -190,14 +179,18 @@ endif() option(SANITIZER_ALLOW_CXXABI "Allow use of C++ ABI details in ubsan" ON) -set(SANITIZE_CAN_USE_CXXABI OFF) +set(SANITIZER_CAN_USE_CXXABI OFF) if (cxxabi_supported AND SANITIZER_ALLOW_CXXABI) set(SANITIZER_CAN_USE_CXXABI ON) endif() pythonize_bool(SANITIZER_CAN_USE_CXXABI) macro(handle_default_cxx_lib var) - if (${var} STREQUAL "default") + # Specifying -stdlib= in CMAKE_CXX_FLAGS overrides the defaults. + if (CMAKE_CXX_FLAGS MATCHES "-stdlib=([a-zA-Z+]*)") + set(${var}_LIBNAME "${CMAKE_MATCH_1}") + set(${var}_SYSTEM 1) + elseif (${var} STREQUAL "default") if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") set(${var}_LIBNAME "libc++") set(${var}_SYSTEM 1) @@ -285,7 +278,11 @@ if(NOT COMPILER_RT_HAS_FUNC_SYMBOL) add_definitions(-D__func__=__FUNCTION__) endif() -# Provide some common commmandline flags for Sanitizer runtimes. +# Provide some common commandline flags for Sanitizer runtimes. +if("${ANDROID_API_LEVEL}" GREATER_EQUAL 29) + list(APPEND SANITIZER_COMMON_CFLAGS -fno-emulated-tls) + string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " -fno-emulated-tls") +endif() if(NOT WIN32) append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC SANITIZER_COMMON_CFLAGS) endif() @@ -362,6 +359,17 @@ endif() append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS) +if(CMAKE_CXX_COMPILER_ID MATCHES Clang) + list(APPEND THREAD_SAFETY_FLAGS + "-Werror=thread-safety" + "-Werror=thread-safety-reference" + "-Werror=thread-safety-beta" + ) + list(APPEND SANITIZER_COMMON_CFLAGS ${THREAD_SAFETY_FLAGS}) + string(REPLACE ";" " " thread_safety_flags_space_sep "${THREAD_SAFETY_FLAGS}") + string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${thread_safety_flags_space_sep}") +endif() + # If we're using MSVC, # always respect the optimization flags set by CMAKE_BUILD_TYPE instead. if (NOT MSVC) @@ -421,7 +429,6 @@ endif() append_list_if(COMPILER_RT_HAS_WGNU_FLAG -Wno-gnu SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG -Wno-c99-extensions SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG -Wno-non-virtual-dtor SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_WD4146_FLAG /wd4146 SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_WD4291_FLAG /wd4291 SANITIZER_COMMON_CFLAGS) append_list_if(COMPILER_RT_HAS_WD4391_FLAG /wd4391 SANITIZER_COMMON_CFLAGS) @@ -445,12 +452,39 @@ else() endif() append_list_if(COMPILER_RT_HAS_LIBC c SANITIZER_COMMON_LINK_LIBS) - if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") - list(APPEND SANITIZER_COMMON_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro) list(APPEND SANITIZER_COMMON_LINK_LIBS zircon) endif() +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") + set(SANITIZER_NO_UNDEFINED_SYMBOLS_DEFAULT ON) +else() + set(SANITIZER_NO_UNDEFINED_SYMBOLS_DEFAULT OFF) +endif() +option(SANITIZER_NO_UNDEFINED_SYMBOLS "Report error on unresolved symbol references" ${SANITIZER_NO_UNDEFINED_SYMBOLS_DEFAULT}) +if (SANITIZER_NO_UNDEFINED_SYMBOLS) + list(APPEND SANITIZER_COMMON_LINK_FLAGS -Wl,-z,defs) +endif() + +# TODO: COMPILER_RT_COMMON_CFLAGS and COMPILER_RT_COMMON_LINK_FLAGS are +# intended for use in non-sanitizer runtimes such as libFuzzer, profile or XRay, +# move these higher to include common flags, then derive SANITIZER_COMMON_CFLAGS +# and SANITIZER_COMMON_LINK_FLAGS from those and append sanitizer-specific flags. +set(COMPILER_RT_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS}) +set(COMPILER_RT_COMMON_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) + +# We don't use the C++ standard library, so avoid including it by mistake. +append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ SANITIZER_COMMON_CFLAGS) +append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SANITIZER_COMMON_LINK_FLAGS) + +# Remove -stdlib= which is unused when passing -nostdinc++... +string(REGEX MATCHALL "-stdlib=[a-zA-Z+]*" stdlib_flag "${CMAKE_CXX_FLAGS}") +string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + +# ...we need it to build some runtimes and tests so readd it where appropriate. +list(APPEND COMPILER_RT_COMMON_CFLAGS ${stdlib_flag}) +list(APPEND COMPILER_RT_COMMON_LINK_FLAGS ${stdlib_flag}) + macro(append_libcxx_libs var) if (${var}_INTREE) if (SANITIZER_USE_STATIC_LLVM_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND)) @@ -483,6 +517,54 @@ elseif (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libstdc++") append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_TEST_CXX_LIBRARIES) endif() +# TODO: There's a lot of duplication across lib/*/tests/CMakeLists.txt files, +# move some of the common flags to COMPILER_RT_UNITTEST_CFLAGS. + +# Unittests need access to C++ standard library. +string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}") + +# When cross-compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help in compilation +# and linking of unittests. +string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}") +set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS}) + +# Unittests support. +set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest) +set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc) +set(COMPILER_RT_GTEST_CFLAGS + -DGTEST_NO_LLVM_SUPPORT=1 + -DGTEST_HAS_RTTI=0 + -I${COMPILER_RT_GTEST_PATH}/include + -I${COMPILER_RT_GTEST_PATH} +) +if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + # FreeBSD has its pthread functions marked with thread safety annotations, but + # googletest is not compatible with such annotations. Disable the thread + # safety warnings-as-errors until googletest has been fixed. + list(APPEND NO_THREAD_SAFETY_FLAGS ${THREAD_SAFETY_FLAGS}) + list(TRANSFORM NO_THREAD_SAFETY_FLAGS REPLACE "error=" "no-") + list(APPEND COMPILER_RT_GTEST_CFLAGS ${NO_THREAD_SAFETY_FLAGS}) +endif() + +# Mocking support. +set(COMPILER_RT_GMOCK_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock) +set(COMPILER_RT_GMOCK_SOURCE ${COMPILER_RT_GMOCK_PATH}/src/gmock-all.cc) +set(COMPILER_RT_GMOCK_CFLAGS + -DGTEST_NO_LLVM_SUPPORT=1 + -DGTEST_HAS_RTTI=0 + -I${COMPILER_RT_GMOCK_PATH}/include + -I${COMPILER_RT_GMOCK_PATH} +) + +append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS) +append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS) +append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override COMPILER_RT_UNITTEST_CFLAGS) + +if(MSVC) + # gtest use a lot of stuff marked as deprecated on Windows. + list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations) +endif() + # Warnings to turn off for all libraries, not just sanitizers. append_string_if(COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG -Wno-unused-parameter CMAKE_C_FLAGS CMAKE_CXX_FLAGS) @@ -497,6 +579,15 @@ if (CMAKE_LINKER MATCHES "link.exe$") set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221") endif() +if(${CMAKE_SYSTEM_NAME} MATCHES "AIX") + set(CMAKE_C_ARCHIVE_CREATE " -X32_64 qc ") + set(CMAKE_CXX_ARCHIVE_CREATE " -X32_64 qc ") + set(CMAKE_C_ARCHIVE_APPEND " -X32_64 q ") + set(CMAKE_CXX_ARCHIVE_APPEND " -X32_64 q ") + set(CMAKE_C_ARCHIVE_FINISH " -X32_64 ") + set(CMAKE_CXX_ARCHIVE_FINISH " -X32_64 ") +endif() + add_subdirectory(include) option(COMPILER_RT_USE_LIBCXX @@ -537,14 +628,26 @@ else() set(COMPILER_RT_HAS_LLD TRUE) endif() endif() + +if(ANDROID) + set(COMPILER_RT_HAS_LLD TRUE) + set(COMPILER_RT_TEST_USE_LLD TRUE) + append_list_if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG -fuse-ld=lld SANITIZER_COMMON_LINK_FLAGS) + append_list_if(COMPILER_RT_HAS_LLD -fuse-ld=lld COMPILER_RT_UNITTEST_LINK_FLAGS) + if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) + set(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT FALSE) + endif() +endif() pythonize_bool(COMPILER_RT_HAS_LLD) +pythonize_bool(COMPILER_RT_TEST_USE_LLD) add_subdirectory(lib) if(COMPILER_RT_INCLUDE_TESTS) add_subdirectory(unittests) add_subdirectory(test) - if (COMPILER_RT_STANDALONE_BUILD) + # Don't build llvm-lit for runtimes-build, it will clean up map_config. + if (COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD) # If we have a valid source tree, generate llvm-lit into the bin directory. # The user can still choose to have the check targets *use* a different lit # by specifying -DLLVM_EXTERNAL_LIT, but we generate it regardless. diff --git a/gnu/llvm/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/gnu/llvm/compiler-rt/cmake/Modules/AddCompilerRT.cmake index dab55707338..bc69ec95c41 100644 --- a/gnu/llvm/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/gnu/llvm/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -109,11 +109,11 @@ endfunction() function(add_asm_sources output) set(${output} ${ARGN} PARENT_SCOPE) - # Xcode will try to compile asm files as C ('clang -x c'), and that will fail. - if (${CMAKE_GENERATOR} STREQUAL "Xcode") - enable_language(ASM) - else() - # Pass ASM file directly to the C++ compiler. + # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. https://gitlab.kitware.com/cmake/cmake/-/issues/20771 + # MinGW didn't work correctly with assembly prior to CMake 3.17. https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09 + # Workaround these two issues by compiling as C. + # Same workaround used in libunwind. Also update there if changed here. + if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION VERSION_LESS 3.17)) set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C) endif() endfunction() @@ -124,6 +124,21 @@ macro(set_output_name output name arch) else() if(ANDROID AND ${arch} STREQUAL "i386") set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}") + elseif("${arch}" MATCHES "^arm") + if(COMPILER_RT_DEFAULT_TARGET_ONLY) + set(triple "${COMPILER_RT_DEFAULT_TARGET_TRIPLE}") + else() + set(triple "${TARGET_TRIPLE}") + endif() + # When using arch-suffixed runtime library names, clang only looks for + # libraries named "arm" or "armhf", see getArchNameForCompilerRTLib in + # clang. Therefore, try to inspect both the arch name and the triple + # if it seems like we're building an armhf target. + if ("${arch}" MATCHES "hf$" OR "${triple}" MATCHES "hf$") + set(${output} "${name}-armhf${COMPILER_RT_OS_SUFFIX}") + else() + set(${output} "${name}-arm${COMPILER_RT_OS_SUFFIX}") + endif() else() set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}") endif() @@ -133,26 +148,28 @@ endmacro() # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime( -# {OBJECT|STATIC|SHARED} +# {OBJECT|STATIC|SHARED|MODULE} # ARCHS # OS # SOURCES # CFLAGS # LINK_FLAGS # DEFS +# DEPS # LINK_LIBS (only for shared library) # OBJECT_LIBS # PARENT_TARGET # ADDITIONAL_HEADERS
) function(add_compiler_rt_runtime name type) - if(NOT type MATCHES "^(OBJECT|STATIC|SHARED)$") - message(FATAL_ERROR "type argument must be OBJECT, STATIC or SHARED") + if(NOT type MATCHES "^(OBJECT|STATIC|SHARED|MODULE)$") + message(FATAL_ERROR + "type argument must be OBJECT, STATIC, SHARED or MODULE") return() endif() cmake_parse_arguments(LIB "" "PARENT_TARGET" - "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS" + "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS" ${ARGN}) set(libnames) # Until we support this some other way, build compiler-rt runtime without LTO @@ -329,6 +346,9 @@ function(add_compiler_rt_runtime name type) RUNTIME DESTINATION ${install_dir_${libname}} ${COMPONENT_OPTION}) endif() + if(LIB_DEPS) + add_dependencies(${libname} ${LIB_DEPS}) + endif() set_target_properties(${libname} PROPERTIES OUTPUT_NAME ${output_name_${libname}}) set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime") @@ -351,7 +371,7 @@ function(add_compiler_rt_runtime name type) add_custom_command(TARGET ${libname} POST_BUILD COMMAND codesign --sign - $ - WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} + WORKING_DIRECTORY ${COMPILER_RT_OUTPUT_LIBRARY_DIR} ) endif() endif() @@ -376,39 +396,6 @@ function(add_compiler_rt_runtime name type) endif() endfunction() -# when cross compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help -# in compilation and linking of unittests. -string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}") -set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS}) - -# Unittests support. -set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest) -set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc) -set(COMPILER_RT_GTEST_CFLAGS - -DGTEST_NO_LLVM_SUPPORT=1 - -DGTEST_HAS_RTTI=0 - -I${COMPILER_RT_GTEST_PATH}/include - -I${COMPILER_RT_GTEST_PATH} -) - -# Mocking support. -set(COMPILER_RT_GMOCK_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock) -set(COMPILER_RT_GMOCK_SOURCE ${COMPILER_RT_GMOCK_PATH}/src/gmock-all.cc) -set(COMPILER_RT_GMOCK_CFLAGS - -DGTEST_NO_LLVM_SUPPORT=1 - -DGTEST_HAS_RTTI=0 - -I${COMPILER_RT_GMOCK_PATH}/include - -I${COMPILER_RT_GMOCK_PATH} -) - -append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS) -append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS) - -if(MSVC) - # gtest use a lot of stuff marked as deprecated on Windows. - list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations) -endif() - # Compile and register compiler-rt tests. # generate_compiler_rt_tests( # @@ -524,7 +511,7 @@ macro(add_compiler_rt_resource_file target_name file_name component) add_custom_target(${target_name} DEPENDS ${dst_file}) # Install in Clang resource directory. install(FILES ${file_name} - DESTINATION ${COMPILER_RT_INSTALL_PATH}/share + DESTINATION ${COMPILER_RT_INSTALL_DATA_DIR} COMPONENT ${component}) add_dependencies(${component} ${target_name}) @@ -541,7 +528,7 @@ macro(add_compiler_rt_script name) add_custom_target(${name} DEPENDS ${dst}) install(FILES ${dst} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin) + DESTINATION ${COMPILER_RT_INSTALL_BINARY_DIR}) endmacro(add_compiler_rt_script src name) # Builds custom version of libc++ and installs it in . @@ -563,7 +550,7 @@ macro(add_custom_libcxx name prefix) if(LIBCXX_USE_TOOLCHAIN) set(compiler_args -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_CXX_COMPILER}) - if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT RUNTIMES_BUILD) + if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD) set(toolchain_deps $) set(force_deps DEPENDS $) endif() @@ -612,6 +599,10 @@ macro(add_custom_libcxx name prefix) CMAKE_OBJDUMP CMAKE_STRIP CMAKE_SYSROOT + LIBCXX_HAS_MUSL_LIBC + PYTHON_EXECUTABLE + Python3_EXECUTABLE + Python2_EXECUTABLE CMAKE_SYSTEM_NAME) foreach(variable ${PASSTHROUGH_VARIABLES}) get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET) diff --git a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake new file mode 100644 index 00000000000..3b61430f471 --- /dev/null +++ b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake @@ -0,0 +1,80 @@ +include(CMakeParseArguments) +include(CompilerRTUtils) + +function(get_aix_libatomic_default_link_flags link_flags export_list) + set(linkopts + "-Wl,-H512 -Wl,-D0 \ + -Wl,-T512 -Wl,-bhalt:4 -Wl,-bernotok \ + -Wl,-bnoentry -Wl,-bexport:${export_list} \ + -Wl,-bmodtype:SRE -Wl,-lc") + # Add `-Wl,-G`. Quoted from release notes of cmake-3.16.0 + # > On AIX, runtime linking is no longer enabled by default. + # See https://cmake.org/cmake/help/latest/release/3.16.html + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0") + set(linkopts "-Wl,-G" "${linkopts}") + endif() + set(${link_flags} ${linkopts} PARENT_SCOPE) +endfunction() + +function(get_aix_libatomic_type type) + if(${CMAKE_VERSION} VERSION_LESS "3.16.0") + set(${type} SHARED PARENT_SCOPE) + else() + set(${type} MODULE PARENT_SCOPE) + endif() +endfunction() + +macro(archive_aix_libatomic name) + cmake_parse_arguments(LIB + "" + "" + "ARCHS;PARENT_TARGET" + ${ARGN}) + set(shared_libraries_to_archive "") + foreach (arch ${LIB_ARCHS}) + if(CAN_TARGET_${arch}) + set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/libatomic-${arch}.dir") + # FIXME: Target name should be kept consistent with definition + # in AddCompilerRT.cmake added by + # add_compiler_rt_runtime( SHARED ...) + set(target ${name}-dynamic-${arch}) + if(TARGET ${target}) + file(MAKE_DIRECTORY ${output_dir}) + add_custom_command(OUTPUT "${output_dir}/libatomic.so.1" + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + copy "$" + "${output_dir}/libatomic.so.1" + # If built with MODULE, F_LOADONLY is set. + # We have to remove this flag at POST_BUILD. + COMMAND ${CMAKE_STRIP} -X32_64 -E + "${output_dir}/libatomic.so.1" + DEPENDS ${target}) + list(APPEND shared_libraries_to_archive "${output_dir}/libatomic.so.1") + endif() + endif() + endforeach() + if(shared_libraries_to_archive) + set(output_dir "") + set(install_dir "") + # If LLVM defines top level library directory, we want to deliver + # libatomic.a at top level. See `llvm/cmake/modules/AddLLVM.cmake' + # setting _install_rpath on AIX for reference. + if(LLVM_LIBRARY_OUTPUT_INTDIR AND CMAKE_INSTALL_PREFIX) + set(output_dir "${LLVM_LIBRARY_OUTPUT_INTDIR}") + set(install_dir "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}") + else() + get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir) + get_compiler_rt_install_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} install_dir) + endif() + add_custom_command(OUTPUT "${output_dir}/libatomic.a" + COMMAND ${CMAKE_AR} -X32_64 r "${output_dir}/libatomic.a" + ${shared_libraries_to_archive} + DEPENDS ${shared_libraries_to_archive}) + install(FILES "${output_dir}/libatomic.a" + DESTINATION ${install_dir}) + add_custom_target(aix-libatomic + DEPENDS "${output_dir}/libatomic.a") + endif() + add_dependencies(${LIB_PARENT_TARGET} aix-libatomic) +endmacro() diff --git a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTCompile.cmake b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTCompile.cmake index 07b589beb2d..1b42f24c08d 100644 --- a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTCompile.cmake +++ b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTCompile.cmake @@ -70,29 +70,36 @@ function(clang_compile object_file source) if (TARGET CompilerRTUnitTestCheckCxx) list(APPEND SOURCE_DEPS CompilerRTUnitTestCheckCxx) endif() - string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath}) - string(REGEX MATCH "[.](m|mm)$" is_objc ${source_rpath}) - if(is_cxx) - string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}") - else() - string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}") - endif() + if(COMPILER_RT_STANDALONE_BUILD) + # Only add global flags in standalone build. + string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath}) + if(is_cxx) + string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}") + else() + string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}") + endif() - if (MSVC) - translate_msvc_cflags(global_flags "${global_flags}") - endif() + if (MSVC) + translate_msvc_cflags(global_flags "${global_flags}") + endif() - if (APPLE) - set(global_flags ${OSX_SYSROOT_FLAG} ${global_flags}) + if (APPLE) + set(global_flags ${OSX_SYSROOT_FLAG} ${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) + set(compile_flags ${global_flags} ${SOURCE_CFLAGS}) + else() + set(compile_flags ${SOURCE_CFLAGS}) endif() + + string(REGEX MATCH "[.](m|mm)$" is_objc ${source_rpath}) if (is_objc) - list(APPEND global_flags -ObjC) + list(APPEND compile_flags "-ObjC") 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) - set(compile_flags ${global_flags} ${SOURCE_CFLAGS}) add_custom_command( OUTPUT ${object_file} COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c @@ -136,7 +143,7 @@ macro(clang_compiler_add_cxx_check) COMMAND bash -c "${CMD}" COMMENT "Checking that just-built clang can find C++ headers..." VERBATIM) - if (NOT COMPILER_RT_STANDALONE_BUILD AND NOT RUNTIMES_BUILD) + if (NOT COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD) ADD_DEPENDENCIES(CompilerRTUnitTestCheckCxx clang) endif() endif() diff --git a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake index be8d7e733c7..276fcbb9c0e 100644 --- a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake +++ b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake @@ -289,6 +289,15 @@ macro(darwin_add_builtin_library name suffix) endforeach(cflag) endif() + if ("${LIB_OS}" MATCHES ".*sim$") + # Pass an explicit -simulator environment to the -target option to ensure + # that we don't rely on the architecture to infer whether we're building + # for the simulator. + string(REGEX REPLACE "sim" "" base_os "${LIB_OS}") + list(APPEND builtin_cflags + -target "${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator") + endif() + set_target_compile_flags(${libname} ${sysroot_flag} ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG} @@ -386,12 +395,28 @@ macro(darwin_add_builtin_libraries) set(CMAKE_CXX_FLAGS "") set(CMAKE_ASM_FLAGS "") - set(PROFILE_SOURCES ../profile/InstrProfiling - ../profile/InstrProfilingBuffer - ../profile/InstrProfilingPlatformDarwin - ../profile/InstrProfilingWriter) + append_string_if(COMPILER_RT_HAS_ASM_LSE " -DHAS_ASM_LSE" CFLAGS) + + set(PROFILE_SOURCES ../profile/InstrProfiling.c + ../profile/InstrProfilingBuffer.c + ../profile/InstrProfilingPlatformDarwin.c + ../profile/InstrProfilingWriter.c + ../profile/InstrProfilingInternal.c + ../profile/InstrProfilingVersionVar.c) foreach (os ${ARGN}) list_intersect(DARWIN_BUILTIN_ARCHS DARWIN_${os}_BUILTIN_ARCHS BUILTIN_SUPPORTED_ARCH) + + if((arm64 IN_LIST DARWIN_BUILTIN_ARCHS OR arm64e IN_LIST DARWIN_BUILTIN_ARCHS) AND NOT TARGET lse_builtin_symlinks) + add_custom_target( + lse_builtin_symlinks + BYPRODUCTS ${lse_builtins} + ${arm64_lse_commands} + ) + + set(deps_arm64 lse_builtin_symlinks) + set(deps_arm64e lse_builtin_symlinks) + endif() + foreach (arch ${DARWIN_BUILTIN_ARCHS}) darwin_find_excluded_builtins_list(${arch}_${os}_EXCLUDED_BUILTINS OS ${os} @@ -406,6 +431,7 @@ macro(darwin_add_builtin_libraries) darwin_add_builtin_library(clang_rt builtins OS ${os} ARCH ${arch} + DEPS ${deps_${arch}} SOURCES ${filtered_sources} CFLAGS ${CFLAGS} -arch ${arch} PARENT_TARGET builtins) @@ -430,6 +456,7 @@ macro(darwin_add_builtin_libraries) darwin_add_builtin_library(clang_rt cc_kext OS ${os} ARCH ${arch} + DEPS ${deps_${arch}} SOURCES ${filtered_sources} ${PROFILE_SOURCES} CFLAGS ${CFLAGS} -arch ${arch} -mkernel DEFS KERNEL_USE @@ -444,21 +471,18 @@ macro(darwin_add_builtin_libraries) PARENT_TARGET builtins LIPO_FLAGS ${${os}_cc_kext_lipo_flags} DEPENDS ${${os}_cc_kext_libs} - OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR} - INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR}) + OUTPUT_DIR ${COMPILER_RT_OUTPUT_LIBRARY_DIR} + INSTALL_DIR ${COMPILER_RT_INSTALL_LIBRARY_DIR}) endif() endforeach() - # We put the x86 sim slices into the archives for their base OS foreach (os ${ARGN}) - if(NOT ${os} MATCHES ".*sim$") - darwin_lipo_libs(clang_rt.${os} - PARENT_TARGET builtins - LIPO_FLAGS ${${os}_builtins_lipo_flags} ${${os}sim_builtins_lipo_flags} - DEPENDS ${${os}_builtins_libs} ${${os}sim_builtins_libs} - OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR} - INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR}) - endif() + darwin_lipo_libs(clang_rt.${os} + PARENT_TARGET builtins + LIPO_FLAGS ${${os}_builtins_lipo_flags} + DEPENDS ${${os}_builtins_libs} + OUTPUT_DIR ${COMPILER_RT_OUTPUT_LIBRARY_DIR} + INSTALL_DIR ${COMPILER_RT_INSTALL_LIBRARY_DIR}) endforeach() darwin_add_embedded_builtin_libraries() endmacro() @@ -496,9 +520,9 @@ macro(darwin_add_embedded_builtin_libraries) set(DARWIN_macho_embedded_ARCHS armv6m armv7m armv7em armv7 i386 x86_64) set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR - ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded) + ${COMPILER_RT_OUTPUT_LIBRARY_DIR}/macho_embedded) set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR - ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded) + ${COMPILER_RT_INSTALL_LIBRARY_DIR}/macho_embedded) set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi") set(CFLAGS_i386 "-march=pentium") diff --git a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake new file mode 100644 index 00000000000..1080a4d0a79 --- /dev/null +++ b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake @@ -0,0 +1,75 @@ +# This macro mocks enough of the changes `LLVMConfig.cmake` makes so that +# compiler-rt can successfully configure itself when a LLVM toolchain is +# available but the corresponding CMake build files are not. +# +# The motivation for this is to be able to generate the compiler-rt +# lit tests suites and run them against an arbitrary LLVM toolchain +# which doesn't ship the LLVM CMake build files. +macro(compiler_rt_mock_llvm_cmake_config) + message(STATUS "Attempting to mock the changes made by LLVMConfig.cmake") + compiler_rt_mock_llvm_cmake_config_set_cmake_path() + compiler_rt_mock_llvm_cmake_config_set_target_triple() + compiler_rt_mock_llvm_cmake_config_include_cmake_files() +endmacro() + +macro(compiler_rt_mock_llvm_cmake_config_set_cmake_path) + # Point `LLVM_CMAKE_PATH` at the source tree in the monorepo. + set(LLVM_CMAKE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") + if (NOT EXISTS "${LLVM_CMAKE_PATH}") + message(FATAL_ERROR "LLVM_CMAKE_PATH (${LLVM_CMAKE_PATH}) does not exist") + endif() + list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") + message(STATUS "LLVM_CMAKE_PATH: \"${LLVM_CMAKE_PATH}\"") +endmacro() + +function(compiler_rt_mock_llvm_cmake_config_set_target_triple) + # Various bits of compiler-rt depend on the `TARGET_TRIPLE`variable being + # defined. This function tries to set a sensible value for the variable. + # This is a function rather than a macro to avoid polluting the variable + # namespace. + set(COMPILER_OUTPUT "") + + # If the user provides `COMPILER_RT_DEFAULT_TARGET_ONLY` and `CMAKE_C_COMPILER_TARGET` + # (see `construct_compiler_rt_default_triple`) then prefer that to examining the + # compiler. + if (COMPILER_RT_DEFAULT_TARGET_ONLY) + if (NOT "${CMAKE_C_COMPILER_TARGET}" STREQUAL "") + message(STATUS + "Using CMAKE_C_COMPILER_TARGET (${CMAKE_C_COMPILER_TARGET}) as TARGET_TRIPLE") + endif() + set(COMPILER_OUTPUT "${CMAKE_C_COMPILER_TARGET}") + endif() + + # Try asking the compiler for its default target triple. + set(HAD_ERROR FALSE) + if ("${COMPILER_OUTPUT}" STREQUAL "") + if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang|GNU") + # Note: Clang also supports `-print-target-triple` but gcc doesn't + # support this flag. + execute_process( + COMMAND "${CMAKE_C_COMPILER}" -dumpmachine + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE COMPILER_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + message(FATAL_ERROR + "Fetching target triple from compiler \"${CMAKE_C_COMPILER_ID}\" " + "is not implemented.") + endif() + endif() + + if (HAD_ERROR) + message(FATAL_ERROR "Fetching target triple from compiler failed") + endif() + set(TARGET_TRIPLE "${COMPILER_OUTPUT}") + message(STATUS "TARGET_TRIPLE: \"${TARGET_TRIPLE}\"") + if ("${TARGET_TRIPLE}" STREQUAL "") + message(FATAL_ERROR "TARGET_TRIPLE cannot be empty") + endif() + set(TARGET_TRIPLE "${TARGET_TRIPLE}" PARENT_SCOPE) +endfunction() + +macro(compiler_rt_mock_llvm_cmake_config_include_cmake_files) + # Some compiler-rt CMake code needs to call code in this file. + include("${LLVM_CMAKE_PATH}/AddLLVM.cmake") +endmacro() diff --git a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTUtils.cmake index 99b9f0e4af4..5543e3c6afc 100644 --- a/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTUtils.cmake +++ b/gnu/llvm/compiler-rt/cmake/Modules/CompilerRTUtils.cmake @@ -158,6 +158,7 @@ macro(detect_target_arch) check_symbol_exists(__i386__ "" __I386) check_symbol_exists(__mips__ "" __MIPS) check_symbol_exists(__mips64__ "" __MIPS64) + check_symbol_exists(__powerpc__ "" __PPC) check_symbol_exists(__powerpc64__ "" __PPC64) check_symbol_exists(__powerpc64le__ "" __PPC64LE) check_symbol_exists(__riscv "" __RISCV) @@ -172,17 +173,25 @@ macro(detect_target_arch) elseif(__AARCH64) add_default_target_arch(aarch64) elseif(__X86_64) - add_default_target_arch(x86_64) + if(CMAKE_SIZEOF_VOID_P EQUAL "4") + add_default_target_arch(x32) + elseif(CMAKE_SIZEOF_VOID_P EQUAL "8") + add_default_target_arch(x86_64) + else() + message(FATAL_ERROR "Unsupported pointer size for X86_64") + endif() elseif(__I386) add_default_target_arch(i386) elseif(__MIPS64) # must be checked before __MIPS add_default_target_arch(mips64) elseif(__MIPS) add_default_target_arch(mips) - elseif(__PPC64) + elseif(__PPC64) # must be checked before __PPC add_default_target_arch(powerpc64) elseif(__PPC64LE) add_default_target_arch(powerpc64le) + elseif(__PPC) + add_default_target_arch(powerpc) elseif(__RISCV) if(CMAKE_SIZEOF_VOID_P EQUAL "4") add_default_target_arch(riscv32) @@ -206,6 +215,57 @@ macro(detect_target_arch) endif() endmacro() +function(get_compiler_rt_root_source_dir ROOT_DIR_VAR) + # Compute the path to the root of the Compiler-RT source tree + # regardless of how the project was configured. + # + # This function is useful because using `${CMAKE_SOURCE_DIR}` + # is error prone due to the numerous ways Compiler-RT can be + # configured. + # + # `ROOT_DIR_VAR` - the name of the variable to write the result to. + # + # TODO(dliew): When CMake min version is 3.17 or newer use + # `CMAKE_CURRENT_FUNCTION_LIST_DIR` instead. + if ("${ROOT_DIR_VAR}" STREQUAL "") + message(FATAL_ERROR "ROOT_DIR_VAR cannot be empty") + endif() + + # Compiler-rt supports different source root paths. + # Handle each case here. + set(PATH_TO_COMPILER_RT_SOURCE_ROOT "") + if (DEFINED CompilerRTBuiltins_SOURCE_DIR) + # Compiler-RT Builtins standalone build. + # `llvm-project/compiler-rt/lib/builtins` + set(PATH_TO_COMPILER_RT_SOURCE_ROOT "${CompilerRTBuiltins_SOURCE_DIR}/../../") + elseif(DEFINED CompilerRT_SOURCE_DIR) + # Compiler-RT standalone build. + # `llvm-project/compiler-rt` + set(PATH_TO_COMPILER_RT_SOURCE_ROOT "${CompilerRT_SOURCE_DIR}") + elseif (EXISTS "${CMAKE_SOURCE_DIR}/../compiler-rt") + # In tree build with LLVM as the root project. + # See `llvm-project/projects/`. + # Assumes monorepo layout. + set(PATH_TO_COMPILER_RT_SOURCE_ROOT "${CMAKE_SOURCE_DIR}/../compiler-rt") + else() + message(FATAL_ERROR "Unhandled Compiler-RT source root configuration.") + endif() + + get_filename_component(ROOT_DIR "${PATH_TO_COMPILER_RT_SOURCE_ROOT}" ABSOLUTE) + if (NOT EXISTS "${ROOT_DIR}") + message(FATAL_ERROR "Path \"${ROOT_DIR}\" doesn't exist") + endif() + + # Sanity check: Make sure we can locate the current source file via the + # computed path. + set(PATH_TO_CURRENT_FILE "${ROOT_DIR}/cmake/Modules/CompilerRTUtils.cmake") + if (NOT EXISTS "${PATH_TO_CURRENT_FILE}") + message(FATAL_ERROR "Could not find \"${PATH_TO_CURRENT_FILE}\"") + endif() + + set("${ROOT_DIR_VAR}" "${ROOT_DIR}" PARENT_SCOPE) +endfunction() + macro(load_llvm_config) if (NOT LLVM_CONFIG_PATH) find_program(LLVM_CONFIG_PATH "llvm-config" @@ -216,6 +276,20 @@ macro(load_llvm_config) "Reconfigure with -DLLVM_CONFIG_PATH=path/to/llvm-config.") endif() endif() + + # Compute path to LLVM sources assuming the monorepo layout. + # We don't set `LLVM_MAIN_SRC_DIR` directly to avoid overriding a user provided + # CMake cache value. + get_compiler_rt_root_source_dir(COMPILER_RT_ROOT_SRC_PATH) + get_filename_component(LLVM_MAIN_SRC_DIR_DEFAULT "${COMPILER_RT_ROOT_SRC_PATH}/../llvm" ABSOLUTE) + if (NOT EXISTS "${LLVM_MAIN_SRC_DIR_DEFAULT}") + # TODO(dliew): Remove this legacy fallback path. + message(WARNING + "LLVM source tree not found at \"${LLVM_MAIN_SRC_DIR_DEFAULT}\". " + "You are not using the monorepo layout. This configuration is DEPRECATED.") + endif() + + set(FOUND_LLVM_CMAKE_PATH FALSE) if (LLVM_CONFIG_PATH) execute_process( COMMAND ${LLVM_CONFIG_PATH} "--obj-root" "--bindir" "--libdir" "--src-root" "--includedir" @@ -233,10 +307,20 @@ macro(load_llvm_config) set(LLVM_BINARY_DIR ${BINARY_DIR} CACHE PATH "Path to LLVM build tree") set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") - set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Paths to LLVM headers") + if (NOT EXISTS "${LLVM_MAIN_SRC_DIR_DEFAULT}") + # TODO(dliew): Remove this legacy fallback path. + message(WARNING + "Consulting llvm-config for the LLVM source path " + "as a fallback. This behavior will be removed in the future.") + # We don't set `LLVM_MAIN_SRC_DIR` directly to avoid overriding a user + # provided CMake cache value. + set(LLVM_MAIN_SRC_DIR_DEFAULT "${MAIN_SRC_DIR}") + message(STATUS "Using LLVM source path (${LLVM_MAIN_SRC_DIR_DEFAULT}) from llvm-config") + endif() + # Detect if we have the LLVMXRay and TestingSupport library installed and # available from llvm-config. execute_process( @@ -295,13 +379,44 @@ macro(load_llvm_config) set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR_CMAKE_STYLE}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") endif() - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") - # Get some LLVM variables from LLVMConfig. - include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake") + set(LLVM_CMAKE_INCLUDE_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") + if (EXISTS "${LLVM_CMAKE_INCLUDE_FILE}") + list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") + # Get some LLVM variables from LLVMConfig. + include("${LLVM_CMAKE_INCLUDE_FILE}") + set(FOUND_LLVM_CMAKE_PATH TRUE) + else() + set(FOUND_LLVM_CMAKE_PATH FALSE) + message(WARNING "LLVM CMake path (${LLVM_CMAKE_INCLUDE_FILE}) reported by llvm-config does not exist") + endif() + unset(LLVM_CMAKE_INCLUDE_FILE) set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) endif() + + # Finally set the cache variable now that `llvm-config` has also had a chance + # to set `LLVM_MAIN_SRC_DIR_DEFAULT`. + set(LLVM_MAIN_SRC_DIR "${LLVM_MAIN_SRC_DIR_DEFAULT}" CACHE PATH "Path to LLVM source tree") + message(STATUS "LLVM_MAIN_SRC_DIR: \"${LLVM_MAIN_SRC_DIR}\"") + if (NOT EXISTS "${LLVM_MAIN_SRC_DIR}") + # TODO(dliew): Make this a hard error + message(WARNING "LLVM_MAIN_SRC_DIR (${LLVM_MAIN_SRC_DIR}) does not exist. " + "You can override the inferred path by adding " + "`-DLLVM_MAIN_SRC_DIR=` to your CMake invocation " + "where `` is the path to the `llvm` directory in " + "the `llvm-project` repo. " + "This will be treated as error in the future.") + endif() + + if (NOT FOUND_LLVM_CMAKE_PATH) + # This configuration tries to configure without the prescence of `LLVMConfig.cmake`. It is + # intended for testing purposes (generating the lit test suites) and will likely not support + # a build of the runtimes in compiler-rt. + include(CompilerRTMockLLVMCMakeConfig) + compiler_rt_mock_llvm_cmake_config() + endif() + endmacro() macro(construct_compiler_rt_default_triple) @@ -323,6 +438,14 @@ macro(construct_compiler_rt_default_triple) string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE}) list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_DEFAULT_TARGET_ARCH) + + # Map various forms of the architecture names to the canonical forms + # (as they are used by clang, see getArchNameForCompilerRTLib). + if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "^i.86$") + # Android uses i686, but that's remapped at a later stage. + set(COMPILER_RT_DEFAULT_TARGET_ARCH "i386") + endif() + # Determine if test target triple is specified explicitly, and doesn't match the # default. if(NOT COMPILER_RT_DEFAULT_TARGET_TRIPLE STREQUAL TARGET_TRIPLE) @@ -375,18 +498,18 @@ endfunction() function(get_compiler_rt_install_dir arch install_dir) if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) get_compiler_rt_target(${arch} target) - set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/lib/${target} PARENT_SCOPE) + set(${install_dir} ${COMPILER_RT_INSTALL_LIBRARY_DIR}/${target} PARENT_SCOPE) else() - set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE) + set(${install_dir} ${COMPILER_RT_INSTALL_LIBRARY_DIR} PARENT_SCOPE) endif() endfunction() function(get_compiler_rt_output_dir arch output_dir) if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) get_compiler_rt_target(${arch} target) - set(${output_dir} ${COMPILER_RT_OUTPUT_DIR}/lib/${target} PARENT_SCOPE) + set(${output_dir} ${COMPILER_RT_OUTPUT_LIBRARY_DIR}/${target} PARENT_SCOPE) else() - set(${output_dir} ${COMPILER_RT_LIBRARY_OUTPUT_DIR} PARENT_SCOPE) + set(${output_dir} ${COMPILER_RT_OUTPUT_LIBRARY_DIR} PARENT_SCOPE) endif() endfunction() diff --git a/gnu/llvm/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt b/gnu/llvm/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt index e61c222587e..6c6680023c7 100644 --- a/gnu/llvm/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt +++ b/gnu/llvm/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt @@ -1,8 +1,12 @@ -cmake_minimum_required(VERSION 3.4.3) +# TODO(phosek): We should use the runtimes build instead configured with +# LLVM_ENABLE_RUNTIMES=libcxxabi;libcxx to avoid duplication of logic. + +cmake_minimum_required(VERSION 3.13.4) project(custom-libcxx C CXX) +find_package(Python3 REQUIRED COMPONENTS Interpreter) + # Build static libcxxabi. -set(LIBCXXABI_STANDALONE_BUILD 1) set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") set(LIBCXXABI_ENABLE_EXCEPTIONS ON CACHE BOOL "") set(LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE STRING "") @@ -11,7 +15,6 @@ set(LIBCXXABI_INCLUDE_TESTS OFF CACHE BOOL "") add_subdirectory(${COMPILER_RT_LIBCXXABI_PATH} ${CMAKE_CURRENT_BINARY_DIR}/cxxabi) # Build static libcxx without exceptions. -set(LIBCXX_STANDALONE_BUILD 1) set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") diff --git a/gnu/llvm/compiler-rt/cmake/Modules/UseLibtool.cmake b/gnu/llvm/compiler-rt/cmake/Modules/UseLibtool.cmake index 38d197d4846..130810c970d 100644 --- a/gnu/llvm/compiler-rt/cmake/Modules/UseLibtool.cmake +++ b/gnu/llvm/compiler-rt/cmake/Modules/UseLibtool.cmake @@ -34,6 +34,14 @@ if(CMAKE_LIBTOOL) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_LIBTOOL}\" -static ${LIBTOOL_NO_WARNING_FLAG} -o ") endforeach() + + # By default, CMake invokes ranlib on a static library after installing it. + # libtool will have produced the table of contents for us already, and ranlib + # does not understanding universal binaries, so skip this step. It's important + # to set it to empty instead of unsetting it to shadow the cache variable, and + # we don't want to unset the cache variable to not affect anything outside + # this scope. + set(CMAKE_RANLIB "") endif() # If DYLD_LIBRARY_PATH is set we need to set it on archiver commands diff --git a/gnu/llvm/compiler-rt/cmake/base-config-ix.cmake b/gnu/llvm/compiler-rt/cmake/base-config-ix.cmake index 964dd598f10..c11342e6881 100644 --- a/gnu/llvm/compiler-rt/cmake/base-config-ix.cmake +++ b/gnu/llvm/compiler-rt/cmake/base-config-ix.cmake @@ -5,7 +5,6 @@ include(CheckIncludeFile) include(CheckCXXSourceCompiles) -include(TestBigEndian) check_include_file(unwind.h HAVE_UNWIND_H) @@ -69,8 +68,8 @@ else() "Path where built compiler-rt libraries should be stored.") set(COMPILER_RT_EXEC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH "Path where built compiler-rt executables should be stored.") - set(COMPILER_RT_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH - "Path where built compiler-rt libraries should be installed.") + set(COMPILER_RT_INSTALL_PATH "" CACHE PATH + "Prefix for directories where built compiler-rt artifacts should be installed.") option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." OFF) option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" OFF) # Use a host compiler to compile/link tests. @@ -86,20 +85,45 @@ else() set(COMPILER_RT_TEST_COMPILER_ID GNU) endif() +function(extend_install_path joined_path current_segment) + if("${current_segment}" STREQUAL "") + set(temp_path "${COMPILER_RT_INSTALL_PATH}") + elseif("${COMPILER_RT_INSTALL_PATH}" STREQUAL "") + set(temp_path "${current_segment}") + elseif(IS_ABSOLUTE "${current_segment}") + message(WARNING "Since \"${current_segment}\" is absolute, it overrides COMPILER_RT_INSTALL_PATH: \"${COMPILER_RT_INSTALL_PATH}\".") + set(temp_path "${current_segment}") + else() + set(temp_path "${COMPILER_RT_INSTALL_PATH}/${current_segment}") + endif() + set(${joined_path} "${temp_path}" PARENT_SCOPE) +endfunction() + if(NOT DEFINED COMPILER_RT_OS_DIR) string(TOLOWER ${CMAKE_SYSTEM_NAME} COMPILER_RT_OS_DIR) endif() if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(COMPILER_RT_LIBRARY_OUTPUT_DIR - ${COMPILER_RT_OUTPUT_DIR}) - set(COMPILER_RT_LIBRARY_INSTALL_DIR - ${COMPILER_RT_INSTALL_PATH}) -else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) - set(COMPILER_RT_LIBRARY_OUTPUT_DIR + set(COMPILER_RT_OUTPUT_LIBRARY_DIR + ${COMPILER_RT_OUTPUT_DIR}/lib) + extend_install_path(default_install_path lib) + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt libraries should be installed.") +else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(COMPILER_RT_OUTPUT_LIBRARY_DIR ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR}) - set(COMPILER_RT_LIBRARY_INSTALL_DIR - ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR}) + extend_install_path(default_install_path "lib/${COMPILER_RT_OS_DIR}") + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt libraries should be installed.") endif() +extend_install_path(default_install_path bin) +set(COMPILER_RT_INSTALL_BINARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt executables should be installed.") +extend_install_path(default_install_path include) +set(COMPILER_RT_INSTALL_INCLUDE_DIR "${default_install_path}" CACHE PATH + "Path where compiler-rt headers should be installed.") +extend_install_path(default_install_path share) +set(COMPILER_RT_INSTALL_DATA_DIR "${default_install_path}" CACHE PATH + "Path where compiler-rt data files should be installed.") if(APPLE) # On Darwin if /usr/include/c++ doesn't exist, the user probably has Xcode but @@ -171,16 +195,8 @@ macro(test_targets) add_default_target_arch(${COMPILER_RT_DEFAULT_TARGET_ARCH}) elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64") if(NOT MSVC) - if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD") - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - test_target_arch(i386 __i386__ "-m32") - else() - test_target_arch(x86_64 "" "-m64") - endif() - else() - test_target_arch(x86_64 "" "-m64") - test_target_arch(i386 __i386__ "-m32") - endif() + test_target_arch(x86_64 "" "-m64") + test_target_arch(i386 __i386__ "-m32") else() if (CMAKE_SIZEOF_VOID_P EQUAL 4) test_target_arch(i386 "" "") @@ -188,19 +204,13 @@ macro(test_targets) test_target_arch(x86_64 "" "") endif() endif() + elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64le") + test_target_arch(powerpc64le "" "-m64") elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc") - # Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration - # will fail with this option when building with a sanitizer. - cmake_push_check_state() - string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN) - cmake_pop_check_state() - - if(HOST_IS_BIG_ENDIAN) - test_target_arch(powerpc64 "" "-m64") - else() - test_target_arch(powerpc64le "" "-m64") + if(CMAKE_SYSTEM_NAME MATCHES "AIX") + test_target_arch(powerpc "" "-m32") endif() + test_target_arch(powerpc64 "" "-m64") elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x") test_target_arch(s390x "" "") elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "sparc") diff --git a/gnu/llvm/compiler-rt/cmake/builtin-config-ix.cmake b/gnu/llvm/compiler-rt/cmake/builtin-config-ix.cmake index 8de901513be..fe5661b7763 100644 --- a/gnu/llvm/compiler-rt/cmake/builtin-config-ix.cmake +++ b/gnu/llvm/compiler-rt/cmake/builtin-config-ix.cmake @@ -10,7 +10,6 @@ builtin_check_c_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG) builtin_check_c_compiler_flag(-fno-builtin COMPILER_RT_HAS_FNO_BUILTIN_FLAG) builtin_check_c_compiler_flag(-std=c11 COMPILER_RT_HAS_STD_C11_FLAG) builtin_check_c_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG) -builtin_check_c_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG) builtin_check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FREESTANDING_FLAG) builtin_check_c_compiler_flag(-fxray-instrument COMPILER_RT_HAS_XRAY_COMPILER_FLAG) @@ -22,14 +21,28 @@ int foo(int x, int y) { } ") +builtin_check_c_compiler_source(COMPILER_RT_HAS_FLOAT16 +" +_Float16 foo(_Float16 x) { + return x; +} +" +) + +builtin_check_c_compiler_source(COMPILER_RT_HAS_ASM_LSE +" +asm(\".arch armv8-a+lse\"); +asm(\"cas w0, w1, [x2]\"); +") set(ARM64 aarch64) -set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) +set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv8m.main armv8.1m.main) set(HEXAGON hexagon) set(X86 i386) set(X86_64 x86_64) set(MIPS32 mips mipsel) set(MIPS64 mips64 mips64el) +set(PPC32 powerpc) set(PPC64 powerpc64 powerpc64le) set(RISCV32 riscv32) set(RISCV64 riscv64) @@ -47,7 +60,7 @@ endif() set(ALL_BUILTIN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} - ${HEXAGON} ${MIPS32} ${MIPS64} ${PPC64} + ${HEXAGON} ${MIPS32} ${MIPS64} ${PPC32} ${PPC64} ${RISCV32} ${RISCV64} ${SPARC} ${SPARCV9} ${WASM32} ${WASM64} ${VE}) @@ -108,7 +121,7 @@ if(APPLE) set(DARWIN_watchos_BUILTIN_MIN_VER 2.0) set(DARWIN_watchos_BUILTIN_MIN_VER_FLAG ${DARWIN_watchos_MIN_VER_FLAG}=${DARWIN_watchos_BUILTIN_MIN_VER}) - set(DARWIN_watchos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 armv7k) + set(DARWIN_watchos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 armv7k arm64_32) set(DARWIN_watchossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86}) endif() if(COMPILER_RT_ENABLE_TVOS) diff --git a/gnu/llvm/compiler-rt/cmake/config-ix.cmake b/gnu/llvm/compiler-rt/cmake/config-ix.cmake index 2edc1dabd90..39b9120f00a 100644 --- a/gnu/llvm/compiler-rt/cmake/config-ix.cmake +++ b/gnu/llvm/compiler-rt/cmake/config-ix.cmake @@ -6,7 +6,7 @@ include(CheckLibraryExists) include(CheckSymbolExists) include(TestBigEndian) -function(check_linker_flag flag out_var) +function(compiler_rt_check_linker_flag flag out_var) cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") check_cxx_compiler_flag("" ${out_var}) @@ -55,6 +55,7 @@ endif () # CodeGen options. check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG) +check_c_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG) check_c_compiler_flag(-std=c11 COMPILER_RT_HAS_STD_C11_FLAG) check_cxx_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG) check_cxx_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG) @@ -106,6 +107,7 @@ check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" COMPILER_RT_HAS_WNON_VIRT check_cxx_compiler_flag("-Werror -Wvariadic-macros" COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG) check_cxx_compiler_flag("-Werror -Wunused-parameter" COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG) check_cxx_compiler_flag("-Werror -Wcovered-switch-default" COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG) +check_cxx_compiler_flag("-Werror -Wsuggest-override" COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG) check_cxx_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC) check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG) @@ -121,7 +123,9 @@ check_cxx_compiler_flag(/wd4800 COMPILER_RT_HAS_WD4800_FLAG) check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL) # Includes. -check_include_files("sys/auxv.h" COMPILER_RT_HAS_AUXV) +check_cxx_compiler_flag(-nostdinc++ COMPILER_RT_HAS_NOSTDINCXX_FLAG) +check_cxx_compiler_flag(-nostdlib++ COMPILER_RT_HAS_NOSTDLIBXX_FLAG) +check_include_files("sys/auxv.h" COMPILER_RT_HAS_AUXV) # Libraries. check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL) @@ -131,17 +135,18 @@ check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD) check_library_exists(execinfo backtrace "" COMPILER_RT_HAS_LIBEXECINFO) # Look for terminfo library, used in unittests that depend on LLVMSupport. +if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON) + set(MAYBE_REQUIRED REQUIRED) +else() + set(MAYBE_REQUIRED) +endif() if(LLVM_ENABLE_TERMINFO) - foreach(library terminfo tinfo curses ncurses ncursesw) - string(TOUPPER ${library} library_suffix) - check_library_exists( - ${library} setupterm "" COMPILER_RT_HAS_TERMINFO_${library_suffix}) - if(COMPILER_RT_HAS_TERMINFO_${library_suffix}) - set(COMPILER_RT_HAS_TERMINFO TRUE) - set(COMPILER_RT_TERMINFO_LIB "${library}") - break() - endif() - endforeach() + find_library(COMPILER_RT_TERMINFO_LIB NAMES terminfo tinfo curses ncurses ncursesw ${MAYBE_REQUIRED}) +endif() +if(COMPILER_RT_TERMINFO_LIB) + set(LLVM_ENABLE_TERMINFO 1) +else() + set(LLVM_ENABLE_TERMINFO 0) endif() if (ANDROID AND COMPILER_RT_HAS_LIBDL) @@ -152,11 +157,24 @@ check_library_exists(c++ __cxa_throw "" COMPILER_RT_HAS_LIBCXX) check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX) # Linker flags. -check_linker_flag("-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT) -check_linker_flag("-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) +compiler_rt_check_linker_flag("-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT) +compiler_rt_check_linker_flag("-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) + +set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat") +compiler_rt_check_linker_flag("${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT) + +set(DUMMY_VERS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/dummy.vers) +file(WRITE ${DUMMY_VERS} "{};") +set(VERS_OPTION "-Wl,--version-script,${DUMMY_VERS}") +if(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT) + # Solaris 11.4 ld only supports --version-script with + # -z gnu-version-script-compat. + string(APPEND VERS_OPTION " ${VERS_COMPAT_OPTION}") +endif() +compiler_rt_check_linker_flag("${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT) if(ANDROID) - check_linker_flag("-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL) + compiler_rt_check_linker_flag("-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL) check_library_exists(log __android_log_write "" COMPILER_RT_HAS_LIBLOG) endif() @@ -202,7 +220,7 @@ endfunction() # specific architecture. When cross-compiling, this is controled via # COMPILER_RT_TEST_COMPILER and COMPILER_RT_TEST_COMPILER_CFLAGS. macro(get_test_cc_for_arch arch cc_out cflags_out) - if(ANDROID OR ${arch} MATCHES "arm|aarch64") + if(ANDROID OR ${arch} MATCHES "arm|aarch64|riscv32|riscv64") # This is only true if we are cross-compiling. # Build all tests with host compiler and use host tools. set(${cc_out} ${COMPILER_RT_TEST_COMPILER}) @@ -261,6 +279,7 @@ set(X86 i386) set(X86_64 x86_64) set(MIPS32 mips mipsel) set(MIPS64 mips64 mips64el) +set(PPC32 powerpc) set(PPC64 powerpc64 powerpc64le) set(RISCV32 riscv32) set(RISCV64 riscv64) @@ -269,6 +288,7 @@ set(SPARC sparc) set(SPARCV9 sparcv9) set(WASM32 wasm32) set(WASM64 wasm64) +set(VE ve) if(APPLE) set(ARM64 arm64) @@ -278,9 +298,9 @@ endif() set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} ${RISCV64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9}) -set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} +set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64} ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9}) -set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV32} ${RISCV64}) +set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV32} ${RISCV64} ${VE}) set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64}) if(ANDROID) @@ -290,7 +310,7 @@ else() endif() if(OS_NAME MATCHES "Linux") - set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64}) + set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${S390X}) elseif (OS_NAME MATCHES "Windows") set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64}) elseif(OS_NAME MATCHES "Android") @@ -299,23 +319,24 @@ else() set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64}) endif() -set(ALL_GWP_ASAN_SUPPORTED_ARCH ${X86} ${X86_64}) +set(ALL_GWP_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}) if(APPLE) set(ALL_LSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64} ${ARM64}) else() - set(ALL_LSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64} ${ARM64} ${ARM32} ${PPC64} ${S390X}) + set(ALL_LSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64} ${ARM64} ${ARM32} ${PPC64} ${S390X} ${RISCV64}) endif() set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}) set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64}) -set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC64} +set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64}) +set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} ${PPC64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9}) -set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64}) +set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}) set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64} ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9}) set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${MIPS32} ${MIPS64}) set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS64}) set(ALL_SCUDO_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${PPC64}) -set(ALL_SCUDO_STANDALONE_SUPPORTED_ARCH ${X86} ${X86_64}) +set(ALL_SCUDO_STANDALONE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${PPC64}) if(APPLE) set(ALL_XRAY_SUPPORTED_ARCH ${X86_64}) else() @@ -323,6 +344,10 @@ set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} powe endif() set(ALL_SHADOWCALLSTACK_SUPPORTED_ARCH ${ARM64}) +if (UNIX) +set(ALL_ORC_SUPPORTED_ARCH ${X86_64}) +endif() + if(APPLE) include(CompilerRTDarwinUtils) @@ -379,6 +404,7 @@ if(APPLE) set(TSAN_SUPPORTED_OS osx) set(XRAY_SUPPORTED_OS osx) set(FUZZER_SUPPORTED_OS osx) + set(ORC_SUPPORTED_OS osx) # Note: In order to target x86_64h on OS X the minimum deployment target must # be 10.8 or higher. @@ -412,7 +438,7 @@ if(APPLE) -lc++ -lc++abi) - check_linker_flag("-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION) + compiler_rt_check_linker_flag("-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION) if(COMPILER_RT_HAS_APP_EXTENSION) list(APPEND DARWIN_COMMON_LINK_FLAGS "-fapplication-extension") endif() @@ -534,6 +560,9 @@ if(APPLE) list_intersect(HWASAN_SUPPORTED_ARCH ALL_HWASAN_SUPPORTED_ARCH SANITIZER_COMMON_SUPPORTED_ARCH) + list_intersect(MEMPROF_SUPPORTED_ARCH + ALL_MEMPROF_SUPPORTED_ARCH + SANITIZER_COMMON_SUPPORTED_ARCH) list_intersect(PROFILE_SUPPORTED_ARCH ALL_PROFILE_SUPPORTED_ARCH SANITIZER_COMMON_SUPPORTED_ARCH) @@ -564,6 +593,9 @@ if(APPLE) list_intersect(SHADOWCALLSTACK_SUPPORTED_ARCH ALL_SHADOWCALLSTACK_SUPPORTED_ARCH SANITIZER_COMMON_SUPPORTED_ARCH) + list_intersect(ORC_SUPPORTED_ARCH + ALL_ORC_SUPPORTED_ARCH + SANITIZER_COMMON_SUPPORTED_ARCH) else() filter_available_targets(CRT_SUPPORTED_ARCH ${ALL_CRT_SUPPORTED_ARCH}) @@ -582,6 +614,7 @@ else() filter_available_targets(LSAN_SUPPORTED_ARCH ${ALL_LSAN_SUPPORTED_ARCH}) filter_available_targets(MSAN_SUPPORTED_ARCH ${ALL_MSAN_SUPPORTED_ARCH}) filter_available_targets(HWASAN_SUPPORTED_ARCH ${ALL_HWASAN_SUPPORTED_ARCH}) + filter_available_targets(MEMPROF_SUPPORTED_ARCH ${ALL_MEMPROF_SUPPORTED_ARCH}) filter_available_targets(PROFILE_SUPPORTED_ARCH ${ALL_PROFILE_SUPPORTED_ARCH}) filter_available_targets(TSAN_SUPPORTED_ARCH ${ALL_TSAN_SUPPORTED_ARCH}) filter_available_targets(UBSAN_SUPPORTED_ARCH ${ALL_UBSAN_SUPPORTED_ARCH}) @@ -594,6 +627,7 @@ else() filter_available_targets(SHADOWCALLSTACK_SUPPORTED_ARCH ${ALL_SHADOWCALLSTACK_SUPPORTED_ARCH}) filter_available_targets(GWP_ASAN_SUPPORTED_ARCH ${ALL_GWP_ASAN_SUPPORTED_ARCH}) + filter_available_targets(ORC_SUPPORTED_ARCH ${ALL_ORC_SUPPORTED_ARCH}) endif() if (MSVC) @@ -608,7 +642,8 @@ else() set(CAN_SYMBOLIZE 1) endif() -find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold ${LLVM_DEFAULT_TARGET_TRIPLE}-ld ld DOC "The gold linker") +find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld") +find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold DOC "GNU gold") if(COMPILER_RT_SUPPORTED_ARCH) list(REMOVE_DUPLICATES COMPILER_RT_SUPPORTED_ARCH) @@ -621,7 +656,7 @@ set(COMPILER_RT_SANITIZERS_TO_BUILD all CACHE STRING list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}") if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND - (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD|NetBSD|OpenBSD|Fuchsia|SunOS" OR + (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD|NetBSD|Fuchsia|SunOS" OR (OS_NAME MATCHES "Windows" AND NOT CYGWIN AND (NOT MINGW OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")))) set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE) @@ -635,8 +670,7 @@ else() set(COMPILER_RT_HAS_INTERCEPTION FALSE) endif() -if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH AND - NOT OS_NAME MATCHES "OpenBSD") +if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH) set(COMPILER_RT_HAS_ASAN TRUE) else() set(COMPILER_RT_HAS_ASAN FALSE) @@ -664,7 +698,7 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND LSAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|NetBSD|Fuchsia") + OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|Fuchsia") set(COMPILER_RT_HAS_LSAN TRUE) else() set(COMPILER_RT_HAS_LSAN FALSE) @@ -684,8 +718,15 @@ else() set(COMPILER_RT_HAS_HWASAN FALSE) endif() +if (COMPILER_RT_HAS_SANITIZER_COMMON AND MEMPROF_SUPPORTED_ARCH AND + OS_NAME MATCHES "Linux") + set(COMPILER_RT_HAS_MEMPROF TRUE) +else() + set(COMPILER_RT_HAS_MEMPROF FALSE) +endif() + if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD") + OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX") set(COMPILER_RT_HAS_PROFILE TRUE) else() set(COMPILER_RT_HAS_PROFILE FALSE) @@ -699,14 +740,14 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|OpenBSD|Windows|Android|Fuchsia|SunOS") + OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|Windows|Android|Fuchsia|SunOS") set(COMPILER_RT_HAS_UBSAN TRUE) else() set(COMPILER_RT_HAS_UBSAN FALSE) endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Linux|FreeBSD|NetBSD|OpenBSD|Android|Darwin") + OS_NAME MATCHES "Linux|FreeBSD|NetBSD|Android|Darwin") set(COMPILER_RT_HAS_UBSAN_MINIMAL TRUE) else() set(COMPILER_RT_HAS_UBSAN_MINIMAL FALSE) @@ -741,14 +782,20 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND XRAY_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|OpenBSD|Fuchsia") + OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|Fuchsia") set(COMPILER_RT_HAS_XRAY TRUE) else() set(COMPILER_RT_HAS_XRAY FALSE) endif() +if (ORC_SUPPORTED_ARCH) + set(COMPILER_RT_HAS_ORC TRUE) +else() + set(COMPILER_RT_HAS_ORC FALSE) +endif() + if (COMPILER_RT_HAS_SANITIZER_COMMON AND FUZZER_SUPPORTED_ARCH AND - OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|FreeBSD|OpenBSD|Fuchsia|Windows") + OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|FreeBSD|Fuchsia|Windows") set(COMPILER_RT_HAS_FUZZER TRUE) else() set(COMPILER_RT_HAS_FUZZER FALSE) diff --git a/gnu/llvm/compiler-rt/docs/BuildingCompilerRT.rst b/gnu/llvm/compiler-rt/docs/BuildingCompilerRT.rst new file mode 100644 index 00000000000..2ab6f083fc6 --- /dev/null +++ b/gnu/llvm/compiler-rt/docs/BuildingCompilerRT.rst @@ -0,0 +1,92 @@ +.. _BuildingCompilerRT: + +=============== +Building Compiler-RT +=============== + +.. contents:: + :local: + +.. _build instructions: + +The instructions on this page are aimed at vendors who ship Compiler-RT as part of an +operating system distribution, a toolchain or similar shipping vehicules. If you +are a user merely trying to use Compiler-RT in your program, you most likely want to +refer to your vendor's documentation, or to the general documentation for using +LLVM, Clang, the various santizers, etc. + +CMake Options +============= + +Here are some of the CMake variables that are used often, along with a +brief explanation and LLVM-specific notes. For full documentation, check the +CMake docs or execute ``cmake --help-variable VARIABLE_NAME``. + +**CMAKE_BUILD_TYPE**:STRING + Sets the build type for ``make`` based generators. Possible values are + Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio + the user sets the build type with the IDE settings. + +**CMAKE_INSTALL_PREFIX**:PATH + Path where LLVM will be installed if "make install" is invoked or the + "INSTALL" target is built. + +**CMAKE_CXX_COMPILER**:STRING + The C++ compiler to use when building and testing Compiler-RT. + + +.. _compiler-rt-specific options: + +Compiler-RT specific options +----------------------- + +.. option:: COMPILER_RT_INSTALL_PATH:PATH + + **Default**: ```` (empty relative path) + + Prefix for directories where built Compiler-RT artifacts should be installed. + Can be an absolute path, like the default empty string, in which case it is + relative ``CMAKE_INSTALL_PREFIX``. If setting a relative path, make sure to + include the ``:PATH`` with your ``-D``, i.e. use + ``-DCOMPILER_RT_INSTALL_PATH:PATH=...`` not + ``-DCOMPILER_RT_INSTALL_PATH=...``, otherwise CMake will convert the + path to an absolute path. + +.. option:: COMPILER_RT_INSTALL_LIBRARY_DIR:PATH + + **Default**: ``lib`` + + Path where built Compiler-RT libraries should be installed. If a relative + path, relative to ``COMPILER_RT_INSTALL_PATH``. + +.. option:: COMPILER_RT_INSTALL_BINARY_DIR:PATH + + **Default**: ``bin`` + + Path where built Compiler-RT executables should be installed. If a relative + path, relative to ``COMPILER_RT_INSTALL_PATH``. + +.. option:: COMPILER_RT_INSTALL_INCLUDE_DIR:PATH + + **Default**: ``include`` + + Path where Compiler-RT headers should be installed. If a relative + path, relative to ``COMPILER_RT_INSTALL_PATH``. + +.. option:: COMPILER_RT_INSTALL_DATA_DIR:PATH + + **Default**: ``share`` + + Path where Compiler-RT data should be installed. If a relative + path, relative to ``COMPILER_RT_INSTALL_PATH``. + +.. _LLVM-specific variables: + +LLVM-specific options +--------------------- + +.. option:: LLVM_LIBDIR_SUFFIX:STRING + + Extra suffix to append to the directory where libraries are to be + installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64`` + to install libraries to ``/usr/lib64``. diff --git a/gnu/llvm/compiler-rt/include/CMakeLists.txt b/gnu/llvm/compiler-rt/include/CMakeLists.txt index d47d7baeb11..7b415f0b88a 100644 --- a/gnu/llvm/compiler-rt/include/CMakeLists.txt +++ b/gnu/llvm/compiler-rt/include/CMakeLists.txt @@ -20,6 +20,12 @@ if (COMPILER_RT_BUILD_SANITIZERS) ) endif(COMPILER_RT_BUILD_SANITIZERS) +if (COMPILER_RT_BUILD_MEMPROF) + set(MEMPROF_HEADERS + sanitizer/memprof_interface.h + ) +endif(COMPILER_RT_BUILD_MEMPROF) + if (COMPILER_RT_BUILD_XRAY) set(XRAY_HEADERS xray/xray_interface.h @@ -37,6 +43,7 @@ endif(COMPILER_RT_BUILD_PROFILE) set(COMPILER_RT_HEADERS ${SANITIZER_HEADERS} ${FUZZER_HEADERS} + ${MEMPROF_HEADERS} ${XRAY_HEADERS} ${PROFILE_HEADERS}) @@ -62,22 +69,22 @@ set_target_properties(compiler-rt-headers PROPERTIES FOLDER "Compiler-RT Misc") install(FILES ${SANITIZER_HEADERS} COMPONENT compiler-rt-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer) + DESTINATION ${COMPILER_RT_INSTALL_INCLUDE_DIR}/sanitizer) # Install fuzzer headers. install(FILES ${FUZZER_HEADERS} COMPONENT compiler-rt-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/fuzzer) + DESTINATION ${COMPILER_RT_INSTALL_INCLUDE_DIR}/fuzzer) # Install xray headers. install(FILES ${XRAY_HEADERS} COMPONENT compiler-rt-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/xray) + DESTINATION ${COMPILER_RT_INSTALL_INCLUDE_DIR}/xray) # Install profile headers. install(FILES ${PROFILE_HEADERS} COMPONENT compiler-rt-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/profile) + DESTINATION ${COMPILER_RT_INSTALL_INCLUDE_DIR}/profile) if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDEs. add_custom_target(install-compiler-rt-headers diff --git a/gnu/llvm/compiler-rt/include/fuzzer/FuzzedDataProvider.h b/gnu/llvm/compiler-rt/include/fuzzer/FuzzedDataProvider.h index 83bcd0134a7..71cb427ec4a 100644 --- a/gnu/llvm/compiler-rt/include/fuzzer/FuzzedDataProvider.h +++ b/gnu/llvm/compiler-rt/include/fuzzer/FuzzedDataProvider.h @@ -14,11 +14,13 @@ #define LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_ #include +#include #include #include #include #include #include +#include #include #include #include @@ -71,6 +73,8 @@ class FuzzedDataProvider { // Returns a value from the given array. template T PickValueInArray(const T (&array)[size]); + template + T PickValueInArray(const std::array &array); template T PickValueInArray(std::initializer_list list); // Writes data to the given destination and returns number of bytes written. @@ -301,6 +305,12 @@ T FuzzedDataProvider::PickValueInArray(const T (&array)[size]) { return array[ConsumeIntegralInRange(0, size - 1)]; } +template +T FuzzedDataProvider::PickValueInArray(const std::array &array) { + static_assert(size > 0, "The array must be non empty."); + return array[ConsumeIntegralInRange(0, size - 1)]; +} + template T FuzzedDataProvider::PickValueInArray(std::initializer_list list) { // TODO(Dor1s): switch to static_assert once C++14 is allowed. @@ -380,7 +390,7 @@ TS FuzzedDataProvider::ConvertUnsignedToSigned(TU value) { return static_cast(value); } else { constexpr auto TS_min = std::numeric_limits::min(); - return TS_min + static_cast(value - TS_min); + return TS_min + static_cast(value - TS_min); } } diff --git a/gnu/llvm/compiler-rt/include/profile/InstrProfData.inc b/gnu/llvm/compiler-rt/include/profile/InstrProfData.inc index a6913527e67..7d2097cfc29 100644 --- a/gnu/llvm/compiler-rt/include/profile/InstrProfData.inc +++ b/gnu/llvm/compiler-rt/include/profile/InstrProfData.inc @@ -6,15 +6,15 @@ |* \*===----------------------------------------------------------------------===*/ /* - * This is the master file that defines all the data structure, signature, + * This is the main file that defines all the data structure, signature, * constant literals that are shared across profiling runtime library, * compiler (instrumentation), and host tools (reader/writer). The entities * defined in this file affect the profile runtime ABI, the raw profile format, * or both. * - * The file has two identical copies. The master copy lives in LLVM and + * The file has two identical copies. The primary copy lives in LLVM and * the other one sits in compiler-rt/lib/profile directory. To make changes - * in this file, first modify the master copy and copy it over to compiler-rt. + * in this file, first modify the primary copy and copy it over to compiler-rt. * Testing of any change in this file can start only after the two copies are * synced up. * @@ -129,6 +129,7 @@ INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::Type::getInt8PtrTy(Ctx), Next, \ #endif INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic()) INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version()) +INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL)) INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize) INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesBeforeCounters, PaddingBytesBeforeCounters) INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize) @@ -154,17 +155,7 @@ INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last) VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \ INSTR_PROF_COMMA VALUE_PROF_FUNC_PARAM(void *, Data, Type::getInt8PtrTy(Ctx)) INSTR_PROF_COMMA -#ifndef VALUE_RANGE_PROF VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) -#else /* VALUE_RANGE_PROF */ -VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, PreciseRangeStart, Type::getInt64Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, PreciseRangeLast, Type::getInt64Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, LargeValue, Type::getInt64Ty(Ctx)) -#endif /*VALUE_RANGE_PROF */ #undef VALUE_PROF_FUNC_PARAM #undef INSTR_PROF_COMMA /* VALUE_PROF_FUNC_PARAM end */ @@ -655,11 +646,11 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure, (uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129 /* Raw profile format version (start from 1). */ -#define INSTR_PROF_RAW_VERSION 5 +#define INSTR_PROF_RAW_VERSION 7 /* Indexed profile format version (start from 1). */ -#define INSTR_PROF_INDEX_VERSION 6 +#define INSTR_PROF_INDEX_VERSION 7 /* Coverage mapping format version (start from 0). */ -#define INSTR_PROF_COVMAP_VERSION 3 +#define INSTR_PROF_COVMAP_VERSION 5 /* Profile version is always of type uint64_t. Reserve the upper 8 bits in the * version for other variants of profile. We set the lowest bit of the upper 8 @@ -671,8 +662,10 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure, #define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL) #define VARIANT_MASK_IR_PROF (0x1ULL << 56) #define VARIANT_MASK_CSIR_PROF (0x1ULL << 57) +#define VARIANT_MASK_INSTR_ENTRY (0x1ULL << 58) #define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version #define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime +#define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias /* The variable that holds the name of the profile data * specified via command line. */ @@ -753,9 +746,9 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure, #define INSTR_PROF_VALUE_PROF_FUNC __llvm_profile_instrument_target #define INSTR_PROF_VALUE_PROF_FUNC_STR \ INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_FUNC) -#define INSTR_PROF_VALUE_RANGE_PROF_FUNC __llvm_profile_instrument_range -#define INSTR_PROF_VALUE_RANGE_PROF_FUNC_STR \ - INSTR_PROF_QUOTE(INSTR_PROF_VALUE_RANGE_PROF_FUNC) +#define INSTR_PROF_VALUE_PROF_MEMOP_FUNC __llvm_profile_instrument_memop +#define INSTR_PROF_VALUE_PROF_MEMOP_FUNC_STR \ + INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_MEMOP_FUNC) /* InstrProfile per-function control data alignment. */ #define INSTR_PROF_DATA_ALIGNMENT 8 @@ -783,3 +776,122 @@ typedef struct InstrProfValueData { #endif #undef COVMAP_V2_OR_V3 + +#ifdef INSTR_PROF_VALUE_PROF_MEMOP_API + +#ifdef __cplusplus +#define INSTR_PROF_INLINE inline +#else +#define INSTR_PROF_INLINE +#endif + +/* The value range buckets (22 buckets) for the memop size value profiling looks + * like: + * + * [0, 0] + * [1, 1] + * [2, 2] + * [3, 3] + * [4, 4] + * [5, 5] + * [6, 6] + * [7, 7] + * [8, 8] + * [9, 15] + * [16, 16] + * [17, 31] + * [32, 32] + * [33, 63] + * [64, 64] + * [65, 127] + * [128, 128] + * [129, 255] + * [256, 256] + * [257, 511] + * [512, 512] + * [513, UINT64_MAX] + * + * Each range has a 'representative value' which is the lower end value of the + * range and used to store in the runtime profile data records and the VP + * metadata. For example, it's 2 for [2, 2] and 64 for [65, 127]. + */ +#define INSTR_PROF_NUM_BUCKETS 22 + +/* + * Clz and Popcount. This code was copied from + * compiler-rt/lib/fuzzer/{FuzzerBuiltins.h,FuzzerBuiltinsMsvc.h} and + * llvm/include/llvm/Support/MathExtras.h. + */ +#if defined(_MSC_VER) && !defined(__clang__) + +#include +INSTR_PROF_VISIBILITY INSTR_PROF_INLINE +int InstProfClzll(unsigned long long X) { + unsigned long LeadZeroIdx = 0; +#if !defined(_M_ARM64) && !defined(_M_X64) + // Scan the high 32 bits. + if (_BitScanReverse(&LeadZeroIdx, (unsigned long)(X >> 32))) + return (int)(63 - (LeadZeroIdx + 32)); // Create a bit offset + // from the MSB. + // Scan the low 32 bits. + if (_BitScanReverse(&LeadZeroIdx, (unsigned long)(X))) + return (int)(63 - LeadZeroIdx); +#else + if (_BitScanReverse64(&LeadZeroIdx, X)) return 63 - LeadZeroIdx; +#endif + return 64; +} +INSTR_PROF_VISIBILITY INSTR_PROF_INLINE +int InstProfPopcountll(unsigned long long X) { + // This code originates from https://reviews.llvm.org/rG30626254510f. + unsigned long long v = X; + v = v - ((v >> 1) & 0x5555555555555555ULL); + v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL); + v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0FULL; + return (int)((unsigned long long)(v * 0x0101010101010101ULL) >> 56); +} + +#else + +INSTR_PROF_VISIBILITY INSTR_PROF_INLINE +int InstProfClzll(unsigned long long X) { return __builtin_clzll(X); } +INSTR_PROF_VISIBILITY INSTR_PROF_INLINE +int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); } + +#endif /* defined(_MSC_VER) && !defined(__clang__) */ + +/* Map an (observed) memop size value to the representative value of its range. + * For example, 5 -> 5, 22 -> 17, 99 -> 65, 256 -> 256, 1001 -> 513. */ +INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint64_t +InstrProfGetRangeRepValue(uint64_t Value) { + if (Value <= 8) + // The first ranges are individually tracked. Use the value as is. + return Value; + else if (Value >= 513) + // The last range is mapped to its lowest value. + return 513; + else if (InstProfPopcountll(Value) == 1) + // If it's a power of two, use it as is. + return Value; + else + // Otherwise, take to the previous power of two + 1. + return (UINT64_C(1) << (64 - InstProfClzll(Value) - 1)) + 1; +} + +/* Return true if the range that an (observed) memop size value belongs to has + * only a single value in the range. For example, 0 -> true, 8 -> true, 10 -> + * false, 64 -> true, 100 -> false, 513 -> false. */ +INSTR_PROF_VISIBILITY INSTR_PROF_INLINE unsigned +InstrProfIsSingleValRange(uint64_t Value) { + if (Value <= 8) + // The first ranges are individually tracked. + return 1; + else if (InstProfPopcountll(Value) == 1) + // If it's a power of two, there's only one value. + return 1; + else + // Otherwise, there's more than one value in the range. + return 0; +} + +#endif /* INSTR_PROF_VALUE_PROF_MEMOP_API */ diff --git a/gnu/llvm/compiler-rt/include/sanitizer/asan_interface.h b/gnu/llvm/compiler-rt/include/sanitizer/asan_interface.h index 6af93aad651..792ef9cfaa3 100644 --- a/gnu/llvm/compiler-rt/include/sanitizer/asan_interface.h +++ b/gnu/llvm/compiler-rt/include/sanitizer/asan_interface.h @@ -188,8 +188,8 @@ const char *__asan_get_report_description(void); /// \param addr Address to locate. /// \param name Buffer to store the variable's name. /// \param name_size Size in bytes of the variable's name buffer. -/// \param region_address [out] Address of the region. -/// \param region_size [out] Size of the region in bytes. +/// \param[out] region_address Address of the region. +/// \param[out] region_size Size of the region in bytes. /// /// \returns Returns the category of the given pointer as a constant string. const char *__asan_locate_address(void *addr, char *name, size_t name_size, @@ -204,7 +204,7 @@ const char *__asan_locate_address(void *addr, char *name, size_t name_size, /// \param addr A heap address. /// \param trace A buffer to store the stack trace. /// \param size Size in bytes of the trace buffer. -/// \param thread_id [out] The thread ID of the address. +/// \param[out] thread_id The thread ID of the address. /// /// \returns Returns the number of stored frames or 0 on error. size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size, @@ -219,7 +219,7 @@ size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size, /// \param addr A heap address. /// \param trace A buffer to store the stack trace. /// \param size Size in bytes of the trace buffer. -/// \param thread_id [out] The thread ID of the address. +/// \param[out] thread_id The thread ID of the address. /// /// \returns Returns the number of stored frames or 0 on error. size_t __asan_get_free_stack(void *addr, void **trace, size_t size, @@ -228,8 +228,8 @@ size_t __asan_get_free_stack(void *addr, void **trace, size_t size, /// Gets the current shadow memory mapping (useful for calling from the /// debugger). /// -/// \param shadow_scale [out] Shadow scale value. -/// \param shadow_offset [out] Offset value. +/// \param[out] shadow_scale Shadow scale value. +/// \param[out] shadow_offset Offset value. void __asan_get_shadow_mapping(size_t *shadow_scale, size_t *shadow_offset); /// This is an internal function that is called to report an error. However, @@ -302,8 +302,8 @@ void *__asan_get_current_fake_stack(void); /// /// \param fake_stack An opaque handler to a fake stack. /// \param addr Address to test. -/// \param beg [out] Beginning of fake frame. -/// \param end [out] End of fake frame. +/// \param[out] beg Beginning of fake frame. +/// \param[out] end End of fake frame. /// \returns Stack address or NULL. void *__asan_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, void **end); diff --git a/gnu/llvm/compiler-rt/include/sanitizer/common_interface_defs.h b/gnu/llvm/compiler-rt/include/sanitizer/common_interface_defs.h index f979c6a8f63..cd69285b8d4 100644 --- a/gnu/llvm/compiler-rt/include/sanitizer/common_interface_defs.h +++ b/gnu/llvm/compiler-rt/include/sanitizer/common_interface_defs.h @@ -43,6 +43,9 @@ void __sanitizer_set_report_path(const char *path); // Tell the tools to write their reports to the provided file descriptor // (casted to void *). void __sanitizer_set_report_fd(void *fd); +// Get the current full report file path, if a path was specified by +// an earlier call to __sanitizer_set_report_path. Returns null otherwise. +const char *__sanitizer_get_report_path(); // Notify the tools that the sandbox is going to be turned on. The reserved // parameter will be used in the future to hold a structure with functions @@ -320,7 +323,7 @@ void __sanitizer_print_memory_profile(size_t top_percent, /// signal callback runs during the switch, it will not benefit from stack /// use-after-return detection. /// -/// \param fake_stack_save [out] Fake stack save location. +/// \param[out] fake_stack_save Fake stack save location. /// \param bottom Bottom address of stack. /// \param size Size of stack in bytes. void __sanitizer_start_switch_fiber(void **fake_stack_save, @@ -335,8 +338,8 @@ void __sanitizer_start_switch_fiber(void **fake_stack_save, /// __sanitizer_start_switch_fiber(). /// /// \param fake_stack_save Fake stack save location. -/// \param bottom_old [out] Bottom address of old stack. -/// \param size_old [out] Size of old stack in bytes. +/// \param[out] bottom_old Bottom address of old stack. +/// \param[out] size_old Size of old stack in bytes. void __sanitizer_finish_switch_fiber(void *fake_stack_save, const void **bottom_old, size_t *size_old); diff --git a/gnu/llvm/compiler-rt/include/sanitizer/dfsan_interface.h b/gnu/llvm/compiler-rt/include/sanitizer/dfsan_interface.h index 81546e5df71..cd3b6d6e2b1 100644 --- a/gnu/llvm/compiler-rt/include/sanitizer/dfsan_interface.h +++ b/gnu/llvm/compiler-rt/include/sanitizer/dfsan_interface.h @@ -21,33 +21,15 @@ extern "C" { #endif -typedef uint16_t dfsan_label; - -/// Stores information associated with a specific label identifier. A label -/// may be a base label created using dfsan_create_label, with associated -/// text description and user data, or an automatically created union label, -/// which represents the union of two label identifiers (which may themselves -/// be base or union labels). -struct dfsan_label_info { - // Fields for union labels, set to 0 for base labels. - dfsan_label l1; - dfsan_label l2; - - // Fields for base labels. - const char *desc; - void *userdata; -}; +typedef uint8_t dfsan_label; +typedef uint32_t dfsan_origin; /// Signature of the callback argument to dfsan_set_write_callback(). typedef void (*dfsan_write_callback_t)(int fd, const void *buf, size_t count); -/// Computes the union of \c l1 and \c l2, possibly creating a union label in -/// the process. +/// Computes the union of \c l1 and \c l2, resulting in a union label. dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2); -/// Creates and returns a base label with the given description and user data. -dfsan_label dfsan_create_label(const char *desc, void *userdata); - /// Sets the label for each address in [addr,addr+size) to \c label. void dfsan_set_label(dfsan_label label, void *addr, size_t size); @@ -63,26 +45,24 @@ void dfsan_add_label(dfsan_label label, void *addr, size_t size); /// value. dfsan_label dfsan_get_label(long data); +/// Retrieves the immediate origin associated with the given data. The returned +/// origin may point to another origin. +/// +/// The type of 'data' is arbitrary. +dfsan_origin dfsan_get_origin(long data); + /// Retrieves the label associated with the data at the given address. dfsan_label dfsan_read_label(const void *addr, size_t size); -/// Retrieves a pointer to the dfsan_label_info struct for the given label. -const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label); - /// Returns whether the given label label contains the label elem. int dfsan_has_label(dfsan_label label, dfsan_label elem); -/// If the given label label contains a label with the description desc, returns -/// that label, else returns 0. -dfsan_label dfsan_has_label_with_desc(dfsan_label label, const char *desc); - -/// Returns the number of labels allocated. -size_t dfsan_get_label_count(void); - /// Flushes the DFSan shadow, i.e. forgets about all labels currently associated -/// with the application memory. Will work only if there are no other -/// threads executing DFSan-instrumented code concurrently. -/// Use this call to start over the taint tracking within the same procces. +/// with the application memory. Use this call to start over the taint tracking +/// within the same process. +/// +/// Note: If another thread is working with tainted data during the flush, that +/// taint could still be written to shadow after the flush. void dfsan_flush(void); /// Sets a callback to be invoked on calls to write(). The callback is invoked @@ -90,12 +70,6 @@ void dfsan_flush(void); /// callback executes. Pass in NULL to remove any callback. void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback); -/// Writes the labels currently used by the program to the given file -/// descriptor. The lines of the output have the following format: -/// -///