[PATCH v3 mtd-utils 3/4] configure.ac: Add a check for execinfo and backtrace
Zhihao Cheng
chengzhihao1 at huawei.com
Tue Feb 18 17:24:01 PST 2025
在 2025/2/19 8:33, Fabio Estevam 写道:
> musl relies on an external execinfo library to provide backtrace
> functionality. If musl cannot link to libexecinfo, the following link
> error happens:
>
> | /work/festevam/oe/poky/build/tmp/work/core2-64-poky-linux-musl/mtd-utils/2.3.0/recipe-sysroot-native/usr/bin/x86_64-poky-linux-musl/../../libexec/x86_64-poky-linux-musl/gcc/x86_64-poky-linux-musl/14.2.0/ld: ubifs-utils/libubifs/mkfs_ubifs-io.o: in function `dump_stack':
> | /usr/src/debug/mtd-utils/2.3.0/ubifs-utils/common/defs.h:71:(.text+0x25): undefined reference to `backtrace'
> ....
> | collect2: error: ld returned 1 exit status
> | make: *** [Makefile:2959: mkfs.ubifs] Error 1
>
> Fix the problem by checking for backtrace support in libc first and if not
> found, then check for backtrace support in the external libexecinfo.
>
> Signed-off-by: Fabio Estevam <festevam at gmail.com>
> Suggested-by: Khem Raj <raj.khem at gmail.com>
> ---
> Change since v2:
> - Check for backtrace support in libc first and if not
> found, then check libexecinfo. (Khem)
>
> configure.ac | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
> diff --git a/configure.ac b/configure.ac
> index 2a79ba820fc0..296901e61760 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -238,6 +238,17 @@ if test "x$need_cmocka" = "xyes"; then
> PKG_CHECK_MODULES(CMOCKA, [cmocka], [], [cmocka_missing="yes"])
> fi
>
> +AC_CHECK_FUNC([backtrace], [have_backtrace=yes], [have_backtrace=no])
> +
> +if test "x$have_backtrace" = "xno"; then
> + AC_CHECK_LIB([execinfo], [backtrace],
> + [LIBS="$LIBS -lexecinfo"
> + AC_DEFINE([HAVE_BACKTRACE], [1], [backtrace is available via libexecinfo])],
> + [AC_MSG_WARN([backtrace support not found])])
> +else
> + AC_DEFINE([HAVE_BACKTRACE], [1], [backtrace is available via libc])
> +fi
> +
> AC_CHECK_HEADERS([execinfo.h])
>
> ##### produce summary on dependencies #####
>
More information about the linux-mtd
mailing list