Thanks for your time!
I am having a hard time building a debian package with LTO. When I build it without LTO, everything works fine. However, when LTO is enabled, the static library components lose all their symbols, as shown below, which causes undefined reference errors when they are linked against.
$ nm ./libQt5QmlDevTools.a -C
qqmljsast.o:
nm: qqmljsast.o: no symbols
qqmljsastvisitor.o:
nm: qqmljsastvisitor.o: no symbols
qqmljsengine_p.o:
nm: qqmljsengine_p.o: no symbols
qqmljslexer.o:
nm: qqmljslexer.o: no symbols
qv4bytecodegenerator.o:
nm: qv4bytecodegenerator.o: no symbols
...
I tried both with and without -ffat-lto-objects but neither helped. I can confirm the symbols were still present before the dh_strip stage during the building process. It seems some operations later removed all symbols in the .a files
$ nm ./libQt5QmlDevTools.a -C
qqmljsast.o:
U __cxa_atexit
U __cxa_guard_acquire
U __cxa_guard_release
U __cxa_pure_virtual
U __dso_handle
U operator==(QString const&, QString const&)
U QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)
U QArrayData::shared_null
U QArrayData::allocate(unsigned long, unsigned long, unsigned long, QFlags<QArrayData::AllocationOption>)
00000000 W QConcatenable<QString>::appendTo(QString const&, QChar*&)
U QAbstractConcatenable::appendLatin1To(char const*, int, QChar*)
00000000 W QQmlJS::MemoryPool::allocate_helper(unsigned long)
00000000 W QQmlJS::MemoryPool::allocate(unsigned long)
00000000 T QQmlJS::AST::CaseClause::accept0(QQmlJS::AST::Visitor*)
00000000 W QQmlJS::AST::CaseClause::~CaseClause()
00000000 W QQmlJS::AST::CaseClause::~CaseClause()
00000000 W QQmlJS::AST::CaseClause::~CaseClause()
00000000 T QQmlJS::AST::Expression::accept0(QQmlJS::AST::Visitor*)
00000000 W QQmlJS::AST::Expression::~Expression()
00000000 W QQmlJS::AST::Expression::~Expression()
00000000 W QQmlJS::AST::Expression::~Expression()
...
...
dh_strip_nondeterminism
dh_compress
dh_fixperms
debian/rules override_dh_missing
make[1]: Entering directory '/G/Packages/Qt/qtdeclarative'
dh_missing --fail-missing
make[1]: Leaving directory '/G/Packages/Qt/qtdeclarative'
dh_dwz
dh_strip
dh_makeshlibs
dh_shlibdeps
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
The additional flags I used besides the default setup of the origin package is:
export DEB_CFLAGS_APPEND="-O3 -flto=jobserver -fdevirtualize-at-ltrans -fipa-pta -flto-odr-type-merging -ffat-lto-objects -flto-compression-level=9"
export DEB_CXXFLAGS_APPEND="-O3 -flto=jobserver -fdevirtualize-at-ltrans -fipa-pta -flto-odr-type-merging -ffat-lto-objects -flto-compression-level=9"
export DEB_LDFLAGS_APPEND="-O3 -flto=jobserver -fdevirtualize-at-ltrans -fipa-pta -flto-odr-type-merging -ffat-lto-objects -flto-compression-level=9"
And the message below is the nm output for the .a file built without LTO
$ nm ./libQt5QmlDevTools.a -C
qqmljsast.o:
U __cxa_atexit
U __cxa_guard_acquire
U __cxa_guard_release
U __cxa_pure_virtual
U __dso_handle
U _GLOBAL_OFFSET_TABLE_
0000000000000000 r .LC0
0000000000000040 r .LC1
0000000000000080 r .LC2
00000000000000c0 r .LC3
0000000000000100 r .LC4
0000000000000000 r .LC6
0000000000000005 r .LC7
U malloc
U memcpy
U qt_version_tag
U realloc
U __stack_chk_fail
U operator==(QString const&, QString const&)
0000000000000000 b guard variable for QQmlJS::AST::NumericLiteralPropertyName::asString() const::locale
U QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)
U QArrayData::shared_null
U QArrayData::allocate(unsigned long, unsigned long, unsigned long, QFlags<QArrayData::AllocationOption>)
U QAbstractConcatenable::appendLatin1To(char const*, int, QChar*)
0000000000000000 W QQmlJS::MemoryPool::allocate_helper(unsigned long)
0000000000005510 T QQmlJS::AST::CaseClause::accept0(QQmlJS::AST::Visitor*)
0000000000000000 W QQmlJS::AST::CaseClause::~CaseClause()
0000000000000000 W QQmlJS::AST::CaseClause::~CaseClause()
0000000000000000 W QQmlJS::AST::CaseClause::~CaseClause()
0000000000000000 n QQmlJS::AST::CaseClause::~CaseClause()
0000000000004ee0 T QQmlJS::AST::Expression::accept0(QQmlJS::AST::Visitor*)
0000000000000000 W QQmlJS::AST::Expression::~Expression()
0000000000000000 W QQmlJS::AST::Expression::~Expression()
0000000000000000 W QQmlJS::AST::Expression::~Expression()
0000000000000000 n QQmlJS::AST::Expression::~Expression()
...
...