[llvm-dev] LLVM compilation problem with musl

Dmitry Golovin via llvm-dev
Sun, 04 Jun 2017 19:54:45 -0000

I'm trying to compile LLVM with musl libc library. The compilation process
fails on the following:

    x86_64-linux-musl-g++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Ilib/Support -I../lib/Support -Iinclude -I../include -fPIC
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W
-Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -fno-rtti -MD
-MT lib/Support/CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o -MF
lib/Support/CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o.d -o
lib/Support/CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o -c
../lib/Support/DynamicLibrary.cpp
    In file included from ../lib/Support/DynamicLibrary.cpp:111:0:
    ../lib/Support/Unix/DynamicLibrary.inc: In function ‘void* DoSearch(const
char*)’:
    ../lib/Support/Unix/DynamicLibrary.inc:102:42: error: invalid conversion
from ‘const void*’ to ‘void*’ [-fpermissive]
        if (!strcmp(SymbolName, #SYM)) return &SYM
                                              ^
    ../lib/Support/Unix/DynamicLibrary.inc:109:5: note: in expansion of macro
‘EXPLICIT_SYMBOL’
         EXPLICIT_SYMBOL(stderr);
         ^~~~~~~~~~~~~~~
    ../lib/Support/Unix/DynamicLibrary.inc:102:42: error: invalid conversion
from ‘const void*’ to ‘void*’ [-fpermissive]
        if (!strcmp(SymbolName, #SYM)) return &SYM
                                              ^
    ../lib/Support/Unix/DynamicLibrary.inc:110:5: note: in expansion of macro
‘EXPLICIT_SYMBOL’
         EXPLICIT_SYMBOL(stdout);
         ^~~~~~~~~~~~~~~
    ../lib/Support/Unix/DynamicLibrary.inc:102:42: error: invalid conversion
from ‘const void*’ to ‘void*’ [-fpermissive]
        if (!strcmp(SymbolName, #SYM)) return &SYM
                                              ^
    ../lib/Support/Unix/DynamicLibrary.inc:111:5: note: in expansion of macro
‘EXPLICIT_SYMBOL’
         EXPLICIT_SYMBOL(stdin);
         ^~~~~~~~~~~~~~~

Have anyone had similar problem? Maybe someone had already successfully compiled
LLVM with musl?

All musl-based distros (like Alpine, sabotage, void-musl) should be affected. I
think that Rust team had similar problem
(https://github.com/rust-lang/rust/issues/28667) and they came up with some kind
of workaround for it.

Regards,
Dmitry