Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 675876 - sys-devel/gcc: -Wl,--wrap not supported with LTO
Summary: sys-devel/gcc: -Wl,--wrap not supported with LTO
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard: was: dev-util/cmocka-1.1.3 - ld: .../...
Keywords:
Depends on:
Blocks: systemwide-gold lto
  Show dependency tree
 
Reported: 2019-01-19 20:20 UTC by cryptopsy
Modified: 2022-05-11 14:48 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (dev-util:cmocka-1.1.3:20190119-214616.log,50.11 KB, text/plain)
2019-01-19 20:20 UTC, cryptopsy
Details
emerge --info (info,5.67 KB, text/plain)
2019-01-19 20:20 UTC, cryptopsy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cryptopsy 2019-01-19 20:20:18 UTC
Created attachment 562208 [details]
build.log

compiles fine without LTO
Comment 1 cryptopsy 2019-01-19 20:20:51 UTC
Created attachment 562210 [details]
emerge --info
Comment 2 Sergei Trofimovich (RETIRED) 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
    https://wiki.gentoo.org/wiki/Gcc-ICE-reporting-guide#Expand_-march.3Dnative.2C_exact_gcc_version_and_other_system-specific_options
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: https://gitlab.com/cmocka/cmocka/commit/ee264da1aa222b354cee36184ab48c2072f62243
Upstream issue: https://gitlab.com/cmocka/cmocka/issues/14

MUST BE BUILD WITH: -DWITH_EXAMPLES=OFF
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 (RETIRED) 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/libcmocka.so.0.5.1 /usr/lib/librt.so 
/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 (RETIRED) gentoo-dev 2019-01-24 22:39:45 UTC
Also registered in gcc upstream as https://gcc.gnu.org/PR88643
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):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=30c33c07c94332463b72487288d5b02372e64190

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

    dev-util/cmocka: Add USE examples, EAPI-7 bump
    
    Bug: https://bugs.gentoo.org/675876
    Package-Manager: Portage-2.3.58, Repoman-2.3.12
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 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(-)
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-05-11 01:59:26 UTC
Apparently a gold bug.