namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.03k stars 444 forks source link

Build failures with LTO #1927

Open namhyung opened 4 months ago

namhyung commented 4 months ago

Currently I see a build failure for LTO build. Maybe there's a problem with the arch object which is linked with the plain ld.

$ ./configure --cflags=-flto

$ make
...
  LINK     arch/x86_64/uftrace.o
  LINK     uftrace
lto-wrapper: warning: using serial compilation of 6 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
...
  LINK     arch/x86_64/mcount-entry.op
  LINK     libmcount/libmcount.so
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
/usr/bin/ld: /tmp/ccJCPo6b.ltrans0.ltrans.o: in function `mcount_rstack_restore':
uftrace/libmcount/misc.c:128:(.text+0x18a): undefined reference to `plthook_return'
/usr/bin/ld: /tmp/ccJCPo6b.ltrans0.ltrans.o: in function `mcount_rstack_reset':
uftrace/libmcount/misc.c:207:(.text+0x7aa): undefined reference to `plthook_return'
/usr/bin/ld: /tmp/ccJCPo6b.ltrans0.ltrans.o: in function `mcount_startup':
uftrace/libmcount/mcount.c:2054:(.text+0xcb6f): undefined reference to `mcount_return'
/usr/bin/ld: /tmp/ccJCPo6b.ltrans2.ltrans.o: in function `mcount_setup_trampoline':
uftrace/arch/x86_64/mcount-dynamic.c:30:(.text+0x180c): undefined reference to `__xray_entry'
/usr/bin/ld: uftrace/arch/x86_64/mcount-dynamic.c:31:(.text+0x1817): undefined reference to `__xray_exit'
/usr/bin/ld: uftrace/arch/x86_64/mcount-dynamic.c:83:(.text+0x194f): undefined reference to `__dentry__'
collect2: error: ld returned 1 exit status

On a parallel build, I also saw a different error:

$ make -j 8
...
  LINK     libmcount/libmcount.so
uftrace/libmcount/plthook.c:90:1: error: function ‘uftrace___cyg_profile_func_exit’ redeclared as variable
   90 | ALIAS_DECL(__cyg_profile_func_exit);
      | ^
uftrace/libmcount/mcount.c:2181:1: note: previously declared here
 2181 | UFTRACE_ALIAS(__cyg_profile_func_exit);
      | ^
uftrace/libmcount/plthook.c:89:1: error: function ‘uftrace___cyg_profile_func_enter’ redeclared as variable
   89 | ALIAS_DECL(__cyg_profile_func_enter);
uftrace/libmcount/mcount.c:2175:1: note: previously declared here
 2175 | UFTRACE_ALIAS(__cyg_profile_func_enter);
      | ^
lto1: fatal error: errors during merging of translation units
compilation terminated.
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
FantasqueX commented 4 months ago

Related issue https://github.com/namhyung/uftrace/issues/1343

namhyung commented 4 months ago

Thanks for the link!