https://bugs.llvm.org/show_bug.cgi?id=49156

            Bug ID: 49156
           Summary: CMake configure fails with multiple duplicate target
                    clashes
           Product: Build scripts
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: cmake
          Assignee: unassignedb...@nondot.org
          Reporter: k...@pobox.com
                CC: llvm-bugs@lists.llvm.org

Created attachment 24520
  --> https://bugs.llvm.org/attachment.cgi?id=24520&action=edit
CMakeError.log and CMakeOutput.log

Debian 10 X64, Cmake 3.19.2, tip of the release12.x branch from the repo.

This is my first attempt to build the Clang toolchain from scratch. When I
attempted to generate build files for Ninja, I got 16 nearly identical
failures:

CMake Error at cmake/modules/LLVMExternalProjectUtils.cmake:330
(add_custom_target):
  add_custom_target cannot create target "cxxabi" because another target with
  the same name already exists.  The existing target is a custom target
  created in source directory "/home/kkm/work/llvm-project/libcxxabi/src".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  runtimes/CMakeLists.txt:230 (llvm_ExternalProject_Add)
  runtimes/CMakeLists.txt:365 (runtime_default_target)

All of them mention the same files and line numbers, and differ only in the
target name and the source directory. Here's what I'm grepping out of the whole
list of these errors:

$ printf "%s\t%s\n" $(grep -Po '".+?"' errs)
"builtins"      "/home/kkm/work/llvm-project/compiler-rt/lib/builtins"
"compiler-rt"   "/home/kkm/work/llvm-project/compiler-rt"
"install-compiler-rt"   "/home/kkm/work/llvm-project/compiler-rt"
"install-compiler-rt-stripped"  "/home/kkm/work/llvm-project/compiler-rt"
"cxx"   "/home/kkm/work/llvm-project/libcxx/src"
"install-cxx"   "/home/kkm/work/llvm-project/libcxx/src"
"install-cxx-stripped"  "/home/kkm/work/llvm-project/libcxx/src"
"cxxabi"        "/home/kkm/work/llvm-project/libcxxabi/src"
"install-cxxabi"        "/home/kkm/work/llvm-project/libcxxabi/src"
"install-cxxabi-stripped"       "/home/kkm/work/llvm-project/libcxxabi/src"
"unwind"        "/home/kkm/work/llvm-project/libunwind/src"
"install-unwind"        "/home/kkm/work/llvm-project/libunwind/src"
"install-unwind-stripped"       "/home/kkm/work/llvm-project/libunwind/src"
"check-cxx"     "/home/kkm/work/llvm-project/libcxx/test"
"check-cxxabi"  "/home/kkm/work/llvm-project/libcxxabi/test"
"check-unwind"  "/home/kkm/work/llvm-project/libunwind/test"

This is a chunk of my build script:

projects="clang;clang-tools-extra;compiler-rt;libcxxabi;libcxx;libunwind;lld;lldb;polly"
runtimes="compiler-rt;libcxx;libcxxabi;libunwind"
vendor="kkm[210212]"

set -ex

[[ -d .git && -d llvm ]] || exit 1

cmake -S llvm -B Build -G Ninja                 \
      -DCMAKE_POLICY_DEFAULT_CMP0002=NEW        \
      -DCMAKE_POLICY_DEFAULT_CMP0114=NEW        \
      -DCMAKE_CXX_STANDARD=17                   \
      -DCMAKE_BUILD_TYPE=Release                \
      -DCMAKE_C_COMPILER=clang-11               \
      -DCMAKE_CXX_COMPILER=clang++-11           \
      -DLLVM_ENABLE_PROJECTS="$projects"        \
      -DLLVM_ENABLE_RUNTIMES="$runtimes"        \
      -DCLANG_DEFAULT_CXX_STDLIB=libc++         \
      -DCLANG_DEFAULT_RTLIB=compiler-rt         \
      -DCLANG_VENDOR="$vendor"                  \
      -DLLD_VENDOR="$vendor"                    \
      -DLLVM_BUILD_32_BITS=OFF                  \
      -DLLVM_CCACHE_BUILD=ON                    \
      -DLLVM_TARGETS_TO_BUILD=X86               \
      -DLLVM_ENABLE_LLD=ON                      \
      -DLLVM_ENABLE_DOXYGEN=ON                  \
      -DLLVM_ENABLE_OCAMLDOC=OFF                \
      -DLLVM_OPTIMIZED_TABLEGEN=ON              \
      -DLLVM_LIBDIR_SUFFIX=64                   \
      -DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=ON \
      -DLIBCXXABI_USE_LLVM_UNWINDER=ON          \
      -DLIBCXXABI_USE_COMPILER_RT=ON            \
      -DLIBCXX_CXX_ABI=libcxxabi                \
      -DLIBUNWIND_USE_COMPILER_RT=ON


The policies CMP0002 and CMP0114 were mentioned in these messages, and I tried
all 4 combinations of OLD/NEW, to no avail. Am I doing it wrong, or is this a
genuine bug?

My goal is to build the toolchain to be as self-contained as possible, using
only the system's own libc6, because my final target must be Amazon Linux 2
Docker image, based on the very aged RHEL7, although they so luckily threw in a
newer GCC 7.x, which is, fingers crossed, probably recent enough to bootstrap
the whole kaboodle. The SLES pre-built rpms from GitHub releases almost did it,
but not quite (lib directories did not match), unfortunately, so building from
source seems the cleanest option. If only it weren't failing... :)

I'm attaching CMake output logs, just in case, from my final run with exactly
these arguments. Let me know please if any other generated files will be
helpful. Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to