Issue |
140863
|
Summary |
[libc++] Unable to build libc++ for bare matel target
|
Labels |
libc++
|
Assignees |
|
Reporter |
neko-para
|
I'm targetting i686-elf without c library. I'd like to setup libc++, so that headers like `cstdarg` or `cstddef` can be used.
I'd like to just install the headers without building library, but I cannot find a related option in libcxx/CMakeLists.txt. Or I shall just manually copy these headers?
* build command
```shell
cmake runtimes -B build-runtimes -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx" --toolchain /Users/nekosu/Documents/Projects/njos/i686-elf.cmake -DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC=OFF -DLIBCXX_ENABLE_EXCEPTIONS=OFF -DLIBCXX_ENABLE_RTTI=OFF -DLIBCXX_ENABLE_FILESYSTEM=OFF -DLIBCXX_INCLUDE_TESTS=OFF -DLIBCXX_ENABLE_RANDOM_DEVICE=OFF -DLIBCXX_ENABLE_LOCALIZATION=OFF -DLIBCXX_ENABLE_UNICODE=OFF -DLIBCXX_HAS_TERMINAL_AVAILABLE=OFF -DLIBCXX_ENABLE_WIDE_CHARACTERS=OFF -DLIBCXX_ENABLE_THREADS=OFF -DLIBCXX_ENABLE_MONOTONIC_CLOCK=OFF -DLIBCXX_INSTALL_LIBRARY=OFF -DLLVM_DEFAULT_TARGET_TRIPLE=i686-elf
```
* toolchain file
```cmake
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR x86)
set(TOOL_PREFIX /opt/llvm-20)
set(CMAKE_C_COMPILER_TARGET i686-elf)
set(CMAKE_C_COMPILER ${TOOL_PREFIX}/bin/clang)
set(CMAKE_CXX_COMPILER_TARGET i686-elf)
set(CMAKE_CXX_COMPILER ${TOOL_PREFIX}/bin/clang++)
set(CMAKE_ASM_COMPILER_TARGET i686-elf)
set(CMAKE_ASM_COMPILER ${TOOL_PREFIX}/bin/clang)
set(CMAKE_C_FLAGS "-ffreestanding -nostdlib")
set(CMAKE_CXX_FLAGS "-ffreestanding -nostdlib -fno-rtti -fno-exceptions")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
```
* failed output
```shell
[ 92%] Built target generate-cxx-headers
[ 92%] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/algorithm.cpp.obj
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1854:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/for_each.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__ranges/movable_box.h:21:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/optional:190:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__functional/hash.h:25:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/cstring:66:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/string.h:98:102: error: unknown type name 'size_t'; did you mean 'std::size_t'?
98 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) {
| ^~~~~~
| std::size_t
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__cstddef/size_t.h:20:7: note: 'std::size_t' declared here
20 | using size_t = decltype(sizeof(int));
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1854:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/for_each.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__ranges/movable_box.h:21:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/optional:190:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__functional/hash.h:25:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/cstring:66:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/string.h:101:90: error: unknown type name 'size_t'; did you mean 'std::size_t'?
101 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) {
| ^~~~~~
| std::size_t
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__cstddef/size_t.h:20:7: note: 'std::size_t' declared here
20 | using size_t = decltype(sizeof(int));
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1854:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/for_each.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__ranges/movable_box.h:21:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/optional:190:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__functional/hash.h:36:8: error: reference to unresolved using declaration
36 | std::memcpy(&__r, __p, sizeof(__r));
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/cstring:82:1: note: using declaration annotated with 'using_if_exists' here
82 | using ::memcpy _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:120:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:14:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__mbstate_t.h:51:4: error: "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
51 | # error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:136:14: error: reference to unresolved using declaration
136 | typedef fpos<mbstate_t> streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:136:14: error: reference to unresolved using declaration
136 | typedef fpos<mbstate_t> streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:141:14: error: reference to unresolved using declaration
141 | typedef fpos<mbstate_t> u8streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:141:14: error: reference to unresolved using declaration
141 | typedef fpos<mbstate_t> u8streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:143:14: error: reference to unresolved using declaration
143 | typedef fpos<mbstate_t> u16streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:143:14: error: reference to unresolved using declaration
143 | typedef fpos<mbstate_t> u16streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:144:14: error: reference to unresolved using declaration
144 | typedef fpos<mbstate_t> u32streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1908:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/shuffle.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__random/uniform_int_distribution.h:20:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/iosfwd:144:14: error: reference to unresolved using declaration
144 | typedef fpos<mbstate_t> u32streampos;
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here
25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
| ^
In file included from /Users/nekosu/Documents/Projects/llvm-project/libcxx/src/algorithm.cpp:9:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/algorithm:1854:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__algorithm/for_each.h:16:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__ranges/movable_box.h:21:
In file included from /Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/optional:190:
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__functional/hash.h:36:3: error: excess elements in scalar initializer
36 | std::memcpy(&__r, __p, sizeof(__r));
| ^ ~~~~~~~~~~~~~~~~~~
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__functional/hash.h:56:24: note: in instantiation of function template specialization 'std::__loadword<unsigned int>' requested here
56 | _Size __k = std::__loadword<_Size>(__data);
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__functional/hash.h:279:12: note: in instantiation of member function 'std::__murmur2_or_cityhash<unsigned int>::operator()' requested here
279 | return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
| ^
/Users/nekosu/Documents/Projects/llvm-project/build-runtimes/include/c++/v1/__functional/hash.h:324:18: note: in instantiation of member function 'std::__scalar_hash<std::_PairT>::operator()' requested here
324 | return _HashT()(__p);
| ^
13 errors generated.
gmake[2]: *** [libcxx/src/CMakeFiles/cxx_static.dir/build.make:79: libcxx/src/CMakeFiles/cxx_static.dir/algorithm.cpp.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:484: libcxx/src/CMakeFiles/cxx_static.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs