Help wanted with LLVM build failure on Linux using GitHub master branch

I’ve tried building the current state of the master branch both on pop os and after that failed in wsl (debian) on the same mashine and I am getting the same compilation error on both. If you have an idea on how I can resolve this issue, thanks :slight_smile:
I used the following cmake command:

cmake -G "Ninja" -DLLVM_ENABLE_PROJECTS="all" -DCMAKE_BUILD_TYPE="Debug" -DLLVM_ENABLE_ASSERTIONS=On ../llvm

and am running ninja using

ninja -j11

to keep one core for some other stuff running on my system at the same time.
I get the following build error (here built using ninja -j1 so if there is another error it wouldn’t be mixed in; there is additional non error Text afterwards):

paul@pop-os:~/development/llvm-project/build$ ninja -j1
[4/7069] Building CXX object projects/libc/src/string/CMakeFiles/libc.src.string.bcopy.dir/bcopy.cpp.o
FAILED: projects/libc/src/string/CMakeFiles/libc.src.string.bcopy.dir/bcopy.cpp.o 
/usr/bin/c++ -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/paul/development/llvm-project/build/projects/libc/src/string -I/home/paul/development/llvm-project/libc/src/string -I/home/paul/development/llvm-project/build/include -I/home/paul/development/llvm-project/llvm/include -I/home/paul/development/llvm-project/build/projects/libc/include -I/home/paul/development/llvm-project/libc -I/home/paul/development/llvm-project/build/projects/libc -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -fpie -ffreestanding -fno-builtin -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -Wall -Wextra -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wstrict-prototypes -DLLVM_LIBC_PUBLIC_PACKAGING -std=c++17 -MD -MT projects/libc/src/string/CMakeFiles/libc.src.string.bcopy.dir/bcopy.cpp.o -MF projects/libc/src/string/CMakeFiles/libc.src.string.bcopy.dir/bcopy.cpp.o.d -o projects/libc/src/string/CMakeFiles/libc.src.string.bcopy.dir/bcopy.cpp.o -c /home/paul/development/llvm-project/libc/src/string/bcopy.cpp
cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:15,
                 from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_generic.h:437: warning: ignoring ‘#pragma nounroll ’ [-Wunknown-pragmas]
  437 | #pragma nounroll
      | 
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_generic.h:463: warning: ignoring ‘#pragma nounroll ’ [-Wunknown-pragmas]
  463 | #pragma nounroll
      | 
In file included from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:26: warning: ignoring ‘#pragma nounroll ’ [-Wunknown-pragmas]
   26 | #pragma nounroll
      | 
/home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:30: warning: ignoring ‘#pragma nounroll ’ [-Wunknown-pragmas]
   30 | #pragma nounroll
      | 
In file included from /home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:15,
                 from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_generic.h: In static member function ‘static __llvm_libc::generic::VectorType<Size>::Type __llvm_libc::generic::VectorType<Size>::splat(uint8_t)’:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_generic.h:85:10: error: invalid types ‘__llvm_libc::generic::VectorType<Size>::Type {aka unsigned char}[size_t {aka long unsigned int}]’ for array subscript
   85 |       Out[i] = static_cast<uint8_t>(value);
      |          ^
In file included from /home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:16,
                 from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h: In function ‘__llvm_libc::BcmpReturnType __llvm_libc::x86::avx512bw::bcmp64(__llvm_libc::CPtr, __llvm_libc::CPtr)’:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h:126:48: note: use ‘-flax-vector-conversions’ to permit conversions between vectors with differing element types or numbers of subparts
  126 |   const uint64_t mask = _mm512_cmpneq_epi8_mask(load<T>(p1), load<T>(p2));
      |                         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h:126:56: error: cannot convert ‘__vector(64) char’ to ‘__m512i’
  126 |   const uint64_t mask = _mm512_cmpneq_epi8_mask(load<T>(p1), load<T>(p2));
      |                                                 ~~~~~~~^~~~
      |                                                        |
      |                                                        __vector(64) char
In file included from /usr/lib/gcc/x86_64-linux-gnu/11/include/immintrin.h:59,
                 from /home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h:25,
                 from /home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:16,
                 from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/usr/lib/gcc/x86_64-linux-gnu/11/include/avx512bwintrin.h:2642:34: note:   initializing argument 1 of ‘__mmask64 _mm512_cmpneq_epi8_mask(__m512i, __m512i)’
 2642 | _mm512_cmpneq_epi8_mask (__m512i __X, __m512i __Y)
      |                          ~~~~~~~~^~~
In file included from /home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:16,
                 from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h: In function ‘__llvm_libc::MemcmpReturnType __llvm_libc::x86::avx512bw::memcmp64(__llvm_libc::CPtr, __llvm_libc::CPtr)’:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h:217:54: error: cannot convert ‘__vector(64) char’ to ‘__m512i’
  217 |   if (uint64_t mask = _mm512_cmpneq_epi8_mask(load<T>(p1), load<T>(p2)))
      |                                               ~~~~~~~^~~~
      |                                                      |
      |                                                      __vector(64) char
In file included from /usr/lib/gcc/x86_64-linux-gnu/11/include/immintrin.h:59,
                 from /home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h:25,
                 from /home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:16,
                 from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/usr/lib/gcc/x86_64-linux-gnu/11/include/avx512bwintrin.h:2642:34: note:   initializing argument 1 of ‘__mmask64 _mm512_cmpneq_epi8_mask(__m512i, __m512i)’
 2642 | _mm512_cmpneq_epi8_mask (__m512i __X, __m512i __Y)
      |                          ~~~~~~~~^~~
In file included from /home/paul/development/llvm-project/libc/src/string/memory_utils/op_builtin.h:18,
                 from /home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:14,
                 from /home/paul/development/llvm-project/libc/src/string/bcopy.cpp:11:
/home/paul/development/llvm-project/libc/src/string/memory_utils/utils.h: In instantiation of ‘T __llvm_libc::load(__llvm_libc::CPtr) [with T = __vector(32) char; __llvm_libc::CPtr = const __llvm_libc::cpp::byte*]’:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h:114:48:   required from here
/home/paul/development/llvm-project/libc/src/string/memory_utils/utils.h:147:39: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
  147 | template <typename T> static inline T load(CPtr ptr) {
      |                                       ^~~~
/home/paul/development/llvm-project/libc/src/string/memory_utils/utils.h: In instantiation of ‘T __llvm_libc::load(__llvm_libc::CPtr) [with T = __vector(64) char; __llvm_libc::CPtr = const __llvm_libc::cpp::byte*]’:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_x86.h:126:56:   required from here
/home/paul/development/llvm-project/libc/src/string/memory_utils/utils.h:147:39: warning: AVX512F vector return without AVX512F enabled changes the ABI [-Wpsabi]
/home/paul/development/llvm-project/libc/src/string/memory_utils/utils.h: In instantiation of ‘void __llvm_libc::deferred_static_assert(const char*) [with bool flag = false]’:
/home/paul/development/llvm-project/libc/src/string/memory_utils/op_builtin.h:30:27:   required from ‘static void __llvm_libc::builtin::Memcpy<Size>::block(__llvm_libc::Ptr, __llvm_libc::CPtr) [with long unsigned int Size = 1; __llvm_libc::Ptr = __llvm_libc::cpp::byte*; __llvm_libc::CPtr = const __llvm_libc::cpp::byte*]’
/home/paul/development/llvm-project/libc/src/string/memory_utils/memmove_implementations.h:28:27:   required from here
/home/paul/development/llvm-project/libc/src/string/memory_utils/utils.h:24:17: error: static assertion failed: compilation error
   24 |   static_assert(flag, "compilation error");
      |                 ^~~~
/home/paul/development/llvm-project/libc/src/string/memory_utils/utils.h:24:17: note: ‘false’ evaluates to false
ninja: build stopped: subcommand failed.
paul@pop-os:~/development/llvm-project/build$ 

I did successfully build LLVM on this mashine inside Wsl about 2 years ago but don’t have that build or clone around anymore.

I am building LLVM to do some playing around with it, so don’t suggest just downloading prebuilt binaries since I want to modify the source code in the future and rebuild :wink:

Edit 1: Fix broken markdown

The HEAD of main (we don’t use master anymore) isn’t guaranteed to build or test cleanly. I’d say pull a new revision and try again.

If you want to be sure of a good revision, you’ll want to look at the buildbot console and find one that has only green (or yellow, but no red) on that row.

Thank you very much.

If the main isn’t guaranteed to build cleanly, the getting started page in the docs probably shouldn’t include git commands that would clone main/it should include that info.
Also the problem was something different someone on the discord pointed out to me, parts of llvms libc do not currently build with gcc although that is considered a regression, so by just not building that part, building main worked fine.

But thanks :wink:

Thanks for discovering this regression! Though I’m sorry you discovered a regression. There isn’t (yet) a bot testing that libc builds with gcc, one will be set up. Work is underway to get libc building properly with non-Clang compilers (e.g. ⚙ D139712 [libc] Add compiler, builtin and feature detection).