Failing to build on musl

So I’m trying to (cross-)compile xgboost 1.0.2 on musl, and failing.

Here’s what I did:

mkdir build
cd build

The output of cmake can be seen here

On running make, I get errors like this

[  1%] Building CXX object src/CMakeFiles/objxgboost.dir/c_api/
cd /workspace/srcdir/xgboost/build/src && /opt/bin/x86_64-linux-musl-g++ --sysroot=/opt/x86_64-linux-musl/x86_64-linux-musl/sys-root/ -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_BUILTIN_PREFETCH_PRESENT=1 -DXGBOOST_MM_PREFETCH_PRESENT=1 -D_MWAITXINTRIN_H_INCLUDED -I/workspace/srcdir/xgboost/include -I/workspace/srcdir/xgboost/dmlc-core/include -I/workspace/srcdir/xgboost/rabit/include  -O3 -DNDEBUG -fPIC   -funroll-loops -fopenmp -std=gnu++11 -o CMakeFiles/objxgboost.dir/c_api/ -c /workspace/srcdir/xgboost/src/c_api/
In file included from /workspace/srcdir/xgboost/dmlc-core/include/dmlc/./serializer.h:22,
                 from /workspace/srcdir/xgboost/dmlc-core/include/dmlc/io.h:446,
                 from /workspace/srcdir/xgboost/rabit/include/rabit/internal/utils.h:16,
                 from /workspace/srcdir/xgboost/rabit/include/rabit/serializable.h:11,
                 from /workspace/srcdir/xgboost/rabit/include/rabit/./internal/engine.h:10,
                 from /workspace/srcdir/xgboost/rabit/include/rabit/rabit.h:48,
                 from /workspace/srcdir/xgboost/src/c_api/
/workspace/srcdir/xgboost/dmlc-core/include/dmlc/././endian.h:34:6: error: #error "Unable to determine endianness of your machine; use CMake to compile"
     #error "Unable to determine endianness of your machine; use CMake to compile"
/workspace/srcdir/xgboost/dmlc-core/include/dmlc/./serializer.h: In static member function ‘static void dmlc::serializer
::ArithmeticHandler<T>::Write(dmlc::Stream*, const T&)’: /workspace/srcdir/xgboost/dmlc-core/include/dmlc/././endian.h:39:33: error: ‘DMLC_LITTLE_ENDIAN’ was not declared in this scope

So in trying to troubleshoot this, I find that cmake has created a build/dmlc-core/include/build_config.h with the right incantations. However, I don’t understand how those variables get included in the build. Clearly the compiler hasnt found the DMLC_CMAKE_LITTLE_ENDIAN variable that is defined in the build_config.h file.

I last did something similar on xgboost 0.82, and things seem to have worked then.

Any pointers to how to further debug this?



Can you post the content of build/dmlc-core/include/build_config.h? The DMLC_CMAKE_LITTLE_ENDIAN variable should be defined there. The header is included in include/dmlc-core/base.h.

Another way you can do is to use Docker to compile XGBoost. I’ve had success with this approach in the past.

The header is included in include/dmlc-core/base.h .

Thanks that is very helpful, it made me dig in further. The actual error here (about ENDIAN) turned out to be a bit of red herring. I now have a standard way to replicate this, and hence have created a github issue about this problem.