<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64879>64879</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc] Full libc build failure on an aarch64 host with linux using clang-16
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
amargaritov
</td>
</tr>
</table>
<pre>
Hi, I am trying to build full libc on an aarch64 host running Linux using clang-16. Following [documentation](https://libc.llvm.org/full_host_build.html) for building full libc on a host, I am using this commands to configure & install:
```bash
SYSROOT=/home/user/full_libc_install;
cmake ../llvm \
-G Ninja \ # Generator
-DLLVM_ENABLE_PROJECTS="clang;libc;lld;compiler-rt" \ # Enabled projects
-DCMAKE_BUILD_TYPE=Debug \ # Select build type
-DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16 \
-DLLVM_LIBC_FULL_BUILD=ON \ # We want the full libc
-DLLVM_LIBC_INCLUDE_SCUDO=ON \ # Include Scudo in the libc
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF \
-DCMAKE_INSTALL_PREFIX=$SYSROOT #
ninja install-clang install-builtins install-compiler-rt \
install-core-resource-headers install-libc install-lld
```
However, the installation phase fails at the stage of installing compiler-rt with the following error:
```console
FAILED: projects/compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone-aarch64.dir/linux.cpp.o
/usr/bin/clang++-16 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_LIBCPP_ENABLE_HARDENED_MODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/user/llvm-project/build_clean_full-libc_clang16-by-clang16/projects/compiler-rt/lib/scudo/standalone -I/home/user/llvm-project/compiler-rt/lib/scudo/standalone -I/home/user/llvm-project/build_clean_full-libc_clang16-by-clang16/include -I/home/user/llvm-project/llvm/include -I/home/user/llvm-project/compiler-rt/lib/scudo/standalone/../.. -I/home/user/llvm-project/compiler-rt/lib/scudo/standalone/include -I/home/user/llvm-project/build_clean_full-libc_clang16-by-clang16/projects/compiler-rt/../libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wall -Wno-unused-parameter -g -march=armv8-a -fno-lto -Werror=conversion -Wall -Wextra -pedantic -g -nostdinc++ -fvisibility=hidden -fno-exceptions -Wno-pedantic -O3 -Werror=thread-safety -ffreestanding -std=c++17 -MD -MT projects/compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone-aarch64.dir/linux.cpp.o -MF projects/compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone-aarch64.dir/linux.cpp.o.d -o projects/compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone-aarch64.dir/linux.cpp.o -c /home/user/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp
In file included from /home/user/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp:29:
In file included from /usr/include/aarch64-linux-gnu/sys/time.h:25:
/usr/include/aarch64-linux-gnu/bits/types/struct_timeval.h:8:8: error: redefinition of 'timeval'
struct timeval
^
/home/user/llvm-project/build_clean_full-libc_clang16-by-clang16/projects/compiler-rt/../libc/include/llvm-libc-types/struct_timeval.h:15:8: note: previous definition is here
struct timeval {
^
In file included from /home/user/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp:29:
```
For your information, on an aarch64 host, the failure is present on release/16.x and release/17.x branches. On an aarch64 host, the failure is present if gcc-12 is used as a compiler. The commands builds full libc successfully on an x86 host with Linux using clang-16 .
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWF9z4jgS_zTOi0ousAOBBx4A4xnu-JMCcmSfXMJq29qVJU6SSbhPfyXZ4LBh72aqZivUTMCt1q__qPVTW0RrlguAkdebeL3ogVSmkGpESqJyopiRp4eDpOfRd-YFUzRHpERGnZnIkZHoUDFOUVZxjjg7pEgKRAQiRKVF_xEVUhukKiGs9oKJ6h1V2v5OORE57vZ9FEvO5ZuVeb0JlWlVgjDEMCm8XuQFg8KYo_bCsRfEXhBbGz7np9KXKveC2BpOrJXEOeIXpuReMESZVLVrFvjWO-fUNZLaHVMwjVJZlkRQbcNKpchYXilAXtBHTGhDOLdedCKvM_b6nfrfgeiiFm1_227W650XRl4QF7IEL4grDeriozWfXHEmqJ6VluQPQL5vI-OnEiGvN61HEEL4G1ox8TtxUuQFIfoGAhQxUjU6OFos_rVMZqvxZDFLnjfrf8ymu63zIXAZ9sKJNWy_OPXCSSrLI-OgsDJeEKAWeSbIgQNFRyV_h9To1olouhz_c5ZMXuaLKNn99jzzwiiCQ5W3k7fAITVNKZjzEa7u1XOnyXS9fJ4vZhsvjC4r346-vn4a94KJF0ysVpuQJtjFfDJN4pfFonbJC6P1CrmPdcf5swf0RoRBpoB27e-gzFfTxUs0S7bTl2h9AbqizEXKKwpom1ZUIiYc3A3Sxetks2vy45CS7W68isaL9WqW7Oe778nVYm3jY0ifIb7tn5PxdryyunGM7n_-CuKT_cat7-PNLLpFvIFwCzFfbXfjxSJ53szi-aurosemrG1Cam3hKrIpZOwW6_pkC8AwodvhttxuS7tVUIAVaFmpFHABhIJqp7ste33g9E-br378Lt_gZPfZ1C1Qo-4IBB0LogFlhHGNSF0P2pAckMwuio6MPrj5xkxRF86Vl0ApqT7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