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

Bug 675876

Summary: sys-devel/gcc: -Wl,--wrap not supported with LTO
Product: Gentoo Linux Reporter: cryptopsy
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: CONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also:
Whiteboard: was: dev-util/cmocka-1.1.3 - ld: .../temp/ccTALwcE.ltrans0.ltrans.o: in function `calc_uptime': <artificial>:(.text+0x48): undefined reference to `__wrap_uptime'
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 618550    
Attachments: build.log
emerge --info

Description cryptopsy 2019-01-19 20:20:18 UTC
Created attachment 562208 [details]

compiles fine without LTO
Comment 1 cryptopsy 2019-01-19 20:20:51 UTC
Created attachment 562210 [details]
emerge --info
Comment 2 Sergei Trofimovich gentoo-dev 2019-01-21 22:36:07 UTC
> CFLAGS="-march=native -O3 -pipe -flto -floop-interchange -floop-strip-mine -floop-block -fgraphite-identity -mindirect-branch=thunk -mindirect-branch-register"
> CXXFLAGS="-march=native -O3 -pipe -flto -floop-interchange -floop-strip-mine -floop-block -fgraphite-identity -mindirect-branch=thunk -mindirect-branch-register"

Can you try to minimize CFLAGS/CXXFLAGS while the error is still observable?

You can use
to expand -march=native.
Comment 3 David Heidelberg (okias) 2019-01-23 11:16:10 UTC
Will be fixed in 1.1.4

Fixed by commit:
Upstream issue:

Comment 4 Andreas Sturmlechner gentoo-dev 2019-01-24 22:32:24 UTC
But that's not really a fix, is it?
Comment 5 Sergei Trofimovich gentoo-dev 2019-01-24 22:37:12 UTC
Reproduced locally with C*FLAGS="-O2 -pipe -flto":

# LANG=C make V=1 VERBOSE=1
/usr/lib64/ccache/bin/x86_64-pc-linux-gnu-gcc -O2 -pipe -flto -fdiagnostics-show-option -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -O2 -pipe -flto -Wl,--hash-style=gnu  -Wl,--wrap=uptime CMakeFiles/test_uptime.dir/test_uptime.c.o  -o test_uptime -Wl,-rpath,/dev/shm/portage/dev-util/cmocka-1.1.3/work/cmocka-1.1.3-abi_x86_64.amd64/src ../../../src/ /usr/lib/ 
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/cc3ig6Xu.ltrans0.ltrans.o: in function `calc_uptime':
<artificial>:(.text+0x46): undefined reference to `__wrap_uptime'
collect2: error: ld returned 1 exit status

I think gcc's lto driver does not understand semantics of -Wl,--wrap= symbol renaming.
Comment 6 Sergei Trofimovich gentoo-dev 2019-01-24 22:39:45 UTC
Also registered in gcc upstream as
Comment 7 Larry the Git Cow gentoo-dev 2019-01-24 22:59:52 UTC
The bug has been referenced in the following commit(s):

commit 30c33c07c94332463b72487288d5b02372e64190
Author:     Andreas Sturmlechner <>
AuthorDate: 2019-01-24 22:32:32 +0000
Commit:     Andreas Sturmlechner <>
CommitDate: 2019-01-24 22:59:33 +0000

    dev-util/cmocka: Add USE examples, EAPI-7 bump
    Package-Manager: Portage-2.3.58, Repoman-2.3.12
    Signed-off-by: Andreas Sturmlechner <>

 dev-util/cmocka/cmocka-1.1.3.ebuild               | 13 ++++---
 dev-util/cmocka/files/cmocka-1.1.3-examples.patch | 45 +++++++++++++++++++++++
 2 files changed, 52 insertions(+), 6 deletions(-)