dslm4515 / CMLFS

Clang-Built Musl Linux From Scratch
MIT License
105 stars 18 forks source link

LLVM11 - libcxx fails to build, linux/futex.h not found #11

Closed dslm4515 closed 3 years ago

dslm4515 commented 3 years ago

[ 2-llvmtools >> 04-libcxx ] Building libcxx under llvm source fails to build:

[187/264] Building CXX object src/CMakeFiles/cxx_static.dir/atomic.cpp.o
FAILED: src/CMakeFiles/cxx_static.dir/atomic.cpp.o 
/cgnutools/bin/x86_64-cmlfs-linux-musl-clang++  -DNDEBUG -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_N
O_PRAGMA_SYSTEM_HEADER -D_LIBCPP_LINK_PTHREAD_LIB -D_LIBCPP_LINK_RT_LIB -Iinclude/c++build -DLIBCXX
_BUILDING_LIBCXXABI -nostdinc++ -fvisibility-inlines-hidden -fvisibility=hidden -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wno-user-defined-literals -Wno-covered-switch-default -Wno-ignored-attributes -Wno-error -I /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1 -include /mnt/cmlfs/sources/llvm/projects/libcxx/build/__config_site -std=c++14 -MD -MT src/CMakeFiles/cxx_static.dir/atomic.cpp.o -MF src/CMakeFiles/cxx_static.dir/atomic.cpp.o.d -o src/CMakeFiles/cxx_static.dir/atomic.cpp.o -c ../src/atomic.cpp
../src/atomic.cpp:21:10: fatal error: 'linux/futex.h' file not found
#include <linux/futex.h>
         ^~~~~~~~~~~~~~~
1 error generated.
[188/264] Building CXX object src/CMakeFiles/cxx_static.dir/barrier.cpp.o
ninja: build stopped: subcommand failed.

Same error if built with make instead of ninja

dslm4515 commented 3 years ago

Prefix the cmake command with CFLAGS="$CFLAGS -I/llvmtools/include" CXXFLAGS="$CXXFLAGS -I/llvmtools/include" and error goes away but another pops up:

[ 69%] Building CXX object src/CMakeFiles/cxx_shared.dir/debug.cpp.o                                                                            
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:                                                                 In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:                                             /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean
 '__signbit'?                                                                                                                                   
using ::signbit;                                                                                                                                
      ~~^~~~~~~                                                                                                                                 
        __signbit                                                                                                                               
/llvmtools/include/math.h:93:5: note: '__signbit' declared here                                                                                 
int __signbit(double);                                                                                                                          
    ^                                                                                                                                           
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:                                                                 In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:                                             /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you m
ean '__fpclassify'?                                                                                                                             
using ::fpclassify;                                                                                                                             
      ~~^~~~~~~~~~                                                                                                                              
        __fpclassify                                                                                                                            
/llvmtools/include/math.h:51:5: note: '__fpclassify' declared here                                                                              
int __fpclassify(double);                                                                                                                       
    ^                                                                                                                                           
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:                                                                 In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace; di[65/1875]n 'finite'?
using ::isfinite;
      ~~^~~~~~~~
        finite
/llvmtools/include/math.h:401:13: note: 'finite' declared here
int         finite(double);
            ^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:327:9: error: no member named 'isgreater' in the global namespace; did you mean '__isgreater'?
using ::isgreater;
      ~~^~~~~~~~~
        __isgreater
/llvmtools/include/math.h:118:1: note: '__isgreater' declared here
__ISREL_DEF(greater, >, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:554:1: note: expanded from here
__isgreater
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:328:9: error: no member named 'isgreaterequal' in the global namespace; did you mean '__isgreaterequal'?
using ::isgreaterequal;
      ~~^~~~~~~~~~~~~~
        __isgreaterequal
/llvmtools/include/math.h:121:1: note: '__isgreaterequal' declared here
__ISREL_DEF(greaterequal, >=, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:557:1: note: expanded from here
__isgreaterequal
^                                                                                                                                      [17/1875]
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace; did you mean '__isless'?
using ::isless;
      ~~^~~~~~
        __isless
/llvmtools/include/math.h:109:1: note: '__isless' declared here
__ISREL_DEF(less, <, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:545:1: note: expanded from here
__isless
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace; did you mean '__islessequal'?
using ::islessequal;
      ~~^~~~~~~~~~~
        __islessequal
/llvmtools/include/math.h:112:1: note: '__islessequal' declared here
__ISREL_DEF(lessequal, <=, double_t) 
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:548:1: note: expanded from here
__islessequal
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace; did you mean '__islessgreater'?
using ::islessgreater;
      ~~^~~~~~~~~~~~~
        __islessgreater
/llvmtools/include/math.h:115:1: note: '__islessgreater' declared here
__ISREL_DEF(lessgreater, !=, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:551:1: note: expanded from here
__islessgreater
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/debug.cpp:15:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/__hash_table:18:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
make[2]: *** [src/CMakeFiles/cxx_shared.dir/build.make:180: src/CMakeFiles/cxx_shared.dir/debug.cpp.o] Error 1
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/projects/libcxx/build'
make[1]: *** [CMakeFiles/Makefile2:408: src/CMakeFiles/cxx_shared.dir/all] Error 2
make[1]: Leaving directory '/mnt/cmlfs/sources/llvm/projects/libcxx/build'
make: *** [Makefile:130: all] Error 2
make: Leaving directory '/mnt/cmlfs/sources/llvm/projects/libcxx/build'
dslm4515 commented 3 years ago

per owl4ce:

Using -isystem instead of -Ifor CXX flags and build successful

cmake -B build  \
      -DCMAKE_INSTALL_PREFIX=/llvmtools \
      -DLLVM_PATH="${LLVMSRC}" \
      -DLIBCXX_ENABLE_SHARED=ON \
      -DLIBCXX_ENABLE_STATIC=ON  \
      -DLIBCXX_HAS_MUSL_LIBC=ON \
      -DLIBCXX_USE_COMPILER_RT=ON \
      -DLIBCXX_CXX_ABI=libcxxabi \
      -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/llvmtools/include" \
      -DLIBCXXABI_USE_LLVM_UNWINDER=ON \
      -DLIBCXX_CXX_ABI_LIBRARY_PATH=/llvmtools/lib \
      -DLIBCXX_INSTALL_HEADERS=ON \
      -DCMAKE_CXX_FLAGS="-isystem /llvmtools/include" \

Removed line

      -DCMAKE_C_FLAGS="-I/llvmtools/include" 

source: https://github.com/dslm4515/CMLFS/issues/9