Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

conflicting elf definitions in system headers



Hi!

When building pkgtools/pkg and NetBSD 10 or current, there's a new
build failure compared to NetBSD 9.

--- libpkg_la-pkg_elf.lo ---
In file included from /usr/include/link_elf.h:7,
                 from /usr/include/link.h:40,
                 from pkg_elf.c:52:
/usr/include/sys/exec_elf.h:112:3: error: conflicting types for 'Elf32_Ehdr'; have 'struct <anonymous>'
  112 | } Elf32_Ehdr;
      |   ^~~~~~~~~~
In file included from /usr/include/elfdefinitions.h:34,
                 from /usr/include/libelf.h:40,
                 from /usr/include/gelf.h:34,
                 from pkg_elf.c:49:
/usr/include/sys/elfdefinitions.h:1969:3: note: previous declaration of 'Elf32_Ehdr' with type 'Elf32_Ehdr'
 1969 | } Elf32_Ehdr;
      |   ^~~~~~~~~~
/usr/include/sys/exec_elf.h:129:3: error: conflicting types for 'Elf64_Ehdr'; have 'struct <anonymous>'
  129 | } Elf64_Ehdr;
      |   ^~~~~~~~~~
/usr/include/sys/elfdefinitions.h:1988:3: note: previous declaration of 'Elf64_Ehdr' with type 'Elf64_Ehdr'
 1988 | } Elf64_Ehdr;
      |   ^~~~~~~~~~
/usr/include/sys/exec_elf.h:424:3: error: conflicting types for 'Elf32_Phdr'; have 'struct <anonymous>'
  424 | } Elf32_Phdr;
      |   ^~~~~~~~~~
/usr/include/sys/elfdefinitions.h:2172:3: note: previous declaration of 'Elf32_Phdr' with type 'Elf32_Phdr'
 2172 | } Elf32_Phdr;
      |   ^~~~~~~~~~

(this goes on for many other symbols, I'll attach the log)

The header file inclusion chain in libpkg/pkg_elf.c is:

#include <gelf.h>
...
#if defined(HAVE_LINK_H) && !defined(__DragonFly__) && defined(HAVE_LIBELF)
#include <link.h>
#endif


gelf.h
-> libelf.h
   -> /usr/include/elfdefinitions.h
      -> /usr/include/sys/elfdefinitions.h

link.h
-> link_elf.h
   -> sys/exec_elf.h


Are these headers expected to conflict, and the bug is in the program
including both?  In this case, which header should it include?

Or is this a bug in our headers?

Cheers,
 Thomas

Attachment: log.gz
Description: Binary data



Home | Main Index | Thread Index | Old Index