Re: Oh dear. I regret to inform you that commit 0e65dfbaf3a0299e4837216a103c28625d4b4f1d might be unfortunate

Rainer Orth
2019-05-29T10:21:20Z

[-- Attachment #1: Type: text/plain, Size: 6720 bytes --]

Simon Marchi <simark@simark.ca> writes:

> On 2019-05-28 8:02 p.m., gdb-buildbot@sergiodj.net wrote:
>> My lords, ladies, gentlemen, members of the public.
>>
>> It is a matter of great regret and sadness to inform you that commit:
>>
>> libctf: build system
>> 0e65dfbaf3a0299e4837216a103c28625d4b4f1d
>>
>> might have made GDB unwell. Since I am just your Butler BuildBot,
>> I kindly ask that a human superior officer double-check this.
>>
>> Please note that if you are reading this message on gdb-patches, there might
>> be other builders broken.
>>
>> You can find more details about the unfortunate breakage in the next messages.
>>
>> Cheers,
>>
>> Your GDB BuildBot.
>>
>
> In case you have trouble spotting the error, I believe it is
>
> ../../binutils-gdb/libctf/ctf-archive.c:24:10: fatal error: endian.h: No such file or directory
> #include <endian.h>
> ^~~~~~~~~~
>
> which you can find if you follow one of the "Full build" URLs in the other messages.

Unfortunately, it's way worse than that:

* <endian.h> isn't even needed at all: gdb master still compiles with
that include removed.

* Once this is fixed, the Solaris build still fails with several
instances of

/vol/src/gnu/gdb/hg/master/dist/libctf/ctf-hash.c: In function 'ctf_hashtab_insert':
/vol/src/gnu/gdb/hg/master/dist/libctf/ctf-hash.c:141:7: error: 'errno' undeclared (first use in this function)
141 | errno = -ENOMEM;
| ^~~~~

It turns out that ctf-impl.h (for reasons that completely escape me)
includes <sys/errno.h> instead of <errno.h>. Once that is fixed, the
amd64-pc-solaris2.11 libctf build at least finishes.

* There are still quite a number of warnings that I didn't bother look
into (all seen with gdb 9.1.0 on Solaris 11.5/x86):

/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c: In function 'ctf_arc_write':
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:110:24: warning: implicit declaration of function 'htole64' [-Wimplicit-function-declaration]
110 | archdr->ctfa_magic = htole64 (CTFA_MAGIC);
| ^~~~~~~
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:132:31: warning: implicit declaration of function 'le64toh' [-Wimplicit-function-declaration]
132 | for (i = 0, namesz = 0; i < le64toh (archdr->ctfa_nfiles); i++)
| ^~~~~~~
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:132:29: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
132 | for (i = 0, namesz = 0; i < le64toh (archdr->ctfa_nfiles); i++)
| ^
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:145:10: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
145 | i < le64toh (archdr->ctfa_nfiles); i++)
| ^
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:172:3: warning: implicit declaration of function 'qsort_r'; did you mean 'qsort'? [-Wimplicit-function-declaration]
172 | qsort_r ((ctf_archive_modent_t *) ((char *) archdr
| ^~~~~~~
| qsort
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c: In function 'ctf_arc_bufopen':
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:320:33: warning: comparison is always true due to limited range of data type [-Wtype-limits]
320 | if (le64toh (arc->ctfa_magic) != CTFA_MAGIC)
| ^~
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c: In function 'ctf_arc_open_internal':
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:357:33: warning: comparison is always true due to limited range of data type [-Wtype-limits]
357 | if (le64toh (arc->ctfa_magic) != CTFA_MAGIC)
| ^~
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c: In function 'ctf_arc_open_by_offset':
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:514:3: warning: implicit declaration of function 'bzero' [-Wimplicit-function-declaration]
514 | bzero (&ctfsect, sizeof (ctf_sect_t));
| ^~~~~
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:514:3: warning: incompatible implicit declaration of built-in function 'bzero'
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c: In function 'ctf_archive_raw_iter_internal':
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:546:17: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
546 | for (i = 0; i < le64toh (arc->ctfa_nfiles); i++)
| ^
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-create.c: In function 'ctf_update':
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-create.c:346:3: warning: implicit declaration of function 'qsort_r'; did you mean 'qsort'? [-Wimplicit-function-declaration]
346 | qsort_r (dvarents, nvars, sizeof (ctf_varent_t), ctf_sort_var, s0);
| ^~~~~~~
| qsort
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c: In function 'ctf_archive_iter_internal':
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-archive.c:594:17: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
594 | for (i = 0; i < le64toh (arc->ctfa_nfiles); i++)
| ^
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-create.c: In function 'ctf_add_member_offset':
configure: loading cache ./config.cache
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-create.c:1351:10: warning: implicit declaration of function 'roundup' [-Wimplicit-function-declaration]
1351 | off = roundup (off, NBBY) / NBBY;
| ^~~~~~~
/vol/src/gnu/gdb/hg/master/local/libctf/ctf-create.c:1352:24: warning: implicit declaration of function 'MAX' [-Wimplicit-function-declaration]
1352 | off = roundup (off, MAX (malign, 1));
| ^~~

E.g. qsort_r is a glibc addition not present on Solaris (and NetBSD,
it seems), bzero would need <strings.h> if really necessary rather
than using memset.

I'll never understand why some Oracle guys find it so hard to locate
some Solaris box in the company and try that stuff there. After all,
CTF and libctf originated on Solaris and adding it to binutils-gdb
shouldn't break the Solaris build.

Rainer

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

2019-05-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>

* ctf-archive.c: Don't include <endian.h>.
* ctf-impl.h: Include <errno.h> instead of <sys/errno.h>.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-libctf-compile.patch --]
[-- Type: text/x-patch, Size: 547 bytes --]

diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
--- a/libctf/ctf-archive.c
+++ b/libctf/ctf-archive.c
@@ -21,7 +21,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <elf.h>
-#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -21,7 +21,7 @@
#define _CTF_IMPL_H

#include "config.h"
-#include <sys/errno.h>
+#include <errno.h>
#include <ctf-api.h>
#include <sys/types.h>
#include <stdlib.h>