[Mesa-dev] [PATCH 1/2] util: Add utility build-id code.
Jonathan Gray
jsg at jsg.id.au
Sat Feb 18 06:17:16 UTC 2017
On Fri, Feb 17, 2017 at 08:30:17AM -0800, Matt Turner wrote:
> On Fri, Feb 17, 2017 at 5:39 AM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> > On 17 February 2017 at 01:10, Jonathan Gray <jsg at jsg.id.au> wrote:
> >> On Thu, Feb 16, 2017 at 04:25:02PM +0000, Emil Velikov wrote:
> >>> On 16 February 2017 at 14:23, Jonathan Gray <jsg at jsg.id.au> wrote:
> >>> > On Wed, Feb 15, 2017 at 11:11:50AM -0800, Matt Turner wrote:
> >>> >> 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 at collabora.com>
> >>> >
> >>> > I don't have time to dig into details right now but this broke the Mesa
> >>> > build on OpenBSD and likely other non-linux platforms:
> >>> >
> >>> > libtool: compile: gcc -DPACKAGE_NAME=\"Mesa\" -DPACKAGE_TARNAME=\"mesa\" -DPACKAGE_VERSION=\"17.1.0-devel\" "-DPACKAGE_STRING=\"Mesa 17.1.0-devel\"" "-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\"" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesa\" -DVERSION=\"17.1.0-devel\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DYYTEXT_POINTER=1 -DHAVE___BUILTIN_CLZ=1 -DHAVE___BUILTIN_CLZLL=1 -DHAVE___BUILTIN_CTZ=1 -DHAVE___BUILTIN_EXPECT=1 -DHAVE___BUILTIN_FFS=1 -DHAVE___BUILTIN_FFSLL=1 -DHAVE___BUILTIN_POPCOUNT=1 -DHAVE___BUILTIN_POPCOUNTLL=1 -DHAVE_FUNC_ATTRIBUTE_CONST=1 -DHAVE_FUNC_ATTRIBUTE_FLATTEN=1 -DHAVE_FUNC_ATTRIBUTE_FORMAT=1 -DHAVE_FUNC_ATTRIBUTE_MALLOC=1 -DHAVE_FUNC_ATTRIBUTE_PACKED=1 -DHAVE_FUNC_ATTRIBUTE_PURE=1 -DHAVE_FUNC_ATTRIBUTE_UNUSED=1 -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1 -DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT=1 -DHAVE_FUNC_ATTRIBUTE_WEAK=1 -DHAVE_FUNC_ATTRIBUTE_ALIAS=1 -DHAVE_DLADDR=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -I. -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DDEBUG -DTEXTURE_FLOAT_ENABLED -DUSE_X86_64_ASM -DHAVE_SYS_SYSCTL_H -DHAVE_STRTOF -DHAVE_MKOSTEMP -DHAVE_DLOPEN -DHAVE_DL_ITERATE_PHDR -DHAVE_POSIX_MEMALIGN -DHAVE_LIBDRM -DGLX_USE_DRM -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DENABLE_SHADER_CACHE -DHAVE_MINCORE -I../../include -I../../src -I../../src/mapi -I../../src/mesa -I../../src/gallium/include -I../../src/gallium/auxiliary -fvisibility=hidden -Werror=pointer-arith -g -O2 -Wall -std=gnu99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-math-errno -fno-trapping-math -MT libmesautil_la-build_id.lo -MD -MP -MF .deps/libmesautil_la-build_id.Tpo -c build_id.c -fPIC -DPIC -o .libs/libmesautil_la-build_id.o
> >>> > In file included from /usr/include/elf_abi.h:31,
> >>> > from /usr/include/link_elf.h:10,
> >>> > from /usr/include/link.h:39,
> >>> > from build_id.c:25:
> >>> > /usr/include/sys/exec_elf.h:585: error: expected specifier-qualifier-list before 'uint32_t'
> >>> > In file included from /usr/include/link.h:39,
> >>> > from build_id.c:25:
> >>> > /usr/include/link_elf.h:22: error: expected specifier-qualifier-list before 'caddr_t'
> >>> > /usr/include/link_elf.h:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
> >>> > In file included from build_id.c:25:
> >>> > /usr/include/link.h:49: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'struct'
> >>> > /usr/include/link.h:65: error: expected specifier-qualifier-list before 'caddr_t'
> >>> These look like issue in your platform code/headers. Perhaps some bad
> >>> interaction with the bits that Mesa defines ?
> >>>
> >>> Quick workaround is to check the function only when needed, roughly
> >>> like this pseudo code:
> >>>
> >>> if test $building_any_vulkan_driver = yes ;then
> >>> require_dl...=yes
> >>> ....
> >>> fi
> >>> ....
> >>>
> >>> if test $require_dl... = yes ; then
> >>> AC_CHECK_FUNC([dl_iterate_phdr], [DEFINES="$DEFINES
> >>> -DHAVE_DL_ITERATE_PHDR"], [AC_MSG_ERROR([required .... not found])])
> >>> fi
> >>>
> >>>
> >>> Please give it a bash and send us a patch that works on your end.
> >>
> >> Leaning towards something along the lines of the following.
> >> With Nhdr struct definitions added to system exec_elf.h.
> >>
> > IMHO it makes little sense to build the file if no code uses it. That aside:
>
> Agreed, but I think this will be used for shader cache as well.
>
> >
> >> The need for sys/types.h here may go away shortly as well.
> >>
> >> diff --git a/src/util/build_id.c b/src/util/build_id.c
> >> index 2993a80cfe..92250a1f5f 100644
> >> --- a/src/util/build_id.c
> >> +++ b/src/util/build_id.c
> >> @@ -22,12 +22,22 @@
> >> */
> >>
> >> #ifdef HAVE_DL_ITERATE_PHDR
> >> +
> >> +#include <sys/types.h>
> >> #include <link.h>
> >> #include <stddef.h>
> >> #include <string.h>
> >>
> >> #include "build_id.h"
> >>
> >> +#ifndef NT_GNU_BUILD_ID
> >> +#define NT_GNU_BUILD_ID 3
> >> +#endif
> >> +
> >> +#ifndef ElfW
> >> +#define ElfW(type) Elf_##type
> >> +#endif
> >> +
> > AFAICT the ElfW macro is a Linux/Solaris thing and is missing from
> > OpenBSD/FreeBSD. So we do want this, but I have no idea about the
> > rest.
>
> Those changes are fine. I'm a little surprised sys/types.h is needed.
I've just committed a change to the OpenBSD headers to make the include no
longer required. I'll remove it here and sent a git-format'd patch.
More information about the mesa-dev
mailing list