Bug 1193191

Summary: Undefined reference to functions based on gcc linker plugin during OBS build of qore-ssh2-module for s390x
Product: [openSUSE] openSUSE Tumbleweed Reporter: Sarah Kriesch <ada.lovelace>
Component: DevelopmentAssignee: E-mail List <screening-team-bugs>
Status: VERIFIED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P3 - Medium CC: ada.lovelace, ihno, martin.liska, matz
Version: Current   
Target Milestone: ---   
Hardware: S/390-64   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 1190740    
Attachments: full build log

Description Sarah Kriesch 2021-11-29 19:26:52 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
Build Identifier: 

We have got a failed build of qore-ssh2-module for s390x in our ZSystems repository and the build was successfully in factory. Anywaz, this bugreport seems to be closed to the bugreport 1190740 with PostgreSQL and Rust. This one is also failing based on the linker plugin.

Reproducible: Always

Steps to Reproduce:
1. Go to https://build.opensuse.org/package/show/openSUSE:Factory:zSystems/qore-ssh2-module
2. The build is failing


Actual Results:  
Failed build based on the gcc linker plugin

Expected Results:  
Successful build
Comment 1 Sarah Kriesch 2021-11-29 19:35:11 UTC
Created attachment 854147 [details]
full build log
Comment 2 Sarah Kriesch 2021-11-29 19:41:55 UTC
The hints with "Undefined reference" are in the whole build log. That is too much for one comment.

Therefore, here is the start:
[   14s] [ 77%] Linking CXX shared library ssh2-api-1.1.qmod
[   14s] /usr/bin/cmake -E cmake_link_script CMakeFiles/ssh2.dir/link.txt --verbose=1
[   14s] /usr/bin/c++ -fPIC -O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -DNDEBUG -std=c++11 -DBUILDING_DLL=1 -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,ssh2-api-1.1.qmod -o ssh2-api-1.1.qmod CMakeFiles/ssh2.dir/src/SFTPClient.cpp.o CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o CMakeFiles/ssh2.dir/src/SSH2Client.cpp.o CMakeFiles/ssh2.dir/src/ssh2-module.cpp.o CMakeFiles/ssh2.dir/QC_SFTPClient.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Base.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Channel.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Client.cpp.o  -lssh2 
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::waitSocketUnlocked(int, int) const':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:195: undefined reference to `QoreSocket::asyncIoWait(int, bool, bool) const'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::waitSocketUnlocked(ExceptionSink*, char const*, char const*, char const*, int, bool, AbstractDisconnectionHelper*)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:182: undefined reference to `ExceptionSink::raiseErrnoException(char const*, int, char const*, ...)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::doSessionErrUnlocked(ExceptionSink*)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:147: undefined reference to `ExceptionSink::raiseException(char const*, char const*, ...)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::waitSocketUnlocked(ExceptionSink*, char const*, char const*, char const*, int, bool, AbstractDisconnectionHelper*)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:175: undefined reference to `ExceptionSink::raiseException(char const*, char const*, ...)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Channel::check_open(ExceptionSink*)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Channel.h:58: undefined reference to `ExceptionSink::raiseException(char const*, char const*, ...)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Channel::requestPty(ExceptionSink*, QoreString const&, QoreString const&, int, int, int, int, int)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Channel.cpp:74: undefined reference to `QoreString::getBuffer() const'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Channel.cpp:74: undefined reference to `QoreString::strlen() const'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Channel.cpp:74: undefined reference to `QoreString::strlen() const'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Channel.cpp:74: undefined reference to `QoreString::getBuffer() const'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Channel.cpp:74: undefined reference to `QoreString::strlen() const'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::waitSocketUnlocked(int, int) const':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:195: undefined reference to `QoreSocket::asyncIoWait(int, bool, bool) const'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::waitSocketUnlocked(ExceptionSink*, char const*, char const*, char const*, int, bool, AbstractDisconnectionHelper*)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:182: undefined reference to `ExceptionSink::raiseErrnoException(char const*, int, char const*, ...)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::doSessionErrUnlocked(ExceptionSink*)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:147: undefined reference to `ExceptionSink::raiseException(char const*, char const*, ...)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o: in function `SSH2Client::waitSocketUnlocked(ExceptionSink*, char const*, char const*, char const*, int, bool, AbstractDisconnectionHelper*)':
Comment 3 Sarah Kriesch 2021-11-29 19:43:20 UTC
Other functions:
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/ssh2-module.cpp.o: in function `ssh2_module_init()':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:188: undefined reference to `QoreNamespace::addSystemClass(QoreClass*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:189: undefined reference to `QoreNamespace::addSystemClass(QoreClass*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:190: undefined reference to `QoreNamespace::addSystemClass(QoreClass*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:191: undefined reference to `QoreNamespace::addSystemClass(QoreClass*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:194: undefined reference to `QCS_DEFAULT'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:194: undefined reference to `QoreStringNode::QoreStringNode(char const*, QoreEncoding const*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:194: undefined reference to `QoreValue::QoreValue(AbstractQoreNode*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:194: undefined reference to `QoreNamespace::addConstant(char const*, QoreValue)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:78: undefined reference to `QoreStringNodeMaker::QoreStringNodeMaker(char const*, ...)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:79: undefined reference to `QoreString::concat(char const*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:80: undefined reference to `QoreString::concat(char)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/ssh2-module.cpp.o: in function `_GLOBAL__sub_I_ssh2_module.cpp':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:39: undefined reference to `QoreNamespace::QoreNamespace(char const*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/ssh2-module.cpp.o: in function `__static_initialization_and_destruction_0':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/ssh2-module.cpp:39: undefined reference to `QoreNamespace::~QoreNamespace()'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/src/SFTPClient.cpp.o: in function `SSH2Client::waitSocketUnlocked(int, int) const':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/SSH2Client.h:195: undefined reference to `QoreSocket::asyncIoWait(int, bool, bool) const'
Comment 4 Sarah Kriesch 2021-11-29 19:44:17 UTC
Build failure message:
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /usr/include/qore/QoreValue.h:169: undefined reference to `QoreSimpleValue::set(AbstractQoreNode*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /usr/include/qore/QoreValue.h:169: undefined reference to `QoreSimpleValue::set(AbstractQoreNode*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: /usr/include/qore/QoreValue.h:169: undefined reference to `QoreSimpleValue::set(AbstractQoreNode*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/QC_SSH2Client.cpp.o: in function `initSSH2ClientClass(QoreNamespace&)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/QC_SSH2Client.qpp:346: undefined reference to `DateTimeNode::makeRelative(int, int, int, int, int, int, int)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/QC_SSH2Client.cpp.o: in function `QoreSimpleValue::assign(AbstractQoreNode*)':
[   14s] /usr/include/qore/QoreValue.h:169: undefined reference to `QoreSimpleValue::set(AbstractQoreNode*)'
[   14s] /usr/lib64/gcc/s390x-suse-linux/11/../../../../s390x-suse-linux/bin/ld: CMakeFiles/ssh2.dir/QC_SSH2Client.cpp.o: in function `initSSH2ClientClass(QoreNamespace&)':
[   14s] /home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/src/QC_SSH2Client.qpp:346: undefined reference to `QoreClass::addMethod(char const*, QoreValue (*)(QoreObject*, AbstractPrivateData*, QoreListNode const*, unsigned long, ExceptionSink*), ClassAccess, long long, long long, QoreTypeInfo const*, unsigned int, ...)'
[   14s] collect2: error: ld returned 1 exit status
[   14s] make[3]: *** [CMakeFiles/ssh2.dir/build.make:240: ssh2-api-1.1.qmod] Error 1
[   14s] make[3]: Leaving directory '/home/abuild/rpmbuild/BUILD/module-ssh2-release-0.9.15/build'
[   14s] make[2]: *** [CMakeFiles/Makefile2:94: CMakeFiles/ssh2.dir/all] Error 2
[   14s] make[1]: *** [CMakeFiles/Makefile2:183: CMakeFiles/docs.dir/rule] Error 2
[   14s] make: *** [Makefile:231: docs] Error 2
Comment 5 Martin Liška 2021-11-30 13:30:26 UTC
Well, the package also fails for other targets (x86_64, i586) in Factory:
https://build.opensuse.org/package/show/openSUSE:Factory/qore-ssh2-module

How is that related to the linker plugin?
Comment 6 Martin Liška 2021-11-30 13:35:10 UTC
The linker command looks like:
[   10s] /usr/bin/c++ -fPIC -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -DNDEBUG -std=c++11 -DBUILDING_DLL=1 -O2 -g -DNDEBUG  -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,ssh2-api-1.1.qmod -o ssh2-api-1.1.qmod CMakeFiles/ssh2.dir/src/SFTPClient.cpp.o CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o CMakeFiles/ssh2.dir/src/SSH2Client.cpp.o CMakeFiles/ssh2.dir/src/ssh2-module.cpp.o CMakeFiles/ssh2.dir/QC_SFTPClient.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Base.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Channel.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Client.cpp.o  -lssh2 

as seen, it very likely misses -lqore_library_or_what.
Comment 7 Michael Matz 2021-11-30 13:45:44 UTC
LLVM or clang aren't even used in that build, it's clearly not related to the TLS problem.  This seems to be a normal bug in that it doesn't link against the libraries that provide the required symbols.  From the build log:

% /usr/bin/c++ -fPIC -O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -DNDEBUG -std=c++11 -DBUILDING_DLL=1 -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,ssh2-api-1.1.qmod -o ssh2-api-1.1.qmod CMakeFiles/ssh2.dir/src/SFTPClient.cpp.o CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o CMakeFiles/ssh2.dir/src/SSH2Client.cpp.o CMakeFiles/ssh2.dir/src/ssh2-module.cpp.o CMakeFiles/ssh2.dir/QC_SFTPClient.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Base.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Channel.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Client.cpp.o  -lssh2
...
undefined reference to `QoreSocket::asyncIoWait(int, bool, bool) const'
...

From the name of the missing function (and all the others!) I assume it would be
provided by one of the Qore libraries.  But the link command only links against
-lssh2.  It also links with -Wl,--no-undefined, so it explicitely wants to
be informed about missing functions.

A working link command (from devel:languages:misc openSUSE_Factory/s390x) is:

% /usr/bin/c++ -fPIC -O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -DNDEBUG -std=c++11 -DBUILDING_DLL=1 -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,ssh2-api-0.24.qmod -o ssh2-api-0.24.qmod CMakeFiles/ssh2.dir/src/SFTPClient.cpp.o CMakeFiles/ssh2.dir/src/SSH2Channel.cpp.o CMakeFiles/ssh2.dir/src/SSH2Client.cpp.o CMakeFiles/ssh2.dir/src/ssh2-module.cpp.o CMakeFiles/ssh2.dir/QC_SFTPClient.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Base.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Channel.cpp.o CMakeFiles/ssh2.dir/QC_SSH2Client.cpp.o  -pthread -lqore -lssh2

Note in particular the "-lqore".  It's also not correct that this package
breaks only on s390x.  In devel:languages:misc it clearly breaks
for Tumbleweed i586 and x86_64, with the exact same message as above, and
also fails to list -lqore in the linker command.  In contrast, as said above,
it does work in the openSUSE_Factory/s390x repos, with -lqore in the command.

I have no idea what is supposed to add the missing -lqore to the link command
line, I assume it's some cmake macro or configuration.  That is what you need
to debug: why cmake fails to add -lqore.
Comment 8 Sarah Kriesch 2021-12-02 14:50:36 UTC
Thank you for this explanation.
That is unrelated to the TLS problem. That is the reason, that I did not add that all into the same bug report.

I thought, that it would be also related to the linker plugin problem. The reason is an equal structure with the "undefined reference to" and the hint with "error: ld returned 1 exit status".
Comment 9 Ihno Krumreich 2022-03-01 16:22:18 UTC
Verified.