Skip to content

Commit 03a0120

Browse files
DanAlbertEliminater74
authored andcommitted
libunwind_llvm: Merge to upstream r320528.
Gets us https://reviews.llvm.org/D39468 which lets us update the NDK's version of the unwinder. Test: make native Test: external/libcxx/run_tests.py # no regressions Bug: rust-lang/rust#17520 Change-Id: I1284fb151c00f1ae4350c73ad9033246720d5190 Signed-off-by: mydongistiny <[email protected]> Signed-off-by: Eliminater74 <[email protected]>
1 parent a3a975c commit 03a0120

35 files changed

+1627
-397
lines changed

CMakeLists.txt

+30-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
133133
option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
134134
option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUDE_DOCS})
135135

136+
set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
137+
"Define suffix of library directory name (32/64)")
138+
option(LIBUNWIND_INSTALL_LIBRARY "Install the libunwind library." ON)
136139
set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
137140
set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
138141
set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
@@ -162,7 +165,22 @@ set(CMAKE_MODULE_PATH
162165
set(LIBUNWIND_COMPILER ${CMAKE_CXX_COMPILER})
163166
set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
164167
set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
165-
set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
168+
if (LLVM_LIBRARY_OUTPUT_INTDIR)
169+
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
170+
else()
171+
set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX})
172+
endif()
173+
174+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
175+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
176+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
177+
178+
set(LIBUNWIND_INSTALL_PREFIX "" CACHE STRING
179+
"Define libunwind destination prefix.")
180+
181+
if (NOT LIBUNWIND_INSTALL_PREFIX MATCHES "^$|.*/")
182+
message(FATAL_ERROR "LIBUNWIND_INSTALL_PREFIX has to end with \"/\".")
183+
endif()
166184

167185
set(LIBUNWIND_C_FLAGS "")
168186
set(LIBUNWIND_CXX_FLAGS "")
@@ -193,6 +211,10 @@ add_target_flags_if(LIBUNWIND_GCC_TOOLCHAIN
193211
add_target_flags_if(LIBUNWIND_SYSROOT
194212
"--sysroot=${LIBUNWIND_SYSROOT}")
195213

214+
if (LIBUNWIND_TARGET_TRIPLE)
215+
set(TARGET_TRIPLE "${LIBUNWIND_TARGET_TRIPLE}")
216+
endif()
217+
196218
# Configure compiler.
197219
include(config-ix)
198220

@@ -290,6 +312,11 @@ if (MSVC)
290312
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
291313
endif()
292314

315+
# Disable DLL annotations on Windows for static builds.
316+
if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
317+
add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
318+
endif()
319+
293320
#===============================================================================
294321
# Setup Source Code
295322
#===============================================================================
@@ -321,3 +348,5 @@ add_subdirectory(src)
321348
if (LIBUNWIND_INCLUDE_DOCS)
322349
add_subdirectory(docs)
323350
endif()
351+
352+
add_subdirectory(test)

CREDITS.txt

-71
This file was deleted.

cmake/config-ix.cmake

+13-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
2929
elseif (LIBUNWIND_HAS_GCC_S_LIB)
3030
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
3131
endif ()
32+
if (MINGW)
33+
# Mingw64 requires quite a few "C" runtime libraries in order for basic
34+
# programs to link successfully with -nodefaultlibs.
35+
if (LIBUNWIND_USE_COMPILER_RT)
36+
set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY})
37+
else ()
38+
set(MINGW_RUNTIME gcc_s gcc)
39+
endif()
40+
set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32
41+
shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME}
42+
moldname mingwex msvcrt)
43+
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
44+
endif()
3245
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
3346
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
3447
endif ()
@@ -39,7 +52,6 @@ endif ()
3952

4053
# Check compiler flags
4154
check_c_compiler_flag(-funwind-tables LIBUNWIND_HAS_FUNWIND_TABLES)
42-
check_cxx_compiler_flag(-fPIC LIBUNWIND_HAS_FPIC_FLAG)
4355
check_cxx_compiler_flag(-fno-exceptions LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG)
4456
check_cxx_compiler_flag(-fno-rtti LIBUNWIND_HAS_NO_RTTI_FLAG)
4557
check_cxx_compiler_flag(-fstrict-aliasing LIBUNWIND_HAS_FSTRICT_ALIASING_FLAG)

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
# built documents.
4848
#
4949
# The short X.Y version.
50-
version = '5.0'
50+
version = '6.0'
5151
# The full version, including alpha/beta/rc tags.
52-
release = '5.0'
52+
release = '6.0'
5353

5454
# The language for content autogenerated by Sphinx. Refer to documentation
5555
# for a list of supported languages.

docs/index.rst

+14-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ that never materialized (e.g. remote unwinding).
1515

1616
The unwinder has two levels of API. The high level APIs are the `_Unwind_*`
1717
functions which implement functionality required by `__cxa_*` exception
18-
funcionts. The low level APIs are the `unw_*` functions which are an interface
18+
functions. The low level APIs are the `unw_*` functions which are an interface
1919
defined by the old HP libunwind project.
2020

2121
Getting Started with libunwind
@@ -41,16 +41,19 @@ Platform and Compiler Support
4141

4242
libunwind is known to work on the following platforms:
4343

44-
============ ==================== ============ ========================
45-
OS Arch Compilers Unwind Info
46-
============ ==================== ============ ========================
47-
Mac OS X i386, x86_64 Clang, GCC DWARF CFI
48-
iOS ARM Clang SjLj
49-
Linux i386, x86_64 Clang, GCC DWARF CFI
50-
Linux ARM Clang, GCC EHABI
51-
Bare Metal ARM Clang, GCC EHABI
52-
NetBSD x86_64 Clang, GCC DWARF CFI
53-
============ ==================== ============ ========================
44+
============ ======================== ============ ========================
45+
OS Arch Compilers Unwind Info
46+
============ ======================== ============ ========================
47+
Any i386, x86_64, ARM Clang SjLj
48+
Bare Metal ARM Clang, GCC EHABI
49+
FreeBSD i386, x86_64, ARM64 Clang DWARF CFI
50+
iOS ARM Clang SjLj
51+
Linux ARM Clang, GCC EHABI
52+
Linux i386, x86_64, ARM64 Clang, GCC DWARF CFI
53+
Mac OS X i386, x86_64 Clang, GCC DWARF CFI
54+
NetBSD x86_64 Clang, GCC DWARF CFI
55+
Windows i386, x86_64, ARM, ARM64 Clang DWARF CFI
56+
============ ======================== ============ ========================
5457

5558
The following minimum compiler versions are strongly recommended.
5659

include/__libunwind_config.h

+42-14
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,68 @@
1515
#define _LIBUNWIND_ARM_EHABI
1616
#endif
1717

18+
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86 8
19+
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64 32
20+
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC 112
21+
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64 95
22+
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM 287
23+
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K 31
24+
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS 65
25+
1826
#if defined(_LIBUNWIND_IS_NATIVE_ONLY)
1927
# if defined(__i386__)
2028
# define _LIBUNWIND_TARGET_I386
2129
# define _LIBUNWIND_CONTEXT_SIZE 8
22-
# define _LIBUNWIND_CURSOR_SIZE 19
23-
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 9
30+
# define _LIBUNWIND_CURSOR_SIZE 15
31+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86
2432
# elif defined(__x86_64__)
2533
# define _LIBUNWIND_TARGET_X86_64 1
26-
# define _LIBUNWIND_CONTEXT_SIZE 21
27-
# define _LIBUNWIND_CURSOR_SIZE 33
28-
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 17
34+
# if defined(_WIN64)
35+
# define _LIBUNWIND_CONTEXT_SIZE 54
36+
# define _LIBUNWIND_CURSOR_SIZE 66
37+
# else
38+
# define _LIBUNWIND_CONTEXT_SIZE 21
39+
# define _LIBUNWIND_CURSOR_SIZE 33
40+
# endif
41+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64
2942
# elif defined(__ppc__)
3043
# define _LIBUNWIND_TARGET_PPC 1
3144
# define _LIBUNWIND_CONTEXT_SIZE 117
32-
# define _LIBUNWIND_CURSOR_SIZE 128
33-
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 113
45+
# define _LIBUNWIND_CURSOR_SIZE 124
46+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC
3447
# elif defined(__aarch64__)
3548
# define _LIBUNWIND_TARGET_AARCH64 1
3649
# define _LIBUNWIND_CONTEXT_SIZE 66
3750
# define _LIBUNWIND_CURSOR_SIZE 78
38-
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 96
51+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64
3952
# elif defined(__arm__)
4053
# define _LIBUNWIND_TARGET_ARM 1
4154
# if defined(__ARM_WMMX)
42-
# define _LIBUNWIND_CONTEXT_SIZE 60
43-
# define _LIBUNWIND_CURSOR_SIZE 67
55+
# define _LIBUNWIND_CONTEXT_SIZE 61
56+
# define _LIBUNWIND_CURSOR_SIZE 68
4457
# else
4558
# define _LIBUNWIND_CONTEXT_SIZE 42
4659
# define _LIBUNWIND_CURSOR_SIZE 49
4760
# endif
48-
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 96
61+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM
4962
# elif defined(__or1k__)
5063
# define _LIBUNWIND_TARGET_OR1K 1
5164
# define _LIBUNWIND_CONTEXT_SIZE 16
52-
# define _LIBUNWIND_CURSOR_SIZE 28
53-
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32
65+
# define _LIBUNWIND_CURSOR_SIZE 24
66+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K
67+
# elif defined(__mips__)
68+
# if defined(_ABIO32) && defined(__mips_soft_float)
69+
# define _LIBUNWIND_TARGET_MIPS_O32 1
70+
# define _LIBUNWIND_CONTEXT_SIZE 18
71+
# define _LIBUNWIND_CURSOR_SIZE 24
72+
# elif defined(_ABI64) && defined(__mips_soft_float)
73+
# define _LIBUNWIND_TARGET_MIPS_N64 1
74+
# define _LIBUNWIND_CONTEXT_SIZE 35
75+
# define _LIBUNWIND_CURSOR_SIZE 47
76+
# else
77+
# error "Unsupported MIPS ABI and/or environment"
78+
# endif
79+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS
5480
# else
5581
# error "Unsupported architecture."
5682
# endif
@@ -61,9 +87,11 @@
6187
# define _LIBUNWIND_TARGET_AARCH64 1
6288
# define _LIBUNWIND_TARGET_ARM 1
6389
# define _LIBUNWIND_TARGET_OR1K 1
90+
# define _LIBUNWIND_TARGET_MIPS_O32 1
91+
# define _LIBUNWIND_TARGET_MIPS_N64 1
6492
# define _LIBUNWIND_CONTEXT_SIZE 128
6593
# define _LIBUNWIND_CURSOR_SIZE 140
66-
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 120
94+
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287
6795
#endif // _LIBUNWIND_IS_NATIVE_ONLY
6896

6997
#endif // ____LIBUNWIND_CONFIG_H__

include/libunwind.h

+58-4
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ typedef struct unw_cursor_t unw_cursor_t;
7272
typedef struct unw_addr_space *unw_addr_space_t;
7373

7474
typedef int unw_regnum_t;
75-
#if defined(_LIBUNWIND_ARM_EHABI)
76-
typedef uint32_t unw_word_t;
75+
typedef uintptr_t unw_word_t;
76+
#if defined(__arm__)
7777
typedef uint64_t unw_fpreg_t;
7878
#else
79-
typedef uint64_t unw_word_t;
8079
typedef double unw_fpreg_t;
8180
#endif
8281

@@ -188,7 +187,24 @@ enum {
188187
UNW_X86_64_R12 = 12,
189188
UNW_X86_64_R13 = 13,
190189
UNW_X86_64_R14 = 14,
191-
UNW_X86_64_R15 = 15
190+
UNW_X86_64_R15 = 15,
191+
UNW_X86_64_RIP = 16,
192+
UNW_X86_64_XMM0 = 17,
193+
UNW_X86_64_XMM1 = 18,
194+
UNW_X86_64_XMM2 = 19,
195+
UNW_X86_64_XMM3 = 20,
196+
UNW_X86_64_XMM4 = 21,
197+
UNW_X86_64_XMM5 = 22,
198+
UNW_X86_64_XMM6 = 23,
199+
UNW_X86_64_XMM7 = 24,
200+
UNW_X86_64_XMM8 = 25,
201+
UNW_X86_64_XMM9 = 26,
202+
UNW_X86_64_XMM10 = 27,
203+
UNW_X86_64_XMM11 = 28,
204+
UNW_X86_64_XMM12 = 29,
205+
UNW_X86_64_XMM13 = 30,
206+
UNW_X86_64_XMM14 = 31,
207+
UNW_X86_64_XMM15 = 32,
192208
};
193209

194210

@@ -547,4 +563,42 @@ enum {
547563
UNW_OR1K_R31 = 31,
548564
};
549565

566+
// MIPS registers
567+
enum {
568+
UNW_MIPS_R0 = 0,
569+
UNW_MIPS_R1 = 1,
570+
UNW_MIPS_R2 = 2,
571+
UNW_MIPS_R3 = 3,
572+
UNW_MIPS_R4 = 4,
573+
UNW_MIPS_R5 = 5,
574+
UNW_MIPS_R6 = 6,
575+
UNW_MIPS_R7 = 7,
576+
UNW_MIPS_R8 = 8,
577+
UNW_MIPS_R9 = 9,
578+
UNW_MIPS_R10 = 10,
579+
UNW_MIPS_R11 = 11,
580+
UNW_MIPS_R12 = 12,
581+
UNW_MIPS_R13 = 13,
582+
UNW_MIPS_R14 = 14,
583+
UNW_MIPS_R15 = 15,
584+
UNW_MIPS_R16 = 16,
585+
UNW_MIPS_R17 = 17,
586+
UNW_MIPS_R18 = 18,
587+
UNW_MIPS_R19 = 19,
588+
UNW_MIPS_R20 = 20,
589+
UNW_MIPS_R21 = 21,
590+
UNW_MIPS_R22 = 22,
591+
UNW_MIPS_R23 = 23,
592+
UNW_MIPS_R24 = 24,
593+
UNW_MIPS_R25 = 25,
594+
UNW_MIPS_R26 = 26,
595+
UNW_MIPS_R27 = 27,
596+
UNW_MIPS_R28 = 28,
597+
UNW_MIPS_R29 = 29,
598+
UNW_MIPS_R30 = 30,
599+
UNW_MIPS_R31 = 31,
600+
UNW_MIPS_HI = 64,
601+
UNW_MIPS_LO = 65,
602+
};
603+
550604
#endif

0 commit comments

Comments
 (0)