Bug #110216 failed to compile in static mode
Submitted: 27 Feb 2023 6:04 Modified: 3 Mar 2023 22:49
Reporter: alex xing (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.32 OS:Debian
Assigned to: CPU Architecture:Any
Tags: Contribution

[27 Feb 2023 6:04] alex xing
Description:
debian 8
gcc (GCC) 8.5.0
g++ (GCC) 8.5.0
cmake version 3.9.6

export LD_LIBRARY_PATH=/home/xingying01/data/mpc-0.8.1/lib:/home/xingying01/data/gmp-4.3.2/lib:/home/xingying01/data/mpfr-2.4.2/lib:/home/xingying01/data/gcc_upgrade/gcc-8.5.0/lib64:$LD_LIBRARY_PATH
export PATH=/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin:$PATH
export CC="/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/gcc -static-libgcc"
export CXX="/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/g++  -static-libstdc++"

/home/xingying01/data/gcc_upgrade/cmake-3.9.6/bin/cmake .. -DCMAKE_C_COMPILER=/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/gcc -DCMAKE_CXX_COMPILER=/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/g++ -DCMAKE_BUILD_TYPE=RelWithDebInfo  -DWITH_BOOST=../boost/boost_1_77_0  -DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" -DWITH_EMBEDDED_SERVER=0 -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-static-libgcc"

How to repeat:
error log:
Segmentation fault (core dumped)
plugin/x/protocol/protobuf/CMakeFiles/mysqlxmessages_lite.dir/build.make:94: recipe for target 'plugin/x/generated/protobuf_lite/mysqlx_expect.pb.cc' failed
make[2]: *** [plugin/x/generated/protobuf_lite/mysqlx_expect.pb.cc] Error 139
make[2]: *** Waiting for unfinished jobs....
[ 61%] Running C++ protobuf compiler on /home/xingying01/data/innosql-8.0.32/plugin/x/protocol/protobuf/mysqlx_session.proto
Segmentation fault
plugin/x/protocol/protobuf/CMakeFiles/mysqlxmessages.dir/build.make:150: recipe for target 'plugin/x/generated/protobuf/mysqlx_sql.pb.cc' failed
make[2]: *** [plugin/x/generated/protobuf/mysqlx_sql.pb.cc] Error 139
make[2]: *** Waiting for unfinished jobs....
Segmentation fault (core dumped)
plugin/group_replication/protobuf/CMakeFiles/gr_protobuf_lite.dir/build.make:62: recipe for target 'plugin/group_replication/generated/protobuf_lite/replication_group_member_actions.pb.cc' failed
make[2]: *** [plugin/group_replication/generated/protobuf_lite/replication_group_member_actions.pb.cc] Error 139
CMakeFiles/Makefile2:9275: recipe for target 'plugin/group_replication/protobuf/CMakeFiles/gr_protobuf_lite.dir/all' failed
make[1]: *** [plugin/group_replication/protobuf/CMakeFiles/gr_protobuf_lite.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Segmentation fault
plugin/x/protocol/protobuf/CMakeFiles/mysqlxmessages.dir/build.make:110: recipe for target 'plugin/x/generated/protobuf/mysqlx_notice.pb.cc' failed
make[2]: *** [plugin/x/generated/protobuf/mysqlx_notice.pb.cc] Error 139

Suggested fix:
compile just like:
export LD_LIBRARY_PATH=/home/xingying01/data/mpc-0.8.1/lib:/home/xingying01/data/gmp-4.3.2/lib:/home/xingying01/data/mpfr-2.4.2/lib:/home/xingying01/data/gcc_upgrade/gcc-8.5.0/lib64:$LD_LIBRARY_PATH
export PATH=/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin:$PATH
export CC="/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/gcc -static-libgcc"
export CXX="/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/g++  -static-libstdc++"

/home/xingying01/data/gcc_upgrade/cmake-3.9.6/bin/cmake .. -DCMAKE_C_COMPILER=/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/gcc -DCMAKE_CXX_COMPILER=/home/xingying01/data/gcc_upgrade/gcc-8.5.0/bin/g++ -DCMAKE_BUILD_TYPE=RelWithDebInfo  -DWITH_BOOST=../boost/boost_1_77_0  -DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" -DWITH_EMBEDDED_SERVER=0 -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-static-libgcc"
[27 Feb 2023 6:07] alex xing
a simple patch to solve this problem

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: static_compile.patch (text/plain), 643 bytes.

[27 Feb 2023 6:47] MySQL Verification Team
Hello Alex Xing,

Thank you for the report and contribution.

regards,
umesh
[3 Mar 2023 22:49] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Server 8.0.33 release, and here's the proposed changelog entry from the documentation team:

Building with -static-libgcc -static-libstdc++ now also builds the
bundled protobuf with static libraries, as required.

Thank you for the bug report.
[21 Apr 2023 9:01] Frederic Descamps
Thank you for your contribution that is now part of 8.0.33