libc doesn't build on WSL Ubunty 22.04
Hi! I try to build libc library on WSL Ubunty 22.04, using of this instruction: https://libc.llvm.org/fullbuild_mode.html#fullbuild-mode. But I get this error:
user@NB-2088:~/llvm-libs/build$ cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="clang;libc;lld;compiler-rt" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_LIBC_FULL_BUILD=ON -DLLVM_LIBC_INCLUDE_SCUDO=ON -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON -DCOMPILER_RT_BUILD_GWP_ASAN=OFF -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF
CMake Error: The source "/home/user/llvm-libs/llvm/CMakeLists.txt" does not match the source "/home/user/llvm-libs/libc/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
In the main page I saw libc is not complite now. I can't to build because of this problem? Can you tell when library will be compilte?
@llvm/issue-subscribers-libc
Hi,
The libc is complete enough to be practically useful. I notice that your build directory is under llvm-libs. I am not sure what llvm-libs is. Our instructions on the website assume that your build is under the llvm-project checkout directory named llvm-project.
Thanks for the answer! But now I had the another problem. I use command:
user@NB-2088:~/llvm-project/build$ cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="clang;libc;lld;compiler-rt" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_LIBC_FULL_BUILD=ON -DLLVM_LIBC_INCLUDE_SCUDO=ON -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON -DCOMPILER_RT_BUILD_GWP_ASAN=OFF -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF
I cannot attach log, but there is the first problem:
Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)":
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Determining if the include file malloc/malloc.h exists failed with the following output:
Change Dir: /home/user/llvm-project/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_e4e65 && [1/2] Building C object CMakeFiles/cmTC_e4e65.dir/CheckIncludeFile.c.o
FAILED: CMakeFiles/cmTC_e4e65.dir/CheckIncludeFile.c.o
/usr/bin/clang -O3 -DNDEBUG -MD -MT CMakeFiles/cmTC_e4e65.dir/CheckIncludeFile.c.o -MF CMakeFiles/cmTC_e4e65.dir/CheckIncludeFile.c.o.d -o CMakeFiles/cmTC_e4e65.dir/CheckIncludeFile.c.o -c /home/user/llvm-project/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/user/llvm-project/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'malloc/malloc.h' file not found
#include <malloc/malloc.h>
^~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
I also try to use overlay mode:
user@NB-2088:~/llvm-project/build$ cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="libc" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
-- bolt project is disabled
-- clang project is disabled
-- clang-tools-extra project is disabled
-- compiler-rt project is disabled
-- cross-project-tests project is disabled
-- libc project is enabled
-- libclc project is disabled
-- libcxx project is disabled
-- libcxxabi project is disabled
-- libunwind project is disabled
-- lld project is disabled
-- lldb project is disabled
-- mlir project is disabled
-- openmp project is disabled
-- polly project is disabled
-- pstl project is disabled
-- flang project is disabled
CMake Error at cmake/modules/CheckCompilerVersion.cmake:120 (message):
libstdc++ version should be at least 5.1 because LLVM will soon use new C++
features which your toolchain version doesn't support. You can temporarily
opt out using LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN, but very soon your
toolchain won't be supported.
Call Stack (most recent call first):
cmake/config-ix.cmake:14 (include)
CMakeLists.txt:732 (include)
-- Configuring incomplete, errors occurred!
See also "/home/user/llvm-project/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/llvm-project/build/CMakeFiles/CMakeError.log".
but
user@NB-2088:~/llvm-project/build$ sudo apt-get install libstdc++6
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libstdc++6 is already the newest version (12.1.0-2ubuntu1~22.04).
About your problem with the full build, it seems like CMake is unable to find something on your system which it is expecting.
With respect to the overlay mode problem, the libstdc++ on your system is an old version. Try passing -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN as suggested by the error message.
This flag doesn’t resolve the problem, I got a lot of other errors. About full build. Did you have a full list of dependencies?
The first step for you would probably be to ensure that you are able to build clang on your system. You will find instructions here: https://clang.llvm.org/get_started.html
If you are able to get clang building successfully, then we can attempt building libc and go from there.
I solved my problem with re-install WSL. Thanks