[CLN-list] Linking against cln fails when built with link-time-optimization
Atri Bhattacharya
badshah400 at opensuse.org
Sun Sep 20 20:49:46 CEST 2020
Hi Alexey,
On Sun, 2020-09-20 at 20:35 +0400, Alexey Sheplyakov wrote:
> Hi!
>
> 20.09.2020, 15:11, "Atri Bhattacharya" <badshah400 at opensuse.org>:
> > Hello,
> > When the shared library for CLN is built with link-time
> > optimization
> > [1] (LTO) enabled, linking against libcln.so fails (for example
> > GiNaC
> > fails to build).
>
> Can't reproduce it here with gcc 7.5 and binutils 2.30.
>
Thanks for your response. I have set up a test project to reproduce the
problem here (and try any suggestions you may have):
<https://build.opensuse.org/project/show/home:badshah400:boo1176710>
where both cln and ginac are being built with LTO enabled against GCC
10.1 and binutils 2.34. Here is the relevant build failure for ginac
(cln tests do pass here as well):
---
[ 137s] [ 81%] Linking CXX shared library libginac.so
[ 137s] cd /home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/build/ginac && /usr/bin/cmake -E cmake_link_script CMakeFiles/ginac.dir/link.txt --verbose=1
[ 137s] /var/lib/build/ccache/bin/c++ -fPIC -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DNDEBUG -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,libginac.so.6 -o libginac.so.6.4.5 CMakeFiles/ginac.dir/add.cpp.o CMakeFiles/ginac.dir/archive.cpp.o CMakeFiles/ginac.dir/basic.cpp.o CMakeFiles/ginac.dir/clifford.cpp.o CMakeFiles/ginac.dir/color.cpp.o CMakeFiles/ginac.dir/constant.cpp.o CMakeFiles/ginac.dir/excompiler.cpp.o CMakeFiles/ginac.dir/ex.cpp.o CMakeFiles/ginac.dir/expair.cpp.o CMakeFiles/ginac.dir/expairseq.cpp.o CMakeFiles/ginac.dir/exprseq.cpp.o CMakeFiles/ginac.dir/factor.cpp.o CMakeFiles/ginac.dir/fail.cpp.o CMakeFiles/ginac.dir/fderivative.cpp.o CMakeFiles/ginac.dir/function.cpp.o CMakeFiles/ginac.dir/idx.cpp.o CMakeFiles/ginac.dir/indexed.cpp.o CMakeFiles/ginac.dir/inifcns.cpp.o CMakeFiles/ginac.dir/inifcns_gamma.cpp.o CMakeFiles/ginac.dir/inifcns_nstdsums.cpp.o CMakeFiles/ginac.dir/inifcns_trans.cpp.o CMakeFiles/ginac.dir/integral.cpp.o CMakeFiles/ginac.dir/lst.cpp.o CMakeFiles/ginac.dir/matrix.cpp.o CMakeFiles/ginac.dir/mul.cpp.o CMakeFiles/ginac.dir/ncmul.cpp.o CMakeFiles/ginac.dir/normal.cpp.o CMakeFiles/ginac.dir/numeric.cpp.o CMakeFiles/ginac.dir/operators.cpp.o CMakeFiles/ginac.dir/parser/default_reader.cpp.o CMakeFiles/ginac.dir/parser/lexer.cpp.o CMakeFiles/ginac.dir/parser/parse_binop_rhs.cpp.o CMakeFiles/ginac.dir/parser/parse_context.cpp.o CMakeFiles/ginac.dir/parser/parser_compat.cpp.o CMakeFiles/ginac.dir/parser/parser.cpp.o CMakeFiles/ginac.dir/polynomial/chinrem_gcd.cpp.o CMakeFiles/ginac.dir/polynomial/collect_vargs.cpp.o CMakeFiles/ginac.dir/polynomial/cra_garner.cpp.o CMakeFiles/ginac.dir/polynomial/divide_in_z_p.cpp.o CMakeFiles/ginac.dir/polynomial/gcd_uvar.cpp.o CMakeFiles/ginac.dir/polynomial/mgcd.cpp.o CMakeFiles/ginac.dir/polynomial/mod_gcd.cpp.o CMakeFiles/ginac.dir/polynomial/normalize.cpp.o CMakeFiles/ginac.dir/polynomial/optimal_vars_finder.cpp.o CMakeFiles/ginac.dir/polynomial/pgcd.cpp.o CMakeFiles/ginac.dir/polynomial/primpart_content.cpp.o CMakeFiles/ginac.dir/polynomial/remainder.cpp.o CMakeFiles/ginac.dir/polynomial/upoly_io.cpp.o CMakeFiles/ginac.dir/power.cpp.o CMakeFiles/ginac.dir/print.cpp.o CMakeFiles/ginac.dir/pseries.cpp.o CMakeFiles/ginac.dir/registrar.cpp.o CMakeFiles/ginac.dir/relational.cpp.o CMakeFiles/ginac.dir/remember.cpp.o CMakeFiles/ginac.dir/symbol.cpp.o CMakeFiles/ginac.dir/symmetry.cpp.o CMakeFiles/ginac.dir/tensor.cpp.o CMakeFiles/ginac.dir/utils.cpp.o CMakeFiles/ginac.dir/wildcard.cpp.o /usr/lib64/libcln.so -ldl
[ 137s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /tmp/libginac.so.6.4.5.5CSKjJ.ltrans27.ltrans.o: in function `GiNaC::print_real_number(GiNaC::print_context const&, cln::cl_R const&)':
[ 137s] /home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/ginac/numeric.cpp:411: undefined reference to `cln::denominator(cln::cl_RA const&)'
[ 137s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /tmp/libginac.so.6.4.5.5CSKjJ.ltrans27.ltrans.o: in function `GiNaC::print_real_csrc(GiNaC::print_context const&, cln::cl_R const&)':
[ 137s] /home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/ginac/numeric.cpp:451: undefined reference to `cln::denominator(cln::cl_RA const&)'
[ 137s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /tmp/libginac.so.6.4.5.5CSKjJ.ltrans27.ltrans.o: in function `GiNaC::numeric::numer() const':
[ 137s] /home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/ginac/numeric.cpp:1370: undefined reference to `cln::denominator(cln::cl_RA const&)'
[ 137s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/ginac/numeric.cpp:1374: undefined reference to `cln::denominator(cln::cl_RA const&)'
[ 137s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/ginac/numeric.cpp:1374: undefined reference to `cln::denominator(cln::cl_RA const&)'
[ 137s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /tmp/libginac.so.6.4.5.5CSKjJ.ltrans27.ltrans.o:/home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/ginac/numeric.cpp:1376: more undefined references to `cln::denominator(cln::cl_RA const&)' follow
[ 137s] collect2: error: ld returned 1 exit status
[ 137s] make[2]: *** [ginac/CMakeFiles/ginac.dir/build.make:989: ginac/libginac.so.6.4.5] Error 1
[ 137s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/ginac-1.7.11.git20200829/build'
[ 137s] make[1]: *** [CMakeFiles/Makefile2:598: ginac/CMakeFiles/ginac.dir/all] Error 2
[ 137s] make: *** [Makefile:163: all] Error 2
---
Turning off LTO for cln fixes this linking issue (as noted in the
original bug report). Perhaps it is a GCC regression or something, but
I am merely guessing as opposed to really understanding the issue. Full
build log (for ginac) here:
<https://build.opensuse.org/package/live_build_log/home:badshah400:boo1176710/ginac/openSUSE_Tumbleweed/x86_64>
Thanks again for looking into this and best wishes.
--
Atri Bhattacharya
More information about the CLN-list
mailing list