Skip to content

Commit ee22502

Browse files
author
Mark Wielaard
committed
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 <[email protected]>
1 parent 507e7e2 commit ee22502

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2016-11-23 Mark Wielaard <[email protected]>
2+
3+
* configure.ac: Add test for bad fts.h. Add -DBAD_FTS=1 to CFLAGS
4+
if necessary.
5+
16
2016-11-02 Mark Wielaard <[email protected]>
27

38
* configure.ac: Add check for whether gcc accepts

configure.ac

+9
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ dnl tests, because the choice of the file model can (in principle) affect
144144
dnl whether functions and headers are available, whether they work, etc.
145145
AC_SYS_LARGEFILE
146146

147+
dnl Older glibc had a broken fts that didn't work with Large File Systems.
148+
dnl We want the version that can handler LFS, but include workaround if we
149+
dnl get a bad one. Add define to CFLAGS (not AC_DEFINE it) since we need to
150+
dnl check it before including config.h (which might define _FILE_OFFSET_BITS).
151+
AC_CACHE_CHECK([whether fts.h is bad when included (with LFS)], ac_cv_bad_fts,
152+
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <fts.h>]])],
153+
ac_cv_bad_fts=no, ac_cv_bad_fts=yes)])
154+
AS_IF([test "x$ac_cv_bad_fts" = "xyes"], [CFLAGS="$CFLAGS -DBAD_FTS=1"])
155+
147156
dnl enable debugging of branch prediction.
148157
AC_ARG_ENABLE([debugpred],
149158
AS_HELP_STRING([--enable-debugpred],[build binaries with support to debug branch prediction]),

libdwfl/ChangeLog

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
2015-10-11 Akihiko Odaki <[email protected]>
1+
2016-11-23 Mark Wielaard <[email protected]>
2+
3+
* linux-kernel-modules.c: Only include fts.h early if BAD_FTS is
4+
defined.
5+
6+
2016-10-11 Akihiko Odaki <[email protected]>
27

38
* core-file.c: Remove sys/param.h.
49
* dwfl_segment_report_module.c: Likewise. Add system.h include.

libdwfl/linux-kernel-modules.c

+13-7
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
the GNU Lesser General Public License along with this program. If
2727
not, see <http://www.gnu.org/licenses/>. */
2828

29-
/* We include this before config.h because it can't handle _FILE_OFFSET_BITS.
29+
/* In case we have a bad fts we include this before config.h because it
30+
can't handle _FILE_OFFSET_BITS.
3031
Everything we need here is fine if its declarations just come first. */
31-
32-
#include <fts.h>
32+
#ifdef BAD_FTS
33+
#include <fts.h>
34+
#endif
3335

3436
#include <config.h>
3537

@@ -44,11 +46,15 @@
4446
#include <fcntl.h>
4547
#include <unistd.h>
4648

47-
/* Since fts.h is included before config.h, its indirect inclusions may not
49+
/* If fts.h is included before config.h, its indirect inclusions may not
4850
give us the right LFS aliases of these functions, so map them manually. */
49-
#ifdef _FILE_OFFSET_BITS
50-
#define open open64
51-
#define fopen fopen64
51+
#ifdef BAD_FTS
52+
#ifdef _FILE_OFFSET_BITS
53+
#define open open64
54+
#define fopen fopen64
55+
#endif
56+
#else
57+
#include <fts.h>
5258
#endif
5359

5460

0 commit comments

Comments
 (0)