Search code examples
mysqlgccglibc

Link MySQL with different glibc


I'm trying to link MySQL with a different glibc that provides e.g. a different pthread implementation and actually thought I got it right a few days ago. Obviously, I took notes and wanted to reproduce the outcome but I can't get it to link properly, so I must have forgotten a step.

What I did previously was simply to add the flags pointing to my glibc and the default one second to the cmake command.

GLIBC_FLAGS="-Wl,--rpath=/path/to/my/glibc/build/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/path/to/my/glibc/build/lib/ld-linux-x86-64.so.2

cmake \
    -DCMAKE_INSTALL_PREFIX=../install \
    .. \
    -DCMAKE_C_FLAGS="$GLIBC_FLAGS" \
    -DCMAKE_CXX_FLAGS="$GLIBC_FLAGS"

These flags work when building a simple a test-program but seem not to work with MySQL as ldd reports the default glibc for mysqld.

$ ldd install/bin/mysqld
    linux-vdso.so.1 =>  (0x00007fff14ffe000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f4f1c9bb000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4f1c7b7000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4f1c599000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f4f1c295000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4f1bf91000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4f1bd7a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4f1b9b2000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f4f1cc13000)

I also tried to set the LD_LIBRARY_PATH and changing the linker flags and lib variables in BUILD/scripts/mysql_config but none of these seem to work.

What is necessary to link MySQL against a different glibc?


Solution

  • After a Kernel-Update, cmake apparently ignored the DCMAKE_CXX_FLAGS and DCMAKE_C_FLAGS if they contained a colon-separated list of paths (the options were used when they contained only a single path).

    I worked around this by setting the colon-separated pathlist directly in the CMakeLists.txt in the MySQL root directory.