Subject: MariaDB failed to link 'libgcc_s.so' with our ld-wrapper.

From: 宋文武 <[email-masked]>
Date: Fri, 17 Apr 2015 22:57:20 +0800

In my patch for mariadb, I have to set LDFLAGS to '-lgcc_s':
  https://lists.gnu.org/archive/html/guix-devel/2015-04/msg00321.html

without this, binaries are built linked with libstdc++.so, but
have a not found entry for libgcc_s.so, eg:
  $ ldd ./build/sql/gen_lex_hash
        linux-vdso.so.1 (0x00007ffcfbfea000)
        libpthread.so.0 => /gnu/store/wiqbxcvzj3r35hd55yxzz919b1dv1hnv-glibc-2.21/lib/libpthread.so.0 (0x00007ff62a182000)
        libstdc++.so.6 => /gnu/store/h132igxl2lkj3sbfcbknn2rd493j7d1l-gcc-4.8.4-lib/lib/gcc/x86_64-unknown-linux-gnu/4.8.4/../../../libstdc++.so.6 (0x00007ff629e80000)
        libm.so.6 => /gnu/store/wiqbxcvzj3r35hd55yxzz919b1dv1hnv-glibc-2.21/lib/libm.so.6 (0x00007ff629b7e000)
        libc.so.6 => /gnu/store/wiqbxcvzj3r35hd55yxzz919b1dv1hnv-glibc-2.21/lib/libc.so.6 (0x00007ff6297de000)
        /gnu/store/wiqbxcvzj3r35hd55yxzz919b1dv1hnv-glibc-2.21/lib/ld-linux-x86-64.so.2 (0x00007ff62a39f000)
        libgcc_s.so.1 => not found

The link script (sql/CMakeFiles/gen_lex_hash.dir/link.txt) contains:
--------------------------------------------------------------------
  /gnu/store/4sqgnc9bc1kmn058yp4xnj4vpydmfzpq-gcc-4.8.4/bin/c++    -fno-exceptions -fno-rtti -O3 -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized -DDBUG_OFF   CMakeFiles/gen_lex_hash.dir/gen_lex_hash.cc.o  -o gen_lex_hash  -lpthread
--------------------------------------------------------------------

And the build script (sql/CMakefils/gen_lex_hash.dir/flags.make):
-----------------------------------------------------------------
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.1

# compile CXX with /gnu/store/4sqgnc9bc1kmn058yp4xnj4vpydmfzpq-gcc-4.8.4/bin/c++
CXX_FLAGS =  -fno-exceptions -fno-rtti -O3 -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized -DDBUG_OFF -I/var/tmp/nix-build-mariadb-10.0.17.drv-0/build/include -I/var/tmp/nix-build-mariadb-10.0.17.drv-0/mariadb-10.0.17/include -I/var/tmp/nix-build-mariadb-10.0.17.drv-0/mariadb-10.0.17/sql -I/var/tmp/nix-build-mariadb-10.0.17.drv-0/mariadb-10.0.17/zlib -I/var/tmp/nix-build-mariadb-10.0.17.drv-0/mariadb-10.0.17/extra/yassl/include -I/var/tmp/nix-build-mariadb-10.0.17.drv-0/mariadb-10.0.17/extra/yassl/taocrypt/include -I/var/tmp/nix-build-mariadb-10.0.17.drv-0/build/sql    -DHAVE_YASSL -DYASSL_PREFIX -DHAVE_OPENSSL -DMULTI_THREADED

CXX_DEFINES = -DHAVE_CONFIG_H -DHAVE_EVENT_SCHEDULER -DHAVE_POOL_OF_THREADS -DMYSQL_SERVER
------------------------------------------------------------------

As Ludovic Courtès tell,  '-static-libgcc' may be the issue.