Bug 32372 - binutils fails to build with GCC trunk (defaults to -std=gnu23) (bfd/elf64-ppc.c:4667:20: error: incompatible types when returning type ‘_Bool’ but ‘struct plt_entry **’ was expected)
Summary: binutils fails to build with GCC trunk (defaults to -std=gnu23) (bfd/elf64-pp...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.44
Assignee: Sam James
URL:
Keywords:
Depends on: 32374
Blocks:
  Show dependency treegraph
 
Reported: 2024-11-16 04:32 UTC by Sam James
Modified: 2024-11-19 06:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2024-11-16 04:32:10 UTC
GCC trunk now defaults to -std=gnu23:
```
/bin/sh ./libtool  --tag=CC   --mode=compile x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd  -DBINDIR='"/usr/x86_64-pc-linux-gnu/binutils-bin/9999"' -DLIBDIR='"/usr/lib64/binutils/x86_64-pc-linux-gnu/9999"' -I. -I/var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd -I/var/tmp/portage/sys-devel/binutils-9999
/work/binutils/bfd/../include  -DHAVE_all_vecs   -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144   -O3 -march=native -mtls-dialect=gnu2 -pipe -fcf-protection=none -fdiagnostics-color=always -fdiagnostics-urls=never -frecord-gcc-switches -fdiagnostics-details -Warray-bounds -Wstrict-aliasing -Wfree-nonheap-object -Wuninitialized -Wmaybe-un
initialized -Wreturn-type -Werror=lto-type-mismatch -Werror=strict-aliasing -Werror=odr -Warray-bounds -fdiagnostics-details -Wstringop-overread -Wstringop-overflow -Wstringop-truncation -Wbuiltin-declaration-mismatch -ggdb3   -fprofile-generate -flto=jobserver -ffat-lto-objects -c -o elf64-ppc.lo /var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd/elf64-ppc.c   libtool: compile:  x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd -DBINDIR=\"/usr/x86_64-pc-linux-gnu/binutils-bin/9999\" -DLIBDIR=\"/usr/lib64/binutils/x86_64-pc-linux-gnu/9999\" -I. -I/var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd -I/var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd/../inclu
de -DHAVE_all_vecs -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -O3 -march=native -mtls-dialect=gnu2 -pipe -fcf-protection=none -fdiagnostics-color=always -fdiagnostics-urls=never -frecord-gcc-switches -fdiagnostics-details -Warray-bounds -Wstrict-aliasing -Wfree-nonheap-object -Wuninitialized -Wmaybe-uninitialized -Wreturn-type -Werro
r=lto-type-mismatch -Werror=strict-aliasing -Werror=odr -Warray-bounds -fdiagnostics-details -Wstringop-overread -Wstringop-overflow -Wstringop-truncation -Wbuiltin-declaration-mismatch -ggdb3 -fprofile-generate -flto=jobserver -ffat-lto-objects -c /var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd/elf64-ppc.c  -fPIC -DPIC -o .libs/elf64-ppc.o                   /var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd/elf64-ppc.c: In function ‘update_local_sym_info’:                                                                              /var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd/elf64-ppc.c:4667:20: error: incompatible types when returning type ‘_Bool’ but ‘struct plt_entry **’ was expected
 4667 |             return false;                                                                                                                                                               |                    ^~~~~
make[4]: *** [Makefile:1773: elf64-ppc.lo] Error 1
```
Comment 1 Sam James 2024-11-16 04:32:50 UTC
We should just return NULL there instead.
Comment 2 Sam James 2024-11-16 04:41:12 UTC
I'll send patches for all of these when done.

/var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd/elf32-ppc.c: In function ‘ppc_elf_tls_setup’:
/var/tmp/portage/sys-devel/binutils-9999/work/binutils/bfd/elf32-ppc.c:4355:32: error: incompatible types when returning type ‘_Bool’ but ‘asection *’ {aka ‘struct bfd_section *’} was ex
pected
 4355 |                         return false;
      |                                ^~~~~
make[4]: *** [Makefile:1773: elf32-ppc.lo] Error 1

This one is again fine to do as NULL because we return _bfd_elf_tls_setup in the happy case and that itself may return NULL (tls).
Comment 3 Sam James 2024-11-16 04:58:38 UTC
The fake static_assert use becomes a nuisance in decode_micromips_operand.
Comment 5 Sourceware Commits 2024-11-18 03:09:36 UTC
The master branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=931e4f9b09512bb9012204bb2e4060ab6d9b9b46

commit 931e4f9b09512bb9012204bb2e4060ab6d9b9b46
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 05:01:58 2024 +0000

    bfd: fix -std=gnu23 compatibility wrt _Bool
    
    GCC trunk now defaults to -std=gnu23. We return false in a few places
    which can't work when true/false are a proper type (_Bool). Return NULL
    where appropriate instead of false. All callers handle this appropriately.
    
    ChangeLog:
            PR ld/32372
    
            * elf32-ppc.c (ppc_elf_tls_setup): Return NULL.
            * elf32-xtensa.c (translate_reloc_bfd_fix): Ditto.
            (translate_reloc): Ditto.
            * elf64-ppc.c (update_local_sym_info): Ditto.
            * mach-o.c (bfd_mach_o_lookup_uuid_command): Ditto.
            * xsym.c (bfd_sym_read_name_table): Ditto.
Comment 6 Sourceware Commits 2024-11-18 03:09:41 UTC
The master branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4

commit 8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 05:03:52 2024 +0000

    opcodes: fix -std=gnu23 compatibility wrt static_assert
    
    static_assert is declared in C23 so we can't reuse that identifier:
    * Define our own static_assert conditionally;
    
    * Rename "static assert" hacks to _N as we do already in some places
      to avoid a conflict.
    
    ChangeLog:
            PR ld/32372
    
            * i386-gen.c (static_assert): Define conditionally.
            * mips-formats.h (MAPPED_INT): Rename identifier.
            (MAPPED_REG): Rename identifier.
            (OPTIONAL_MAPPED_REG): Rename identifier.
            * s390-opc.c (static_assert): Define conditionally.
Comment 7 Sourceware Commits 2024-11-18 03:09:46 UTC
The master branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=eeff15bc88b89abed1cdb4d3b1b2cc7b4cec6fe7

commit eeff15bc88b89abed1cdb4d3b1b2cc7b4cec6fe7
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 05:12:51 2024 +0000

    binutils: fix -std=gnu23 compatibility wrt _Bool
    
    GCC trunk now defaults to -std=gnu23. We return false in a few places
    which can't work when true/false are a proper type (_Bool). Return NULL
    where appropriate instead of false. All callers handle this appropriately.
    
    ChangeLog:
            PR ld/32372
    
            * prdbg.c (visibility_name): Return NULL.
Comment 8 Sourceware Commits 2024-11-18 03:09:51 UTC
The master branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bf447eec6d7b69cba652127e2f38f102de38de39

commit bf447eec6d7b69cba652127e2f38f102de38de39
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 07:07:02 2024 +0000

    ld: fix -std=gnu23 compatibility wrt _Bool
    
    GCC trunk now defaults to -std=gnu23. We return false in a few places
    which can't work when true/false are a proper type (_Bool). Return NULL
    where appropriate instead of false. All callers handle this appropriately.
    
    ChangeLog:
            PR ld/32372
    
            * pdb.c (add_stream): Return NULL.
Comment 9 Sam James 2024-11-18 03:14:00 UTC
Fixed for 2.44. I may backport the non-gprofng bits later.
Comment 10 Sourceware Commits 2024-11-19 06:41:35 UTC
The binutils-2_43-branch branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cf23d6835070637387b57605e4e6ac884dc3780a

commit cf23d6835070637387b57605e4e6ac884dc3780a
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 05:01:58 2024 +0000

    bfd: fix -std=gnu23 compatibility wrt _Bool
    
    GCC trunk now defaults to -std=gnu23. We return false in a few places
    which can't work when true/false are a proper type (_Bool). Return NULL
    where appropriate instead of false. All callers handle this appropriately.
    
    ChangeLog:
            PR ld/32372
    
            * elf32-ppc.c (ppc_elf_tls_setup): Return NULL.
            * elf32-xtensa.c (translate_reloc_bfd_fix): Ditto.
            (translate_reloc): Ditto.
            * elf64-ppc.c (update_local_sym_info): Ditto.
            * mach-o.c (bfd_mach_o_lookup_uuid_command): Ditto.
            * xsym.c (bfd_sym_read_name_table): Ditto.
    
    (cherry picked from commit 931e4f9b09512bb9012204bb2e4060ab6d9b9b46)
Comment 11 Sourceware Commits 2024-11-19 06:41:40 UTC
The binutils-2_43-branch branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3a88870559ff297dd3d11abacbfc2b5a1bda5f3e

commit 3a88870559ff297dd3d11abacbfc2b5a1bda5f3e
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 05:03:52 2024 +0000

    opcodes: fix -std=gnu23 compatibility wrt static_assert
    
    static_assert is declared in C23 so we can't reuse that identifier:
    * Define our own static_assert conditionally;
    
    * Rename "static assert" hacks to _N as we do already in some places
      to avoid a conflict.
    
    ChangeLog:
            PR ld/32372
    
            * i386-gen.c (static_assert): Define conditionally.
            * mips-formats.h (MAPPED_INT): Rename identifier.
            (MAPPED_REG): Rename identifier.
            (OPTIONAL_MAPPED_REG): Rename identifier.
            * s390-opc.c (static_assert): Define conditionally.
    
    (cherry picked from commit 8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4)
Comment 12 Sourceware Commits 2024-11-19 06:41:45 UTC
The binutils-2_43-branch branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=74401db8de037bd109f06ddd93155c0d081f092e

commit 74401db8de037bd109f06ddd93155c0d081f092e
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 05:12:51 2024 +0000

    binutils: fix -std=gnu23 compatibility wrt _Bool
    
    GCC trunk now defaults to -std=gnu23. We return false in a few places
    which can't work when true/false are a proper type (_Bool). Return NULL
    where appropriate instead of false. All callers handle this appropriately.
    
    ChangeLog:
            PR ld/32372
    
            * prdbg.c (visibility_name): Return NULL.
    
    (cherry picked from commit eeff15bc88b89abed1cdb4d3b1b2cc7b4cec6fe7)
Comment 13 Sourceware Commits 2024-11-19 06:41:51 UTC
The binutils-2_43-branch branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=059f36543368d24075018354eb8454a952aff96b

commit 059f36543368d24075018354eb8454a952aff96b
Author: Sam James <sam@gentoo.org>
Date:   Sat Nov 16 07:07:02 2024 +0000

    ld: fix -std=gnu23 compatibility wrt _Bool
    
    GCC trunk now defaults to -std=gnu23. We return false in a few places
    which can't work when true/false are a proper type (_Bool). Return NULL
    where appropriate instead of false. All callers handle this appropriately.
    
    ChangeLog:
            PR ld/32372
    
            * pdb.c (add_stream): Return NULL.
    
    (cherry picked from commit bf447eec6d7b69cba652127e2f38f102de38de39)