skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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 :)


Please signup or login to give your own answer.
Back To Top
Search