* Build problem with latest GCC (auto-load.c fails to compile)
@ 2016-12-21 21:15 Steve Ellcey
2016-12-22 16:04 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Steve Ellcey @ 2016-12-21 21:15 UTC (permalink / raw)
To: gdb-patches
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1636 bytes --]
Has anyone tried building gdb with the latest (top-of-tree) GCC sources?
I just did that and the build died with message shown below.
Steve Ellcey
sellcey@caviumnetworks.com
../../../src/binutils-gdb/gdb/auto-load.c: In function âvoid print_scripts(VEC_loaded_script_ptr*)â:
../../../src/binutils-gdb/gdb/auto-load.c:1317:52: error: argument 1 null where non-null expected [-Werror=nonnull]
sizeof (loaded_script_ptr), sort_scripts_by_name);
^
In file included from /home/ubuntu/sellcey/test-ifunc/install-init/include/c++/7.0.0/cstdlib:75:0,
from /home/ubuntu/sellcey/test-ifunc/install-init/include/c++/7.0.0/stdlib.h:36,
from build-gnulib/import/stdlib.h:36,
from ../../../src/binutils-gdb/gdb/common/common-defs.h:53,
from ../../../src/binutils-gdb/gdb/defs.h:28,
from ../../../src/binutils-gdb/gdb/auto-load.c:20:
/usr/include/stdlib.h:764:13: note: in a call to function âvoid qsort(void*, size_t, size_t, __compar_fn_t)â declared here
extern void qsort (void *__base, size_t __nmemb, size_t __size,
^~~~~
cc1plus: all warnings being treated as errors
Makefile:1880: recipe for target 'auto-load.o' failed
make[2]: *** [auto-load.o] Error 1
make[2]: Leaving directory '/home/ubuntu/sellcey/test-ifunc/obj/binutils-gdb/gdb'
Makefile:10455: recipe for target 'all-gdb' failed
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory '/home/ubuntu/sellcey/test-ifunc/obj/binutils-gdb'
Makefile:850: recipe for target 'all' failed
make: *** [all] Error 2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Build problem with latest GCC (auto-load.c fails to compile)
2016-12-21 21:15 Build problem with latest GCC (auto-load.c fails to compile) Steve Ellcey
@ 2016-12-22 16:04 ` Pedro Alves
2016-12-22 18:43 ` Steve Ellcey
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2016-12-22 16:04 UTC (permalink / raw)
To: sellcey, gdb-patches
On 12/21/2016 09:15 PM, Steve Ellcey wrote:
> Has anyone tried building gdb with the latest (top-of-tree) GCC sources?
> I just did that and the build died with message shown below.
I don't see the warning/error here, with ToT GCC.
>
>
>
> ../../../src/binutils-gdb/gdb/auto-load.c: In function ‘void print_scripts(VEC_loaded_script_ptr*)’:
> ../../../src/binutils-gdb/gdb/auto-load.c:1317:52: error: argument 1 null where non-null expected [-Werror=nonnull]
> sizeof (loaded_script_ptr), sort_scripts_by_name);
> ^
That's:
static void
print_scripts (VEC (loaded_script_ptr) *scripts)
{
int i;
loaded_script_ptr script;
qsort (VEC_address (loaded_script_ptr, scripts),
VEC_length (loaded_script_ptr, scripts),
sizeof (loaded_script_ptr), sort_scripts_by_name);
for (i = 0; VEC_iterate (loaded_script_ptr, scripts, i, script); ++i)
print_script (script);
}
By design, a NULL VEC pointer is an empty VEC (though empty VECs can
be non-NULL if memory has already been reserved). And VEC_address
returns NULL on such NULL VECs.
So sounds like GCC thinks that "scripts" here may be NULL
somehow? I'm not immediately seeing how, given:
script_files = VEC_alloc (loaded_script_ptr, 10);
script_texts = VEC_alloc (loaded_script_ptr, 10);
Might be a GCC bug. There's ongoing discussion on the gcc-patches
list about these -Wnonnull warnings.
Calling qsort with a null base is undefined, even if nmemb is 0. So
fix could be simply to skip the qsort if the VEC is
empty (or len <= 1, since it's pointless to sort one element), like
we do in other places. Something like:
static void
print_scripts (VEC (loaded_script_ptr) *scripts)
{
int i;
loaded_script_ptr script;
if (VEC_length (int, ids) > 1)
qsort (VEC_address (loaded_script_ptr, scripts),
VEC_length (loaded_script_ptr, scripts),
sizeof (loaded_script_ptr), sort_scripts_by_name);
for (i = 0; VEC_iterate (loaded_script_ptr, scripts, i, script); ++i)
print_script (script);
}
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Build problem with latest GCC (auto-load.c fails to compile)
2016-12-22 16:04 ` Pedro Alves
@ 2016-12-22 18:43 ` Steve Ellcey
0 siblings, 0 replies; 3+ messages in thread
From: Steve Ellcey @ 2016-12-22 18:43 UTC (permalink / raw)
To: Pedro Alves, sellcey, gdb-patches
On Thu, 2016-12-22 at 16:04 +0000, Pedro Alves wrote:
> On 12/21/2016 09:15 PM, Steve Ellcey wrote:
> >
> > Has anyone tried building gdb with the latest (top-of-tree) GCC
> > sources?
> > I just did that and the build died with message shown below.
> I don't see the warning/error here, with ToT GCC.
I don't get it anymore either. Â I think this was a bogus warning and it
was fixed in GCC with the patch for GCC bug 78817.
Steve Ellcey
sellcey@caviumnetworks.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-22 18:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-21 21:15 Build problem with latest GCC (auto-load.c fails to compile) Steve Ellcey
2016-12-22 16:04 ` Pedro Alves
2016-12-22 18:43 ` Steve Ellcey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).