[tnozaki-gcc] MKDTRACE=yes build failure caused by conflict definition between sys/elfdefinitions.h and sys/exec_elf.h

Issue #283 open
Takehiko NOZAKI repo owner created an issue
#   compile  libctf/ctf_lib.lo
cc -O  -DCTF_OLD_VERSIONS -I/usr/src/tools/compat/obj.amd64 -I/usr/src/tools/libctf/../compat  -I/usr/src/tools/libctf/../../external/cddl/osnet/sys  -I/usr/src/tools/libctf/../../external/cddl/osnet/include  -I/usr/src/tools/libctf/../../external/cddl/osnet/dist/head  -I/usr/src/tools/libctf/../../external/cddl/osnet/dist/common/ctf  -I/usr/src/tools/libctf/../../external/cddl/osnet/dist/lib/libctf/common  -I/usr/src/tools/libctf/../../external/cddl/osnet/dist/uts/common  -I/usr/src/tools/libctf/../../external/bsd/libelf/dist -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -I/usr/tooldir/include -c -o ctf_lib.lo.o    /usr/src/tools/libctf/../../external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c
In file included from /usr/include/libelf.h:33:0,
                 from /usr/include/gelf.h:32,
                 from /usr/src/tools/libctf/../../external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c:46:
/usr/include/sys/elfdefinitions.h:1802:3: error: conflicting types for 'Elf32_Cap'
/usr/tooldir/include/nbinclude/sys/exec_elf.h:612:3: note: previous declaration of 'Elf32_Cap' was here
/usr/include/sys/elfdefinitions.h:1811:3: error: conflicting types for 'Elf64_Cap'
/usr/tooldir/include/nbinclude/sys/exec_elf.h:620:3: note: previous declaration of 'Elf64_Cap' was here
...

Comments (3)

  1. Takehiko NOZAKI reporter

    recent libelf’s elfdefinitions.h never used OS dependent header file(such as elf.h, sys/exec_elf.h, machine/elf_machdep.h), it uses own generated header file(sys/elfdefinitions.h) from these headers by m4 script.

    the reason why: some MD macro required by libelf - for example R_386_32 - it’s impossible to get from machine/macdep_elf.h under none i386/amd64 port.

    so, if you include both libelf.h and sys/exec_elf.h same time, include guard doesn’t not work anymore, and causes severe namespace pollution.

    for more worse, DTrace has Solaris’s elf.h compat layer(it uses sys/exec_elf.h internally).

    and more^2 worse, USETOOLS’s compat layer(nbtool_config.h) has own sys/exec_elf.h for cross build.

    why ISO-C specification don't have namespace like C++?(it’s not joking…)

  2. Takehiko NOZAKI reporter

    BUGFIX: Issue #283 - MKDTRACE=yes build failure caused by conflict definition between sys/elfdefinitions.h and sys/exec_elf.h - use libelf.h instead of sys/exec_elf.h for Solaris's elf.h's emulation - adjust ctfconvert to new libdwarf API, patch from FreeBSD r261246, original commit message:

    [ctfconvert] * Switch to the APIs from the new libdwarf. * Improve die_mem_offset() so that DW_AT_data_member_location attributes generated by Clang 3.4 can be handled properly. * Make use of DW_AT_byte_size attribute of the member DIE to calculate the bits occupied by the member's type, without actually resolving the type. This way ctfconvert can deal with the case that Clang 3.4 sometimes emits DIE for struct/union member before emitting the DIE for the type of that member.

    → <<cset 35b388b1ebf5>>

  3. Log in to comment