Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 775845

Summary: dev-db/mysql-connector-c: When LLD is installed package fails to link
Product: Gentoo Linux Reporter: Matthew Dawson <matthew>
Component: Current packagesAssignee: Gentoo Linux MySQL bugs team <mysql-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: ionen, jnerin, sam
Priority: Normal    
Version: unspecified   
Hardware: x86   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=710272
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 331933, 731004    

Description Matthew Dawson 2021-03-13 19:05:49 UTC
If sys-devel/lld is installed, mysql-connector-c will by default attempt to link using it.  When using a recent GCC (tested on both GCC 9 and 10 at least), this fails to link due to a relocation lld does not support (build failures below).

Turning off the USE_LD_LLD flag in cmake fixes the build.  This does not appear to affect the AMD64 build (this was seen during a cross compile for the x86 ABI).

This issue occurs on at least version 8.0.22 and 8.0.23.

[183/230] : && /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -pipe -mstackrealign -O3 -march=native -ggdb3 -fno-omit-frame-pointer -Wall -Wextra -Wformat-security -Wvla -Wundef -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=2 -Wstringop-truncation -Wsuggest-override -Wlogical-op -DDBUG_OFF -DNDEBUG  -fuse-ld=lld -Wl,-O1 -Wl,--as-needed utilities/CMakeFiles/comp_err.dir/comp_err.cc.o -o runtime_output_directory/comp_err  -lpthread  archive_output_directory/libmysys.a  archive_output_directory/libstrings.a  archive_output_directory/libmysys.a  archive_output_directory/libstrings.a  archive_output_directory/libmytime.a  /usr/lib/libz.so  /usr/lib/libzstd.so  -lm  -lrt  /usr/lib/libssl.so  /usr/lib/libcrypto.so  -ldl  -lpthread && :
FAILED: runtime_output_directory/comp_err 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -pipe -mstackrealign -O3 -march=native -ggdb3 -fno-omit-frame-pointer -Wall -Wextra -Wformat-security -Wvla -Wundef -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=2 -Wstringop-truncation -Wsuggest-override -Wlogical-op -DDBUG_OFF -DNDEBUG  -fuse-ld=lld -Wl,-O1 -Wl,--as-needed utilities/CMakeFiles/comp_err.dir/comp_err.cc.o -o runtime_output_directory/comp_err  -lpthread  archive_output_directory/libmysys.a  archive_output_directory/libstrings.a  archive_output_directory/libmysys.a  archive_output_directory/libstrings.a  archive_output_directory/libmytime.a  /usr/lib/libz.so  /usr/lib/libzstd.so  -lm  -lrt  /usr/lib/libssl.so  /usr/lib/libcrypto.so  -ldl  -lpthread && :
ld.lld: error: my_default.cc:(.debug_info+0xC0FD0): has non-ABS relocation R_386_GOTOFF against symbol 'default_paths'
ld.lld: error: ctype-uca.cc:(.debug_info+0x191E03): has non-ABS relocation R_386_GOTOFF against symbol '.LC4'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Comment 1 Ionen Wolkens gentoo-dev 2021-03-14 08:28:06 UTC
The failure happens because you also have -ggdb3, otherwise lld works on x86 (either native or abi_x86_32).

But the added -fuse-ld=lld not respecting users' settings is its own issue. It seems to be a default as long as LTO is not enabled.
Comment 2 Matthew Dawson 2021-03-20 18:13:08 UTC
(In reply to Ionen Wolkens from comment #1)
> The failure happens because you also have -ggdb3, otherwise lld works on x86
> (either native or abi_x86_32).
True, though I don't think that option should break packages normally?  Also in case anyone else stumbles on this bug, this occurred when I tested just -g.

> 
> But the added -fuse-ld=lld not respecting users' settings is its own issue.
> It seems to be a default as long as LTO is not enabled.
What would be the best way to fix this issue then?  Would it make sense to have a use flag like "lld" that enables/disables this option, along with an appropriate dependency?  The CMake file already has the necessary bits, and I could try to make a patch for the ebuild if that's the case.
Comment 3 Thomas Deutschmann (RETIRED) gentoo-dev 2021-03-23 10:36:47 UTC

*** This bug has been marked as a duplicate of bug 710272 ***
Comment 4 Larry the Git Cow gentoo-dev 2023-12-18 06:57:33 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a8da48ae6ee2878605bd985a9be773a095c03203

commit a8da48ae6ee2878605bd985a9be773a095c03203
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-12-18 06:56:05 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-12-18 06:56:05 +0000

    dev-db/mysql-connector-c: fix automagic LLD usage
    
    The build system automagically uses LLD (via -fuse-ld=lld) when gcc + no LTO.
    
    Fix that.
    
    Closes: https://bugs.gentoo.org/710272
    Closes: https://bugs.gentoo.org/775845
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-db/mysql-connector-c/mysql-connector-c-8.0.32-r1.ebuild | 2 ++
 1 file changed, 2 insertions(+)