[PATCH] Handle missing error.h (as seen in musl)
Haelwenn (lanodan) Monnier
contact@hacktivis.me
Fri Nov 22 19:07:47 GMT 2024
From: brahmajit das <brahmajit.xyz@gmail.com>
musl doesn't provide error.h as a result debugedit is failing to build
on musl. So we're creating a error define that redefines the err
function and takes precedence over it. Thanks to gentoo developer
Anthony G. Basile <blueness@gentoo.org> for the patch idea.
Signed-off-by: brahmajit das <brahmajit.xyz@gmail.com>
Ref: https://github.com/gentoo/gentoo/pull/26223
Signed-off-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
---
Note: I'm not subscribed to the list so please CC me on replies
configure.ac | 2 ++
tools/debugedit.c | 5 +++++
tools/sepdebugcrcfix.c | 5 +++++
3 files changed, 12 insertions(+)
diff --git a/configure.ac b/configure.ac
index a5a6e28..b1ef820 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,8 @@ PKG_CHECK_MODULES([XXHASH], [libxxhash >= 0.8.0])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h unistd.h])
+AC_CHECK_HEADERS([error.h],
+ [AC_DEFINE(HAVE_ERROR_H, 1, [has error.h -- non musl system])])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
diff --git a/tools/debugedit.c b/tools/debugedit.c
index beefd65..a713c30 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -26,7 +26,12 @@
#include <byteswap.h>
#include <endian.h>
#include <errno.h>
+#ifdef HAVE_ERROR_H
#include <error.h>
+#else
+#include <err.h>
+#define error(status, errno, ...) err(status, __VA_ARGS__)
+#endif
#include <limits.h>
#include <string.h>
#include <stdlib.h>
diff --git a/tools/sepdebugcrcfix.c b/tools/sepdebugcrcfix.c
index 4516267..83c0504 100644
--- a/tools/sepdebugcrcfix.c
+++ b/tools/sepdebugcrcfix.c
@@ -21,7 +21,12 @@
#include <endian.h>
#include <errno.h>
+#ifdef HAVE_ERROR_H
#include <error.h>
+#else
+#include <err.h>
+#define error(status, errno, ...) err(status, __VA_ARGS__)
+#endif
#include <fcntl.h>
#include <gelf.h>
#include <libelf.h>
--
2.45.2
More information about the Debugedit
mailing list