Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bugzilla DB migration completed. Please report issues to Infra team via email via infra@gentoo.org or IRC

Bug 232968

Summary: [PATCH]sys-devel/binutils-2.18: previous declaration of 'asprintf_chk' was here
Product: Gentoo Linux Reporter: Magnus Granberg <zorry>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: fauli, gengor, kanelxake
Priority: High    
Version: 2008.0   
Hardware: All   
OS: Linux   
URL: http://gcc.gnu.org/ml/gcc-patches/2008-07/msg00292.html
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 259417    
Attachments: Fix for glibc 2.8 and asprintf in libiberty.h

Description Magnus Granberg gentoo-dev 2008-07-25 21:57:04 UTC
With FORTIFY glibc alters the behaviour of asprintf, and this has changed in glibc-2.8 in a way leading to asprintf not being declared properly.

This results with for example things like libiberty (and things shipping with it, i.e. gcc-4.2.4, gcc-4.3.1, binutils-2.18, gdb-6.8) which should declare asprintf on its own if not already declared does not compile (since asprintf being declared two times). 
AVE_DECL_ASPRINTF is computed with _GNU_SOURCE unset,
libiberty/floatformat.c sets _GNU_SOURCE and uses libiberty.h,
so asprintf is redeclared (/usr/include/stdio.h + libiberty.h)



Reproducible: Always

Steps to Reproduce:
1.install hardened gcc 4 toolchain from git git://github.com/Xake/toolchain-overlay.git
2.emerge glibc 2.8
3.emerge binutils-1.18

Actual Results:  
sys-devel/binutils-2.18-r3 with gcc 4.2.4 and glibc 2.8-p20080602 In file included from /var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/libiberty/floatformat.c:40: /var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/libiberty/../include/libiberty.h:589: error: expected declaration specifiers or '...' before numeric constant /var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/libiberty/../include/libiberty.h:589: error: conflicting types for 'asprintf_chk' /usr/include/bits/stdio2.h:135: error: previous declaration of 'asprintf_chk' was here make[2]: *** [floatformat.o] Error 1 make[2]: *** Waiting for unfinished jobs....
gcc and gdb have the same bug.

Expected Results:  
emerge buinutils okey

irc log fron #gcc at irc.oftc.net
<Zorry> iant_work, ping
* ryanarn har avslutat (Read error: Connection reset by peer)
<iant_work> Zorry: pong
<andreast> DannyB: fyi, 36766 works on tuples
<Zorry> iant_work, the ifndef asprintf patch is working on two system now :)
<iant_work> good
* apinski (pinskia@216.68.190.3) gick in i #gcc
<Zorry> iant_work, upstream later ?
<iant_work> Zorry: the comment needs to go on the preceding line, needs to look like other comments, and should be shorter
<Zorry> okey
<iant_work> thanks
<Zorry> iant_work, np
<apinski> hi
<Zorry> iant_work, https://hardened.gentooexperimental.org/secure/attachment/ticket/33/libiberty.h-asprintf-glibc-2.8.patch
<iant_work> Just write /* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL.  */
<iant_work> put the comment before the #ifndef
* ryanarn (~ryanarn@68-117-77-37.dhcp.roch.mn.charter.com) gick in i #gcc
<iant_work> that patch is approved
<iant_work> thanks
<DannyB> that's what she said
<DannyB> richi: i had tracked down the gfortran issue on darwin and geoff keating confirmed my diagnosis
<Zorry> iant_work, okey :) thanx

gcc version 4.2.4 (Gentoo Hardened 4.2.4-r1 p1.0, builtin ssp,fortify, pie-9.0.11)
Portage 2.1.4.4 (hardened/linux/amd64/2008.0, gcc-4.2.4, glibc-2.8_p20080602-r0, 2.6.25-gentoo-r6 x86_64)
=================================================================
System uname: 2.6.25-gentoo-r6 x86_64 Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz
Timestamp of tree: Wed, 23 Jul 2008 09:45:03 +0000
app-shells/bash:     3.2_p33
dev-lang/python:     2.4.4-r13, 2.5.2-r5
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.61-r2
sys-devel/automake:  1.10.1
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.23-r3
ABI="amd64"
ACCEPT_KEYWORDS="amd64"
Comment 1 Magnus Granberg gentoo-dev 2008-07-25 22:00:32 UTC
Created attachment 161379 [details, diff]
Fix for glibc 2.8 and asprintf in libiberty.h

It will fix the error: previous declaration of 'asprintf_chk' was here
in >gcc-4.2 and >gdb-6.8 to
Comment 3 Wormo (RETIRED) gentoo-dev 2008-07-26 00:49:20 UTC
Thanks for the patch
Comment 4 Magnus Granberg gentoo-dev 2008-08-21 23:45:22 UTC
sys-devel/binutils-2.18.50.0.8 fix the problem on binutils but it don't have any keywords. Can some one add ~x86 ~amd64 ~ppc ~ppc64 ?
GCC 4.3 and GDB 6.8 still need the patch.
 
Comment 5 Magnus Granberg gentoo-dev 2008-12-24 03:18:04 UTC
Fixed in piepatch 10.1.2 for gcc-4.3-2
Comment 6 SpanKY gentoo-dev 2009-01-28 01:00:57 UTC
binutils-2.19 and gcc-4.3.2 are fixed.  does gdb-6.8-r1 need the patch still ?
Comment 7 Magnus Granberg gentoo-dev 2009-01-28 04:32:50 UTC
(In reply to comment #6)
> binutils-2.19 and gcc-4.3.2 are fixed.  does gdb-6.8-r1 need the patch still ?
> 
If you put the fortify spec in gcc.c cpp_unique_options then gcc, binutils and gdb don't need the asprintf patch.
Comment 8 Christian Faulhammer (RETIRED) gentoo-dev 2009-02-09 01:35:23 UTC
vapier, which version of binutils needs to go stable for Glibc 2.8?
Comment 9 SpanKY gentoo-dev 2009-02-09 02:08:53 UTC
there is no glibc issue here