Skip to contentSkip to conversation

package/btrfs-progs: fix build issues under musl

PATCH Superseded Brendan Heading 3 participants 3 messages Jul 30, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/btrfs-progs: fix build issues under musl

Fixes http://autobuild.buildroot.net/results/b97/b97f1e9cd459da96e3e1680bb7c43d8103ab12c2/build-end.log

Patches by Thomas to refactor detection of __always_inline and backtrace detection. Also added #include <limits.h> for PATH_MAX.

---
 ...01-configure-refactor-backtrace-detection.patch | 132 +++++++++++++++++++++
 ...onfigure-refactor-always_inline-detection.patch |  56 +++++++++
 ...compile-fix-undefined-PATH_MAX-under-musl.patch |  67 +++++++++++
 3 files changed, 255 insertions(+)
 create mode 100644 package/btrfs-progs/0001-configure-refactor-backtrace-detection.patch
 create mode 100644 package/btrfs-progs/0002-configure-refactor-always_inline-detection.patch
 create mode 100644 package/btrfs-progs/0003-compile-fix-undefined-PATH_MAX-under-musl.patch
package/btrfs-progs/0001-configure-refactor-backtrace-detection.patch new file +132 -0
new file mode 100644
index 0000000..0f834de
@@ -0,0 +1,132 @@
+From 9bef473d17ec01efe760462271791dfaaea280c0 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Wed, 29 Jul 2015 22:35:19 +0200
+Subject: [PATCH 1/3] configure: refactor backtrace() detection
+
+The current code assumes that if __GLIBC__ is not defined, backtrace
+support is not available, and defines BTRFS_DISABLE_BACKTRACE.
+
+However, this macro is already defined by the configure.ac script when
+--disable-backtrace is passed. This means that if you are using a C
+library like musl which does not define __GLIBC__, and you pass
+--disable-backtrace, you get a macro redefinition.
+
+Instead of relying on __GLIBC__, this commit implements a proper
+configure.ac based detection of backtrace support:
+
+ * If the user passes --enable-backtrace, we check if the backtrace()
+   function is available. If not, we abort the configure process with
+   an error. Otherwise we enable backtrace support by defining
+   HAVE_BACKTRACE.
+
+ * If the user passes --disable-backtrace, then we don't enable
+   backtrace support.
+
+ * If the user passes nothing special, we auto-detect: if backtrace()
+   is available, we use it, otherwise we simply warn at configure time
+   but not fail.
+
+Upstream-status: pending
+Signed-off-by: Thomas Petazzoni <[email protected]>
+Signed-off-by: Brendan Heading <[email protected]>
+---
+ configure.ac | 32 ++++++++++++++++++++++----------
+ kerncompat.h |  9 ++++-----
+ 2 files changed, 26 insertions(+), 15 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index c3a22d1..e936a10 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -63,22 +63,34 @@ AC_DEFUN([PKG_STATIC], [
+   fi
+ ])
+ 
+-
++# Provide a --{enable,disable}-backtrace option. If not passed, set
++# enable_backtrace to 'auto' so that we try to enable backtrace
++# support if available, but if not available, we gracefully fallback
++# without backtrace support.
+ AC_ARG_ENABLE([backtrace],
+   AS_HELP_STRING([--disable-backtrace], [disable btrfs backtrace]),
+-  [], [enable_backtrace=yes]
++  [enable_backtrace=${enableval}], [enable_backtrace=auto]
+ )
+ 
+-AS_IF([test "x$enable_backtrace" = xno], [
+-  AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
+-])
+-
+-if test "x$enable_backtrace" = xyes; then
+-	AC_CHECK_HEADERS([execinfo.h])
+-	AC_CHECK_FUNCS([backtrace backtrace_symbols_fd], [],
+-	      AC_MSG_ERROR([standard library does not have backtrace support]))
++# Backtrace support requested (enable_backtrace is either 'yes' or
++# 'auto'), so check for needed headers and functions.
++if test "x$enable_backtrace" != xno; then
++   AC_CHECK_HEADERS([execinfo.h])
++   AC_CHECK_FUNCS([backtrace backtrace_symbols_fd])
+ fi
+ 
++if test "x$ac_cv_func_backtrace" = xno; then
++    # If backtrace support was requested but not available, we fail if
++    # --enable-backtrace was passed, or we simply warn if we're
++    # auto-detecting.
++    if test "x$enable_backtrace" = xyes ; then
++	AC_MSG_ERROR([standard library does not have backtrace support])
++    elif test "x$enable_backtrace" = xauto ; then
++        AC_MSG_WARN([standard library does not have backtrace support, disabled])
++    fi
++else
++    AC_DEFINE([HAVE_BACKTRACE], [1], [Enable backtrace support])
++fi
+ 
+ AC_ARG_ENABLE([documentation],
+ 	      AS_HELP_STRING([--disable-documentation], [do not build domumentation]),
+diff --git a/kerncompat.h b/kerncompat.h
+index 5d92856..8318665 100644
+--- a/kerncompat.h
++++ b/kerncompat.h
+@@ -33,11 +33,10 @@
+ #include <features.h>
+ 
+ #ifndef __GLIBC__
+-#define BTRFS_DISABLE_BACKTRACE
+ #define __always_inline __inline __attribute__ ((__always_inline__))
+ #endif
+ 
+-#ifndef BTRFS_DISABLE_BACKTRACE
++#ifdef HAVE_BACKTRACE
+ #include <execinfo.h>
+ #endif
+ 
+@@ -65,7 +64,7 @@
+ #define ULONG_MAX       (~0UL)
+ #endif
+ 
+-#ifndef BTRFS_DISABLE_BACKTRACE
++#ifdef HAVE_BACKTRACE
+ #define MAX_BACKTRACE	16
+ static inline void print_trace(void)
+ {
+@@ -285,7 +284,7 @@ static inline long IS_ERR(const void *ptr)
+ #define vmalloc(x) malloc(x)
+ #define vfree(x) free(x)
+ 
+-#ifndef BTRFS_DISABLE_BACKTRACE
++#ifdef HAVE_BACKTRACE
+ #define BUG_ON(c) assert_trace(#c, __FILE__, __func__, __LINE__, !(c))
+ #else
+ #define BUG_ON(c) assert(!(c))
+@@ -293,7 +292,7 @@ static inline long IS_ERR(const void *ptr)
+ 
+ #define WARN_ON(c) BUG_ON(c)
+ 
+-#ifndef BTRFS_DISABLE_BACKTRACE
++#ifdef HAVE_BACKTRACE
+ #define	ASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (c))
+ #else
+ #define ASSERT(c) assert(c)
+-- 
+2.4.3
+
package/btrfs-progs/0002-configure-refactor-always_inline-detection.patch new file +56 -0

56 lines not on this page · raw message

package/btrfs-progs/0003-compile-fix-undefined-PATH_MAX-under-musl.patch new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.4.3
#1 lore raw

PATCH 1/1 package/btrfs-progs: fix build issues under musl

Quoted 8 lines · Brendan Heading

Fixes http://autobuild.buildroot.net/results/b97/b97f1e9cd459da96e3e1
680bb7c43d8103ab12c2/build-end.log

Patches by Thomas to refactor detection of __always_inline and backtrace
detection. Also added #include <limits.h> for PATH_MAX.

btrfs-progs successfully builds with musl after applying this patch.

#2 lore raw

PATCH 1/1 package/btrfs-progs: fix build issues under musl

In reply to Brendan Heading

Dear Brendan Heading,

Quoted 6 lines · Brendan Heading

++AX_GCC_FUNC_ATTRIBUTE(always_inline)
++
++if test "x$ax_cv_have_func_attribute_always_inline" = xyes; then
++ AC_DEFINE([HAVE_ALWAYS_INLINE], [1], [Enable always_inline support])
++fi
++

This should no longer be part of the patch.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com