Bug 1763325

Summary: argp.h kills __attribute__, causing gcc 4.8.5 with -std=c++ results in compile / link errors for __gthrw_pthread_mutex_* functions
Product: Red Hat Enterprise Linux 7 Reporter: Frank Ch. Eigler <fche>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.7CC: ashankar, codonell, dj, fweimer, jakub, mcermak, mnewsome, ohudlick, pfrankli, skolosov
Target Milestone: rcKeywords: Patch, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.17-315.el7 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-09-29 19:20:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1782203    
Attachments:
Description Flags
gcc -E preprocessed form of a random snapshot of elfutils debuginfod
none
same, with -E -dD none

Description Frank Ch. Eigler 2019-10-18 19:48:26 UTC
Created attachment 1627252 [details]
gcc -E  preprocessed form of a random snapshot of elfutils debuginfod

attached .i file, compiled thusly:

$ g++ -std=c++11 -g -O2  -c -o debuginfod.o debuginfod.i

shows:

/usr/include/c++/4.8.2/x86_64-redhat-linux/bits/gthr-default.h:115:37: warning: ‘int __gthrw_pthread_mutex_lock(pthread_mutex_t*) throw ()’ used but never defined [enabled by default]
 __gthrw(pthread_mutex_lock)
                                     ^
/usr/include/c++/4.8.2/x86_64-redhat-linux/bits/gthr-default.h:120:39: warning: ‘int __gthrw_pthread_mutex_unlock(pthread_mutex_t*) throw ()’ used but never defined [enabled by default]
 __gthrw(pthread_mutex_unlock)
                                       ^

linking fails with these gthr-relevant symbols:

$ g++ -std=c++11  -g -O2  -o debuginfod debuginfod.i|& grep gthr
[...]
/tmp/cc92jQNh.o: In function `__gthread_mutex_lock':
/usr/include/c++/4.8.2/x86_64-redhat-linux/bits/gthr-default.h:748: undefined reference to `__gthrw_pthread_mutex_lock(pthread_mutex_t*)'
/usr/include/c++/4.8.2/x86_64-redhat-linux/bits/gthr-default.h:748: undefined reference to `__gthrw_pthread_mutex_lock(pthread_mutex_t*)'
/tmp/cc92jQNh.o: In function `__gthread_mutex_unlock':
[...]

Comment 2 Jakub Jelinek 2019-10-18 20:02:26 UTC
Something is doing
#define __attribute__(x)
or something similar before including the libstdc++ headers.  That can't work.

Comment 3 Frank Ch. Eigler 2019-10-18 20:13:21 UTC
Created attachment 1627254 [details]
same, with -E -dD

Comment 4 Frank Ch. Eigler 2019-10-18 20:19:20 UTC
from discussions with jakub:
glibc-headers-2.17-292.el7.x86_64

/usr/include/argp.h:

#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later.  */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \
  defined __STRICT_ANSI__
#  define __attribute__(Spec) /* empty */
# endif


this bit in argp.h disables the __attribute__ mechanism that other system libraries rely on.  The __STRICT_ANSI__ condition is probably unnecessary here.


https://sourceware.org/bugzilla/show_bug.cgi?id=16907 appears to be this same bug.  Please consider a backport.

Comment 6 Florian Weimer 2019-11-25 16:03:08 UTC
Upstream commit:

commit 2c820533c61fed175390bc6058afbbe42d2edc37
Author: Florian Weimer <fweimer>
Date:   Thu Aug 18 11:15:42 2016 +0200

    argp: Do not override GCC keywords with macros [BZ #16907]
    
    glibc provides fallback definitions already.  It is not necessary to
    suppress warnings for unknown attributes because GCC does this
    automatically for system headers.
    
    This commit does not sync with gnulib because gnulib has started to use
    _GL_* macros in the header file, which are arguably in the gnulib
    implementation space and not suitable for an installed glibc header
    file.

Comment 12 errata-xmlrpc 2020-09-29 19:20:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Low: glibc security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:3861