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
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

[   20s] make[3]: Entering directory '/home/abuild/rpmbuild/BUILD/osmo-sgsn-'
[   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- 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- 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

Also see:

It also seems to be a known issue:
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.