Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 305075

Summary: sys-libs/glibc: gentoo patches use undefined __offsetof in sys/queue.h
Product: Gentoo Linux Reporter: Markus Rathgeb <maggu2810>
Component: New packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: didier-bugzillagentoo, martin, tcunha
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: A simple testcase to point out the problem

Description Markus Rathgeb 2010-02-14 16:26:14 UTC
I prepared to setup a symbian development environmont on my gentoo machine.
After downloading gnupoc-package-1.15 (http://www.martin.st/symbian/) and begin to install.
It breaks by compiling libelf-elftoolchain of the elf2e32 tool.

The maintainer of the package shows a lot of engagement to find the source of the problem (big thanks again to him).

It would be the easiest to post their last email that points out the problem:
===
Ah, here's the problem. The official glibc doesn't have this definition in 
this header, the gentoo developers have copied additional items into this 
header from FreeBSD, see http://bugs.gentoo.org/201979. This patch is in 
http://dev.gentoo.org/~vapier/dist/glibc-2.11-patches-1.tar.bz2.

The problem here is that this defines STAILQ_LAST to use __offsetof. In 
FreeBSD, __offsetof is defined in some way so that it is usable, but this 
definition isn't available on linux. So, this header should either be 
updated to use plain "offsetof" (which is ANSI C, defined in stddef.h), or 
__offsetof should be defined in some way.

The libelf-elftoolchain code checks for STAILQ_LAST - if the system has it 
defined, it uses that instead, otherwise it uses its own definition as a 
fallback.

Either way, this is your distribution shipping broken headers.
===

IMHO: If the gentoo patches introduce a macro for STAILQ_LAST it should be ensured that the macro is working.

Reproducible: Always

Steps to Reproduce:
Comment 1 Martin Storsjö 2010-03-04 10:16:13 UTC
Created attachment 222019 [details]
A simple testcase to point out the problem
Comment 2 Martin Storsjö 2010-03-04 10:23:18 UTC
I suggest changing the summary of the bug report to "sys-libs/glibc: gentoo patches use undefined __offsetof in sys/queue.h".

The attached testcase stailq.c is a condensed example of what's happening in this case. Portable code includes sys/queue.h and uses the definitions found there, if they're available, otherwise supplies its own definition of some macros. Normal glibc sys/queue.h doesn't contain a definition of STAILQ_LAST, but the gentoo patched version does. The version in gentoo sys/queue.h is copied verbatim from freebsd, and uses __offsetof, which is defined elsewhere on BSD systems, but not on gentoo.

I suggest to simply change __offsetof into offsetof (which to my knowledge is a standard C feature since about C90) in this function macro.
Comment 3 Didier Barvaux 2010-04-05 11:43:06 UTC
Confirmed on a stable x86 system with sys-libs/glibc-2.10.1-r1.