This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH libctf] Fix a number of build problems found on Solaris and NetBSD
- From: John Marshall <John dot W dot Marshall at glasgow dot ac dot uk>
- To: Nick Alcock <nick dot alcock at oracle dot com>, "Jose E. Marchesi" <jose dot marchesi at oracle dot com>
- Cc: Alan Modra <amodra at gmail dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>, Nick Clifton <nickc at redhat dot com>, Szabolcs Nagy <nsz at port70 dot net>, "christophe dot lyon at linaro dot org" <christophe dot lyon at linaro dot org>, Rainer Orth <ro at cebitec dot uni-bielefeld dot de>, Simon Marchi <simark at simark dot ca>, Kamil Rytarowski <n54 at gmx dot com>
- Date: Fri, 31 May 2019 12:24:17 +0000
- Subject: Re: [PATCH libctf] Fix a number of build problems found on Solaris and NetBSD
- References: <8736kw2h5b.fsf@esperi.org.uk> <87o93k0yje.fsf@esperi.org.uk> <20190531001910.GB6820@bubble.grove.modra.org> <877ea73s2n.fsf@oracle.com>
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