Building MariaDB with musl: /usr/bin/ld cannot find -lgcc_s

左心房为你撑大大i 提交于 2020-12-13 17:55:53

问题


I am trying to build MariaDB v10.3 with a musl tool chain on x86_64 Debian kernel v4.19. I have mainly been using the musl-gcc gcc wrapper to achieve this. The relevant packages I installed are as follows:

  • musl (1.1.21-2): standard C library
  • musl-dev (1.1.21-2): standard C library development files
  • musl-tools (1.1.21-2): standard C library tools

To build MariaDB, I first run:

CC=/usr/bin/musl-gcc cmake ../ -DWITHOUT_TOKUDB=1

which exits cleanly, and then I follow that up with:

make CC=/usr/bin/musl-gcc

which error with the following message:

Scanning dependencies of target strings-t
[ 12%] Building C object unittest/strings/CMakeFiles/strings-t.dir/strings-t.c.o
[ 12%] Linking CXX executable strings-t
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make[2]: *** [unittest/strings/CMakeFiles/strings-t.dir/build.make:94: unittest/strings/strings-t] Error 1
make[1]: *** [CMakeFiles/Makefile2:731: unittest/strings/CMakeFiles/strings-t.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Now I know the library that musl is looking for (libgcc_s.so) is located in /lib/gcc/x86_64-linux-gnu/8/ but my attempts to include the library using LDFLAGS or symlinking the library into /usr/lib/x86_64-linux-musl/ have failed.

Am I going about compiling MariaDB the right way? I imagine I am doing something wrong as Alpine Linux can run it.


回答1:


Thus why don't looking how alpine is building it ?

https://git.alpinelinux.org/aports/tree/main/mariadb/APKBUILD?id=3ca8e70b047f37a01df42e3244014a6635893abc

seems they disable test -DSKIP_TESTS=ON ref: https://git.alpinelinux.org/aports/tree/main/mariadb/APKBUILD?id=3ca8e70b047f37a01df42e3244014a6635893abc#n186

And their ppc-glibc patch ? https://git.alpinelinux.org/aports/tree/main/mariadb/ppc-remove-glibc-dep.patch?id=3ca8e70b047f37a01df42e3244014a6635893abc




回答2:


I will update this answer when I become completely successful, but the solution thus far has been to use musl-cross-make to compile all libraries and such to specifically target musl. Since getting musl-cross-make I have been building all the dependencies from scratch (which is not fun :)). Thus far, I have gotten a more-or-less successful configuration and I am working on compilation (hammering out the last few dependencies).

I am using the following script to build things:

#!/bin/bash

set -euo pipefail

# musl paths
MUSL_PREFIX='/usr/local/x86_64-linux-musl'
MUSL_INC="$MUSL_PREFIX/include"
MUSL_LIB="$MUSL_PREFIX/lib"
CC='/usr/local/bin/x86_64-linux-musl-gcc'
CXX='/usr/local/bin/x86_64-linux-musl-g++'

    #
    # CMake couldn't locate lz4 when I installed it manually, so we bundle
    # it in with the MariaDB build
    #
    wget https://github.com/lz4/lz4/archive/v1.7.5.tar.gz
    tar -xzf v1.7.5.tar.gz
    rm v1.7.5.tar.gz
    mv lz4-1.7.5 /home/ajg/mariadb/storage/mroonga/vendor/groonga/vendor/

    # Configure the build
    CC="$CC"                        \
    CXX="$CXX"                      \
    LDFLAGS="-L$MUSL_LIB -Wl,-rpath,$MUSL_LIB"      \
    CFLAGS="-I$MUSL_INC"                    \
    CXXFLAGS="-I$MUSL_INC"                  \
    CPPFLAGS="-I$MUSL_INC"                  \
    CMAKE_PREFIX_PATH="$MUSL_PREFIX"            \
    cmake . -DWITHOUT_TOKUDB=1 -DGRN_WITH_BUNDLED_LZ4=ON

    # Make it
    make                            \
    CC="$CC"                        \
    CXX="$CXX"                      \
    LDFLAGS="-L$MUSL_LIB -Wl,-rpath,$MUSL_LIB"      \
    CFLAGS="-I$MUSL_INC"                    \
    CXXFLAGS="-I$MUSL_INC"                  \
    CPPFLAGS="-I$MUSL_INC"

I hope this helps someone else out in the future :)



来源:https://stackoverflow.com/questions/64217764/building-mariadb-with-musl-usr-bin-ld-cannot-find-lgcc-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!