Compiling error (conflicting types) (Alpine Linux)

Dear experts,

I am trying to compile a minimal ROOT (v6.12.06) on Alpine Linux, but I am having some real difficulty doing so.

I am compiling with cmake --build . --target install -- -j4

The error is immediately below. Below that I’ve also added the cmake output and the cmake flags I am using, in case that is of any help. BTW do I really need Python just to compile ROOT? CMake yes says but I cannot believe it.

/var/tmp/root-6.12.06/core/clib/src/mmapsup.c:47:15: error: conflicting types for 'getpagesize'
 extern size_t getpagesize PARAMS ((void));
In file included from /usr/include/fortify/unistd.h:20:0,
                 from /var/tmp/root-6.12.06/core/clib/res/mmprivate.h:56,
                 from /var/tmp/root-6.12.06/core/clib/src/mmapsup.c:26:
/usr/include/unistd.h:164:5: note: previous declaration of 'getpagesize' was here
 int getpagesize(void);
make[2]: *** [core/clib/CMakeFiles/Clib.dir/build.make:255: core/clib/CMakeFiles/Clib.dir/src/mmapsup.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....

Cmake output:

-- The C compiler identification is GNU 6.4.0
-- The CXX compiler identification is GNU 6.4.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GCC. Major version 6, minor version 4
-- Performing Test HAS_CXX11
-- Performing Test HAS_CXX11 - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found a 64bit system
-- Found GNU compiler collection
-- Performing Test GLIBCXX_USE_CXX11_ABI
-- Performing Test GLIBCXX_USE_CXX11_ABI - Success
-- ROOT Platform: linux
-- ROOT Architecture: linuxx8664gcc
-- Build Type: RelWithDebInfo
-- Compiler Flags:  -pipe -m64  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -fPIC -pthread -std=c++11 -O2 -g -DNDEBUG
-- Looking for ZLib
-- Zlib not found. Switching on builtin_zlib option
-- Building zlib included in ROOT itself
-- Looking for Unuran
-- Unuran not found. Switching on builtin_unuran option
-- Looking for Freetype
-- FreeType not found. Switching on builtin_freetype option
-- Building freetype version 2.6.1 included in ROOT itself
-- Looking for PCRE
-- PCRE not found. Switching on builtin_pcre option
-- Building pcre version 8.37 included in ROOT itself
-- Looking for LZMA
-- LZMA not found. Switching on builtin_lzma option
-- Building LZMA version 5.2.1 included in ROOT itself
-- Looking for LZ4
-- LZ4 not found. Switching on builtin_lz4 option
-- Building LZ4 version v1.7.5 included in ROOT itself
-- Looking for gl2ps
-- Could NOT find GL2PS (missing: GL2PS_LIBRARY GL2PS_INCLUDE_DIR) 
-- gl2ps not found. Switching on builtin_gl2ps option
-- Enabled support for:  builtin_freetype builtin_ftgl builtin_gl2ps builtin_llvm builtin_lzma builtin_lz4 builtin_pcre builtin_unuran builtin_zlib cling cxx11 explicitlink thread
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/gcc
-- Found ZLIB: /var/tmp/root-build/lib/libZLIB.a  
-- Looking for backtrace
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR) 
-- Native target architecture is X86
-- Threads disabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- OCaml bindings disabled.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Building with -fPIC
-- Found PythonInterp: /usr/bin/python2.7 (found version "2.7.14") 
-- Constructing LLVMBuild project information
-- Linker detection: GNU ld
-- Targeting X86
-- Could NOT find Z3 (missing: Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at least version "4.5")
-- Clang version: 5.0.0
-- Cling version (from VERSION file): ROOT_0.6~dev
-- Cling will look for C++ headers in '/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../include/c++/6.4.0:/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../include/c++/6.4.0/x86_64-alpine-linux-musl:/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../include/c++/6.4.0/backward' at runtime.
-- And if not found, will invoke: 'g++' for them.
-- Performing Test CXX_HAS_Wno_maybe_uninitialized
-- Performing Test CXX_HAS_Wno_maybe_uninitialized - Success
-- Performing Test CXX_HAS_fno_rtti
-- Performing Test CXX_HAS_fno_rtti - Success
-- Performing Test C_HAS_Wno_strict_overflow
-- Performing Test C_HAS_Wno_strict_overflow - Success
-- Performing Test C_HAS_Wno_maybe_uninitialized
-- Performing Test C_HAS_Wno_maybe_uninitialized - Success
-- Performing Test C_HAS_Wno_parentheses_equality
-- Performing Test C_HAS_Wno_parentheses_equality - Success
-- Performing Test found_setresuid
-- Performing Test found_setresuid - Success
-- Performing Test found_stdstringview
-- Performing Test found_stdstringview - Failed
-- Performing Test found_stdexpstringview
-- Performing Test found_stdexpstringview - Failed
-- Performing Test found_stdapply
-- Performing Test found_stdapply - Failed
-- Performing Test found_stdinvoke
-- Performing Test found_stdinvoke - Failed
-- Performing Test found_attribute_always_inline
-- Performing Test found_attribute_always_inline - Success
Running /var/tmp/root-6.12.06/build/unix/
Making /var/tmp/root-build/include/compiledata.h
-- Configuring done
-- Generating done
-- Build files have been written to: /var/tmp/root-build

The cmake flags I am using:

    -Dfail-on-missing=ON \
    -Dminimal=ON \
    -Dtmva=OFF \
    -Dmathmore=OFF \
    -Dpython=OFF \
    -Dopengl=OFF \
    -Droofit=OFF \
    -Dxml=OFF \
    -Dssl=OFF \
    -Dcastor=OFF \
    -Dmysql=OFF \
    -Doracle=OFF \
    -Dpgsql=OFF \
    -Dsqlite=OFF \
    -Dpythia6=OFF \
    -Dpythia8=OFF \
    -Dfftw3=OFF \
    -Dxrootd=OFF \
    -Dgfal=OFF \
    -Ddavix=OFF \
    -Dfitsio=OFF \

Thank you for any insight.

I think the problem potentially stems from the fact that Alpine does not use glibc, but instead musl libc (a nice pun name). Perhaps ROOT supports C standard libraries besides glibc on linux (I do not know), but it clearly does not support musl libc.

I base this on the fact that I also see this error whilst compiling:

/var/tmp/root-6.12.06/core/unix/src/TUnixSystem.cxx:218:25: fatal error: fpu_control.h: No such file or directory
 #include <fpu_control.h>
compilation terminated.
make[2]: *** [core/unix/CMakeFiles/Unix.dir/build.make:63: core/unix/CMakeFiles/Unix.dir/src/TUnixSystem.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:17255: core/unix/CMakeFiles/Unix.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

The fpu_control.h is a header in glibc which is not found in musl libc. This suggests I cannot compile ROOT on Alpine Linux without some changes within ROOT itself. My new dream is to cross compile for Alpine Linux from a glibc distro.

I am not aware of any Alpine Linux support.

From the first error, it looks like mmapsup.c forward declares getpagesize with the wrong return type. This can be easily fixed. The second error, seems coming from the fpu_control.h and it looks like we do not use the contents of it. We can likely remove this #include.

If you succeed in compiling ROOT on the platform I’d like to follow up and put the patch in ROOT’s master.

I will keep trying, but having attempted to compile all translation units, I have found there are errors in addition to the one I showed above. From what I can tell, all pertain to C standard library support.

Yes, all ROOT builds on Linux use glibc (or the system libc, e.g. on macOS). I’m not sure there is demand to support musl libc, uclibc, etc, but given that experiments are trying to use ROOT in embedded environments, sooner or later we might have to support the alternative libraries too. I’m not sure how much we can help at the moment with this, but if you file detailed bug reports for each failure you see, we will fix them when the time allows. Of course, patches are welcome too!

Yes, after having looked at the code I think making ROOT more portable would be a bit of work. I originally wanted to compile on Alpine because I am writing a Docker image for an app in which ROOT is a dependency, and obviously ROOT is very large, so I was hoping to save space elsewhere by using a tiny base image (FWIW I have since settled on debian:stretch-slim).

I had hoped to write a quick patch to get it to compile, but there are a couple of difficulties that I came across:

  • There is no __MUSL__ macro (for good reason I am told) so the familiar #ifdef __GLIBC__ pattern is not adaptable. Instead I think ROOT must test the standard library for functionality/features before compiling. I think to some extent it already does this based on the cmake output, but not to a sufficient degree.

  • LLVM. I do not know much, but based on this: where it is said that LLVM assumes glibc. I have not looked into the LLVM bundled with ROOT, but I assume it is the same there. Perhaps the solution then is to build LLVM separately. I assume the presence of the builtin_llvm build flag suggests one can use an external LLVM? I could definitely be wrong on this though.

Anyway I may look at this more in the future for a “fun” little project but for now I will leave it there.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.