From: patrick Date: Fri, 17 Dec 2021 12:25:51 +0000 (+0000) Subject: Import LLVM 13.0.0 release. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b3056a3bf3ec413ee3116a1cefa486c0a9d2e580;p=openbsd Import LLVM 13.0.0 release. --- diff --git a/gnu/llvm/libunwind/CMakeLists.txt b/gnu/llvm/libunwind/CMakeLists.txt index e44a103648f..81eddbc2487 100644 --- a/gnu/llvm/libunwind/CMakeLists.txt +++ b/gnu/llvm/libunwind/CMakeLists.txt @@ -1,12 +1,12 @@ +if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libcxx") + message(FATAL_ERROR "libunwind requires being built in a monorepo layout with libcxx available") +endif() + #=============================================================================== # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.4.3) - -if (POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default -endif() +cmake_minimum_required(VERSION 3.13.4) # Add path for custom modules set(CMAKE_MODULE_PATH @@ -15,105 +15,31 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) +set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH + "Specify path to libc++ source.") + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_BUILD) project(libunwind LANGUAGES C CXX ASM) - # Rely on llvm-config. - set(CONFIG_OUTPUT) - if(NOT LLVM_CONFIG_PATH) - find_program(LLVM_CONFIG_PATH "llvm-config") - endif() - if (DEFINED LLVM_PATH) - set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include") - set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree") - set(LLVM_MAIN_SRC_DIR ${LLVM_PATH}) - set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules") - elseif(LLVM_CONFIG_PATH) - message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}") - set(CONFIG_COMMAND ${LLVM_CONFIG_PATH} "--includedir" "--prefix" "--src-root") - execute_process(COMMAND ${CONFIG_COMMAND} - RESULT_VARIABLE HAD_ERROR - OUTPUT_VARIABLE CONFIG_OUTPUT) - if (NOT HAD_ERROR) - string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" - CONFIG_OUTPUT ${CONFIG_OUTPUT}) - else() - string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}") - message(STATUS "${CONFIG_COMMAND_STR}") - message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") - endif() - - list(GET CONFIG_OUTPUT 0 INCLUDE_DIR) - list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT) - list(GET CONFIG_OUTPUT 2 MAIN_SRC_DIR) - - set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") - set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") - set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py") - - # --cmakedir is supported since llvm r291218 (4.0 release) - execute_process( - COMMAND ${LLVM_CONFIG_PATH} --cmakedir - RESULT_VARIABLE HAD_ERROR - OUTPUT_VARIABLE CONFIG_OUTPUT - ERROR_QUIET) - if(NOT HAD_ERROR) - string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH_FROM_LLVM_CONFIG) - file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH_FROM_LLVM_CONFIG}" LLVM_CMAKE_PATH) - else() - file(TO_CMAKE_PATH "${LLVM_BINARY_DIR}" LLVM_BINARY_DIR_CMAKE_STYLE) - set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR_CMAKE_STYLE}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") - endif() - else() - message(WARNING "UNSUPPORTED LIBUNWIND CONFIGURATION DETECTED: " - "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. " - "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config " - "or -DLLVM_PATH=path/to/llvm-source-root.") - endif() - - if (EXISTS ${LLVM_CMAKE_PATH}) - # Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions. - set(LLVM_ENABLE_WARNINGS ON) - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") - include("${LLVM_CMAKE_PATH}/AddLLVM.cmake") - include("${LLVM_CMAKE_PATH}/HandleLLVMOptions.cmake") - else() - message(WARNING "Not found: ${LLVM_CMAKE_PATH}") - endif() - set(PACKAGE_NAME libunwind) - set(PACKAGE_VERSION 11.1.0) + set(PACKAGE_VERSION 13.0.0git) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") - if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) - set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) - else() - # Seek installed Lit. - find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit - DOC "Path to lit.py") - endif() + # Add the CMake module path of libcxx so we can reuse HandleOutOfTreeLLVM.cmake + set(LIBUNWIND_LIBCXX_CMAKE_PATH "${LIBUNWIND_LIBCXX_PATH}/cmake/Modules") + list(APPEND CMAKE_MODULE_PATH "${LIBUNWIND_LIBCXX_CMAKE_PATH}") - if (LLVM_LIT) - # Define the default arguments to use with 'lit', and an option for the user - # to override. - set(LIT_ARGS_DEFAULT "-sv") - if (MSVC OR XCODE) - set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") - endif() - set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") - - # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools. - if (WIN32 AND NOT CYGWIN) - set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") - endif() - else() - set(LLVM_INCLUDE_TESTS OFF) - endif() + # In a standalone build, we don't have llvm to automatically generate the + # llvm-lit script for us. So we need to provide an explicit directory that + # the configurator should write the script into. + set(LIBUNWIND_STANDALONE_BUILD 1) + set(LLVM_LIT_OUTPUT_DIR "${LIBUNWIND_BINARY_DIR}/bin") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) + # Find the LLVM sources and simulate LLVM CMake options. + include(HandleOutOfTreeLLVM) else() set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py") endif() @@ -137,7 +63,10 @@ option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON) option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to refer to pthread functions." OFF) option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUDE_DOCS}) +option(LIBUNWIND_INCLUDE_TESTS "Build the libunwind tests." ${LLVM_INCLUDE_TESTS}) +option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF) option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. Requires locking dl_iterate_phdr." OFF) +option(LIBUNWIND_REMEMBER_HEAP_ALLOC "Use heap instead of the stack for .cfi_remember_state." OFF) set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") @@ -148,7 +77,7 @@ cmake_dependent_option(LIBUNWIND_INSTALL_STATIC_LIBRARY cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY "Install the shared libunwind library." ON "LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF) -set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.") +set(LIBUNWIND_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Target triple for cross compiling.") set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.") set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") set(LIBUNWIND_TEST_LINKER_FLAGS "" CACHE STRING @@ -157,6 +86,8 @@ set(LIBUNWIND_TEST_COMPILER_FLAGS "" CACHE STRING "Additional compiler flags for test programs.") set(LIBUNWIND_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING "The Lit testing configuration to use when running the tests.") +set(LIBUNWIND_TEST_PARAMS "" CACHE STRING + "A list of parameters to run the Lit test suite with.") if (NOT LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_STATIC) message(FATAL_ERROR "libunwind must be built as either a shared or static library.") @@ -171,7 +102,7 @@ elseif(LIBUNWIND_BUILD_32_BITS) message(FATAL_ERROR "LIBUNWIND_BUILD_32_BITS=ON is not supported on this platform.") endif() -option(LIBUNWIND_HERMETIC_STATIC_LIBRARY +option(LIBUNWIND_HIDE_SYMBOLS "Do not export any symbols from the static library." OFF) #=============================================================================== @@ -183,34 +114,28 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -set(LIBUNWIND_COMPILER ${CMAKE_CXX_COMPILER}) -set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) - -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION - ${PACKAGE_VERSION}) - if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) + set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH + "Path where built libunwind libraries should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) endif() elseif(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX}) + set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH + "Path where built libunwind libraries should be installed.") else() set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX}) + set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH + "Path where built libunwind libraries should be installed.") endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR}) -set(LIBUNWIND_INSTALL_PREFIX "" CACHE STRING "Define libunwind destination prefix.") - set(LIBUNWIND_C_FLAGS "") set(LIBUNWIND_CXX_FLAGS "") set(LIBUNWIND_COMPILE_FLAGS "") @@ -227,25 +152,21 @@ include(HandleLibunwindFlags) add_target_flags_if(LIBUNWIND_BUILD_32_BITS "-m32") if(LIBUNWIND_TARGET_TRIPLE) - add_target_flags("--target=${LIBUNWIND_TARGET_TRIPLE}") + add_target_flags_if_supported("--target=${LIBUNWIND_TARGET_TRIPLE}") elseif(CMAKE_CXX_COMPILER_TARGET) set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}") endif() if(LIBUNWIND_GCC_TOOLCHAIN) - add_target_flags("--gcc-toolchain=${LIBUNWIND_GCC_TOOLCHAIN}") + add_target_flags_if_supported("--gcc-toolchain=${LIBUNWIND_GCC_TOOLCHAIN}") elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) set(LIBUNWIND_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") endif() if(LIBUNWIND_SYSROOT) - add_target_flags("--sysroot=${LIBUNWIND_SYSROOT}") + add_target_flags_if_supported("--sysroot=${LIBUNWIND_SYSROOT}") elseif(CMAKE_SYSROOT) set(LIBUNWIND_SYSROOT "${CMAKE_SYSROOT}") endif() -if (LIBUNWIND_TARGET_TRIPLE) - set(TARGET_TRIPLE "${LIBUNWIND_TARGET_TRIPLE}") -endif() - # Configure compiler. include(config-ix) @@ -275,6 +196,16 @@ add_compile_flags_if_supported(-Wunused-variable) add_compile_flags_if_supported(-Wwrite-strings) add_compile_flags_if_supported(-Wundef) +add_compile_flags_if_supported(-Wno-suggest-override) + +if (WIN32) + # The headers lack matching dllexport attributes (_LIBUNWIND_EXPORT); + # silence the warning instead of cluttering the headers (which aren't + # necessarily the ones that the callers will use anyway) with the + # attributes. + add_compile_flags_if_supported(-Wno-dll-attribute-on-redeclaration) +endif() + if (LIBUNWIND_ENABLE_WERROR) add_compile_flags_if_supported(-Werror) add_compile_flags_if_supported(-WX) @@ -324,6 +255,8 @@ add_cxx_compile_flags_if_supported(-fno-rtti) if (LIBUNWIND_HAS_NOSTDINCXX_FLAG) list(APPEND LIBUNWIND_COMPILE_FLAGS -nostdinc++) # Remove -stdlib flags to prevent them from causing an unused flag warning. + string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() @@ -366,10 +299,18 @@ if (LIBUNWIND_ENABLE_ARM_WMMX) add_compile_flags(-D__ARM_WMMX) endif() +if(LIBUNWIND_IS_BAREMETAL) + add_compile_definitions(_LIBUNWIND_IS_BAREMETAL) +endif() + if(LIBUNWIND_USE_FRAME_HEADER_CACHE) add_compile_definitions(_LIBUNWIND_USE_FRAME_HEADER_CACHE) endif() +if(LIBUNWIND_REMEMBER_HEAP_ALLOC) + add_compile_definitions(_LIBUNWIND_REMEMBER_HEAP_ALLOC) +endif() + # This is the _ONLY_ place where add_definitions is called. if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) @@ -377,7 +318,7 @@ endif() # Disable DLL annotations on Windows for static builds. if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED) - add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS) + add_definitions(-D_LIBUNWIND_HIDE_SYMBOLS) endif() if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) @@ -401,6 +342,6 @@ if (LIBUNWIND_INCLUDE_DOCS) add_subdirectory(docs) endif() -if (EXISTS ${LLVM_CMAKE_PATH}) +if (LIBUNWIND_INCLUDE_TESTS AND EXISTS ${LLVM_CMAKE_PATH}) add_subdirectory(test) endif() diff --git a/gnu/llvm/libunwind/cmake/Modules/HandleLibunwindFlags.cmake b/gnu/llvm/libunwind/cmake/Modules/HandleLibunwindFlags.cmake index 57ba0b8cf7c..675071f9433 100644 --- a/gnu/llvm/libunwind/cmake/Modules/HandleLibunwindFlags.cmake +++ b/gnu/llvm/libunwind/cmake/Modules/HandleLibunwindFlags.cmake @@ -124,6 +124,17 @@ macro(add_target_flags_if condition) endif() endmacro() +# Add all the flags supported by the compiler to all of +# 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS', 'LIBUNWIND_COMPILE_FLAGS' +# and 'LIBUNWIND_LINK_FLAGS'. +macro(add_target_flags_if_supported) + foreach(flag ${ARGN}) + mangle_name("${flag}" flagname) + check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") + add_target_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag}) + endforeach() +endmacro() + # Add a specified list of flags to both 'LIBUNWIND_COMPILE_FLAGS' and # 'LIBUNWIND_LINK_FLAGS'. macro(add_flags) diff --git a/gnu/llvm/libunwind/cmake/config-ix.cmake b/gnu/llvm/libunwind/cmake/config-ix.cmake index 3e42818882b..4ca6bdd8e95 100644 --- a/gnu/llvm/libunwind/cmake/config-ix.cmake +++ b/gnu/llvm/libunwind/cmake/config-ix.cmake @@ -16,16 +16,26 @@ if (NOT LIBUNWIND_USE_COMPILER_RT) endif () endif() -# libunwind is built with -nodefaultlibs, so we want all our checks to also -# use this option, otherwise we may end up with an inconsistency between +# libunwind is using -nostdlib++ at the link step when available, +# otherwise -nodefaultlibs is used. We want all our checks to also +# use one of these options, otherwise we may end up with an inconsistency between # the flags we think we require during configuration (if the checks are -# performed without -nodefaultlibs) and the flags that are actually -# required during compilation (which has the -nodefaultlibs). libc is +# performed without one of those options) and the flags that are actually +# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is # required for the link to go through. We remove sanitizers from the # configuration checks to avoid spurious link errors. -check_c_compiler_flag(-nodefaultlibs LIBUNWIND_HAS_NODEFAULTLIBS_FLAG) -if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + +check_c_compiler_flag(-nostdlib++ LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) +if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") +else() + check_c_compiler_flag(-nodefaultlibs LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) + if (LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + endif() +endif() + +if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG OR LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) if (LIBUNWIND_HAS_C_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () diff --git a/gnu/llvm/libunwind/include/libunwind.h b/gnu/llvm/libunwind/include/libunwind.h index 23ef47f4ac8..0feecd7bd6f 100644 --- a/gnu/llvm/libunwind/include/libunwind.h +++ b/gnu/llvm/libunwind/include/libunwind.h @@ -43,6 +43,12 @@ #define LIBUNWIND_AVAIL #endif +#if defined(_WIN32) && defined(__SEH__) + #define LIBUNWIND_CURSOR_ALIGNMENT_ATTR __attribute__((__aligned__(16))) +#else + #define LIBUNWIND_CURSOR_ALIGNMENT_ATTR +#endif + /* error codes */ enum { UNW_ESUCCESS = 0, /* no error */ @@ -68,7 +74,7 @@ typedef struct unw_context_t unw_context_t; struct unw_cursor_t { uint64_t data[_LIBUNWIND_CURSOR_SIZE]; -}; +} LIBUNWIND_CURSOR_ALIGNMENT_ATTR; typedef struct unw_cursor_t unw_cursor_t; typedef struct unw_addr_space *unw_addr_space_t; @@ -487,16 +493,16 @@ enum { // 64-bit ARM64 registers enum { - UNW_ARM64_X0 = 0, - UNW_ARM64_X1 = 1, - UNW_ARM64_X2 = 2, - UNW_ARM64_X3 = 3, - UNW_ARM64_X4 = 4, - UNW_ARM64_X5 = 5, - UNW_ARM64_X6 = 6, - UNW_ARM64_X7 = 7, - UNW_ARM64_X8 = 8, - UNW_ARM64_X9 = 9, + UNW_ARM64_X0 = 0, + UNW_ARM64_X1 = 1, + UNW_ARM64_X2 = 2, + UNW_ARM64_X3 = 3, + UNW_ARM64_X4 = 4, + UNW_ARM64_X5 = 5, + UNW_ARM64_X6 = 6, + UNW_ARM64_X7 = 7, + UNW_ARM64_X8 = 8, + UNW_ARM64_X9 = 9, UNW_ARM64_X10 = 10, UNW_ARM64_X11 = 11, UNW_ARM64_X12 = 12, @@ -517,24 +523,25 @@ enum { UNW_ARM64_X27 = 27, UNW_ARM64_X28 = 28, UNW_ARM64_X29 = 29, - UNW_ARM64_FP = 29, + UNW_ARM64_FP = 29, UNW_ARM64_X30 = 30, - UNW_ARM64_LR = 30, + UNW_ARM64_LR = 30, UNW_ARM64_X31 = 31, - UNW_ARM64_SP = 31, + UNW_ARM64_SP = 31, + UNW_ARM64_PC = 32, // reserved block UNW_ARM64_RA_SIGN_STATE = 34, // reserved block - UNW_ARM64_D0 = 64, - UNW_ARM64_D1 = 65, - UNW_ARM64_D2 = 66, - UNW_ARM64_D3 = 67, - UNW_ARM64_D4 = 68, - UNW_ARM64_D5 = 69, - UNW_ARM64_D6 = 70, - UNW_ARM64_D7 = 71, - UNW_ARM64_D8 = 72, - UNW_ARM64_D9 = 73, + UNW_ARM64_D0 = 64, + UNW_ARM64_D1 = 65, + UNW_ARM64_D2 = 66, + UNW_ARM64_D3 = 67, + UNW_ARM64_D4 = 68, + UNW_ARM64_D5 = 69, + UNW_ARM64_D6 = 70, + UNW_ARM64_D7 = 71, + UNW_ARM64_D8 = 72, + UNW_ARM64_D9 = 73, UNW_ARM64_D10 = 74, UNW_ARM64_D11 = 75, UNW_ARM64_D12 = 76, @@ -941,4 +948,156 @@ enum { UNW_RISCV_F31 = 63, }; +// VE register numbers +enum { + UNW_VE_S0 = 0, + UNW_VE_S1 = 1, + UNW_VE_S2 = 2, + UNW_VE_S3 = 3, + UNW_VE_S4 = 4, + UNW_VE_S5 = 5, + UNW_VE_S6 = 6, + UNW_VE_S7 = 7, + UNW_VE_S8 = 8, + UNW_VE_S9 = 9, + UNW_VE_S10 = 10, + UNW_VE_S11 = 11, + UNW_VE_S12 = 12, + UNW_VE_S13 = 13, + UNW_VE_S14 = 14, + UNW_VE_S15 = 15, + UNW_VE_S16 = 16, + UNW_VE_S17 = 17, + UNW_VE_S18 = 18, + UNW_VE_S19 = 19, + UNW_VE_S20 = 20, + UNW_VE_S21 = 21, + UNW_VE_S22 = 22, + UNW_VE_S23 = 23, + UNW_VE_S24 = 24, + UNW_VE_S25 = 25, + UNW_VE_S26 = 26, + UNW_VE_S27 = 27, + UNW_VE_S28 = 28, + UNW_VE_S29 = 29, + UNW_VE_S30 = 30, + UNW_VE_S31 = 31, + UNW_VE_S32 = 32, + UNW_VE_S33 = 33, + UNW_VE_S34 = 34, + UNW_VE_S35 = 35, + UNW_VE_S36 = 36, + UNW_VE_S37 = 37, + UNW_VE_S38 = 38, + UNW_VE_S39 = 39, + UNW_VE_S40 = 40, + UNW_VE_S41 = 41, + UNW_VE_S42 = 42, + UNW_VE_S43 = 43, + UNW_VE_S44 = 44, + UNW_VE_S45 = 45, + UNW_VE_S46 = 46, + UNW_VE_S47 = 47, + UNW_VE_S48 = 48, + UNW_VE_S49 = 49, + UNW_VE_S50 = 50, + UNW_VE_S51 = 51, + UNW_VE_S52 = 52, + UNW_VE_S53 = 53, + UNW_VE_S54 = 54, + UNW_VE_S55 = 55, + UNW_VE_S56 = 56, + UNW_VE_S57 = 57, + UNW_VE_S58 = 58, + UNW_VE_S59 = 59, + UNW_VE_S60 = 60, + UNW_VE_S61 = 61, + UNW_VE_S62 = 62, + UNW_VE_S63 = 63, + UNW_VE_V0 = 64 + 0, + UNW_VE_V1 = 64 + 1, + UNW_VE_V2 = 64 + 2, + UNW_VE_V3 = 64 + 3, + UNW_VE_V4 = 64 + 4, + UNW_VE_V5 = 64 + 5, + UNW_VE_V6 = 64 + 6, + UNW_VE_V7 = 64 + 7, + UNW_VE_V8 = 64 + 8, + UNW_VE_V9 = 64 + 9, + UNW_VE_V10 = 64 + 10, + UNW_VE_V11 = 64 + 11, + UNW_VE_V12 = 64 + 12, + UNW_VE_V13 = 64 + 13, + UNW_VE_V14 = 64 + 14, + UNW_VE_V15 = 64 + 15, + UNW_VE_V16 = 64 + 16, + UNW_VE_V17 = 64 + 17, + UNW_VE_V18 = 64 + 18, + UNW_VE_V19 = 64 + 19, + UNW_VE_V20 = 64 + 20, + UNW_VE_V21 = 64 + 21, + UNW_VE_V22 = 64 + 22, + UNW_VE_V23 = 64 + 23, + UNW_VE_V24 = 64 + 24, + UNW_VE_V25 = 64 + 25, + UNW_VE_V26 = 64 + 26, + UNW_VE_V27 = 64 + 27, + UNW_VE_V28 = 64 + 28, + UNW_VE_V29 = 64 + 29, + UNW_VE_V30 = 64 + 30, + UNW_VE_V31 = 64 + 31, + UNW_VE_V32 = 64 + 32, + UNW_VE_V33 = 64 + 33, + UNW_VE_V34 = 64 + 34, + UNW_VE_V35 = 64 + 35, + UNW_VE_V36 = 64 + 36, + UNW_VE_V37 = 64 + 37, + UNW_VE_V38 = 64 + 38, + UNW_VE_V39 = 64 + 39, + UNW_VE_V40 = 64 + 40, + UNW_VE_V41 = 64 + 41, + UNW_VE_V42 = 64 + 42, + UNW_VE_V43 = 64 + 43, + UNW_VE_V44 = 64 + 44, + UNW_VE_V45 = 64 + 45, + UNW_VE_V46 = 64 + 46, + UNW_VE_V47 = 64 + 47, + UNW_VE_V48 = 64 + 48, + UNW_VE_V49 = 64 + 49, + UNW_VE_V50 = 64 + 50, + UNW_VE_V51 = 64 + 51, + UNW_VE_V52 = 64 + 52, + UNW_VE_V53 = 64 + 53, + UNW_VE_V54 = 64 + 54, + UNW_VE_V55 = 64 + 55, + UNW_VE_V56 = 64 + 56, + UNW_VE_V57 = 64 + 57, + UNW_VE_V58 = 64 + 58, + UNW_VE_V59 = 64 + 59, + UNW_VE_V60 = 64 + 60, + UNW_VE_V61 = 64 + 61, + UNW_VE_V62 = 64 + 62, + UNW_VE_V63 = 64 + 63, + UNW_VE_VM0 = 128 + 0, + UNW_VE_VM1 = 128 + 1, + UNW_VE_VM2 = 128 + 2, + UNW_VE_VM3 = 128 + 3, + UNW_VE_VM4 = 128 + 4, + UNW_VE_VM5 = 128 + 5, + UNW_VE_VM6 = 128 + 6, + UNW_VE_VM7 = 128 + 7, + UNW_VE_VM8 = 128 + 8, + UNW_VE_VM9 = 128 + 9, + UNW_VE_VM10 = 128 + 10, + UNW_VE_VM11 = 128 + 11, + UNW_VE_VM12 = 128 + 12, + UNW_VE_VM13 = 128 + 13, + UNW_VE_VM14 = 128 + 14, + UNW_VE_VM15 = 128 + 15, // = 143 + + // Following registers don't have DWARF register numbers. + UNW_VE_VIXR = 144, + UNW_VE_VL = 145, +}; + #endif diff --git a/gnu/llvm/libunwind/src/CMakeLists.txt b/gnu/llvm/libunwind/src/CMakeLists.txt index 309a85b22f5..093804fe4a2 100644 --- a/gnu/llvm/libunwind/src/CMakeLists.txt +++ b/gnu/llvm/libunwind/src/CMakeLists.txt @@ -38,9 +38,12 @@ set(LIBUNWIND_HEADERS dwarf2.h DwarfInstructions.hpp DwarfParser.hpp + EHHeaderParser.hpp + FrameHeaderCache.hpp libunwind_ext.h Registers.hpp RWMutex.hpp + Unwind-EHABI.h UnwindCursor.hpp ../include/libunwind.h ../include/unwind.h @@ -77,7 +80,11 @@ if (LIBUNWIND_ENABLE_THREADS) endif() # Setup flags. -add_link_flags_if_supported(-nodefaultlibs) +if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) + add_link_flags_if_supported(-nostdlib++) +else() + add_link_flags_if_supported(-nodefaultlibs) +endif() # MINGW_LIBRARIES is defined in config-ix.cmake add_library_flags_if(MINGW "${MINGW_LIBRARIES}") @@ -122,20 +129,20 @@ if (LIBUNWIND_ENABLE_SHARED) else() target_compile_options(unwind_shared PRIVATE -fno-rtti) endif() - if(COMMAND llvm_setup_rpath) - llvm_setup_rpath(unwind_shared) - endif() target_link_libraries(unwind_shared PRIVATE ${LIBUNWIND_LIBRARIES}) - set_target_properties(unwind_shared PROPERTIES - CXX_EXTENSIONS OFF - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED ON - COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}" - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" - LINKER_LANGUAGE C - OUTPUT_NAME "unwind" - VERSION "1.0" - SOVERSION "1") + set_target_properties(unwind_shared + PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}" + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" + LINKER_LANGUAGE C + OUTPUT_NAME "unwind" + VERSION "1.0" + SOVERSION "1" + POSITION_INDEPENDENT_CODE ON + ) list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared") if (LIBUNWIND_INSTALL_SHARED_LIBRARY) list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared") @@ -151,20 +158,23 @@ if (LIBUNWIND_ENABLE_STATIC) target_compile_options(unwind_static PRIVATE -fno-rtti) endif() target_link_libraries(unwind_static PRIVATE ${LIBUNWIND_LIBRARIES}) - set_target_properties(unwind_static PROPERTIES - CXX_EXTENSIONS OFF - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED ON - COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}" - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" - LINKER_LANGUAGE C - OUTPUT_NAME "unwind") - - if(LIBUNWIND_HERMETIC_STATIC_LIBRARY) + set_target_properties(unwind_static + PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}" + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" + LINKER_LANGUAGE C + OUTPUT_NAME "unwind" + POSITION_INDEPENDENT_CODE ON + ) + + if(LIBUNWIND_HIDE_SYMBOLS) append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility=hidden) append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) target_compile_options(unwind_static PRIVATE ${UNWIND_STATIC_LIBRARY_FLAGS}) - target_compile_definitions(unwind_static PRIVATE _LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS) + target_compile_definitions(unwind_static PRIVATE _LIBUNWIND_HIDE_SYMBOLS) endif() list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static") @@ -178,8 +188,9 @@ add_custom_target(unwind DEPENDS ${LIBUNWIND_BUILD_TARGETS}) if (LIBUNWIND_INSTALL_LIBRARY) install(TARGETS ${LIBUNWIND_INSTALL_TARGETS} - LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind - ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind) + LIBRARY DESTINATION ${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind + ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind + RUNTIME DESTINATION bin COMPONENT unwind) endif() if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY) diff --git a/gnu/llvm/libunwind/src/FrameHeaderCache.hpp b/gnu/llvm/libunwind/src/FrameHeaderCache.hpp index 813fcd408b2..54d5d33c3cd 100644 --- a/gnu/llvm/libunwind/src/FrameHeaderCache.hpp +++ b/gnu/llvm/libunwind/src/FrameHeaderCache.hpp @@ -32,7 +32,7 @@ class _LIBUNWIND_HIDDEN FrameHeaderCache { struct CacheEntry { uintptr_t LowPC() { return Info.dso_base; }; - uintptr_t HighPC() { return Info.dso_base + Info.dwarf_section_length; }; + uintptr_t HighPC() { return Info.dso_base + Info.text_segment_length; }; UnwindInfoSections Info; CacheEntry *Next; }; diff --git a/gnu/llvm/libunwind/src/Unwind-EHABI.cpp b/gnu/llvm/libunwind/src/Unwind-EHABI.cpp index 32b5cbc3be9..8843db7f54c 100644 --- a/gnu/llvm/libunwind/src/Unwind-EHABI.cpp +++ b/gnu/llvm/libunwind/src/Unwind-EHABI.cpp @@ -97,9 +97,11 @@ _Unwind_Reason_Code ProcessDescriptors( case Descriptor::LU32: descriptor = getNextWord(descriptor, &length); descriptor = getNextWord(descriptor, &offset); + break; case Descriptor::LU16: descriptor = getNextNibble(descriptor, &length); descriptor = getNextNibble(descriptor, &offset); + break; default: assert(false); return _URC_FAILURE; diff --git a/gnu/llvm/libunwind/src/Unwind-seh.cpp b/gnu/llvm/libunwind/src/Unwind-seh.cpp index 403ab2d7711..6e2b4e73e41 100644 --- a/gnu/llvm/libunwind/src/Unwind-seh.cpp +++ b/gnu/llvm/libunwind/src/Unwind-seh.cpp @@ -46,18 +46,6 @@ using namespace libunwind; /// handling. #define STATUS_GCC_UNWIND MAKE_GCC_EXCEPTION(1) // 0x21474343 -/// Class of foreign exceptions based on unrecognized SEH exceptions. -static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0 - -/// Exception cleanup routine used by \c _GCC_specific_handler to -/// free foreign exceptions. -static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) { - (void)urc; - if (exc->exception_class != kSEHExceptionClass) - _LIBUNWIND_ABORT("SEH cleanup called on non-SEH exception"); - free(exc); -} - static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx); static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor); static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor, @@ -108,10 +96,10 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, } } else { // Foreign exception. - exc = (_Unwind_Exception *)malloc(sizeof(_Unwind_Exception)); - exc->exception_class = kSEHExceptionClass; - exc->exception_cleanup = seh_exc_cleanup; - memset(exc->private_, 0, sizeof(exc->private_)); + // We can't interact with them (we don't know the original target frame + // that we should pass on to RtlUnwindEx in _Unwind_Resume), so just + // pass without calling our destructors here. + return ExceptionContinueSearch; } if (!ctx) { __unw_init_seh(&cursor, disp->ContextRecord); diff --git a/gnu/llvm/libunwind/src/Unwind-sjlj.c b/gnu/llvm/libunwind/src/Unwind-sjlj.c index 85a4cc3c69d..fd2a95b74c4 100644 --- a/gnu/llvm/libunwind/src/Unwind-sjlj.c +++ b/gnu/llvm/libunwind/src/Unwind-sjlj.c @@ -32,11 +32,23 @@ struct _Unwind_FunctionContext { // next function in stack of handlers struct _Unwind_FunctionContext *prev; +#if defined(__ve__) + // VE requires to store 64 bit pointers in the buffer for SjLj execption. + // We expand the size of values defined here. This size must be matched + // to the size returned by TargetMachine::getSjLjDataSize(). + + // set by calling function before registering to be the landing pad + uint64_t resumeLocation; + + // set by personality handler to be parameters passed to landing pad function + uint64_t resumeParameters[4]; +#else // set by calling function before registering to be the landing pad uint32_t resumeLocation; // set by personality handler to be parameters passed to landing pad function uint32_t resumeParameters[4]; +#endif // set by calling function before registering _Unwind_Personality_Fn personality; // arm offset=24 diff --git a/gnu/llvm/libunwind/src/UnwindLevel1.c b/gnu/llvm/libunwind/src/UnwindLevel1.c index 3e75b5f13cd..68e5e48b8c0 100644 --- a/gnu/llvm/libunwind/src/UnwindLevel1.c +++ b/gnu/llvm/libunwind/src/UnwindLevel1.c @@ -39,8 +39,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except __unw_init_local(cursor, uc); // Walk each frame looking for a place to stop. - bool handlerNotFound = true; - while (handlerNotFound) { + while (true) { // Ask libunwind to get next frame (skip over first which is // _Unwind_RaiseException). int stepResult = __unw_step(cursor); @@ -102,7 +101,6 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except case _URC_HANDLER_FOUND: // found a catch clause or locals that need destructing in this frame // stop search and remember stack pointer at the frame - handlerNotFound = false; __unw_get_reg(cursor, UNW_REG_SP, &sp); exception_object->private_2 = (uintptr_t)sp; _LIBUNWIND_TRACE_UNWINDING( diff --git a/gnu/llvm/libunwind/src/Unwind_AppleExtras.cpp b/gnu/llvm/libunwind/src/Unwind_AppleExtras.cpp index 536303993ef..e3d41ca2b4e 100644 --- a/gnu/llvm/libunwind/src/Unwind_AppleExtras.cpp +++ b/gnu/llvm/libunwind/src/Unwind_AppleExtras.cpp @@ -8,35 +8,6 @@ //===----------------------------------------------------------------------===// #include "config.h" -#include "AddressSpace.hpp" -#include "DwarfParser.hpp" - - -// private keymgr stuff -#define KEYMGR_GCC3_DW2_OBJ_LIST 302 -extern "C" { - extern void _keymgr_set_and_unlock_processwide_ptr(int key, void *ptr); - extern void *_keymgr_get_and_lock_processwide_ptr(int key); -} - -// undocumented libgcc "struct object" -struct libgcc_object { - void *start; - void *unused1; - void *unused2; - void *fde; - unsigned long encoding; - void *fde_end; - libgcc_object *next; -}; - -// undocumented libgcc "struct km_object_info" referenced by -// KEYMGR_GCC3_DW2_OBJ_LIST -struct libgcc_object_info { - libgcc_object *seen_objects; - libgcc_object *unseen_objects; - unsigned spare[2]; -}; // static linker symbols to prevent wrong two level namespace for _Unwind symbols @@ -140,44 +111,3 @@ NOT_HERE_BEFORE_5_0(_Unwind_SjLj_Resume_or_Rethrow) NOT_HERE_BEFORE_5_0(_Unwind_SjLj_Unregister) #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS) - - -namespace libunwind { - -_LIBUNWIND_HIDDEN -bool checkKeyMgrRegisteredFDEs(uintptr_t pc, void *&fde) { -#if __MAC_OS_X_VERSION_MIN_REQUIRED - // lastly check for old style keymgr registration of dynamically generated - // FDEs acquire exclusive access to libgcc_object_info - libgcc_object_info *head = (libgcc_object_info *) - _keymgr_get_and_lock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST); - if (head != NULL) { - // look at each FDE in keymgr - for (libgcc_object *ob = head->unseen_objects; ob != NULL; ob = ob->next) { - CFI_Parser::FDE_Info fdeInfo; - CFI_Parser::CIE_Info cieInfo; - const char *msg = CFI_Parser::decodeFDE( - LocalAddressSpace::sThisAddressSpace, - (uintptr_t)ob->fde, &fdeInfo, &cieInfo); - if (msg == NULL) { - // Check if this FDE is for a function that includes the pc - if ((fdeInfo.pcStart <= pc) && (pc < fdeInfo.pcEnd)) { - fde = (void*)fdeInfo.pcStart; - _keymgr_set_and_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST, - head); - return true; - } - } - } - } - // release libgcc_object_info - _keymgr_set_and_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST, head); -#else - (void)pc; - (void)fde; -#endif - return false; -} - -} -