0

I'm building the llvm-18.1.3 and facing the all warnings being treated as errors error as follows:

/home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.cpp:16:28: error: ‘void* __llvm_libc_18_1_3_::bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*))’ aliased to external symbol ‘bsearch’
   16 | LLVM_LIBC_FUNCTION(void *, bsearch,
      |                            ^~~~~~~
/home/pi/llvm-project-llvmorg-18.1.3/libc/src/__support/common.h:28:34: note: in definition of macro ‘LLVM_LIBC_FUNCTION_IMPL’
   28 |   decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];                   \
      |                                  ^~~~
/home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.cpp:16:1: note: in expansion of macro ‘LLVM_LIBC_FUNCTION’
   16 | LLVM_LIBC_FUNCTION(void *, bsearch,
      | ^~~~~~~~~~~~~~~~~~
/home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.cpp:16:28: error: ‘void* __llvm_libc_18_1_3_::bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*))’ specifies less restrictive attribute than its target ‘void* bsearch(const void*, const void*, size_t, size_t, __compar_fn_t)’: ‘nonnull’ [-Werror=missing-attributes]
   16 | LLVM_LIBC_FUNCTION(void *, bsearch,
      |                            ^~~~~~~
/home/pi/llvm-project-llvmorg-18.1.3/libc/src/__support/common.h:28:34: note: in definition of macro ‘LLVM_LIBC_FUNCTION_IMPL’
   28 |   decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];                   \
      |                                  ^~~~
/home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.cpp:16:1: note: in expansion of macro ‘LLVM_LIBC_FUNCTION’
   16 | LLVM_LIBC_FUNCTION(void *, bsearch,
      | ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdlib.h:846,
                 from /usr/include/c++/12/cstdlib:75,
                 from /usr/include/c++/12/stdlib.h:36,
                 from /home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.h:12,
                 from /home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.cpp:9:
/usr/include/arm-linux-gnueabihf/bits/stdlib-bsearch.h:20:1: note: ‘void* __llvm_libc_18_1_3_::bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*))’ target declared here
   20 | bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
      | ^~~~~~~
cc1plus: all warnings being treated as errors

So, I've added set(CMAKE_COMPILE_WARNING_AS_ERROR OFF) line to the end of the file libc/src/stdlib/CMakeLists.txt as follow:

…
if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
  add_entrypoint_object(
    malloc
    ALIAS
    DEPENDS
      .${LIBC_TARGET_OS}.malloc
  )

  add_entrypoint_object(
    free
    ALIAS
    DEPENDS
      .${LIBC_TARGET_OS}.free
  )
endif()

set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)

Then, I built again, however, this error continues. What is my fixing wrong and how can I fix this build breaking?

P.S. The cmake is called as follows:

cmake --compile-no-warning-as-error -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/local -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64" -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;cross-project-tests;libc;libclc;lld;lldb;mlir;openmp;polly;pstl;bolt;compiler-rt" -DBUILD_SHARED_LIBS=ON -DLLVM_USE_SPLIT_DWARF=ON -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' -DCMAKE_SHARED_LINKER_FLAGS='-latomic'

2 Answers 2

1

Setting variable CMAKE_COMPILE_WARNING_AS_ERROR affects only on targets created after that setting. That is, the variable should be set in the beginning of CMakeLists.txt, not at the end of it.


More precise, whenever a library or executable target is created, its property COMPILE_WARNING_AS_ERROR takes the value from the variable CMAKE_COMPILE_WARNING_AS_ERROR. That is, for create a target with the property set to OFF, the variable should already be set to that value.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Tsyarev. I've moved set(CMAKE_COMPILE_WARNING_AS_ERROR OFF) from end of file CmakeList.txt to top. But, result was same, still same error.
I've added cmake call.
1

You should not modify the CMakeLists.txt. Instead, add the right parameter to set the according CMake variable when calling cmake.

In your case, setting LLVM_ENABLE_WERROR to OFF should do the trick (cmake -DLLVM_ENABLE_WERROR=OFF <path-to-source>). According to LLVM's documentation, this should be the default value. Please investigate why this is set differently for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.