1config BR2_PACKAGE_LIBUNWIND_MUSL_CONTEXT_REQUIRED
2	bool
3	default y
4	depends on !BR2_ARM_CPU_HAS_ARM
5	depends on !BR2_aarch64
6	depends on !BR2_aarch64_be
7	depends on !BR2_mips
8	depends on !BR2_mipsel
9	depends on !BR2_mips64
10	depends on !BR2_mips64el
11	depends on !BR2_riscv
12	depends on !BR2_x86_64
13	depends on BR2_TOOLCHAIN_USES_MUSL
14
15# libunwind is only available for a certain subset of the
16# architectures (as visible in the list of architectures supported
17# with the glibc C library below).
18#
19# In addition to this, on some architectures libunwind requires the
20# *context() function from the C library, which are only available on
21# certain architectures in uClibc, and not available at all on
22# musl. But on some other architectures, libunwind works without using
23# the *context() functions, which allows it to be built with musl.
24config BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS
25	bool
26	default y if BR2_TOOLCHAIN_USES_GLIBC && \
27		(BR2_ARM_CPU_HAS_ARM || BR2_aarch64 || BR2_mips || BR2_mipsel || \
28		 BR2_mips64 || BR2_mips64el || BR2_powerpc || BR2_sh || \
29		 BR2_i386 || BR2_x86_64)
30	default y if BR2_TOOLCHAIN_USES_UCLIBC && \
31		(BR2_ARM_CPU_HAS_ARM || BR2_mips || BR2_mipsel || \
32		 BR2_mips64 || BR2_mips64el || BR2_x86_64)
33	default y if BR2_TOOLCHAIN_USES_MUSL && \
34		(!BR2_PACKAGE_LIBUNWIND_MUSL_CONTEXT_REQUIRED || \
35		 BR2_PACKAGE_LIBUCONTEXT_ARCH_SUPPORTS)
36
37config BR2_PACKAGE_LIBUNWIND
38	bool "libunwind"
39	depends on BR2_TOOLCHAIN_HAS_THREADS
40	depends on BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS
41	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C11 atomics
42	# forcefully links against libgcc_s, only available in dynamic
43	# linking configurations
44	depends on !BR2_STATIC_LIBS
45	select BR2_PACKAGE_LIBUCONTEXT if BR2_TOOLCHAIN_USES_MUSL && \
46		BR2_PACKAGE_LIBUNWIND_MUSL_CONTEXT_REQUIRED
47	help
48	  C API to determine the call-chain of a program.
49
50	  http://www.nongnu.org/libunwind/index.html
51
52comment "libunwind needs a toolchain w/ threads, dynamic library, gcc >= 4.9"
53	depends on BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS
54	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS || \
55		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
56