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

Bug 865337

Summary: =sys-devel/binutils-2.39[gprofng] fails to build with -D_FORTIFY_SOURCE=2 and Clang
Product: Gentoo Linux Reporter: Alec Ari <neotheuser>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED UPSTREAM    
Severity: normal CC: sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=807766
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 408963    
Attachments: build.log
emerge --info

Description Alec Ari 2022-08-15 23:53:06 UTC
=sys-devel/binutils-2.39 fails to build with -D_FORTIFY_SOURCE=2 and Clang.

Upon googling, this looks very well related:

#807766

https://bugs.gentoo.org/807766

Reproducible: Always

Steps to Reproduce:
1. Force following CFLAGS with Clang:

i.e.:

COMMON_FLAGS="-O2 -fPIC -fstack-protector-strong -fstack-clash-protection -fomit-frame-pointer -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"

2. Attempt to merge =sys-devel/binutils-2.39

3. Wait a few moments
Actual Results:  
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/mmaptrace.c:331:14: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/mmaptrace.c:1286:18: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
1 warning and 2 errors generated.
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:187:15: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:207:15: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:467:16: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:518:19: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:535:15: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:601:16: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:747:14: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:795:14: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/envmgmt.c:822:15: error: no member named '__fprintf_chk' in 'struct CollectorUtilFuncs'
          CALL_UTIL (fprintf)(stderr, "__collector_clearenv(): ERROR: %s\n", dlerror ());
1 warning and 9 errors generated.
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/iolib.c:229:15: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/iolib.c:264:19: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/iolib.c:614:23: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/iolib.c:643:25: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
2 warnings and 4 errors generated.
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:550:14: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:768:18: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:774:18: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:828:15: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:864:13: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
          strerror_r (errno, errmsg, sizeof (errmsg));
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:870:15: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
      strerror_r (errno, errmsg, sizeof (errmsg));
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:987:18: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
/var/tmp/portage/sys-devel/binutils-2.39/work/binutils-2.39/gprofng/libcollector/linetrace.c:990:16: error: no member named '__builtin___snprintf_chk' in 'struct CollectorUtilFuncs'
4 warnings and 8 errors generated.

Expected Results:  
Successful merge of =sys-devel/binutils-2.39

Forcing CFLAGS like this may not be supported by Gentoo but some people are extra cautious in terms of security. Sharing here because =net-libs/libnftnl-1.2.0 was fixed. Most standard Gentoo users may not encounter this bug as GCC is the compiler of choice for most, and the majority do not play with -D_FORTIFY_SOURCE
Comment 1 Alec Ari 2022-08-15 23:53:36 UTC
Created attachment 799825 [details]
build.log
Comment 2 Alec Ari 2022-08-15 23:53:51 UTC
Created attachment 799827 [details]
emerge --info
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-16 00:05:05 UTC
For the record, very interested in bugs involving F_S & clang, even if it's not top of my list to address personally. They're not invalid at all.
Comment 4 Alec Ari 2023-02-17 00:49:28 UTC
This problem is fixed in Binutils 2.40 and even works with -D_FORTIFY_SOURCE=3 with Clang
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-17 01:28:57 UTC
(In reply to Alec Ari from comment #4)
> This problem is fixed in Binutils 2.40 and even works with
> -D_FORTIFY_SOURCE=3 with Clang

Thanks for the update!