1d4e76214Sopenharmony_ci# libunwind 2d4e76214Sopenharmony_ci 3d4e76214Sopenharmony_ci[](https://travis-ci.org/libunwind/libunwind) 4d4e76214Sopenharmony_ci 5d4e76214Sopenharmony_ciThis library supports several architecture/operating-system combinations: 6d4e76214Sopenharmony_ci 7d4e76214Sopenharmony_ci| System | Architecture | Status | 8d4e76214Sopenharmony_ci| :------ | :----------- | :----- | 9d4e76214Sopenharmony_ci| Linux | x86-64 | ✓ | 10d4e76214Sopenharmony_ci| Linux | x86 | ✓ | 11d4e76214Sopenharmony_ci| Linux | ARM | ✓ | 12d4e76214Sopenharmony_ci| Linux | AArch64 | ✓ | 13d4e76214Sopenharmony_ci| Linux | PPC32 | ✓ | 14d4e76214Sopenharmony_ci| Linux | PPC64 | ✓ | 15d4e76214Sopenharmony_ci| Linux | SuperH | ✓ | 16d4e76214Sopenharmony_ci| Linux | IA-64 | ✓ | 17d4e76214Sopenharmony_ci| Linux | PARISC | Works well, but C library missing unwind-info | 18d4e76214Sopenharmony_ci| Linux | Tilegx | 64-bit mode only | 19d4e76214Sopenharmony_ci| Linux | MIPS | Newly added | 20d4e76214Sopenharmony_ci| Linux | RISC-V | 64-bit only | 21d4e76214Sopenharmony_ci| HP-UX | IA-64 | Mostly works, but known to have serious limitations | 22d4e76214Sopenharmony_ci| FreeBSD | x86-64 | ✓ | 23d4e76214Sopenharmony_ci| FreeBSD | x86 | ✓ | 24d4e76214Sopenharmony_ci| FreeBSD | AArch64 | ✓ | 25d4e76214Sopenharmony_ci| Solaris | x86-64 | ✓ | 26d4e76214Sopenharmony_ci 27d4e76214Sopenharmony_ci## Libc Requirements 28d4e76214Sopenharmony_ci 29d4e76214Sopenharmony_cilibunwind depends on getcontext(), setcontext() functions which are missing 30d4e76214Sopenharmony_cifrom C libraries like musl-libc because they are considered to be "obsolescent" 31d4e76214Sopenharmony_ciAPI by POSIX document. The following table tries to track current status of 32d4e76214Sopenharmony_cisuch dependencies 33d4e76214Sopenharmony_ci 34d4e76214Sopenharmony_ci - r, requires 35d4e76214Sopenharmony_ci - p, provides its own implementation 36d4e76214Sopenharmony_ci - empty, no requirement 37d4e76214Sopenharmony_ci 38d4e76214Sopenharmony_ci| Architecture | getcontext | setcontext | 39d4e76214Sopenharmony_ci|--------------|------------|------------| 40d4e76214Sopenharmony_ci| aarch64 | p | | 41d4e76214Sopenharmony_ci| arm | p | | 42d4e76214Sopenharmony_ci| hppa | p | p | 43d4e76214Sopenharmony_ci| ia64 | p | r | 44d4e76214Sopenharmony_ci| mips | p | | 45d4e76214Sopenharmony_ci| ppc32 | r | | 46d4e76214Sopenharmony_ci| ppc64 | r | r | 47d4e76214Sopenharmony_ci| riscv | p | p | 48d4e76214Sopenharmony_ci| s390x | p | p | 49d4e76214Sopenharmony_ci| sh | r | | 50d4e76214Sopenharmony_ci| tilegx | r | r | 51d4e76214Sopenharmony_ci| x86 | p | r | 52d4e76214Sopenharmony_ci| x86_64 | p | p | 53d4e76214Sopenharmony_ci 54d4e76214Sopenharmony_ci## General Build Instructions 55d4e76214Sopenharmony_ci 56d4e76214Sopenharmony_ciIn general, this library can be built and installed with the following 57d4e76214Sopenharmony_cicommands: 58d4e76214Sopenharmony_ci 59d4e76214Sopenharmony_ci $ autoreconf -i # Needed only for building from git. Depends on libtool. 60d4e76214Sopenharmony_ci $ ./configure --prefix=PREFIX 61d4e76214Sopenharmony_ci $ make 62d4e76214Sopenharmony_ci $ make install 63d4e76214Sopenharmony_ci 64d4e76214Sopenharmony_ciwhere `PREFIX` is the installation prefix. By default, a prefix of 65d4e76214Sopenharmony_ci`/usr/local` is used, such that `libunwind.a` is installed in 66d4e76214Sopenharmony_ci`/usr/local/lib` and `unwind.h` is installed in `/usr/local/include`. For 67d4e76214Sopenharmony_citesting, you may want to use a prefix of `/usr/local` instead. 68d4e76214Sopenharmony_ci 69d4e76214Sopenharmony_ci 70d4e76214Sopenharmony_ci### Building with Intel compiler 71d4e76214Sopenharmony_ci 72d4e76214Sopenharmony_ci#### Version 8 and later 73d4e76214Sopenharmony_ci 74d4e76214Sopenharmony_ciStarting with version 8, the preferred name for the IA-64 Intel 75d4e76214Sopenharmony_cicompiler is `icc` (same name as on x86). Thus, the configure-line 76d4e76214Sopenharmony_cishould look like this: 77d4e76214Sopenharmony_ci 78d4e76214Sopenharmony_ci $ ./configure CC=icc CFLAGS="-g -O3 -ip" CXX=icc CCAS=gcc CCASFLAGS=-g \ 79d4e76214Sopenharmony_ci LDFLAGS="-L$PWD/src/.libs" 80d4e76214Sopenharmony_ci 81d4e76214Sopenharmony_ci 82d4e76214Sopenharmony_ci### Building on HP-UX 83d4e76214Sopenharmony_ci 84d4e76214Sopenharmony_ciFor the time being, libunwind must be built with GCC on HP-UX. 85d4e76214Sopenharmony_ci 86d4e76214Sopenharmony_cilibunwind should be configured and installed on HP-UX like this: 87d4e76214Sopenharmony_ci 88d4e76214Sopenharmony_ci $ ./configure CFLAGS="-g -O2 -mlp64" CXXFLAGS="-g -O2 -mlp64" 89d4e76214Sopenharmony_ci 90d4e76214Sopenharmony_ciCaveat: Unwinding of 32-bit (ILP32) binaries is not supported at the moment. 91d4e76214Sopenharmony_ci 92d4e76214Sopenharmony_ci### Workaround for older versions of GCC 93d4e76214Sopenharmony_ci 94d4e76214Sopenharmony_ciGCC v3.0 and GCC v3.2 ship with a bad version of `sys/types.h`. The 95d4e76214Sopenharmony_ciworkaround is to issue the following commands before running 96d4e76214Sopenharmony_ci`configure`: 97d4e76214Sopenharmony_ci 98d4e76214Sopenharmony_ci $ mkdir $top_dir/include/sys 99d4e76214Sopenharmony_ci $ cp /usr/include/sys/types.h $top_dir/include/sys 100d4e76214Sopenharmony_ci 101d4e76214Sopenharmony_ciGCC v3.3.2 or later have been fixed and do not require this 102d4e76214Sopenharmony_ciworkaround. 103d4e76214Sopenharmony_ci 104d4e76214Sopenharmony_ci### Building for PowerPC64 / Linux 105d4e76214Sopenharmony_ci 106d4e76214Sopenharmony_ciFor building for power64 you should use: 107d4e76214Sopenharmony_ci 108d4e76214Sopenharmony_ci $ ./configure CFLAGS="-g -O2 -m64" CXXFLAGS="-g -O2 -m64" 109d4e76214Sopenharmony_ci 110d4e76214Sopenharmony_ciIf your power support altivec registers: 111d4e76214Sopenharmony_ci 112d4e76214Sopenharmony_ci $ ./configure CFLAGS="-g -O2 -m64 -maltivec" CXXFLAGS="-g -O2 -m64 -maltivec" 113d4e76214Sopenharmony_ci 114d4e76214Sopenharmony_ciTo check if your processor has support for vector registers (altivec): 115d4e76214Sopenharmony_ci 116d4e76214Sopenharmony_ci cat /proc/cpuinfo | grep altivec 117d4e76214Sopenharmony_ci 118d4e76214Sopenharmony_ciand should have something like this: 119d4e76214Sopenharmony_ci 120d4e76214Sopenharmony_ci cpu : PPC970, altivec supported 121d4e76214Sopenharmony_ci 122d4e76214Sopenharmony_ciIf libunwind seems to not work (backtracing failing), try to compile 123d4e76214Sopenharmony_ciit with `-O0`, without optimizations. There are some compiler problems 124d4e76214Sopenharmony_cidepending on the version of your gcc. 125d4e76214Sopenharmony_ci 126d4e76214Sopenharmony_ci### Building on FreeBSD 127d4e76214Sopenharmony_ci 128d4e76214Sopenharmony_ciGeneral building instructions apply. To build and execute several tests 129d4e76214Sopenharmony_cion older versions of FreeBSD, you need libexecinfo library available in 130d4e76214Sopenharmony_ciports as devel/libexecinfo. This port has been removed as of 2017 and is 131d4e76214Sopenharmony_ciindeed no longer needed. 132d4e76214Sopenharmony_ci 133d4e76214Sopenharmony_ci## Regression Testing 134d4e76214Sopenharmony_ci 135d4e76214Sopenharmony_ciAfter building the library, you can run a set of regression tests with: 136d4e76214Sopenharmony_ci 137d4e76214Sopenharmony_ci $ make check 138d4e76214Sopenharmony_ci 139d4e76214Sopenharmony_ci### Expected results on IA-64 Linux 140d4e76214Sopenharmony_ci 141d4e76214Sopenharmony_ciUnless you have a very recent C library and compiler installed, it is 142d4e76214Sopenharmony_cicurrently expected to have the following tests fail on IA-64 Linux: 143d4e76214Sopenharmony_ci 144d4e76214Sopenharmony_ci* `Gtest-init` (should pass starting with glibc-2.3.x/gcc-3.4) 145d4e76214Sopenharmony_ci* `Ltest-init` (should pass starting with glibc-2.3.x/gcc-3.4) 146d4e76214Sopenharmony_ci* `test-ptrace` (should pass starting with glibc-2.3.x/gcc-3.4) 147d4e76214Sopenharmony_ci* `run-ia64-test-dyn1` (should pass starting with glibc-2.3.x) 148d4e76214Sopenharmony_ci 149d4e76214Sopenharmony_ciThis does not mean that libunwind cannot be used with older compilers 150d4e76214Sopenharmony_cior C libraries, it just means that for certain corner cases, unwinding 151d4e76214Sopenharmony_ciwill fail. Since they're corner cases, it is not likely for 152d4e76214Sopenharmony_ciapplications to trigger them. 153d4e76214Sopenharmony_ci 154d4e76214Sopenharmony_ciNote: If you get lots of errors in `Gia64-test-nat` and `Lia64-test-nat`, it's 155d4e76214Sopenharmony_cialmost certainly a sign of an old assembler. The GNU assembler used 156d4e76214Sopenharmony_cito encode previous-stack-pointer-relative offsets incorrectly. 157d4e76214Sopenharmony_ciThis bug was fixed on 21-Sep-2004 so any later assembler will be 158d4e76214Sopenharmony_cifine. 159d4e76214Sopenharmony_ci 160d4e76214Sopenharmony_ci### Expected results on x86 Linux 161d4e76214Sopenharmony_ci 162d4e76214Sopenharmony_ciThe following tests are expected to fail on x86 Linux: 163d4e76214Sopenharmony_ci 164d4e76214Sopenharmony_ci* `test-ptrace` 165d4e76214Sopenharmony_ci 166d4e76214Sopenharmony_ci### Expected results on x86-64 Linux 167d4e76214Sopenharmony_ci 168d4e76214Sopenharmony_ciThe following tests are expected to fail on x86-64 Linux: 169d4e76214Sopenharmony_ci 170d4e76214Sopenharmony_ci* `run-ptrace-misc` (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18748> 171d4e76214Sopenharmony_ci and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18749>) 172d4e76214Sopenharmony_ci 173d4e76214Sopenharmony_ci### Expected results on PARISC Linux 174d4e76214Sopenharmony_ci 175d4e76214Sopenharmony_ciCaveat: GCC v3.4 or newer is needed on PA-RISC Linux. Earlier 176d4e76214Sopenharmony_civersions of the compiler failed to generate the exception-handling 177d4e76214Sopenharmony_ciprogram header (`GNU_EH_FRAME`) needed for unwinding. 178d4e76214Sopenharmony_ci 179d4e76214Sopenharmony_ciThe following tests are expected to fail on x86-64 Linux: 180d4e76214Sopenharmony_ci 181d4e76214Sopenharmony_ci* `Gtest-bt` (backtrace truncated at `kill()` due to lack of unwind-info) 182d4e76214Sopenharmony_ci* `Ltest-bt` (likewise) 183d4e76214Sopenharmony_ci* `Gtest-resume-sig` (`Gresume.c:my_rt_sigreturn()` is wrong somehow) 184d4e76214Sopenharmony_ci* `Ltest-resume-sig` (likewise) 185d4e76214Sopenharmony_ci* `Gtest-init` (likewise) 186d4e76214Sopenharmony_ci* `Ltest-init` (likewise) 187d4e76214Sopenharmony_ci* `Gtest-dyn1` (no dynamic unwind info support yet) 188d4e76214Sopenharmony_ci* `Ltest-dyn1` (no dynamic unwind info support yet) 189d4e76214Sopenharmony_ci* `test-setjmp` (`longjmp()` not implemented yet) 190d4e76214Sopenharmony_ci* `run-check-namespace` (toolchain doesn't support `HIDDEN` yet) 191d4e76214Sopenharmony_ci 192d4e76214Sopenharmony_ci### Expected results on HP-UX 193d4e76214Sopenharmony_ci 194d4e76214Sopenharmony_ci`make check` is currently unsupported for HP-UX. You can try to run 195d4e76214Sopenharmony_ciit, but most tests will fail (and some may fail to terminate). The 196d4e76214Sopenharmony_cionly test programs that are known to work at this time are: 197d4e76214Sopenharmony_ci 198d4e76214Sopenharmony_ci* `tests/bt` 199d4e76214Sopenharmony_ci* `tests/Gperf-simple` 200d4e76214Sopenharmony_ci* `tests/test-proc-info` 201d4e76214Sopenharmony_ci* `tests/test-static-link` 202d4e76214Sopenharmony_ci* `tests/Gtest-init` 203d4e76214Sopenharmony_ci* `tests/Ltest-init` 204d4e76214Sopenharmony_ci* `tests/Gtest-resume-sig` 205d4e76214Sopenharmony_ci* `tests/Ltest-resume-sig` 206d4e76214Sopenharmony_ci 207d4e76214Sopenharmony_ci### Expected results on PPC64 Linux 208d4e76214Sopenharmony_ci 209d4e76214Sopenharmony_ci`make check` should run with no more than 10 out of 24 tests failed. 210d4e76214Sopenharmony_ci 211d4e76214Sopenharmony_ci### Expected results on Solaris x86-64 212d4e76214Sopenharmony_ci 213d4e76214Sopenharmony_ci`make check` is passing 27 out of 33 tests. The following six tests are consistently 214d4e76214Sopenharmony_cifailing: 215d4e76214Sopenharmony_ci 216d4e76214Sopenharmony_ci* `Gtest-concurrent` 217d4e76214Sopenharmony_ci* `Ltest-concurrent` 218d4e76214Sopenharmony_ci* `Ltest-init-local-signal` 219d4e76214Sopenharmony_ci* `Lrs-race` 220d4e76214Sopenharmony_ci* `test-setjmp` 221d4e76214Sopenharmony_ci* `x64-unwind-badjmp-signal-frame` 222d4e76214Sopenharmony_ci 223d4e76214Sopenharmony_ci## Performance Testing 224d4e76214Sopenharmony_ci 225d4e76214Sopenharmony_ciThis distribution includes a few simple performance tests which give 226d4e76214Sopenharmony_cisome idea of the basic cost of various libunwind operations. After 227d4e76214Sopenharmony_cibuilding the library, you can run these tests with the following 228d4e76214Sopenharmony_cicommands: 229d4e76214Sopenharmony_ci 230d4e76214Sopenharmony_ci $ cd tests 231d4e76214Sopenharmony_ci $ make perf 232d4e76214Sopenharmony_ci 233d4e76214Sopenharmony_ci## Contacting the Developers 234d4e76214Sopenharmony_ci 235d4e76214Sopenharmony_ciPlease direct all questions regarding this library to <libunwind-devel@nongnu.org>. 236d4e76214Sopenharmony_ci 237d4e76214Sopenharmony_ciYou can do this by sending an email to <libunwind-request@nongnu.org> with 238d4e76214Sopenharmony_cia body of "subscribe libunwind-devel", or you can subscribe and manage your 239d4e76214Sopenharmony_cisubscription via the web-interface at <https://savannah.nongnu.org/mail/?group=libunwind>. 240d4e76214Sopenharmony_ci 241d4e76214Sopenharmony_ciYou can also interact on our GitHub page: <https://github.com/libunwind/libunwind>. 242