Bug 1142709

Summary: -flto breaks function wrapping
Product: [openSUSE] openSUSE Tumbleweed Reporter: Martin Hauke <mardnh>
Component: DevelopmentAssignee: Michael Matz <matz>
Status: RESOLVED UPSTREAM QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: alynx.zhou
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88643
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Martin Hauke 2019-07-24 19:35:57 UTC
Function wrapping is broken with -flto

e.g. package osmo-sgsn
https://build.opensuse.org/package/show/openSUSE:Factory/osmo-sgsn

---snip---
[   20s] make[3]: Entering directory '/home/abuild/rpmbuild/BUILD/osmo-sgsn-1.4.0.29/tests/gbproxy'
[   20s]   CC       gbproxy_test.o
[   20s]   CCLD     gbproxy_test
[   22s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/gbproxy_test.Vzl0RE.ltrans0.ltrans.o: in function `gbproxy_make_sgsn_tlli':
[   22s] /home/abuild/rpmbuild/BUILD/osmo-sgsn-1.4.0.29/tests/gbproxy/gb_proxy.c:278: undefined reference to `__wrap_osmo_get_rand_id'
[   22s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/gbproxy_test.Vzl0RE.ltrans0.ltrans.o: in function `gbprox_process_bssgp_dl.constprop.0':
[   22s] /home/abuild/rpmbuild/BUILD/osmo-sgsn-1.4.0.29/tests/gbproxy/gb_proxy.c:240: undefined reference to `__wrap_osmo_get_rand_id'
[   22s] collect2: error: ld returned 1 exit status
[   22s] make[3]: *** [Makefile:437: gbproxy_test] Error 1
---snip---

Also see:
https://osmocom.org/issues/4116


It also seems to be a known issue:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88643
Comment 1 Richard Biener 2019-07-25 09:48:27 UTC
Yeah, please disable the use of LTO if you rely on -Wl,--wrap.  Tracking upstream.