This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Re: [PATCH libctf] Fix a number of build problems found on Solaris and NetBSD


On 31 May 2019, at 10:13, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> I just pushed the patch in behalf of Nick.

This has improved the build on macOS (previously it was failing due to <endian.h> and off64_t), but the added qsort_r() remains problematic:

gcc -DHAVE_CONFIG_H -I. -I../../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../../binutils-gdb/libctf -I../../../binutils-gdb/libctf/../include -I../../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../../binutils-gdb/libctf/../zlib -g -O2 -MT qsort_r.o -MD -MP -MF .deps/qsort_r.Tpo -c -o qsort_r.o ../../../binutils-gdb/libctf/qsort_r.c
../../../binutils-gdb/libctf/qsort_r.c:99:1: error: conflicting types for 'qsort_r'
_quicksort (void *const pbase, size_t total_elems, size_t size,
^
../../../binutils-gdb/libctf/qsort_r.c:33:21: note: expanded from macro '_quicksort'
# define _quicksort qsort_r
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:325:7: note:
previous declaration is here
void     qsort_r(void *__base, size_t __nel, size_t __width, void *,
^

MacOS (and e.g. it appears FreeBSD, but there it is possibly hidden by a __BSD_VISIBLE define) declares a qsort_r() function with a different signature:

	void
	qsort_r(void *base, size_t nel, size_t width, void *thunk,
		int (*compar)(void *, const void *, const void *));

i.e. the extra void* argument is added before the comparison function rather than after, and similarly in the callback's parameters.

The generated libctf/config.h contains "#define HAVE_DECL_QSORT_R 1", so it's a bit surprising that it tries to build qsort_r.c at all. I suspect AC_LIBOBJ([qsort_r]) should be inside a conditional. However, even if qsort_r.o were properly omitted, trying to use the system qsort_r() with its different signature won't work.

Changing the identifier (e.g. to qsort_r_bork) in the four libctf/*.[ch] files it appears in leads to a working compilation.


Incidentally, this warning seems accurate in saying this free() should be further down:

../../../binutils-gdb/libctf/ctf-dump.c:276:13: warning: variable 'bit' is uninitialized when used here

    John

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