public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: david.oberhollenzer@sigma-star.at
Cc: chengzhihao1@huawei.com, raj.khem@gmail.com,
	linux-mtd@lists.infradead.org, Fabio Estevam <festevam@gmail.com>
Subject: [PATCH v4 mtd-utils 3/4] configure.ac: Add a check for execinfo and backtrace
Date: Wed, 19 Feb 2025 10:02:43 -0300	[thread overview]
Message-ID: <20250219130244.2119582-3-festevam@gmail.com> (raw)
In-Reply-To: <20250219130244.2119582-1-festevam@gmail.com>

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@gmail.com>
Suggested-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
Change since v3:
- None.

 configure.ac | 11 +++++++++++
 1 file changed, 11 insertions(+)

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 #####
-- 
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2025-02-19 13:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 13:02 [PATCH v4 mtd-utils 1/4] ubifs-utils: ubifs.h: Include <fcntl.h> Fabio Estevam
2025-02-19 13:02 ` [PATCH v4 mtd-utils 2/4] ubifs-utils: journal: Include <sys/stat.h> Fabio Estevam
2025-02-19 13:02 ` Fabio Estevam [this message]
2025-02-26 18:23   ` [PATCH v4 mtd-utils 3/4] configure.ac: Add a check for execinfo and backtrace Ross Burton
2025-02-26 20:13     ` Khem Raj
2025-02-27  6:58       ` Zhihao Cheng
2025-02-19 13:02 ` [PATCH v4 mtd-utils 4/4] ubifs-utils: extract_files: Include <linux/limits.h> Fabio Estevam
2025-06-02  5:39   ` David Oberhollenzer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250219130244.2119582-3-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=chengzhihao1@huawei.com \
    --cc=david.oberhollenzer@sigma-star.at \
    --cc=linux-mtd@lists.infradead.org \
    --cc=raj.khem@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox