Bug 99956 - build_id.c:36:20: error: unknown type name 'Elf_Nhdr'
Summary: build_id.c:36:20: error: unknown type name 'Elf_Nhdr'
Status: RESOLVED MOVED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: 17.1
Hardware: x86-64 (AMD64) FreeBSD
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords: bisected, regression
Depends on:
Blocks:
 
Reported: 2017-02-25 01:39 UTC by Vinson Lee
Modified: 2019-09-18 20:25 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Vinson Lee 2017-02-25 01:39:00 UTC
mesa: 292c24ddac5acc35676424f05291c101fcd47b3e (master 17.1.0-devel)

FreeBSD build error.

  CC       libmesautil_la-build_id.lo
build_id.c:36:20: error: unknown type name 'Elf_Nhdr'
 #define ElfW(type) Elf_##type
                    ^
build_id.c:42:4: note: in expansion of macro 'ElfW'
    ElfW(Nhdr) nhdr;
    ^
build_id.c: In function 'build_id_find_nhdr_callback':
build_id.c:71:24: error: request for member 'n_type' in something not a structure or union
          if (note->nhdr.n_type == NT_GNU_BUILD_ID &&
                        ^
build_id.c:72:23: error: request for member 'n_descsz' in something not a structure or union
             note->nhdr.n_descsz != 0 &&
                       ^
build_id.c:73:23: error: request for member 'n_namesz' in something not a structure or union
             note->nhdr.n_namesz == 4 &&
                       ^
build_id.c:36:20: error: 'Elf_Nhdr' undeclared (first use in this function)
 #define ElfW(type) Elf_##type
                    ^
build_id.c:79:33: note: in expansion of macro 'ElfW'
          size_t offset = sizeof(ElfW(Nhdr)) +
                                 ^
build_id.c:36:20: note: each undeclared identifier is reported only once for each function it appears in
 #define ElfW(type) Elf_##type
                    ^
build_id.c:79:33: note: in expansion of macro 'ElfW'
          size_t offset = sizeof(ElfW(Nhdr)) +
                                 ^
build_id.c:80:42: error: request for member 'n_namesz' in something not a structure or union
                          ALIGN(note->nhdr.n_namesz, 4) +
                                          ^
build_id.c:39:35: note: in definition of macro 'ALIGN'
 #define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
                                   ^
build_id.c:81:42: error: request for member 'n_descsz' in something not a structure or union
                          ALIGN(note->nhdr.n_descsz, 4);
                                          ^
build_id.c:39:35: note: in definition of macro 'ALIGN'
 #define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
                                   ^
build_id.c: In function 'build_id_length':
build_id.c:107:21: error: request for member 'n_descsz' in something not a structure or union
    return note->nhdr.n_descsz;
                     ^
build_id.c:108:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
Comment 1 Jonathan Gray 2017-02-25 01:56:37 UTC
Looking at the FreeBSD headers it appears they define Elf_Note not Elf_Nhdr.

https://svnweb.freebsd.org/base/head/sys/sys/elf_common.h?revision=HEAD&view=co

The OpenBSD headers define both at the moment to be compatible though the Elf_Note members on OpenBSD do not have the n_ prefix only the Elf_Nhdr structs do where as the FreeBSD Elf_Note has the n_ prefix.
Comment 2 Vinson Lee 2017-03-22 01:42:33 UTC
Build error introduced with this commit.

commit d4fa083e11fa71abd50e615d6f02b6da4ea34644
Author: Matt Turner <mattst88@gmail.com>
Date:   Tue Feb 14 07:29:56 2017 -0800

    util: Add utility build-id code.
    
    Provides the ability to read the .note.gnu.build-id section of ELF
    binaries, which is inserted by the --build-id=... flag to ld.
    
    Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
    Reviewed-by: Chad Versace <chadversary@chromium.org>
Comment 3 Emil Velikov 2017-03-22 14:18:15 UTC
Quick search showed the following handy website. In there you can see that things "broke" between FreeBSD 10 and 11 - former has Elf_Nhdr while latter does not.

Not sure how to solve this - anyone having a platform like that feel free to send a patch to the mailing list :-)

http://fxr.watson.org/fxr/ident?v=FREEBSD10;i=Elf_Nhdr
Comment 4 Emil Velikov 2017-07-04 10:45:34 UTC
Vinson do check the said site. Alternatively you can see/work with the FreeBSD people - they seems to have some partial solution there [1]

[1] https://github.com/freebsd/freebsd-ports-graphics/blob/master/graphics/mesa-dri/files/patch-src_util_build__id.c
Comment 5 GitLab Migration User 2019-09-18 20:25:46 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/1007.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.