dslm4515 / CMLFS

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

TO-DO: Libc++'s __config_site misplaced #72

Closed dslm4515 closed 1 year ago

dslm4515 commented 1 year ago

Looks like CMake fails to build due too misplaced __config_site header for libc++.

It is at:

/cgnutools/include/x86_64-pc-linux-musl/c++/v1/

But shold be here with __config

/cgnutools/include/c++/v1/

For a work around, just use links:

ln -sv ../../x86_64-pc-linux-musl/c++/v1/__config_site /cgnutools/include/c++/v1/__config_site
ln -sv ../../x86_64-pc-linux-musl/c++/v1/module.modulemap cgnutools/include/c++/v1/module.modulemap
dslm4515 commented 1 year ago

CMake still wont compile. Will try building it under chroot.

dslm4515 commented 1 year ago

Nope. Stage 1 clang has "no C++11 support"

dslm4515 commented 1 year ago

CMake still wont compile

As of commit 1d4aefb61d39071abd8089440cbf54c0b593adb9 , CMake can bootstrap and configure but fails to build:

[ 91%] Building CXX object Source/CursesDialog/CMakeFiles/ccmake.dir/ccmake.cxx.o
In file included from /mnt/cmlfs/sources/cmake-3.25.1/Source/CursesDialog/ccmake.cxx:8:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/iostream:41:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/ios:221:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__locale:18:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/memory:841:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__algorithm/copy.h:12:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__algorithm/unwrap_iter.h:13:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__iterator/iterator_traits.h:14:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__iterator/incrementable_traits.h:15:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/concepts:133:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__concepts/arithmetic.h:15:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/type_traits:421:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__functional/invoke.h:15:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/apply_cv.h:16:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/remove_reference.h:13:
/cgnutools/include/x86_64-pc-linux-musl/c++/v1/cstddef:50:9: error: no member named 'nullptr_t' in the global namespace
using ::nullptr_t;
      ~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
make[2]: *** [Source/CursesDialog/CMakeFiles/ccmake.dir/build.make:76: Source/CursesDialog/CMakeFiles/ccmake.dir/ccmake.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2377: Source/CursesDialog/CMakeFiles/ccmake.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
dslm4515 commented 1 year ago

Looks like C Library implementation [by musl] has nullptr_t defined. Forced the libc++ headers to use musl's stddef.h in place of libc++'s cstddef:

Modified: /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/remove_reference.h

 #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
#define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H

#include <__config>
//#include <cstddef>
#include <stddef.h>

Modified: /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/apply_cv.h

#ifndef _LIBCPP___TYPE_TRAITS_APPLY_CV_H
#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H

#include <__config>
#include <__type_traits/integral_constant.h>
#include <__type_traits/is_const.h>
#include <__type_traits/is_volatile.h>
#include <__type_traits/remove_reference.h>
//#include <cstddef>
#include <stddef.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#  pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
dslm4515 commented 1 year ago

Each time i modify a libc++ header, cmake builds further.... modified these libc++ headers as well: I'll just use a link to replace cstddef with stddef.h

 /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/is_array.h
/cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/remove_extent.h
/cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/is_member_function_pointer.h
dslm4515 commented 1 year ago

Number of headers to modify continues to grow... Perhaps, use a link to replace cstddef with musl's stddef.h ?

ln -sv ../../../stddef.h /cgnutools/include/x86_64-pc-linux-musl/c++/v1/cstddef
dslm4515 commented 1 year ago

Looks like a libc++ header needs musl's stddef.h added:

 /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/is_fundamental.h
dslm4515 commented 1 year ago

New road block:

[  0%] Building CXX object Source/kwsys/CMakeFiles/cmsys.dir/Directory.cxx.o
In file included from /mnt/cmlfs/sources/cmake-3.25.1/Source/kwsys/Directory.cxx:4:
In file included from /mnt/cmlfs/sources/cmake-3.25.1/Source/cmsys/Directory.hxx:7:
In file included from /mnt/cmlfs/sources/cmake-3.25.1/Source/cmsys/Status.hxx:8:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/string:519:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__algorithm/max.h:13:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__algorithm/comp_ref_type.h:13:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__debug:16:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/type_traits:452:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/is_compound.h:14:
In file included from /cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/is_fundamental.h:14:
/cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/is_null_pointer.h:24:49: error: use of undeclared identifier 'nullptr_t'; did you mean 'nullptr'?
template <>          struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
                                                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
make[3]: *** [Source/kwsys/CMakeFiles/cmsys.dir/build.make:174: Source/kwsys/CMakeFiles/cmsys.dir/Directory.cxx.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:1524: Source/kwsys/CMakeFiles/cmsys.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:2384: Source/CursesDialog/CMakeFiles/ccmake.dir/rule] Error 2
make: *** [Makefile:953: ccmake] Error 2
dslm4515 commented 1 year ago

Modified header to use libc++'s cstddef? Since I renamed the real libc++ header as cstddef.orig then made a link of cstddef to point to musl's stddef.h, I added #include <cstddef.orig> to the following libc++ header:

/cgnutools/include/x86_64-pc-linux-musl/c++/v1/__type_traits/is_null_pointer.h

dslm4515 commented 1 year ago

No. Problem just got re-routed:

/cgnutools/include/x86_64-pc-linux-musl/c++/v1/cstddef.orig:50:9: error: no member named 'nullptr_t' in the global namespace
using ::nullptr_t;
      ~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
make[3]: *** [Source/CursesDialog/CMakeFiles/ccmake.dir/build.make:76: Source/CursesDialog/CMakeFiles/ccmake.dir/ccmake.cxx.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:2377: Source/CursesDialog/CMakeFiles/ccmake.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:2384: Source/CursesDialog/CMakeFiles/ccmake.dir/rule] Error 2
make: *** [Makefile:953: ccmake] Error 2
dslm4515 commented 1 year ago

So CMake wont cross compile. BUT compiles fine under chroot!