Bug #111607 Contribution: Fix linkage of \'gen_keyword_list\' executable
Submitted: 28 Jun 2023 14:26 Modified: 10 Jul 2023 11:46
Reporter: OCA Admin (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[28 Jun 2023 14:26] OCA Admin
Description:
This bug tracks a contribution by Daniel Lenski (Github user: dlenski) as described in http://github.com/mysql/mysql-server/pull/460

How to repeat:
See description

Suggested fix:
See contribution code attached
[28 Jun 2023 14:26] OCA Admin
Contribution submitted via Github - Fix linkage of 'gen_keyword_list' executable 
(*) Contribution by Daniel Lenski (Github dlenski, mysql-server/pull/460#issuecomment-1595089285): This contribution is under the OCA signed by Amazon and covering submissions to the MySQL project.

Contribution: git_patch_1329341641.txt (text/plain), 1.80 KiB.

[10 Jul 2023 11:46] MySQL Verification Team
Hello Daniel,

Thank you for the report and contribution.

regards,
Umesh
[11 Jul 2023 6:14] Tor Didriksen
Posted by developer:
 
Hi, and thanks for the bug report. On what platform did you get a linker failure?
I believe the correct patch would be:

--- a/cmake/icu.cmake
+++ b/cmake/icu.cmake
@@ -156,6 +156,7 @@ FUNCTION(MYSQL_USE_BUNDLED_ICU)
 
   ADD_LIBRARY(icu_interface INTERFACE)
   TARGET_LINK_LIBRARIES(icu_interface INTERFACE ${ICU_LIBRARIES})
+  TARGET_LINK_LIBRARIES(icu_interface ${CMAKE_DL_LIBS})
   TARGET_INCLUDE_DIRECTORIES(icu_interface SYSTEM BEFORE INTERFACE
     ${ICU_INCLUDE_DIRS})

actually, we link with this already:
extra/icu/CMakeLists.txt:TARGET_LINK_LIBRARIES(icuuc PRIVATE ${CMAKE_DL_LIBS})

So no patch should be necessary?
[11 Jul 2023 16:40] Daniel Lenski
@Tor Didriksen, I've encountered this build issue both on Amazon Linux 2 as well as on Ubuntu 20.04.
[12 Jul 2023 8:57] Tor Didriksen
Posted by developer:
 

cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Compiler is gcc 9.4.0

git checkout mysql-8.0.33-release
mkdir bin-dbg
cd bin-dbg/
cmake .. -DWITH_DEBUG=1
make -j10 gen_keyword_list
rm bin/gen_keyword_list 
make VERBOSE=1 gen_keyword_list

/usr/bin/c++  -std=c++17 -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=5 -Wstringop-truncation -Wsuggest-override -Wmissing-include-dirs -Wextra-semi -Wlogical-op -Werror -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g   -fuse-ld=lld  -Wl,--build-id=sha1 CMakeFiles/gen_keyword_list.dir/gen_keyword_list.cc.o  -o ../runtime_output_directory/gen_keyword_list  -lpthread ../extra/icu/libicui18n.a ../extra/icu/libicuuc.a -ldl ../extra/icu/libicustubdata.a -lpthread 

ldd bin/gen_keyword_list 
        linux-vdso.so.1 (0x00007ffd240b6000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f894deb5000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f894deaf000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f894dccd000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f894db7e000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f894db63000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f894d971000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f894e08d000)

Same thing for RelWithDebInfo build, configuring with simply 'cmake ..'
/usr/bin/c++  -std=c++17 -fno-omit-frame-pointer -ftls-model=initial-exec -g -O2 -fdebug-prefix-map=/export/home/tmp/gitclone/mysql-trunk/bin-opt=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=5 -Wstringop-truncation -Wsuggest-override -Wmissing-include-dirs -Wextra-semi -Wlogical-op -ffunction-sections -fdata-sections -O2 -g -DNDEBUG -g1  -Wl,-Bsymbolic-functions -Wl,-z,relro -fuse-ld=lld  -Wl,--build-id=sha1 CMakeFiles/gen_keyword_list.dir/gen_keyword_list.cc.o  -o ../runtime_output_directory/gen_keyword_list  -lpthread ../extra/icu/libicui18n.a ../extra/icu/libicuuc.a -ldl ../extra/icu/libicustubdata.a -lpthread 

For both builds we see 'ldl' right after libicuuc.a

What is your full cmake command line? 
And what does 'make VERBOSE=1 gen_keyword_list' show?
[12 Jul 2023 9:03] Tor Didriksen
Posted by developer:
 
For "system" ICU:
cmake .. -DWITH_DEBUG=1 -DWITH_ICU=system
we do not link with -ldl, but we get the dependency anyhow:
ldd bin/gen_keyword_list 
        linux-vdso.so.1 (0x00007ffd1a791000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f105151f000)
        libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f1051339000)
        libicui18n.so.66 => /lib/x86_64-linux-gnu/libicui18n.so.66 (0x00007f105103a000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1050e58000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1050e3d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1050c4b000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1051571000)
        libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f104f188000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f104f182000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f104f033000)

because the system libicui18n.so.66 pulls it in for us
ldd /lib/x86_64-linux-gnu/libicui18n.so.66
        linux-vdso.so.1 (0x00007fff5f54a000)
        libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f16d6c50000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f16d6a6e000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f16d691f000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f16d6904000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f16d6712000)
        libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f16d4c51000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f16d4c2c000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f16d4c26000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f16d714b000)