This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Only workaround fts.h if we have a bad version that doesn't handle LFS.

Older versions of glibc included an fts implementation that didn't have
Large File System support. We worked around that in linux-kernel-modules.c
by including it early before config.h and then redefining some symbols
to get the 64-bit versions. This is somewhat fragile and not necessary
with newer glibc. If possible we want the 64bit fts version always.

Signed-off-by: Mark Wielaard <>
 ChangeLog                      |  5 +++++                   |  9 +++++++++
 libdwfl/ChangeLog              |  7 ++++++-
 libdwfl/linux-kernel-modules.c | 20 +++++++++++++-------
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f21421f..c7e2a2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-23  Mark Wielaard  <>
+	* Add test for bad fts.h. Add -DBAD_FTS=1 to CFLAGS
+	if necessary.
 2016-11-02  Mark Wielaard  <>
 	* Add check for whether gcc accepts
diff --git a/ b/
index c55fb9b..f535123 100644
--- a/
+++ b/
@@ -144,6 +144,15 @@ dnl tests, because the choice of the file model can (in principle) affect
 dnl whether functions and headers are available, whether they work, etc.
+dnl Older glibc had a broken fts that didn't work with Large File Systems.
+dnl We want the version that can handler LFS, but include workaround if we
+dnl get a bad one. Add define to CFLAGS (not AC_DEFINE it) since we need to
+dnl check it before including config.h (which might define _FILE_OFFSET_BITS).
+AC_CACHE_CHECK([whether fts.h is bad when included (with LFS)], ac_cv_bad_fts,
+  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <fts.h>]])],
+		     ac_cv_bad_fts=no, ac_cv_bad_fts=yes)])
+AS_IF([test "x$ac_cv_bad_fts" = "xyes"], [CFLAGS="$CFLAGS -DBAD_FTS=1"])
 dnl enable debugging of branch prediction.
 AS_HELP_STRING([--enable-debugpred],[build binaries with support to debug branch prediction]),
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 27c5d6e..bc627fe 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,4 +1,9 @@
-2015-10-11  Akihiko Odaki  <>
+2016-11-23  Mark Wielaard  <>
+	* linux-kernel-modules.c: Only include fts.h early if BAD_FTS is
+	defined.
+2016-10-11  Akihiko Odaki  <>
 	* core-file.c: Remove sys/param.h.
 	* dwfl_segment_report_module.c: Likewise. Add system.h include.
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index 54c0b90..9cd8ea9 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -26,10 +26,12 @@
    the GNU Lesser General Public License along with this program.  If
    not, see <>.  */
-/* We include this before config.h because it can't handle _FILE_OFFSET_BITS.
+/* In case we have a bad fts we include this before config.h because it
+   can't handle _FILE_OFFSET_BITS.
    Everything we need here is fine if its declarations just come first.  */
-#include <fts.h>
+#ifdef BAD_FTS
+  #include <fts.h>
 #include <config.h>
@@ -44,11 +46,15 @@
 #include <fcntl.h>
 #include <unistd.h>
-/* Since fts.h is included before config.h, its indirect inclusions may not
+/* If fts.h is included before config.h, its indirect inclusions may not
    give us the right LFS aliases of these functions, so map them manually.  */
-#define open open64
-#define fopen fopen64
+#ifdef BAD_FTS
+    #define open open64
+    #define fopen fopen64
+  #endif
+  #include <fts.h>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]