Compiling Samba with LTO

Oleg Endo oleg.endo@t-online.de
Sat Mar 12 01:06:00 GMT 2016


On Fri, 2016-03-11 at 16:27 +0100, Ralph Boehme wrote:

> I'm seeing a problem when building Samba with LTO. Linking fails
> reproducibly at this stage:
> 
> [4086/4247] Linking default/source4/torture/smbtorture
> 13:31:06 runner /usr/bin/gcc
> default/source4/lib/registry/tests/generic_20.o ...
> ... many many object files and libraries ...
> 
> /tmp/cc9skRWL.ltrans3.ltrans.o: In function
> `smbsrv_accept.lto_priv.11':
> <artificial>:(.text+0x4cd6): undefined reference to
> `timeval_current.lto_priv.641'
> /tmp/cc9skRWL.ltrans4.ltrans.o: In function
> `smbsrv_recv_smb2_request':
> <artificial>:(.text+0xf661): undefined reference to
> `timeval_current.lto_priv.641'
> ... many more undefined references to timeval_* ...
> 
> Full build log:
> <https://www.samba.org/~slow/files/log.gz>
> 
> $ gcc --version
> gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2)
> 
> The buildsystem correctly passes -flto when compiling .c files and
> the
> link steps has it as well.
> 
> The missing symbols are in libsamba-util which is among the linked
> libraries:
> 
> $ nm bin/shared/libsamba-util.so.0 | egrep
> 'timeval_current$|timeval_elapsed$'
> 000000000001cd6b T timeval_current
> 000000000001a206 T timeval_elapsed
> 
> The build works just fine without -flto.
> 
> I'd appreciate any pointers on how to get -flto going.

I ran into similar issues when building something without LTO vs. with
LTO.  Sometimes the link order needs to be changed for an LTO build. 
 Sometimes it's required to use -Wl,--whole-archive on some of the libs
and some libs need to be put in a -Wl,-start-group ... -Wl,--end-group.

You might want to try out playing with those and see if it helps in
your case.

Cheers,
Oleg



More information about the Gcc-help mailing list