#
# spec file for package libunwind
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


# Disable LTO on aarch64
# https://github.com/libunwind/libunwind/issues/693
%ifarch aarch64
%define _lto_cflags %{nil}
%endif

# Note the wrong version number from upstream
Name:           libunwind
Version:        1.8.1
Release:        3.1
Summary:        Call chain detection library
License:        MIT
Group:          System/Base
URL:            https://savannah.nongnu.org/projects/libunwind/
Source0:        https://github.com/libunwind/libunwind/releases/download/v%{version}/%{name}-%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        https://github.com/libunwind/libunwind/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc#/%{name}-%{version}.tar.gz.asc
Source2:        %{name}.keyring
Source3:        baselibs.conf
# PATCH-FIX-UPSTREAM https://github.com/libunwind/libunwind/pull/712
Patch1:         dont-disable-documentation-without-latex2man.patch
# PATCH-FIX-UPSTREAM https://github.com/libunwind/libunwind/pull/831
Patch2:         malloc-prototype.patch
BuildRequires:  automake >= 1.14
BuildRequires:  gcc-c++
BuildRequires:  libtool
BuildRequires:  lzma-devel
BuildRequires:  pkgconfig
ExcludeArch:    s390

%description
A C programming interface (API) to determine the call chain of a program.

%package -n libunwind8
Summary:        Call chain detection library for process self-inspection
Group:          System/Libraries
Conflicts:      libunwind < %{version}-%{release}

%description -n libunwind8
A C programming interface (API) to determine the call chain of a
program from within the same process.

%package -n libunwind-coredump0
Summary:        Call chain detection library for coredump images
Group:          System/Libraries
Conflicts:      libunwind < %{version}-%{release}

%description -n libunwind-coredump0
A C programming interface (API) to determine the call chains
of the threads in coredump images.

%package -n libunwind-ptrace0
Summary:        Call chain detection library for ptraced processes
Group:          System/Libraries
Conflicts:      libunwind < %{version}-%{release}

%description -n libunwind-ptrace0
A C programming interface (API) to determine the call chains of
another process by means of using ptrace(2) on it.

%package -n libunwind-setjmp0
Summary:        Non-local goto (setjmp/longmap) implementation based on libunwind
Group:          System/Libraries
Conflicts:      libunwind < %{version}-%{release}

%description -n libunwind-setjmp0
The unwind-setjmp library offers a libunwind-based implementation of
non-local gotos. This is a drop-in replacement for the normal,
system-provided routines of the same name. With this library, setting
up a non-local goto via setjmp is generally faster compared to the
system routines, at the cost of a much slower longjmp.

%package devel
Summary:        Headers for the Unwind library
Group:          Development/Libraries/C and C++
%ifnarch ppc ppc64 ppc64le s390x
Requires:       libunwind-coredump0 = %{version}-%{release}
%endif
Requires:       libunwind-ptrace0 = %{version}-%{release}
Requires:       libunwind-setjmp0 = %{version}-%{release}
Requires:       libunwind8 = %{version}-%{release}

%description devel
A set of C programming interfaces to determine the call chain within a running
program (libunwind), of a coredump image (libunwind-coredump), or of a separate
process (libunwind-ptrace).

%prep
%autosetup -p1 -n %{name}-%{version}

%build
autoreconf -fiv
%configure \
    --enable-minidebuginfo
%make_build

%check
# run-coredump-unwind fails
%make_build check || :

%install
%make_install
find %{buildroot} -iregex '.*\.l?a$' -delete -print
# Help packagers with %%files
find %{buildroot}/%{_libdir} -type f | sort
# Do not install the test files
rm -rf %{buildroot}%{_libexecdir}/%{name}

%post   -n libunwind8 -p /sbin/ldconfig
%postun -n libunwind8 -p /sbin/ldconfig
%post   -n libunwind-coredump0 -p /sbin/ldconfig
%postun -n libunwind-coredump0 -p /sbin/ldconfig
%post   -n libunwind-ptrace0 -p /sbin/ldconfig
%postun -n libunwind-ptrace0 -p /sbin/ldconfig
%post   -n libunwind-setjmp0 -p /sbin/ldconfig
%postun -n libunwind-setjmp0 -p /sbin/ldconfig

%files -n libunwind8
%license COPYING
%doc README NEWS
%{_libdir}/libunwind.so.8*
%ifarch %arm
%{_libdir}/libunwind-arm.so.8*
%else
%ifarch riscv32 riscv64
%{_libdir}/libunwind-riscv.so.8*
%else
%ifarch %ix86
%{_libdir}/libunwind-x86.so.8*
%else
%ifarch ppc
%{_libdir}/libunwind-ppc32.so.8*
%else
%ifarch ppc64 ppc64le
%{_libdir}/libunwind-ppc64.so.8*
%else
%{_libdir}/libunwind-%{_target_cpu}.so.8*
%endif
%endif
%endif
%endif
%endif

%ifnarch ppc ppc64 ppc64le s390x
%files -n libunwind-coredump0
%{_libdir}/libunwind-coredump.so.0*
%endif

%files -n libunwind-setjmp0
%{_libdir}/libunwind-setjmp.so.0*

%files -n libunwind-ptrace0
%{_libdir}/libunwind-ptrace.so.0*

%files devel
%{_includedir}/*
%{_libdir}/%{name}*.so
%{_libdir}/pkgconfig/%{name}*.pc
%{_mandir}/man3/*

%changelog
* Sat Apr  5 2025 Friedrich Haubensak <hsk17@mail.de>
- Add malloc-prototype.patch to fix gcc15 compile time error
* Fri Mar 22 2024 Fabian Vogt <fvogt@suse.com>
- Drop BuildRequires on latex2man, the tarball has manpages already.
  This avoids a large dependency chain:
  * Add dont-disable-documentation-without-latex2man.patch
* Fri Feb 23 2024 Pedro Monreal <pmonreal@suse.com>
- Update to 1.8.1:
  * Fix issue #713 by @cshung in #717
  * Add do-release script by @bregma in #725
  * Backport dotnet-runtime fixes to the 1.8 branch by @bregma in #726
  * [v1.8] Make tests installable by @bregma in #722
  * Bump version to 1.8.1 by @bregma in #727
* Mon Feb 12 2024 Guillaume GARDET <guillaume.gardet@opensuse.org>
- Disable LTO on aarch64 until upstream fix the issue:
  https://github.com/libunwind/libunwind/issues/693
* Tue Jan 30 2024 Pedro Monreal <pmonreal@suse.com>
- Update to 1.8.0:
  * Improve unwinding through a bad function pointer on x86_64
  * Fix UMRs indicated by valgrind (x86_64)
  * fix byte_order_is_valid function logic
  * Use size_t to match R.H.S
  * Move get_proc_info_in_range under dwarf/
  * Bump actions/checkout@v2 to @V3
  * dwarf_find_unwind_table: Find load_base correctly when current
    segment does not start at segbase
  * Add introspection for march=armv8-a+sve
  * Linux: Make get_elf_image guaranteed AS-safe
  * Provide syscall wrappers for mmap and munmap
  * Allow to use a custom dl_iterate_phdr implementation
  * aarch64: unw_step() validates address before calling dwarf_get
  * Provide AS-safe allocator to LZMA
  * Rework register load in aarch64_local_resume()
  * Fix arm postdecrement
  * Added support for unwinding through PPC64 PLT entries
  * Fix array indexing bug in dwarf_search_unwind_table
  * Fix unaligned memory accesses in */Ginit.c
  * Get filename and offset from ip
  * Fix maps leak if caller's pathlen is too small
  * Adjust DYNAMIC addrs in loaded image
  * Fix crash in elf_w(valid_object)
  * Fix segfault on QNX
* Wed Aug 30 2023 Pedro Monreal <pmonreal@suse.com>
- Update to 1.7.2:
  * Don't override sp on arm and mips64.
  * Add direct dependent libraries to remotes.
  * Fix make install failure.
* Mon Aug 28 2023 Pedro Monreal <pmonreal@suse.com>
- Update to 1.7.1:
  * Bump to release 1.7.1 to fix source tarball naming issue
* Fri Jun 23 2023 Pedro Monreal <pmonreal@suse.com>
- Update to 1.7.0:
  * DWARF: dwarf4 fix cie parsing.
  * x86_64: Stop aliasing RSP and CFA.
  * Prefer EXTBL unwinding on ARM.
  * [GCC pedantic] Fix "error: comma at end of enumerator list"
    when linking to libunwind.
  * Fix table indexing in dwarf_search_unwind_table.
  * Expose function-pointer-to-name API.
  * Add port for Linux on LoongArch.
  * Add more POSIX polyfills for nix cross-build on win.
  * DWARF: avoid a data race.
  * skip latex2man check with --disable-documentation.
  * Skip init_mem_validate calls during remote unwind.
  * [Loongarch64] amend the LoongArch64's CMakeLists.txt and compiling error.
  * Update license in pal-single-threaded.c.
  * Fix to malloc call in tdep_get_elf_image.
  * Updated to determine PAGE_SIZE dynamically.
  * Unwind with pointer authentication on arm64.
  * Make some structs non-empty.
  * DWARF: avoid invalid memory access with invalid CFI.
  * fix incorrect store in AArch64 getcontext.
  * avoid leaking registers across sigreturn.
  * Use constant for array size in os-linux.
  * added coredump support for s390x.
  * Allow an alternate LOG_DRIVER to be specified.
  * Remove bashisms from tests/check-namespace.sh.
  * Add autodetection of procfs_status type.
  * Add remote unwinding support for macOS.
  * Expose get_proc_info_in_range API.
  * Autodetect presence of elf_fpregset_t.
  * coredump: stop assuming .text and .eh_frame are both in the first
    segment of an ELF file.
  * Make sigaltstack() optional.
  * Add support for arm fp registers unwind.
  * updated dist to focal for s390x jobs.
  * Add RISC-V machine value in remote unwind.
  * Fix SOFTFP case for arm getcontext.
  * Added support for unwinding from the vsyscall region.
  * Stop the autotools nag about AC_CONFIG_MACRO_DIRS.
  * Fix make distcheck due to missing coredump header.
  * Fix undefined behavior issues in aarch64.
  * Account for lr in aarch64's uc_addr.
  * tests/run-coredump-unwind: Skip test if no coredump has been created.
  * [LoongArch64] Update the port to latest kernel ABI.
  * arm64: Add support for unwinding in SVE functions
  * check-namespace.sh: adjust aarch64 symbols.
  * Updated to determine PAGE_SIZE dynamically for loongarch64.
  * Gia64-test-nat.c: #include <signal.h> for sigaction().
  * Fix for unw_backtrace fast path does not work on x86_64.
  * fix the way load offset is detected so it works with lld linker.
  * Remove the unused powerpc setcontext() dummies.
  * Add unw_backtrace2 function.
- Include the man pages, README and LICENSE files.
- Update libunwind.keyring file.
* Mon May 23 2022 Andreas Schwab <schwab@suse.de>
- Fix dependencies
- Fix file list
* Wed May 18 2022 Jan Engelhardt <jengelh@inai.de>
- Adjust baselibs.conf for shlib guideline.
* Mon May 16 2022 Jan Engelhardt <jengelh@inai.de>
- Add Conflict markers for earlier combined libunwind.
* Fri May 13 2022 Jan Engelhardt <jengelh@inai.de>
- Resolve rpmlint error "libunwind.x86_64: E:
  shlib-policy-name-error SONAME: libunwind-coredump.so.0,
  expected package suffix: 0"
* Fri May  6 2022 Andreas Schwab <schwab@suse.de>
- Enable build on riscv64 and run testsuite
* Thu Apr 21 2022 Dirk Müller <dmueller@suse.com>
- update to 1.6.2:
  * Fix off-by-one error in x86_64 stack frames
  * Fix error in aarch64 unw_sigcontext
  * resolve possible null pointer dereference
  * Switch to C11 atomics
  * RISC-V support
  * aarch64 getcontext functionality
* Tue Jan 19 2021 Dirk Müller <dmueller@suse.com>
- update to 1.5.0:
  * dwarf: clang doesn't respect the static alias
  * Fixed a missing dependency in dwarf-eh.h
  * x86_64: Fix tdep_init_done when built with libatomic_ops
  * mips: make _step_n64 as a static function
  * Added braces to suppress empty if/else warnings
  * Delete hardcode of address size to support MIPS64.
  * Fix format specifier for int64_t:29
  * Add initial support for Solaris x86-64
  * x86_64: Add fixup code if previous RIP was invalid
  * x86-64: make `is_cached_valid_mem` functional
  * arm: clear ip thumb/arm mode bit before move to previous instruction
  * Fix compilation with -fno-common.
  * Fix off-by-one error in x86_64 stack frames
  * aarch64: Fix __sigset build issue on muslC
  * Make SHF_COMPRESSED use contingent on its existence
- remove libunwind_U_dyn_info_list.patch (upstream)
* Tue Oct 20 2020 Berthold Gunreben <azouhr@opensuse.org>
- Enable s390x for building
* Wed May 13 2020 Pedro Monreal Gonzalez <pmonrealgonzalez@suse.com>
- Fix compilation with -fno-common [bsc#1171549]
- Add patch libunwind_U_dyn_info_list.patch
* Tue Apr 28 2020 Pedro Monreal Gonzalez <pmonrealgonzalez@suse.com>
- Update to 1.4.0
  - Fix compilation with -fno-common.
  - arm: clear ip thumb/arm mode bit before move to previous instruction (#131)
  - tests: fix test-coredump-unwind without HAVE_EXECINFO_H (#165)
  - There are 20 not 9 failing tests on Solaris (#162)
  - change asm to __asm__ to support -std=c11 or similar (#149)
  - x86-64: make `is_cached_valid_mem` functional (#146)
  - Allow to build without weak `backtrace` symbol. (#142)
  - fix compile issue on SH platform (#137)
  - Add support for zlib compressed elf .debug_frame sections
  - README: add libc requirement description (#121)
  - Older systems (e.g. RHEL5) do not have pipe2(). (#122)
  - x86_64: Add fixup code if previous RIP was invalid (#120)
  - Fix format specifier for int64_t:29 (#117)
  - Delete hardcode of address size to support MIPS64. (#114)
  - Added braces to suppress empty if/else warnings (#112)
  - mips: make _step_n64 as a static function
  - x86_64: Fix tdep_init_done when built with libatomic_ops
  - x86_64: tsan clean (#109)
  - Fixed a missing dependency in dwarf-eh.h
  - dwarf: clang doesn't respect the static alias (#102)
- Update libunwind.keyring
- Remove libunwind-gcc10-build-fno-common.patch fixed upstream
* Wed Feb 19 2020 Pedro Monreal Gonzalez <pmonrealgonzalez@suse.com>
- Fix build with GCC-10: [bsc#1160876]
  * In GCC-10, the default option -fcommon will change to -fno-common
- Add libunwind-gcc10-build-fno-common.patch
* Sun Jul  7 2019 Jan Engelhardt <jengelh@inai.de>
- Ensure neutrality of description. Avoid name repetition in
  summaries.
* Mon Jul  1 2019 Andreas Schwab <schwab@suse.de>
- Update to 1.3.1
  * Iteration of unwind register states support
  * Freebsd/Armv6 support
  * Many, many dwarf bugfixes
  * Mips remote unwind support
  * aarch64 ptrace support
- fix_versioning_libunwind_1.2.1.patch: removed
* Sun Feb 18 2018 ronisbr@gmail.com
- Add patch `fix_versioning_libunwind_1.2.1.patch`.
  * This patch fixes the upstream bug gh#libunwind/libunwind#30.
    This bug was causing the julia build process to fail.
    NOTE: This patch shall be removed in the next version of
    libunwind.
* Fri Feb  2 2018 tchvatal@suse.com
- Update keyring
* Wed Jan 24 2018 avindra@opensuse.org
- Upgrade to 1.2.1
  * minor package fixes for tilegx, mips, others
  * fix missing include file issues
- cleanup with spec-cleaner
- do not ship static libraries
* Mon Jun 20 2016 tchvatal@suse.com
- Enable minidebugs parsing with lzma
* Tue May 17 2016 tchvatal@suse.com
- Version update to 1.2-rc1, should include all our patches:
  * 0001-Mark-run-ptrace-mapper-and-run-ptrace-misc-as-XFAIL-.patch
  * 0002-Mark-run-ptrace-mapper-and-run-ptrace-misc-as-XFAIL-.patch
  * libunwind-1.1-expected-fails.patch
  * libunwind-CVE-2015-3239.patch
  * libunwind-aarch64.patch
  * libunwind-ppc64le.patch
  * libunwind-1.1-tests.diff
* Sun Apr 24 2016 matwey.kornilov@gmail.com
- Add patches for boo#976955:
  * 0001-Mark-run-ptrace-mapper-and-run-ptrace-misc-as-XFAIL-.patch
  * 0002-Mark-run-ptrace-mapper-and-run-ptrace-misc-as-XFAIL-.patch
* Thu Jul  2 2015 tchvatal@suse.com
- Add patch for bnc#936786 CVE-2015-3239, off by one:
  * libunwind-CVE-2015-3239.patch
* Sun Mar 29 2015 meissner@suse.com
- added baselibs.conf for -xxbit packages
* Wed Mar  4 2015 mpluskal@suse.com
- Use url for source
- Add gpg signature
* Mon May 19 2014 tchvatal@suse.com
- Clean up with spec-cleaner
- Add dependency over libatomic_opts that was missing
- Do not disable fortify-sources as it seems to work with it anyway
* Tue Dec 17 2013 uweigand@de.ibm.com
- libunwind-ppc64le.patch: Add support for ppc64le
* Wed Dec 11 2013 dvaleev@suse.com
- add ppc64le
* Mon Aug 12 2013 schwab@suse.de
- libunwind-aarch64.patch: Add support for AArch64 from upstream
* Sat Jan 26 2013 dmueller@suse.com
- filelist fix for ARM
* Tue Dec 11 2012 dvaleev@suse.com
- update to libunwind 1.1:
    coredump unwind support
    New arch: SuperH
    Improved support for PowerPC, ARM
    Lots of cleanups, perf tweaks
    pkg-config support
- drop all upstreamed patches
- refresh libunwind-1.1-tests.diff patch
- enable ppc ppc64 build
- Mark some tests as expected to fail
  libunwind-1.1-expected-fails.patch
* Mon Aug 20 2012 agraf@suse.com
- add support for ARM
* Mon Mar  5 2012 dmueller@suse.de
- remove build from ARM
* Thu Feb  9 2012 jengelh@medozas.de
- Remove redundant tags/sections
- Fix dangling symlink /usr/lib/libunwind.so (which was
  pointing at "libunwind.so.8.*", verbatim asterisk)
- Throw out .la file
* Wed Nov 23 2011 coolo@suse.com
- add libtool as buildrequire to avoid implicit dependency
* Mon Nov  7 2011 dmueller@suse.de
- disable testsuite when running under qemu
* Mon Oct 17 2011 dmueller@suse.de
-  update to libunwind 1.0.1:
  * hundreds of fixes, see http://git.savannah.gnu.org/gitweb/?p=libunwind.git;a=shortlog
    for details
  * ARM support
  * Greatly improved x86-64 support thanks to Arun Sharma.
  * Support for PPC64 added by  Jose Flavio Aguilar Paulino.
  * Testing, stability and many fixes on x86 (Paul Pluzhnikov)
  * Improved local and remote unwinding on ARM (Ken Werner)
  * Fast unwind (rbp, rsp, rip only) on x86_64 with a fallback to slow code paths
* Sun Oct 31 2010 jengelh@medozas.de
- Use %%_smp_mflags
* Thu Jan 28 2010 rguenther@suse.de
- Build without _FORTIFY_SOURCE, recent glibc fortify longjmp which
  confuses libunwind a lot and breaks the build.
* Thu Oct 15 2009 marek.belisko@open-nandra.com
- Fix typo in Gtest-dyn1.c (bnc#531705)
* Mon Jan 26 2009 schwab@suse.de
- Fix overlapping memcpy.
* Tue May 13 2008 schwab@suse.de
- Update to libunwind 0.98.6.
  * * Fix address-leak triggered by invalid byte-order.  Fixed by Andreas Schwab.
  * * On ia64, get_static_proc_name() no longer uses a weak reference to
    _Uelf64_get_proc_name(), since that was causing problems with archive
    libraries and no longer served any apparent purpose.  Fixed by
    Curt Wohlgemuth.
* Fri Apr 18 2008 rguenther@suse.de
- Fix build.
* Wed Jun  6 2007 schwab@suse.de
- Fix memory leak.
* Thu Jan 26 2006 schwab@suse.de
- Run ldconfig.
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Nov 14 2005 schwab@suse.de
- Undo last change.
* Mon Oct 31 2005 dmueller@suse.de
- build with nonexecutable stack
* Fri Jul 22 2005 schwab@suse.de
- Remove broken tests.
* Mon May  2 2005 schwab@suse.de
- Fix broken test.
* Sat Apr 23 2005 schwab@suse.de
- Only libunwind needs to be in /lib.
- There are no expected testsuite failures on ia64 any more.
* Thu Apr 21 2005 schwab@suse.de
- Update to libunwind 0.98.5.
* Fri Feb 25 2005 schwab@suse.de
- Update to libunwind 0.98.4.
* Thu Feb  3 2005 schwab@suse.de
- Fix libdir.
- Fix warning.
* Tue Dec  7 2004 schwab@suse.de
- Update to libunwind 0.98.3.
* Sun Nov 14 2004 schwab@suse.de
- Don't move around libtool libraries.
* Sun Nov 14 2004 schwab@suse.de
- Split off libunwind-devel.
- Move library to /lib.
- Remove broken test.
* Fri Nov  5 2004 schwab@suse.de
- Update to libunwind 0.98.2.
* Thu Oct 28 2004 schwab@suse.de
- Update to libunwind 0.98.1.
* Wed Sep 29 2004 schwab@suse.de
- Fix installed headers.
* Thu Sep  9 2004 schwab@suse.de
- Update to libunwind 0.98.
- Enable building on x86_64.
* Thu Aug 19 2004 schwab@suse.de
- Update to libunwind 0.97.
* Sun Apr 18 2004 schwab@suse.de
- Pacify autobuild.
* Fri Dec  5 2003 schwab@suse.de
- Update to libunwind 0.96.
* Thu Dec  4 2003 schwab@suse.de
- Update to libunwind 0.95.
* Fri Sep 26 2003 schwab@suse.de
- Update to libunwind 0.93.
* Wed Jul 23 2003 schwab@suse.de
- Fix typo in specfile.
* Thu Jul 11 2002 schwab@suse.de
- Initial version.