This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Compiling Samba with LTO
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: Ralph Boehme <slow at samba dot org>, gcc-help at gcc dot gnu dot org
- Date: Sat, 12 Mar 2016 10:05:51 +0900
- Subject: Re: Compiling Samba with LTO
- Authentication-results: sourceware.org; auth=none
- References: <20160311152725 dot GA31660 at sernet dot sernet dot private>
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